cfndsl 1.3.9 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CfnDsl
4
- VERSION = '1.3.9'
4
+ VERSION = '1.4.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'
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.4.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-08-28 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler