pipedream 0.1.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.cody/buildspec.yml +9 -0
- data/.cody/project.rb +4 -0
- data/.gitignore +16 -11
- data/.gitmodules +9 -0
- data/.rspec +1 -1
- data/CHANGELOG.md +34 -0
- data/Gemfile +3 -1
- data/Gemfile.lock +112 -0
- data/Guardfile +19 -0
- data/LICENSE.txt +18 -17
- data/README.md +55 -21
- data/Rakefile +10 -2
- data/exe/pipe +14 -0
- data/exe/pipedream +14 -0
- data/lib/pipedream/autoloader.rb +21 -0
- data/lib/pipedream/aws_services/helpers.rb +71 -0
- data/lib/pipedream/aws_services.rb +20 -0
- data/lib/pipedream/build.rb +13 -0
- data/lib/pipedream/cli.rb +60 -0
- data/lib/pipedream/command.rb +82 -0
- data/lib/pipedream/completer/script.rb +6 -0
- data/lib/pipedream/completer/script.sh +10 -0
- data/lib/pipedream/completer.rb +159 -0
- data/lib/pipedream/core.rb +63 -0
- data/lib/pipedream/create.rb +12 -0
- data/lib/pipedream/delete.rb +27 -0
- data/lib/pipedream/deploy.rb +40 -0
- data/lib/pipedream/dsl/pipeline/approve.rb +34 -0
- data/lib/pipedream/dsl/pipeline/codebuild.rb +57 -0
- data/lib/pipedream/dsl/pipeline/github.rb +42 -0
- data/lib/pipedream/dsl/pipeline.rb +37 -0
- data/lib/pipedream/dsl/role.rb +50 -0
- data/lib/pipedream/dsl/schedule.rb +30 -0
- data/lib/pipedream/dsl/sns.rb +15 -0
- data/lib/pipedream/dsl/ssm.rb +22 -0
- data/lib/pipedream/dsl/webhook.rb +27 -0
- data/lib/pipedream/evaluate.rb +47 -0
- data/lib/pipedream/help/completion.md +22 -0
- data/lib/pipedream/help/completion_script.md +3 -0
- data/lib/pipedream/help/deploy.md +54 -0
- data/lib/pipedream/help/start.md +20 -0
- data/lib/pipedream/help.rb +9 -0
- data/lib/pipedream/init.rb +68 -0
- data/lib/pipedream/pipeline/s3_bucket.rb +88 -0
- data/lib/pipedream/pipeline.rb +61 -0
- data/lib/pipedream/role.rb +181 -0
- data/lib/pipedream/schedule.rb +99 -0
- data/lib/pipedream/sequence.rb +66 -0
- data/lib/pipedream/setting.rb +82 -0
- data/lib/pipedream/sns.rb +43 -0
- data/lib/pipedream/stack.rb +95 -0
- data/lib/pipedream/start.rb +84 -0
- data/lib/pipedream/update.rb +12 -0
- data/lib/pipedream/version.rb +1 -1
- data/lib/pipedream/webhook.rb +60 -0
- data/lib/pipedream.rb +18 -1
- data/lib/template/.pipedream/pipeline.rb.tt +40 -0
- data/lib/template/.pipedream/schedule.rb +3 -0
- data/lib/template/.pipedream/settings.yml +9 -0
- data/lib/template/.pipedream/sns.rb +14 -0
- data/pipedream.gemspec +25 -14
- data/vendor/aws_data/CHANGELOG.md +7 -0
- data/vendor/aws_data/Gemfile +4 -0
- data/vendor/aws_data/Gemfile.lock +48 -0
- data/vendor/aws_data/LICENSE.txt +21 -0
- data/vendor/aws_data/README.md +42 -0
- data/vendor/aws_data/Rakefile +6 -0
- data/vendor/aws_data/aws_data.gemspec +30 -0
- data/{bin → vendor/aws_data/bin}/console +1 -1
- data/{bin → vendor/aws_data/bin}/setup +0 -0
- data/vendor/aws_data/lib/aws_data/version.rb +3 -0
- data/vendor/aws_data/lib/aws_data.rb +91 -0
- data/vendor/aws_data/spec/aws_data_spec.rb +5 -0
- data/vendor/aws_data/spec/spec_helper.rb +14 -0
- data/vendor/cfn-status/Gemfile +4 -0
- data/vendor/cfn-status/Gemfile.lock +49 -0
- data/vendor/cfn-status/LICENSE.txt +21 -0
- data/vendor/cfn-status/README.md +56 -0
- data/vendor/cfn-status/Rakefile +6 -0
- data/vendor/cfn-status/bin/console +14 -0
- data/vendor/cfn-status/bin/setup +8 -0
- data/vendor/cfn-status/cfn-status.gemspec +30 -0
- data/vendor/cfn-status/lib/cfn/aws_service.rb +56 -0
- data/vendor/cfn-status/lib/cfn/status/version.rb +5 -0
- data/vendor/cfn-status/lib/cfn/status.rb +220 -0
- data/vendor/cfn-status/spec/cfn/status_spec.rb +81 -0
- data/vendor/cfn-status/spec/fixtures/cfn/stack-events-complete.json +1080 -0
- data/vendor/cfn-status/spec/fixtures/cfn/stack-events-in-progress.json +1080 -0
- data/vendor/cfn-status/spec/fixtures/cfn/stack-events-update-rollback-complete.json +1086 -0
- data/vendor/cfn-status/spec/spec_helper.rb +14 -0
- data/vendor/cfn_camelizer/CHANGELOG.md +10 -0
- data/vendor/cfn_camelizer/Gemfile +4 -0
- data/vendor/cfn_camelizer/LICENSE.txt +21 -0
- data/vendor/cfn_camelizer/README.md +40 -0
- data/vendor/cfn_camelizer/Rakefile +6 -0
- data/vendor/cfn_camelizer/bin/console +14 -0
- data/vendor/cfn_camelizer/bin/setup +8 -0
- data/vendor/cfn_camelizer/cfn_camelizer.gemspec +32 -0
- data/vendor/cfn_camelizer/lib/camelizer.yml +27 -0
- data/vendor/cfn_camelizer/lib/cfn_camelizer/version.rb +3 -0
- data/vendor/cfn_camelizer/lib/cfn_camelizer.rb +92 -0
- data/vendor/cfn_camelizer/spec/cfn_camelizer_spec.rb +79 -0
- data/vendor/cfn_camelizer/spec/spec_helper.rb +14 -0
- metadata +295 -23
- data/.travis.yml +0 -7
@@ -0,0 +1,14 @@
|
|
1
|
+
require "bundler/setup"
|
2
|
+
require "cfn/status"
|
3
|
+
|
4
|
+
RSpec.configure do |config|
|
5
|
+
# Enable flags like --only-failures and --next-failure
|
6
|
+
config.example_status_persistence_file_path = ".rspec_status"
|
7
|
+
|
8
|
+
# Disable RSpec exposing methods globally on `Module` and `main`
|
9
|
+
config.disable_monkey_patching!
|
10
|
+
|
11
|
+
config.expect_with :rspec do |c|
|
12
|
+
c.syntax = :expect
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Tung Nguyen
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# CfnCamelizer
|
2
|
+
|
3
|
+
Camelizer for CloudFormation.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'cfn_camelizer'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install cfn_camelizer
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
data = {my_data: 1}
|
25
|
+
CfnCamelizer.transform(data) => {"MyData" => 1}
|
26
|
+
```
|
27
|
+
|
28
|
+
## Development
|
29
|
+
|
30
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
31
|
+
|
32
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
33
|
+
|
34
|
+
## Contributing
|
35
|
+
|
36
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/cfn_camelizer.
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "cfn_camelizer"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
@@ -0,0 +1,32 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "cfn_camelizer/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "cfn_camelizer"
|
8
|
+
spec.version = CfnCamelizer::VERSION
|
9
|
+
spec.authors = ["Tung Nguyen"]
|
10
|
+
spec.email = ["tongueroo@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = "Cfn Camelizer"
|
13
|
+
spec.homepage = "https://github.com/tongueroo/cfn_camelizer"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
# Specify which files should be added to the gem when it is released.
|
17
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
18
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
19
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
20
|
+
end
|
21
|
+
spec.bindir = "exe"
|
22
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
|
+
spec.require_paths = ["lib"]
|
24
|
+
|
25
|
+
spec.add_dependency "activesupport"
|
26
|
+
spec.add_dependency "memoist"
|
27
|
+
spec.add_dependency "rainbow"
|
28
|
+
|
29
|
+
spec.add_development_dependency "bundler"
|
30
|
+
spec.add_development_dependency "rake"
|
31
|
+
spec.add_development_dependency "rspec"
|
32
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
---
|
2
|
+
special_keys:
|
3
|
+
Aws: AWS
|
4
|
+
# Very fine grain control, since these map rules are scoped to specific resources
|
5
|
+
# After the special_keys map for backwards compatibility.
|
6
|
+
resource_keys: # specific to resource types
|
7
|
+
AWS::CloudFormation::Stack:
|
8
|
+
TemplateUrl: TemplateURL
|
9
|
+
AWS::ApplicationAutoScaling::ScalableTarget:
|
10
|
+
RoleArn: RoleARN
|
11
|
+
AWS::AutoScaling::LifecycleHook:
|
12
|
+
RoleArn: RoleARN
|
13
|
+
NotificationTargetArn: NotificationTargetARN
|
14
|
+
AWS::AutoScaling::AutoScalingGroup:
|
15
|
+
VpcZoneIdentifier: VPCZoneIdentifier
|
16
|
+
AWS::Route53::RecordSet:
|
17
|
+
Ttl: TTL
|
18
|
+
AWS::SQS::Queue:
|
19
|
+
DeadLetterTargetArn: deadLetterTargetArn
|
20
|
+
MaxReceiveCount: maxReceiveCount
|
21
|
+
AWS::RDS::DBSubnetGroup:
|
22
|
+
DbSubnetGroupDescription: DBSubnetGroupDescription
|
23
|
+
DbSubnetGroupName: DBSubnetGroupName
|
24
|
+
passthrough_parent_keys:
|
25
|
+
- Fn::Sub # https://amzn.to/2HKwxri
|
26
|
+
- ResponseParameters # API Gateway MethodResponse https://amzn.to/2HKw0Wk
|
27
|
+
- Variables # Lambda Environment Variables https://amzn.to/2HLlttV
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require "cfn_camelizer/version"
|
2
|
+
require "memoist"
|
3
|
+
require "yaml"
|
4
|
+
require "rainbow/ext/string"
|
5
|
+
require "active_support/core_ext/string"
|
6
|
+
require "active_support/core_ext/hash"
|
7
|
+
|
8
|
+
class CfnCamelizer
|
9
|
+
class << self
|
10
|
+
extend Memoist
|
11
|
+
|
12
|
+
def transform(value, parent_keys=[], resource_type=nil)
|
13
|
+
case value
|
14
|
+
when Array
|
15
|
+
value.map { |v| transform(v, parent_keys, resource_type) }
|
16
|
+
when Hash
|
17
|
+
if value.keys.include?(:type)
|
18
|
+
resource_type ||= value[:type]
|
19
|
+
end
|
20
|
+
|
21
|
+
initializer = value.map do |k, v|
|
22
|
+
new_key = camelize_key(k, parent_keys, resource_type)
|
23
|
+
[new_key, transform(v, parent_keys+[new_key], resource_type)]
|
24
|
+
end
|
25
|
+
Hash[initializer]
|
26
|
+
else
|
27
|
+
value # do not transform values
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def camelize_key(k, parent_keys=[], resource_type=nil)
|
32
|
+
k = k.to_s
|
33
|
+
|
34
|
+
if passthrough?(k, parent_keys)
|
35
|
+
k # pass through untouch
|
36
|
+
elsif parent_keys.last == "EventPattern" # top-level
|
37
|
+
k.dasherize
|
38
|
+
elsif parent_keys.include?("EventPattern")
|
39
|
+
# Any keys at 2nd level under EventPattern will be pascalized
|
40
|
+
pascalize(k)
|
41
|
+
else
|
42
|
+
camelize(k, resource_type)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def passthrough?(k, parent_keys)
|
47
|
+
# Do not transform keys under certain parent keys or keys that contain - or /
|
48
|
+
passthrough = camelizer_yaml["passthrough_parent_keys"]
|
49
|
+
intersection = parent_keys & passthrough
|
50
|
+
!intersection.empty? || k.include?('-') || k.include?('/')
|
51
|
+
end
|
52
|
+
|
53
|
+
def camelize(value, resource_type=nil)
|
54
|
+
return value if value.is_a?(Integer)
|
55
|
+
|
56
|
+
value = value.to_s.camelize
|
57
|
+
v = special_map[value] || value # after the special_keys map
|
58
|
+
resource_map(resource_type)[v] || v
|
59
|
+
end
|
60
|
+
|
61
|
+
def pascalize(value)
|
62
|
+
new_value = value.camelize
|
63
|
+
first_char = new_value[0..0].downcase
|
64
|
+
new_value[0] = first_char
|
65
|
+
new_value
|
66
|
+
end
|
67
|
+
|
68
|
+
# Some keys have special mappings
|
69
|
+
def special_map
|
70
|
+
camelizer_yaml["special_keys"]
|
71
|
+
end
|
72
|
+
|
73
|
+
def resource_map(resource_type)
|
74
|
+
camelizer_yaml["resource_keys"][resource_type] || {}
|
75
|
+
end
|
76
|
+
|
77
|
+
def camelizer_yaml
|
78
|
+
# default
|
79
|
+
path = File.expand_path("camelizer.yml", File.dirname(__FILE__))
|
80
|
+
default = YAML.load_file(path)
|
81
|
+
# project specific
|
82
|
+
path = "#{Dir.pwd}/configs/camelizer.yml"
|
83
|
+
if File.exist?(path)
|
84
|
+
project = YAML.load_file(path)
|
85
|
+
default.deep_merge(project)
|
86
|
+
else
|
87
|
+
default
|
88
|
+
end
|
89
|
+
end
|
90
|
+
memoize :camelizer_yaml
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
RSpec.describe CfnCamelizer do
|
2
|
+
let(:camelizer) { CfnCamelizer }
|
3
|
+
context "not camelize the special cases" do
|
4
|
+
it "transform should not transform keys under Fn::Sub" do
|
5
|
+
data = {"UserData"=>{"Fn::Sub"=>["hello", {"k1"=>"v1", "k2"=>"v2"}]}}
|
6
|
+
result = camelizer.transform(data)
|
7
|
+
expect(result).to eq(data)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
it "simple string" do
|
12
|
+
s = "foo_bar"
|
13
|
+
s = camelizer.camelize(s)
|
14
|
+
expect(s).to eq "FooBar"
|
15
|
+
end
|
16
|
+
|
17
|
+
it "transform keys" do
|
18
|
+
h = {foo_bar: 1}
|
19
|
+
result = camelizer.transform(h)
|
20
|
+
result.keys == ["FooBar"]
|
21
|
+
end
|
22
|
+
|
23
|
+
it "do not pasalize anything under Variables" do
|
24
|
+
h = {foo_bar: 1, variables: {dont_touch: 2}}
|
25
|
+
result = camelizer.transform(h)
|
26
|
+
# pp result
|
27
|
+
expect(result).to eq("FooBar"=>1, "Variables"=>{"dont_touch"=>2})
|
28
|
+
end
|
29
|
+
|
30
|
+
# CloudWatch Event patterns have slightly different casing
|
31
|
+
it "dasherize anything under EventPattern at the top level" do
|
32
|
+
h = {foo_bar: 1, event_pattern: {dash_me: 2}}
|
33
|
+
result = camelizer.transform(h)
|
34
|
+
# pp result
|
35
|
+
expect(result).to eq("FooBar"=>1, "EventPattern"=>{"dash-me"=>2})
|
36
|
+
end
|
37
|
+
|
38
|
+
it "camelize anything under EventPattern at any level beyond the top level" do
|
39
|
+
h = {foo_bar: 1, event_pattern: {dash_me: {camelize_me: 3}}}
|
40
|
+
result = camelizer.transform(h)
|
41
|
+
# pp result
|
42
|
+
expect(result).to eq("FooBar"=>1, "EventPattern"=>{"dash-me"=>{"camelizeMe"=>3}})
|
43
|
+
end
|
44
|
+
|
45
|
+
it "dont touch anything under ResponseParameters" do
|
46
|
+
h = {foo_bar: 1, response_parameters: {dont_touch: 3}}
|
47
|
+
result = camelizer.transform(h)
|
48
|
+
# pp result
|
49
|
+
expect(result).to eq("FooBar"=>1, "ResponseParameters"=>{"dont_touch"=>3})
|
50
|
+
end
|
51
|
+
|
52
|
+
it "dont touch anything with - or /" do
|
53
|
+
h = {foo_bar: 1, "has-dash": 2, "has/slash": 3,"application/json":4}
|
54
|
+
result = camelizer.transform(h)
|
55
|
+
# pp result
|
56
|
+
expect(result).to eq("FooBar"=>1, "has-dash"=>2,"has/slash"=>3,"application/json"=>4)
|
57
|
+
end
|
58
|
+
|
59
|
+
it "special map keys" do
|
60
|
+
h = {template_url: 1, ttl: 60}
|
61
|
+
result = camelizer.transform(h)
|
62
|
+
# pp result
|
63
|
+
expect(result).to eq("TemplateURL"=>1, "TTL"=> 60)
|
64
|
+
end
|
65
|
+
|
66
|
+
it "role_arn property under AWS::Events::Rule type maintains normal RoleArn camelization" do
|
67
|
+
h = {
|
68
|
+
events_rule: {
|
69
|
+
type: "AWS::Events::Rule",
|
70
|
+
properties: {
|
71
|
+
role_arn: "some.arn"
|
72
|
+
}
|
73
|
+
}
|
74
|
+
}
|
75
|
+
result = camelizer.transform(h)
|
76
|
+
# pp result
|
77
|
+
expect(result).to eq({"EventsRule"=>{"Type"=>"AWS::Events::Rule", "Properties"=>{"RoleArn"=>"some.arn"}}})
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require "bundler/setup"
|
2
|
+
require "cfn_camelizer"
|
3
|
+
|
4
|
+
RSpec.configure do |config|
|
5
|
+
# Enable flags like --only-failures and --next-failure
|
6
|
+
config.example_status_persistence_file_path = ".rspec_status"
|
7
|
+
|
8
|
+
# Disable RSpec exposing methods globally on `Module` and `main`
|
9
|
+
config.disable_monkey_patching!
|
10
|
+
|
11
|
+
config.expect_with :rspec do |c|
|
12
|
+
c.syntax = :expect
|
13
|
+
end
|
14
|
+
end
|