cfn_camelizer 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/camelizer.yml +28 -7
- data/lib/cfn_camelizer.rb +17 -8
- data/lib/cfn_camelizer/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0765e9ad5840366f4dc60588ef01230d6fd8197d6f8581d8723f0f0c6385e655
|
4
|
+
data.tar.gz: 5af541989f281e5946e8393befa56b3a81d50859b7378f96f37ac802265bfb7d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac32f48489ea365ec19857a3af978a6e21180a1afd479dcaaec96d18611349a5627137ccf648b89f1a8c14cb5a880d91b9f5a0a77b45808839f207ea352e07a0
|
7
|
+
data.tar.gz: b9e45d897be5f2fe349ebe578cdeb662594b1b66f3dc69ad592348f65031c31cc68960f288c47362a5c813bf42c51afd57a9bcf6dde3003fc543053b459522bd
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,13 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
This project *tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
|
5
5
|
|
6
|
+
## [0.3.0]
|
7
|
+
- camelizer.yml: scope camelizing rules more finely with resource_keys rule
|
8
|
+
- add NotificationTargetARN
|
9
|
+
- add AWS::Events::Rule RoleArn
|
10
|
+
- add VpcZoneIdentifier
|
11
|
+
- add ScalableTarget
|
12
|
+
|
6
13
|
## [0.2.0]
|
7
14
|
- add AWS special key
|
8
15
|
|
data/lib/camelizer.yml
CHANGED
@@ -1,13 +1,34 @@
|
|
1
1
|
---
|
2
2
|
special_keys:
|
3
3
|
Aws: AWS
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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::ApplicationAutoScaling::ScalableTarget:
|
8
|
+
RoleArn: RoleARN
|
9
|
+
AWS::AutoScaling::AutoScalingGroup:
|
10
|
+
ServiceLinkedRoleArn: ServiceLinkedRoleARN
|
11
|
+
TargetGroupArns: TargetGroupARNs
|
12
|
+
VpcZoneIdentifier: VPCZoneIdentifier
|
13
|
+
AWS::AutoScaling::LifecycleHook:
|
14
|
+
NotificationTargetArn: NotificationTargetARN
|
15
|
+
RoleArn: RoleARN
|
16
|
+
AWS::CloudFormation::Stack:
|
17
|
+
NotificationArns: NotificationARNs
|
18
|
+
TemplateUrl: TemplateURL
|
19
|
+
AWS::Events::Rule:
|
20
|
+
RoleARN: RoleArn
|
21
|
+
AWS::Route53::RecordSet:
|
22
|
+
Ttl: TTL
|
23
|
+
AWS::RDS::DBSubnetGroup:
|
24
|
+
DbSubnetGroupDescription: DBSubnetGroupDescription
|
25
|
+
DbSubnetGroupName: DBSubnetGroupName
|
26
|
+
AWS::SQS::Queue:
|
27
|
+
DeadLetterTargetArn: deadLetterTargetArn # under RedrivePolicy
|
28
|
+
MaxReceiveCount: maxReceiveCount # under RedrivePolicy
|
29
|
+
AutoScaling::LaunchConfiguration:
|
30
|
+
ClassicLinkVpcId: ClassicLinkVPCId
|
31
|
+
ClassicLinkVpcSecurityGroups: ClassicLinkVPCSecurityGroups
|
11
32
|
passthrough_parent_keys:
|
12
33
|
- Fn::Sub # https://amzn.to/2HKwxri
|
13
34
|
- ResponseParameters # API Gateway MethodResponse https://amzn.to/2HKw0Wk
|
data/lib/cfn_camelizer.rb
CHANGED
@@ -9,14 +9,18 @@ class CfnCamelizer
|
|
9
9
|
class << self
|
10
10
|
extend Memoist
|
11
11
|
|
12
|
-
def transform(value, parent_keys=[])
|
12
|
+
def transform(value, parent_keys=[], resource_type=nil)
|
13
13
|
case value
|
14
14
|
when Array
|
15
|
-
value.map { |v| transform(v, parent_keys) }
|
15
|
+
value.map { |v| transform(v, parent_keys, resource_type) }
|
16
16
|
when Hash
|
17
|
+
if value.keys.include?(:type)
|
18
|
+
resource_type ||= value[:type]
|
19
|
+
end
|
20
|
+
|
17
21
|
initializer = value.map do |k, v|
|
18
|
-
new_key = camelize_key(k, parent_keys)
|
19
|
-
[new_key, transform(v, parent_keys+[new_key])]
|
22
|
+
new_key = camelize_key(k, parent_keys, resource_type)
|
23
|
+
[new_key, transform(v, parent_keys+[new_key], resource_type)]
|
20
24
|
end
|
21
25
|
Hash[initializer]
|
22
26
|
else
|
@@ -24,7 +28,7 @@ class CfnCamelizer
|
|
24
28
|
end
|
25
29
|
end
|
26
30
|
|
27
|
-
def camelize_key(k, parent_keys=[])
|
31
|
+
def camelize_key(k, parent_keys=[], resource_type=nil)
|
28
32
|
k = k.to_s
|
29
33
|
|
30
34
|
if passthrough?(k, parent_keys)
|
@@ -35,7 +39,7 @@ class CfnCamelizer
|
|
35
39
|
# Any keys at 2nd level under EventPattern will be pascalized
|
36
40
|
pascalize(k)
|
37
41
|
else
|
38
|
-
camelize(k)
|
42
|
+
camelize(k, resource_type)
|
39
43
|
end
|
40
44
|
end
|
41
45
|
|
@@ -46,11 +50,12 @@ class CfnCamelizer
|
|
46
50
|
!intersection.empty? || k.include?('-') || k.include?('/')
|
47
51
|
end
|
48
52
|
|
49
|
-
def camelize(value)
|
53
|
+
def camelize(value, resource_type=nil)
|
50
54
|
return value if value.is_a?(Integer)
|
51
55
|
|
52
56
|
value = value.to_s.camelize
|
53
|
-
special_map[value] || value
|
57
|
+
v = special_map[value] || value # after the special_keys map
|
58
|
+
resource_map(resource_type)[v] || v
|
54
59
|
end
|
55
60
|
|
56
61
|
def pascalize(value)
|
@@ -65,6 +70,10 @@ class CfnCamelizer
|
|
65
70
|
camelizer_yaml["special_keys"]
|
66
71
|
end
|
67
72
|
|
73
|
+
def resource_map(resource_type)
|
74
|
+
camelizer_yaml["resource_keys"][resource_type] || {}
|
75
|
+
end
|
76
|
+
|
68
77
|
def camelizer_yaml
|
69
78
|
# default
|
70
79
|
path = File.expand_path("camelizer.yml", File.dirname(__FILE__))
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cfn_camelizer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tung Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -134,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
134
|
- !ruby/object:Gem::Version
|
135
135
|
version: '0'
|
136
136
|
requirements: []
|
137
|
-
rubygems_version: 3.0.
|
137
|
+
rubygems_version: 3.0.3
|
138
138
|
signing_key:
|
139
139
|
specification_version: 4
|
140
140
|
summary: Cfn Camelizer
|