cfndsl 0.8.9 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/cfndsl.rb +1 -2
- data/lib/cfndsl/external_parameters.rb +17 -1
- data/lib/cfndsl/jsonable.rb +8 -0
- data/lib/cfndsl/orchestration_template.rb +0 -9
- data/lib/cfndsl/version.rb +1 -1
- data/spec/cfndsl_spec.rb +3 -1
- data/spec/external_parameters_spec.rb +24 -0
- data/spec/fixtures/test.rb +2 -2
- data/spec/jsonable_spec.rb +15 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NDllMmI2MjhiMWMzYmY0NzAyZDgzZjE2NWJhYzRlOWVjZmUxYmQ5Nw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MjBmNzQ3OWRlMjAxMDZlMmJiOWE4NjZlNTBlZmNmYzExZTc3MTUyMw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
M2YyNjlhOTlhM2RmZDFkNDE3MjFmYTMzZGE2MjI1NjgyNmNjMDA3OTA0NDNj
|
10
|
+
NmYwZmMwYzFjODQxZDBiNTFjMjFkZGQ2M2ZkYzMxNDE1NjI5ZTc3NjI5Y2Q1
|
11
|
+
MjU1N2FhNDFiOTRlNzA0NDljNDJhYTUxNTk4YWE1YjQ2OTc5NmI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OWI3YTUzZGViNTMxYTAyZTc4Y2U3ZjQ5Njg1YjVlZmVjNjVjYThlMzNiNDQx
|
14
|
+
NzBjYTliZjlmOGJhNWQ4ZmM5ODU4ZDQ2ZmRlNWQyNjM3ZWI5OGY1YzkyOTgw
|
15
|
+
YzZiN2ExZmMxYWRjYWE3NGUwYTVhYmYyZDlhOGZiOTlhNDQ1YWE=
|
data/lib/cfndsl.rb
CHANGED
@@ -61,7 +61,7 @@ module CfnDsl
|
|
61
61
|
# rubocop:disable all
|
62
62
|
def self.eval_file_with_extras(filename, extras = [], logstream = nil)
|
63
63
|
b = binding
|
64
|
-
params = CfnDsl::ExternalParameters.
|
64
|
+
params = CfnDsl::ExternalParameters.refresh!
|
65
65
|
extras.each do |type, file|
|
66
66
|
case type
|
67
67
|
when :yaml, :json
|
@@ -85,7 +85,6 @@ module CfnDsl
|
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
|
-
CfnDsl::CloudFormationTemplate.external_parameters params
|
89
88
|
logstream.puts("Loading template file #{filename}") if logstream
|
90
89
|
b.eval(File.read(filename), filename)
|
91
90
|
end
|
@@ -7,8 +7,24 @@ module CfnDsl
|
|
7
7
|
|
8
8
|
attr_reader :parameters
|
9
9
|
|
10
|
+
class << self
|
11
|
+
def defaults(params = {})
|
12
|
+
@defaults ||= {}
|
13
|
+
@defaults.merge! params
|
14
|
+
@defaults
|
15
|
+
end
|
16
|
+
|
17
|
+
def current
|
18
|
+
@current || refresh!
|
19
|
+
end
|
20
|
+
|
21
|
+
def refresh!
|
22
|
+
@current = new
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
10
26
|
def initialize
|
11
|
-
@parameters =
|
27
|
+
@parameters = self.class.defaults.clone
|
12
28
|
end
|
13
29
|
|
14
30
|
def set_param(k, v)
|
data/lib/cfndsl/jsonable.rb
CHANGED
@@ -131,6 +131,14 @@ module CfnDsl
|
|
131
131
|
extend Functions
|
132
132
|
include RefCheck
|
133
133
|
|
134
|
+
def self.external_parameters
|
135
|
+
CfnDsl::ExternalParameters.current
|
136
|
+
end
|
137
|
+
|
138
|
+
def external_parameters
|
139
|
+
self.class.external_parameters
|
140
|
+
end
|
141
|
+
|
134
142
|
# Use instance variables to build a json object. Instance
|
135
143
|
# variables that begin with a single underscore are elided.
|
136
144
|
# Instance variables that begin with two underscores have one of
|
@@ -10,15 +10,6 @@ module CfnDsl
|
|
10
10
|
dsl_attr_setter :AWSTemplateFormatVersion, :Description
|
11
11
|
dsl_content_object :Condition, :Parameter, :Output, :Resource, :Mapping
|
12
12
|
|
13
|
-
def self.external_parameters(params = nil)
|
14
|
-
@external_parameters = params if params
|
15
|
-
@external_parameters
|
16
|
-
end
|
17
|
-
|
18
|
-
def external_parameters
|
19
|
-
self.class.external_parameters
|
20
|
-
end
|
21
|
-
|
22
13
|
def initialize
|
23
14
|
@AWSTemplateFormatVersion = '2010-09-09'
|
24
15
|
end
|
data/lib/cfndsl/version.rb
CHANGED
data/spec/cfndsl_spec.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe CfnDsl do
|
4
|
+
after(:example) { CfnDsl::ExternalParameters.refresh! }
|
5
|
+
|
4
6
|
it 'evaluates a cloud formation' do
|
5
7
|
filename = "#{File.dirname(__FILE__)}/fixtures/test.rb"
|
6
|
-
subject.eval_file_with_extras(filename)
|
8
|
+
subject.eval_file_with_extras(filename, [[:raw, 'test=123']])
|
7
9
|
end
|
8
10
|
|
9
11
|
it 'evaluates a heat' do
|
@@ -8,6 +8,30 @@ describe CfnDsl::ExternalParameters do
|
|
8
8
|
exp
|
9
9
|
end
|
10
10
|
|
11
|
+
context '.defaults' do
|
12
|
+
after(:example) { described_class.defaults.clear }
|
13
|
+
|
14
|
+
it 'allows for defaults to be set for each new parameters instance' do
|
15
|
+
described_class.defaults(reminder: 'You Know What It Is')
|
16
|
+
expect(subject[:reminder]).to eq('You Know What It Is')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context '.current' do
|
21
|
+
it 'retrieves the current parameters instance' do
|
22
|
+
expect(described_class.current).to be_an_instance_of(described_class)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context '.refresh!' do
|
27
|
+
it 'restores the current parameters to the defaults' do
|
28
|
+
described_class.current.set_param(:reminder, 'You Know What It Is')
|
29
|
+
expect(described_class.current[:reminder]).to eq('You Know What It Is')
|
30
|
+
described_class.refresh!
|
31
|
+
expect(described_class.current[:reminder]).to be_nil
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
11
35
|
context '#set_param' do
|
12
36
|
it 'treats keys as symbols only' do
|
13
37
|
subject.set_param('reminder', 'You Know What It Is')
|
data/spec/fixtures/test.rb
CHANGED
@@ -2,7 +2,7 @@ CloudFormation do
|
|
2
2
|
TEST ||= 'no value set'.freeze
|
3
3
|
puts TEST
|
4
4
|
|
5
|
-
Description
|
5
|
+
Description external_parameters[:test]
|
6
6
|
|
7
7
|
Parameter('One') do
|
8
8
|
String
|
@@ -49,7 +49,7 @@ CloudFormation do
|
|
49
49
|
DeviceName '/dev/sda'
|
50
50
|
VirtualName 'stuff'
|
51
51
|
Ebs do
|
52
|
-
SnapshotId
|
52
|
+
SnapshotId external_parameters[:test]
|
53
53
|
VolumeSize Ref('MyInstance')
|
54
54
|
end
|
55
55
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CfnDsl::JSONable do
|
4
|
+
context '.external_parameters' do
|
5
|
+
it 'allows access to the current parameters instance' do
|
6
|
+
expect(subject.class.external_parameters).to be_an_instance_of(CfnDsl::ExternalParameters)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
context '#external_parameters' do
|
11
|
+
it 'allows access to the current parameters instance' do
|
12
|
+
expect(subject.external_parameters).to be_an_instance_of(CfnDsl::ExternalParameters)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
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: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steven Jack
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-06-
|
12
|
+
date: 2016-06-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -91,6 +91,7 @@ files:
|
|
91
91
|
- spec/external_parameters_spec.rb
|
92
92
|
- spec/fixtures/heattest.rb
|
93
93
|
- spec/fixtures/test.rb
|
94
|
+
- spec/jsonable_spec.rb
|
94
95
|
- spec/resources_spec.rb
|
95
96
|
- spec/spec_helper.rb
|
96
97
|
homepage: https://github.com/stevenjack/cfndsl
|
@@ -124,5 +125,6 @@ test_files:
|
|
124
125
|
- spec/external_parameters_spec.rb
|
125
126
|
- spec/fixtures/heattest.rb
|
126
127
|
- spec/fixtures/test.rb
|
128
|
+
- spec/jsonable_spec.rb
|
127
129
|
- spec/resources_spec.rb
|
128
130
|
- spec/spec_helper.rb
|