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.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/.cody/buildspec.yml +9 -0
  3. data/.cody/project.rb +4 -0
  4. data/.gitignore +16 -11
  5. data/.gitmodules +9 -0
  6. data/.rspec +1 -1
  7. data/CHANGELOG.md +34 -0
  8. data/Gemfile +3 -1
  9. data/Gemfile.lock +112 -0
  10. data/Guardfile +19 -0
  11. data/LICENSE.txt +18 -17
  12. data/README.md +55 -21
  13. data/Rakefile +10 -2
  14. data/exe/pipe +14 -0
  15. data/exe/pipedream +14 -0
  16. data/lib/pipedream/autoloader.rb +21 -0
  17. data/lib/pipedream/aws_services/helpers.rb +71 -0
  18. data/lib/pipedream/aws_services.rb +20 -0
  19. data/lib/pipedream/build.rb +13 -0
  20. data/lib/pipedream/cli.rb +60 -0
  21. data/lib/pipedream/command.rb +82 -0
  22. data/lib/pipedream/completer/script.rb +6 -0
  23. data/lib/pipedream/completer/script.sh +10 -0
  24. data/lib/pipedream/completer.rb +159 -0
  25. data/lib/pipedream/core.rb +63 -0
  26. data/lib/pipedream/create.rb +12 -0
  27. data/lib/pipedream/delete.rb +27 -0
  28. data/lib/pipedream/deploy.rb +40 -0
  29. data/lib/pipedream/dsl/pipeline/approve.rb +34 -0
  30. data/lib/pipedream/dsl/pipeline/codebuild.rb +57 -0
  31. data/lib/pipedream/dsl/pipeline/github.rb +42 -0
  32. data/lib/pipedream/dsl/pipeline.rb +37 -0
  33. data/lib/pipedream/dsl/role.rb +50 -0
  34. data/lib/pipedream/dsl/schedule.rb +30 -0
  35. data/lib/pipedream/dsl/sns.rb +15 -0
  36. data/lib/pipedream/dsl/ssm.rb +22 -0
  37. data/lib/pipedream/dsl/webhook.rb +27 -0
  38. data/lib/pipedream/evaluate.rb +47 -0
  39. data/lib/pipedream/help/completion.md +22 -0
  40. data/lib/pipedream/help/completion_script.md +3 -0
  41. data/lib/pipedream/help/deploy.md +54 -0
  42. data/lib/pipedream/help/start.md +20 -0
  43. data/lib/pipedream/help.rb +9 -0
  44. data/lib/pipedream/init.rb +68 -0
  45. data/lib/pipedream/pipeline/s3_bucket.rb +88 -0
  46. data/lib/pipedream/pipeline.rb +61 -0
  47. data/lib/pipedream/role.rb +181 -0
  48. data/lib/pipedream/schedule.rb +99 -0
  49. data/lib/pipedream/sequence.rb +66 -0
  50. data/lib/pipedream/setting.rb +82 -0
  51. data/lib/pipedream/sns.rb +43 -0
  52. data/lib/pipedream/stack.rb +95 -0
  53. data/lib/pipedream/start.rb +84 -0
  54. data/lib/pipedream/update.rb +12 -0
  55. data/lib/pipedream/version.rb +1 -1
  56. data/lib/pipedream/webhook.rb +60 -0
  57. data/lib/pipedream.rb +18 -1
  58. data/lib/template/.pipedream/pipeline.rb.tt +40 -0
  59. data/lib/template/.pipedream/schedule.rb +3 -0
  60. data/lib/template/.pipedream/settings.yml +9 -0
  61. data/lib/template/.pipedream/sns.rb +14 -0
  62. data/pipedream.gemspec +25 -14
  63. data/vendor/aws_data/CHANGELOG.md +7 -0
  64. data/vendor/aws_data/Gemfile +4 -0
  65. data/vendor/aws_data/Gemfile.lock +48 -0
  66. data/vendor/aws_data/LICENSE.txt +21 -0
  67. data/vendor/aws_data/README.md +42 -0
  68. data/vendor/aws_data/Rakefile +6 -0
  69. data/vendor/aws_data/aws_data.gemspec +30 -0
  70. data/{bin → vendor/aws_data/bin}/console +1 -1
  71. data/{bin → vendor/aws_data/bin}/setup +0 -0
  72. data/vendor/aws_data/lib/aws_data/version.rb +3 -0
  73. data/vendor/aws_data/lib/aws_data.rb +91 -0
  74. data/vendor/aws_data/spec/aws_data_spec.rb +5 -0
  75. data/vendor/aws_data/spec/spec_helper.rb +14 -0
  76. data/vendor/cfn-status/Gemfile +4 -0
  77. data/vendor/cfn-status/Gemfile.lock +49 -0
  78. data/vendor/cfn-status/LICENSE.txt +21 -0
  79. data/vendor/cfn-status/README.md +56 -0
  80. data/vendor/cfn-status/Rakefile +6 -0
  81. data/vendor/cfn-status/bin/console +14 -0
  82. data/vendor/cfn-status/bin/setup +8 -0
  83. data/vendor/cfn-status/cfn-status.gemspec +30 -0
  84. data/vendor/cfn-status/lib/cfn/aws_service.rb +56 -0
  85. data/vendor/cfn-status/lib/cfn/status/version.rb +5 -0
  86. data/vendor/cfn-status/lib/cfn/status.rb +220 -0
  87. data/vendor/cfn-status/spec/cfn/status_spec.rb +81 -0
  88. data/vendor/cfn-status/spec/fixtures/cfn/stack-events-complete.json +1080 -0
  89. data/vendor/cfn-status/spec/fixtures/cfn/stack-events-in-progress.json +1080 -0
  90. data/vendor/cfn-status/spec/fixtures/cfn/stack-events-update-rollback-complete.json +1086 -0
  91. data/vendor/cfn-status/spec/spec_helper.rb +14 -0
  92. data/vendor/cfn_camelizer/CHANGELOG.md +10 -0
  93. data/vendor/cfn_camelizer/Gemfile +4 -0
  94. data/vendor/cfn_camelizer/LICENSE.txt +21 -0
  95. data/vendor/cfn_camelizer/README.md +40 -0
  96. data/vendor/cfn_camelizer/Rakefile +6 -0
  97. data/vendor/cfn_camelizer/bin/console +14 -0
  98. data/vendor/cfn_camelizer/bin/setup +8 -0
  99. data/vendor/cfn_camelizer/cfn_camelizer.gemspec +32 -0
  100. data/vendor/cfn_camelizer/lib/camelizer.yml +27 -0
  101. data/vendor/cfn_camelizer/lib/cfn_camelizer/version.rb +3 -0
  102. data/vendor/cfn_camelizer/lib/cfn_camelizer.rb +92 -0
  103. data/vendor/cfn_camelizer/spec/cfn_camelizer_spec.rb +79 -0
  104. data/vendor/cfn_camelizer/spec/spec_helper.rb +14 -0
  105. metadata +295 -23
  106. 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,10 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ This project *tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
5
+
6
+ ## [0.2.0]
7
+ - add AWS special key
8
+
9
+ ## [0.1.0]
10
+ - Initial release
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in cfn_camelizer.gemspec
4
+ gemspec
@@ -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,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -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,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -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,3 @@
1
+ class CfnCamelizer
2
+ VERSION = "0.2.0"
3
+ end
@@ -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