cfndsl 0.15.3 → 0.16.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -83,7 +83,7 @@ module CfnDsl
83
83
  define_method(method) do |value = nil, &block|
84
84
  @Properties ||= {}
85
85
  @Properties[pname] ||= PropertyDefinition.new([])
86
- value = pclass.new unless value
86
+ value ||= pclass.new
87
87
  @Properties[pname].value.push value
88
88
  value.instance_eval(&block) if block
89
89
  value
@@ -138,11 +138,11 @@ module CfnDsl
138
138
  invalids = []
139
139
  @_resource_refs = {}
140
140
  if @Resources
141
- @Resources.keys.each do |resource|
141
+ @Resources.each_key do |resource|
142
142
  @_resource_refs[resource.to_s] = @Resources[resource].build_references({})
143
143
  end
144
- @_resource_refs.keys.each do |origin|
145
- @_resource_refs[origin].keys.each do |ref|
144
+ @_resource_refs.each_key do |origin|
145
+ @_resource_refs[origin].each_key do |ref|
146
146
  invalids.push "Invalid Reference: Resource #{origin} refers to #{ref}" unless valid_ref?(ref, origin)
147
147
  end
148
148
  end
@@ -154,11 +154,11 @@ module CfnDsl
154
154
  invalids = []
155
155
  output_refs = {}
156
156
  if @Outputs
157
- @Outputs.keys.each do |resource|
157
+ @Outputs.each_key do |resource|
158
158
  output_refs[resource.to_s] = @Outputs[resource].build_references({})
159
159
  end
160
- output_refs.keys.each do |origin|
161
- output_refs[origin].keys.each do |ref|
160
+ output_refs.each_key do |origin|
161
+ output_refs[origin].each_key do |ref|
162
162
  invalids.push "Invalid Reference: Output #{origin} refers to #{ref}" unless valid_ref?(ref)
163
163
  end
164
164
  end
@@ -40,28 +40,6 @@ module CfnDsl
40
40
  'Type' => { 'PrimitiveType' => 'String' },
41
41
  'Value' => { 'PrimitiveType' => 'String' }
42
42
  }
43
- },
44
- 'AWS::EC2::VPNGatewayConnection' => {
45
- 'Properties' => {
46
- 'Type' => { 'PrimitiveType' => 'String' },
47
- 'Tags' => { 'Type' => 'List', 'ItemType' => 'Tag' }
48
- }
49
- },
50
- 'AWS::EC2::EIPAssociation' => {
51
- 'Properties' => {
52
- 'AllocationId' => { 'PrimitiveType' => 'String' },
53
- 'EIP' => { 'PrimitiveType' => 'String' },
54
- 'InstanceId' => { 'PrimitiveType' => 'String' },
55
- 'NetworkInterfaceId' => { 'PrimitiveType' => 'String' },
56
- 'PrivateIpAddress' => { 'PrimitiveType' => 'String' }
57
- }
58
- },
59
- 'AWS::Config::ConfigurationRecorder' => {
60
- 'Properties' => {
61
- 'Name' => { 'PrimitiveType' => 'String' },
62
- 'RecordingGroup' => { 'Type' => 'RecordingGroup' },
63
- 'RoleARN' => { 'PrimitiveType' => 'String' }
64
- }
65
43
  }
66
44
  }
67
45
  end
@@ -86,11 +64,6 @@ module CfnDsl
86
64
  'PolicyDocument' => { 'PrimitiveType' => 'Json' },
87
65
  'PolicyName' => { 'PrimitiveType' => 'String' }
88
66
  }
89
- },
90
- 'AWS::Cognito::IdentityPoolRoleAttachment.RulesConfigurationType' => {
91
- 'Properties' => {
92
- 'Rules' => { 'Type' => 'List', 'ItemType' => 'MappingRule' }
93
- }
94
67
  }
95
68
  }
96
69
  end
@@ -65,7 +65,7 @@ module CfnDsl
65
65
  elsif nested_prop_info['PrimitiveItemType']
