cumuliform 0.5.3 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.ruby-version +1 -1
- data/.travis.yml +0 -2
- data/README.md +31 -5
- data/cumuliform.gemspec +0 -1
- data/examples/top-level-value.rb +8 -0
- data/lib/cumuliform/output.rb +5 -1
- data/lib/cumuliform/sections.rb +3 -1
- data/lib/cumuliform/template.rb +14 -0
- data/lib/cumuliform/version.rb +1 -1
- metadata +4 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 86477f5b5e5ff570e701ea108595ab37165e9c2c8c0b908d71a3376925a4d5f2
|
4
|
+
data.tar.gz: 6f77929d740fe9aaecdc83b65d691458441d762688f658b0fd338560b5501f79
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6abcbc9530eddcf37006beaf07fa357ac21b51bc325195825ed9b04b71ee2fadf2a305fea65458b7595a4e522bf44ea751878a1965e8c7f51ce6c7f5dfd05dc8
|
7
|
+
data.tar.gz: ea4cd0da1e21c9a86514ec9d5f4ab7c754240f32bdde7567c8576ebad5786d9d9adbb3cc6bf6bcddae68960145175a8a16841097bf6d3e48d0c03654a7955b2d
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.6
|
data/.travis.yml
CHANGED
@@ -3,8 +3,6 @@ env:
|
|
3
3
|
- CC_TEST_REPORTER_ID=ad171accd9e47d577857f84b0d9032042ea70bf942a219bfa4f5582b5e504a60
|
4
4
|
language: ruby
|
5
5
|
sudo: false
|
6
|
-
rvm:
|
7
|
-
2.4.3
|
8
6
|
before_script:
|
9
7
|
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
10
8
|
- chmod +x ./cc-test-reporter
|
data/README.md
CHANGED
@@ -17,9 +17,7 @@ provides a simple DSL that generates reliably valid JSON and enforces
|
|
17
17
|
referential integrity through convenience wrappers around the common points
|
18
18
|
where CloudFormation expects references between resources. provides.
|
19
19
|
|
20
|
-
Cumuliform
|
21
|
-
|
22
|
-
[tape]: https://www.tape.tv/
|
20
|
+
Cumuliform was originally extracted from ops and deployment code at tape.tv
|
23
21
|
|
24
22
|
## Installation
|
25
23
|
|
@@ -281,8 +279,36 @@ The generated template is:
|
|
281
279
|
}
|
282
280
|
```
|
283
281
|
|
284
|
-
Note that the optional `AWSTemplateFormatVersion`, `
|
285
|
-
|
282
|
+
Note that the optional `AWSTemplateFormatVersion`, and `Metadata` sections are
|
283
|
+
*not* currently supported.
|
284
|
+
|
285
|
+
Here's a trivial template that specifies a `Transform` top-level value (e.g. for [AWS SAM][])
|
286
|
+
|
287
|
+
[AWS SAM]: https://github.com/awslabs/serverless-application-model
|
288
|
+
|
289
|
+
```ruby
|
290
|
+
Cumuliform.template do
|
291
|
+
transform 'AWS::Serverless-2016-10-31'
|
292
|
+
resource 'MyFunction' do
|
293
|
+
{
|
294
|
+
Type: 'AWS::Serverless::Function'
|
295
|
+
}
|
296
|
+
end
|
297
|
+
end
|
298
|
+
```
|
299
|
+
|
300
|
+
And the result:
|
301
|
+
|
302
|
+
```json
|
303
|
+
{
|
304
|
+
"Transform": "AWS::Serverless-2016-10-31",
|
305
|
+
"Resources": {
|
306
|
+
"MyFunction": {
|
307
|
+
"Type": "AWS::Serverless::Function"
|
308
|
+
}
|
309
|
+
}
|
310
|
+
}
|
311
|
+
```
|
286
312
|
|
287
313
|
## Intrinsic functions
|
288
314
|
|
data/cumuliform.gemspec
CHANGED
@@ -23,7 +23,6 @@ non-existent resources because you have a typo.
|
|
23
23
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
24
|
spec.require_paths = ["lib"]
|
25
25
|
|
26
|
-
spec.add_development_dependency "bundler", "~> 1.9"
|
27
26
|
spec.add_development_dependency "rake", "~> 12.0"
|
28
27
|
spec.add_development_dependency "rspec", "~> 3"
|
29
28
|
spec.add_development_dependency "yard", ">= 0.8"
|
data/lib/cumuliform/output.rb
CHANGED
@@ -13,7 +13,11 @@ module Cumuliform
|
|
13
13
|
# @return [Hash] Hash representing the CloudFormation template
|
14
14
|
def to_hash
|
15
15
|
output = {}
|
16
|
-
|
16
|
+
TOP_LEVEL.each do |item_name|
|
17
|
+
value = get_top_level_value(item_name)
|
18
|
+
output[item_name] = value unless value.nil?
|
19
|
+
end
|
20
|
+
SECTION_NAMES.each do |section_name|
|
17
21
|
section = get_section(section_name)
|
18
22
|
output[section_name] = generate_section(section) unless section.empty?
|
19
23
|
end
|
data/lib/cumuliform/sections.rb
CHANGED
@@ -8,16 +8,18 @@ module Cumuliform
|
|
8
8
|
"Resources" => :resource,
|
9
9
|
"Outputs" => :output
|
10
10
|
}
|
11
|
+
SECTION_NAMES = SECTIONS.map { |name, _| name }
|
11
12
|
|
12
13
|
# @api private
|
13
14
|
module Sections
|
14
15
|
def initialize
|
15
|
-
|
16
|
+
SECTION_NAMES.each do |section_name|
|
16
17
|
instance_variable_set(:"@#{section_name}", Section.new(section_name, imports))
|
17
18
|
end
|
18
19
|
end
|
19
20
|
|
20
21
|
def get_section(name)
|
22
|
+
raise ArgumentError, "#{name} is not a valid template section" unless SECTION_NAMES.include?(name)
|
21
23
|
instance_variable_get(:"@#{name}")
|
22
24
|
end
|
23
25
|
|
data/lib/cumuliform/template.rb
CHANGED
@@ -11,12 +11,26 @@ module Cumuliform
|
|
11
11
|
AWS::AccountId AWS::NotificationARNs AWS::NoValue
|
12
12
|
AWS::Region AWS::StackId AWS::StackName
|
13
13
|
}
|
14
|
+
TOP_LEVEL = %w{ Transform Description }
|
14
15
|
|
15
16
|
# Represents a single CloudFormation template
|
16
17
|
class Template
|
17
18
|
include Output
|
18
19
|
include Sections
|
19
20
|
|
21
|
+
def transform(transform)
|
22
|
+
@Transform = transform
|
23
|
+
end
|
24
|
+
|
25
|
+
def description(desc)
|
26
|
+
@Description = desc
|
27
|
+
end
|
28
|
+
|
29
|
+
def get_top_level_value(item_name)
|
30
|
+
raise ArgumentError, "Not an allowed top-level item name" unless TOP_LEVEL.include?(item_name)
|
31
|
+
instance_variable_get(:"@#{item_name}")
|
32
|
+
end
|
33
|
+
|
20
34
|
# @api private
|
21
35
|
def define(&block)
|
22
36
|
instance_exec(&block)
|
data/lib/cumuliform/version.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cumuliform
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Patterson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: bundler
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.9'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '1.9'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: rake
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -115,6 +101,7 @@ files:
|
|
115
101
|
- examples/module-helper.rb
|
116
102
|
- examples/simplest.rb
|
117
103
|
- examples/top-level-declarations.rb
|
104
|
+
- examples/top-level-value.rb
|
118
105
|
- exe/cumuliform
|
119
106
|
- lib/cumuliform.rb
|
120
107
|
- lib/cumuliform/dsl.rb
|
@@ -149,8 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
149
136
|
- !ruby/object:Gem::Version
|
150
137
|
version: '0'
|
151
138
|
requirements: []
|
152
|
-
|
153
|
-
rubygems_version: 2.6.14
|
139
|
+
rubygems_version: 3.0.3
|
154
140
|
signing_key:
|
155
141
|
specification_version: 4
|
156
142
|
summary: DSL library for generating AWS CloudFormation templates
|