cody 0.9.8 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/.gitmodules +0 -9
  3. data/CHANGELOG.md +8 -0
  4. data/Gemfile +0 -2
  5. data/cody.gemspec +3 -3
  6. data/lib/cody.rb +4 -8
  7. data/lib/cody/aws_services.rb +1 -1
  8. data/lib/cody/aws_services/helpers.rb +20 -3
  9. data/lib/cody/cli.rb +2 -13
  10. data/lib/cody/{badge.rb → cli/badge.rb} +1 -1
  11. data/lib/cody/{base.rb → cli/base.rb} +9 -3
  12. data/lib/cody/{delete.rb → cli/delete.rb} +3 -3
  13. data/lib/cody/cli/deploy.rb +7 -0
  14. data/lib/cody/cli/help.rb +11 -0
  15. data/lib/cody/{help → cli/help}/deploy.md +0 -0
  16. data/lib/cody/{help → cli/help}/init.md +0 -0
  17. data/lib/cody/{help → cli/help}/logs.md +0 -0
  18. data/lib/cody/{help → cli/help}/start.md +0 -0
  19. data/lib/cody/{help → cli/help}/stop.md +0 -0
  20. data/lib/cody/{init.rb → cli/init.rb} +1 -2
  21. data/lib/cody/{list.rb → cli/list.rb} +7 -3
  22. data/lib/cody/cli/logs.rb +10 -0
  23. data/lib/cody/{sequence.rb → cli/sequence.rb} +3 -3
  24. data/lib/cody/{start.rb → cli/start.rb} +3 -3
  25. data/lib/cody/{status.rb → cli/status.rb} +2 -1
  26. data/lib/cody/{stop.rb → cli/stop.rb} +2 -1
  27. data/lib/cody/command.rb +11 -0
  28. data/lib/cody/core.rb +5 -5
  29. data/lib/cody/dsl/base.rb +9 -0
  30. data/lib/cody/dsl/project.rb +54 -49
  31. data/lib/cody/dsl/role.rb +11 -11
  32. data/lib/cody/dsl/schedule.rb +8 -8
  33. data/lib/cody/list/no_builds_project.rb +1 -1
  34. data/lib/cody/list/project.rb +1 -1
  35. data/lib/cody/project.rb +23 -23
  36. data/lib/cody/role.rb +20 -20
  37. data/lib/cody/schedule.rb +37 -37
  38. data/lib/cody/stack.rb +16 -71
  39. data/lib/cody/stack/base.rb +104 -0
  40. data/lib/cody/{create.rb → stack/create.rb} +2 -2
  41. data/lib/cody/{update.rb → stack/update.rb} +2 -2
  42. data/lib/cody/tailer.rb +1 -1
  43. data/lib/cody/version.rb +1 -1
  44. data/lib/template/project/buildspec.yml +1 -1
  45. data/lib/template/project/project.rb.tt +5 -19
  46. metadata +64 -70
  47. data/lib/cody/completer.rb +0 -159
  48. data/lib/cody/completer/script.rb +0 -6
  49. data/lib/cody/completer/script.sh +0 -10
  50. data/lib/cody/deploy.rb +0 -40
  51. data/lib/cody/help.rb +0 -9
  52. data/lib/cody/help/completion.md +0 -22
  53. data/lib/cody/help/completion_script.md +0 -3
  54. data/lib/cody/logs.rb +0 -14
  55. data/vendor/aws_data/CHANGELOG.md +0 -7
  56. data/vendor/aws_data/Gemfile +0 -4
  57. data/vendor/aws_data/LICENSE.txt +0 -21
  58. data/vendor/aws_data/README.md +0 -42
  59. data/vendor/aws_data/Rakefile +0 -6
  60. data/vendor/aws_data/aws_data.gemspec +0 -30
  61. data/vendor/aws_data/bin/console +0 -14
  62. data/vendor/aws_data/bin/setup +0 -8
  63. data/vendor/aws_data/lib/aws_data.rb +0 -91
  64. data/vendor/aws_data/lib/aws_data/version.rb +0 -3
  65. data/vendor/aws_data/spec/aws_data_spec.rb +0 -5
  66. data/vendor/aws_data/spec/spec_helper.rb +0 -14
  67. data/vendor/cfn-status/Gemfile +0 -4
  68. data/vendor/cfn-status/LICENSE.txt +0 -21
  69. data/vendor/cfn-status/README.md +0 -56
  70. data/vendor/cfn-status/Rakefile +0 -6
  71. data/vendor/cfn-status/bin/console +0 -14
  72. data/vendor/cfn-status/bin/setup +0 -8
  73. data/vendor/cfn-status/cfn-status.gemspec +0 -30
  74. data/vendor/cfn-status/lib/cfn/aws_service.rb +0 -56
  75. data/vendor/cfn-status/lib/cfn/status.rb +0 -220
  76. data/vendor/cfn-status/lib/cfn/status/version.rb +0 -5
  77. data/vendor/cfn-status/spec/cfn/status_spec.rb +0 -81
  78. data/vendor/cfn-status/spec/fixtures/cfn/stack-events-complete.json +0 -1080
  79. data/vendor/cfn-status/spec/fixtures/cfn/stack-events-in-progress.json +0 -1080
  80. data/vendor/cfn-status/spec/fixtures/cfn/stack-events-update-rollback-complete.json +0 -1086
  81. data/vendor/cfn-status/spec/spec_helper.rb +0 -14
  82. data/vendor/cfn_camelizer/CHANGELOG.md +0 -10
  83. data/vendor/cfn_camelizer/Gemfile +0 -4
  84. data/vendor/cfn_camelizer/LICENSE.txt +0 -21
  85. data/vendor/cfn_camelizer/README.md +0 -40
  86. data/vendor/cfn_camelizer/Rakefile +0 -6
  87. data/vendor/cfn_camelizer/bin/console +0 -14
  88. data/vendor/cfn_camelizer/bin/setup +0 -8
  89. data/vendor/cfn_camelizer/cfn_camelizer.gemspec +0 -32
  90. data/vendor/cfn_camelizer/lib/camelizer.yml +0 -33
  91. data/vendor/cfn_camelizer/lib/cfn_camelizer.rb +0 -92
  92. data/vendor/cfn_camelizer/lib/cfn_camelizer/version.rb +0 -3
  93. data/vendor/cfn_camelizer/spec/cfn_camelizer_spec.rb +0 -79
  94. data/vendor/cfn_camelizer/spec/spec_helper.rb +0 -14