66
66
  nested_prop_type = Array(nested_prop_info['PrimitiveItemType'])
67
67
  elsif nested_prop_info['ItemType']
68
- nested_prop_type = root_resource_name + nested_prop_info['ItemType']
68
+ nested_prop_type = Array(root_resource_name + nested_prop_info['ItemType'])
69
69
  elsif nested_prop_info['Type']
70
70
  nested_prop_type = root_resource_name + nested_prop_info['Type']
71
71
  else
data/lib/cfndsl/types.rb CHANGED
@@ -18,10 +18,10 @@ module CfnDsl
18
18
  type_def.const_set('Types_Internal', types_list)
19
19
  # Do a little sanity checking - all of the types referenced in Resources
20
20
  # should be represented in Types
21
- types_list['Resources'].keys.each do |resource_name|
21
+ types_list['Resources'].each_key do |resource_name|
22
22
  resource = types_list['Resources'][resource_name]
23
- resource.values.each do |thing|
24
- thing.values.each do |type|
23
+ resource.each_value do |thing|
24
+ thing.each_value do |type|
25
25
  if type.is_a?(Array)
26
26
  type.each do |inner_type|
27
27
  puts "unknown type #{inner_type}" unless types_list['Types'].key?(inner_type)
@@ -36,7 +36,7 @@ module CfnDsl
36
36
  # All of the type values should also be references
37
37
  types_list['Types'].values do |type|
38
38
  if type.respond_to?(:values)
39
- type.values.each do |tv|
39
+ type.each_value do |tv|
40
40
  puts "unknown type #{tv}" unless types_list['Types'].key?(tv)
41
41
  end
42
42
  end
@@ -76,13 +76,13 @@ module CfnDsl
76
76
  # We are going to modify the value in some
77
77
  # way, make sure that we have an array to mess
78
78
  # with if we start with nothing
79
- existing = instance_variable_set(variable, []) unless existing
79
+ existing ||= instance_variable_set(variable, [])
80
80
 
81
81
  # special case for just a block, no args
82
82
  if value.nil? && rest.empty? && block
83
83
  val = klass.new
84
84
  existing.push val
85
- value.instance_eval(&block(val))
85
+ val.instance_eval(&block)
86
86
  return existing
87
87
  end
88
88
 
@@ -1,3 +1,3 @@
1
1
  module CfnDsl
2
- VERSION = '0.15.3'.freeze
2
+ VERSION = '0.16.1'.freeze
3
3
  end
data/lib/cfnlego.rb CHANGED
@@ -11,7 +11,7 @@ module Cfnlego
11
11
  content = fetch_resource_content
12
12
  supported_resources = JSON.parse(content)
13
13
  resources = []
14
- supported_resources['ResourceTypes'].each do |resource, _value|
14
+ supported_resources['ResourceTypes'].each_key do |resource|
15
15
  resources << resource
16
16
  end
17
17
  resources
@@ -35,7 +35,7 @@ module Cfnlego
35
35
  begin
36
36
  return Cfnlego::CloudFormation.new(resources).render
37
37
  rescue RuntimeError => e
38
- $stderr.puts "Error: #{e.message}"
38
+ warn "Error: #{e.message}"
39
39
  end
40
40
  nil
41
41
  end
@@ -29,7 +29,7 @@ module Cfnlego
29
29
  data = datainput['ResourceTypes']
30
30
  begin
31
31
  @definition ||= data[@type]
32
- rescue
32
+ rescue RuntimeError
33
33
  raise "unknown #{@type}, no matching definition found"
34
34
  end
35
35
  end
@@ -204,7 +204,7 @@ module DeepMerge
204
204
  end
205
205
  puts "#{di}Returning #{dest.inspect}" if merge_debug
206
206
  dest
207
- end # deep_merge!
207
+ end
208
208
 
209
209
  # allows deep_merge! to uniformly handle overwriting of unmergeable entities
210
210
  def self.overwrite_unmergeables(source, dest, options)
