cfndsl 1.3.9 → 1.5.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.
data/lib/cfndsl/module.rb CHANGED
@@ -79,7 +79,7 @@ class Module
79
79
  raise ArgumentError, "wrong number of arguments (given #{values.size + 1}, expected 1) as #{method}(#{name}) already exists"
80
80
  end
81
81
  instance.instance_eval(&block) if block
82
- return instance
82
+ instance
83
83
  end
84
84
  end
85
85
  end
data/lib/cfndsl/types.rb CHANGED
@@ -14,7 +14,10 @@ module CfnDsl
14
14
  # and not all resources use the general form
15
15
  if property_info['ItemType'] == 'Tag'
16
16
  ['Tag']
17
- elsif (property_info['ItemType'] == 'Json') && (property_info['Type'] == 'List')
17
+ elsif (property_info['Type'] == 'List') && %w[Json List].include?(property_info['ItemType'])
18
+ # List of arbitrary json
19
+ # or List of list eg - AWS::Rekognition::StreamProcessor.PolygonRegionsOfInterest
20
+ # which is actually List of List of embedded type 'Point', but this is not properly represented in the schema
18
21
  ['Json']
19
22
  else
20
23
  Array(root_name + property_info['ItemType'])
@@ -43,8 +46,6 @@ module CfnDsl
43
46
  Array(property_info['PrimitiveItemType'])
44
47
  elsif property_info['PrimitiveTypes']
45
48
  property_info['PrimitiveTypes'][0]
46
- elsif property_info['ItemType'] == 'List'
47
- 'List'
48
49
  elsif property_info['ItemType']
49
50
  extract_list_type(resource_name.split('::').join, property_info)
50
51
  elsif property_info['Type']
@@ -75,8 +76,7 @@ module CfnDsl
75
76
  'Double' => 'Double',
76
77
  'Timestamp' => 'Timestamp',
77
78
  'Map' => 'Map',
78
- 'Long' => 'Long',
79
- 'List' => 'List'
79
+ 'Long' => 'Long'
80
80
  }
81
81
  spec.each_with_object(primitive_types) do |(property_name, property_info), types|
82
82
  # In order to name things uniquely and allow for connections
@@ -112,8 +112,7 @@ module CfnDsl
112
112
  elsif nested_prop_info['Type']
113
113
  root_resource_name + nested_prop_info['Type']
114
114
  else
115
- warn "could not extract property type for #{nested_prop_name} from #{property_name}, assuming Json"
116
- p nested_prop_info
115
+ warn "could not extract property type for #{nested_prop_name} from #{property_name}, assuming Json\n#{nested_prop_info}"
117
116
  'Json'
118
117
  end
119
118
  extracted[nested_prop_name] = nested_prop_type
@@ -275,7 +274,7 @@ module CfnDsl
275
274
  existing.push v
276
275
  end
277
276
  end
278
- return existing
277
+ existing
279
278
  end
280
279
  end
281
280
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CfnDsl
4
- VERSION = '1.3.9'
4
+ VERSION = '1.5.0'
5
5
  end
@@ -88,6 +88,25 @@ describe CfnDsl::CloudFormationTemplate do
88
88
  end
89
89
 
90
90
  describe 'Top level Lists' do
91
+ it 'can add a specific type' do
92
+ template.S3_Bucket('Bucket') do
93
+ InventoryConfiguration do
94
+ Enabled true
95
+ end
96
+ end
97
+ expect(template.to_json).to include('"InventoryConfigurations":[{"Enabled":true}]')
98
+ end
99
+
100
+ it 'handles List of List as arbitrary json' do
101
+ skip 'requires spec 0.69' unless template.respond_to?(:Rekognition_StreamProcessor)
102
+ regions = [[{ X: 0.2, Y: 0.4 }, { X: 0.1, Y: 0.5 }, { X: 0.1, Y: 0.9 }], [{ X: 0.6, Y: 0.3 }, { "X": 0.2, "Y": 0.7 }, { "X": 0.1, "Y": 0.1 }]]
103
+ template.Rekognition_StreamProcessor('StreamProcessor') do
104
+ # Ouch this has a nasty singular form too! strictly PolygonRegionOfInterest should add one list
105
+ PolygonRegionsOfInterest regions
106
+ end
107
+ expect(template.to_json).to include("\"PolygonRegionsOfInterest\":#{regions.to_json}")
108
+ end
109
+
91
110
  it 'appends item if singular form != plural form is passed a single item' do
92
111
  template.AutoScaling_AutoScalingGroup('ASG') do
93
112
  AvailabilityZone 'region-2a'
@@ -8,11 +8,13 @@ describe Cfnlego do
8
8
  context '#Export' do
9
9
  it 'formats correctly' do
10
10
  output = "require 'cfndsl'\nCloudFormation do\n Description 'auto generated cloudformation cfndsl template'\n\n "
11
- output << " EC2_EIP('EIP') do\n Domain String "
12
- output << '# http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-eip.html#cfn-ec2-eip-domain'
13
- output << "\n InstanceId String # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-eip.html#cfn-ec2-eip-instanceid"
14
- output << "\n PublicIpv4Pool String # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-eip.html#cfn-ec2-eip-publicipv4pool"
15
- output << "\n Tags [List] # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-eip.html#cfn-ec2-eip-tags"
11
+ output << " EC2_EIP('EIP') do"
12
+ output << "\n InstanceId String # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-eip.html#cfn-ec2-eip-instanceid"
13
+ output << "\n PublicIpv4Pool String # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-eip.html#cfn-ec2-eip-publicipv4pool"
14
+ output << "\n TransferAddress String # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-eip.html#cfn-ec2-eip-transferaddress"
15
+ output << "\n Domain String # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-eip.html#cfn-ec2-eip-domain"
16
+ output << "\n Tags [List] # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-eip.html#cfn-ec2-eip-tags"
17
+ output << "\n NetworkBorderGroup String # http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-eip.html#cfn-ec2-eip-networkbordergroup"
16
18
  output << "\n end\nend\n"
17
19
  expect(template).to eq output
18
20
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cfndsl
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.9
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Jack
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: exe
13
13
  cert_chain: []
14
- date: 2022-07-26 00:00:00.000000000 Z
14
+ date: 2022-12-28 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler
@@ -187,14 +187,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
187
187
  requirements:
188
188
  - - ">="
189
189
  - !ruby/object:Gem::Version
190
- version: '2.6'
190
+ version: '2.7'
191
191
  required_rubygems_version: !ruby/object:Gem::Requirement
192
192
  requirements:
193
193
  - - ">="
194
194
  - !ruby/object:Gem::Version
195
195
  version: '0'
196
196
  requirements: []
197
- rubygems_version: 3.3.7
197
+ rubygems_version: 3.4.1
198
198
  signing_key:
199
199
  specification_version: 4
200
200
  summary: AWS Cloudformation DSL