@@ -1,14 +0,0 @@
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
@@ -1,10 +0,0 @@
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
@@ -1,4 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- # Specify your gem's dependencies in cfn_camelizer.gemspec
4
- gemspec
@@ -1,21 +0,0 @@
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.
@@ -1,40 +0,0 @@
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).
@@ -1,6 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task :default => :spec
@@ -1,14 +0,0 @@
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__)
@@ -1,8 +0,0 @@
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
@@ -1,32 +0,0 @@
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
@@ -1,33 +0,0 @@
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::AutoScaling::AutoScalingGroup:
8
- ServiceLinkedRoleArn: ServiceLinkedRoleARN
9
- TargetGroupArns: TargetGroupARNs
10
- VpcZoneIdentifier: VPCZoneIdentifier
11
- AutoScaling::LaunchConfiguration:
12
- ClassicLinkVpcId: ClassicLinkVPCId
13
- ClassicLinkVpcSecurityGroups: ClassicLinkVPCSecurityGroups
14
- AWS::AutoScaling::LifecycleHook:
15
- NotificationTargetArn: NotificationTargetARN
16
- RoleArn: RoleARN
17
- AWS::ApplicationAutoScaling::ScalableTarget:
18
- RoleArn: RoleARN
19
- AWS::CloudFormation::Stack:
20
- NotificationArns: NotificationARNs
21
- TemplateUrl: TemplateURL
22
- AWS::Route53::RecordSet:
23
- Ttl: TTL
24
- AWS::RDS::DBSubnetGroup:
25
- DbSubnetGroupDescription: DBSubnetGroupDescription
26
- DbSubnetGroupName: DBSubnetGroupName
27
- AWS::SQS::Queue:
28
- DeadLetterTargetArn: deadLetterTargetArn # under RedrivePolicy
29
- MaxReceiveCount: maxReceiveCount # under RedrivePolicy
30
- passthrough_parent_keys:
31
- - Fn::Sub # https://amzn.to/2HKwxri
32
- - ResponseParameters # API Gateway MethodResponse https://amzn.to/2HKw0Wk
33
- - Variables # Lambda Environment Variables https://amzn.to/2HLlttV
@@ -1,92 +0,0 @@
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
@@ -1,3 +0,0 @@
1
- class CfnCamelizer
2
- VERSION = "0.2.0"
3
- end
@@ -1,79 +0,0 @@
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
@@ -1,14 +0,0 @@
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