@@ -241,4 +241,4 @@ module DeepMerge
241
241
  end
242
242
  obj
243
243
  end
244
- end # module DeepMerge
244
+ end
@@ -9,7 +9,7 @@ module DeepMerge
9
9
  default_opts = { preserve_unmergeables: false }
10
10
  DeepMerge.deep_merge!(source, self, default_opts.merge(options))
11
11
  end
12
- end # DeepMergeHashExt
12
+ end
13
13
  end
14
14
 
15
15
  # Extends hash with deep merge
data/spec/cfndsl_spec.rb CHANGED
@@ -232,11 +232,11 @@ describe CfnDsl::CloudFormationTemplate do
232
232
 
233
233
  context 'FnFormat', 'Multiline' do
234
234
  it 'formats correctly' do
235
- multiline = <<-EOF.gsub(/^ {10}/, '')
235
+ multiline = <<-TEXT.gsub(/^ {10}/, '')
236
236
  This is the first line
237
237
  This is the %0 line
238
238
  This is a %% sign
239
- EOF
239
+ TEXT
240
240
  func = subject.FnFormat(multiline, 'second')
241
241
  expect(func.to_json).to eq('{"Fn::Join":["",["This is the first line\nThis is the ","second"," line\nThis is a ","%"," sign\n"]]}')
242
242
  end
data/spec/cli_spec.rb CHANGED
@@ -65,7 +65,7 @@ describe 'cfndsl', type: :aruba do
65
65
  expect(last_command_started).to have_output_on_stderr(<<-WARN.gsub(/^ {8}/, '').chomp)
66
66
  The creation of constants as config is deprecated!
67
67
  Please switch to the #external_parameters method within your templates to access variables
68
- See https://github.com/stevenjack/cfndsl/issues/170
68
+ See https://github.com/cfndsl/cfndsl/issues/170
69
69
  Use the --disable-binding flag to suppress this message
70
70
  WARN
71
71
  end
@@ -16,7 +16,7 @@ RSpec.describe 'Type Definitions' do
16
16
  resources.each do |name, info|
17
17
  it "#{name} has all property types defined" do
18
18
  properties = info['Properties']
19
- properties.each do |_, type|
19
+ properties.each_value do |type|
20
20
  type = type.first if type.is_a?(Array)
21
21
  expect(types).to have_key(type)
22
22
  end
metadata CHANGED
@@ -1,15 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cfndsl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.3
4
+ version: 0.16.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Jack
8
8
  - Chris Howe
9
+ - Travis Dempsey
10
+ - Greg Cockburn
9
11
  autorequire:
10
12
  bindir: bin
11
13
  cert_chain: []
12
- date: 2017-09-05 00:00:00.000000000 Z
14
+ date: 2017-12-02 00:00:00.000000000 Z
13
15
  dependencies:
14
16
  - !ruby/object:Gem::Dependency
15
17
  name: bundler
@@ -29,6 +31,8 @@ description: DSL for creating AWS Cloudformation templates
29
31
  email:
30
32
  - stevenmajack@gmail.com
31
33
  - chris@howeville.com
34
+ - dempsey.travis@gmail.com
35
+ - gergnz@gmail.com
32
36
  executables:
33
37
  - cfndsl
34
38
  extensions: []
@@ -125,7 +129,7 @@ files:
125
129
  - spec/support/shared_examples/orchestration_template.rb
126
130
  - spec/transform_spec.rb
127
131
  - spec/types_definition_spec.rb
128
- homepage: https://github.com/stevenjack/cfndsl
132
+ homepage: https://github.com/cfndsl/cfndsl
129
133
  licenses:
130
134
  - MIT
131
135
  metadata: {}
@@ -146,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
146
150
  version: '0'
147
151
  requirements: []
148
152
  rubyforge_project:
149
- rubygems_version: 2.6.13
153
+ rubygems_version: 2.7.3
150
154
  signing_key:
151
155
  specification_version: 4
152
156
  summary: AWS Cloudformation DSL