cloudformation-tool 0.8.6 → 0.9.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 16196dd229f1e0040b4b06190e90da9d72dbef2e33ac545055f08a89b3a20339
4
- data.tar.gz: 93bc3913458bd350dea067ccd4c7e4ea6562c760f418f17d7b4d34eb918cf1cc
2
+ SHA1:
3
+ metadata.gz: 8b4c374a9c0af1d6e1142125a3301cda3ed0f253
4
+ data.tar.gz: 881a2ab8d2736c26d7e0d52b81ce0b3d4fff5f4b
5
5
  SHA512:
6
- metadata.gz: 685f2098bfb4278a779683c65fe35937b23a35e9470519a9f2747a912412b13e5229ef81d86c57489170d7a9b88cbb5cb88b2933746cf1fd75786f67b32725ce
7
- data.tar.gz: 33278d66726b92d7a9cec30f54499be8b05ab2eab17b9922e42d212e4f66cafc94aa929d2687482bcc1e6373c51975138501ec35c6c053cb7df35901d90a6a77
6
+ metadata.gz: aa3d75a17b1f4fa484370737a292bf895755fef6f3f22dea7bf645edfc6880c497bcff74d1f39de280c7ff37c01d0633fdc20fdeebaa74ed26ce5cc35499fa7f
7
+ data.tar.gz: ac5f391cb29094cebc079b6d1cdd6b9d63089ba250939348b6fd1410437493322a59f674154c2885cc1c929cfe7256395b2e6c4631339596d25df08329152531
@@ -2,15 +2,23 @@ module CloudFormationTool
2
2
  module CLI
3
3
 
4
4
  class Compile < Clamp::Command
5
+ include ParamSupport
5
6
 
6
7
  parameter 'FILE', 'Template main file'
7
8
 
9
+ add_param_options
10
+
8
11
  def execute
9
12
  if file.end_with? '.init'
10
13
  puts CloudInit.new(file).encode(false) # make sure cloud-init files obey AWS user-data restrictions, but are also printable
11
14
  else
12
- puts CloudFormation.parse(file).to_yaml
13
- # raise CloudFormationTool::Errors::AppError.new("not a valid template file. Only .init and .yaml are supported")
15
+ tpl = CloudFormation.parse(file)
16
+ params = get_params
17
+ data = tpl.compile;
18
+ data['Parameters'].each do |name,param|
19
+ param['Default'] = params[name] if params.has_key? name
20
+ end
21
+ puts data.to_yaml
14
22
  end
15
23
  end
16
24
 
@@ -4,50 +4,12 @@ require 'net/http'
4
4
  module CloudFormationTool
5
5
  module CLI
6
6
  class Create < Clamp::Command
7
-
7
+ include ParamSupport
8
+
8
9
  parameter 'FILE', 'Template main file'
9
10
  parameter '[STACK_NAME]', 'Name of the stack to create. Defaults to directory name'
10
11
 
11
- option [ "-p", "--param" ], "PARAM", [
12
- "Parameter to use with the cloudformation, of the format Mame=Tag",
13
- "Use multiple times to set multiple parameters.",
14
- "See 'parameters' command to list the paramaters supported by the tempalte."
15
- ].join("\n"), multivalued: true
16
- option [ "-i", "--import" ], "FILE", "Import parameters from YAML file or HTTP URL.", :attribute_name => :param_file
17
- option [ "-k", "--import-key" ], "KEY", [
18
- "When loading parameters from a YAML file, use the specified key to load a named",
19
- "map from the file, instead of using just the file itself as the parameter map"
20
- ].join("\n"), :attribute_name => :param_key
21
-
22
- def read_param_file(file)
23
- param_uri = URI(file)
24
- case param_uri.scheme
25
- when /^http/
26
- Net::HTTP.get(param_uri)
27
- else
28
- File.read(file)
29
- end
30
- end
31
-
32
- def get_params
33
- params = if param_file
34
- yaml = YAML.load(read_param_file param_file).to_h
35
- if param_key
36
- raise "Missing parameter section '#{param_key}' in '#{param_file}'!" unless yaml[param_key].is_a? Hash
37
- yaml[param_key]
38
- else
39
- yaml
40
- end
41
- else
42
- Hash.new
43
- end
44
- # allow param_list to override parameters from the param file
45
- param_list.inject(params) do |h, param|
46
- k,v = param.split /\s*[=:]\s*/
47
- h[k] = v
48
- h
49
- end
50
- end
12
+ add_param_options
51
13
 
52
14
  def execute
53
15
  name = stack_name || File.basename(File.dirname(File.expand_path(file)))
@@ -0,0 +1,60 @@
1
+ require 'uri'
2
+ require 'net/http'
3
+
4
+ module CloudFormationTool
5
+ module CLI
6
+ module ParamSupport
7
+
8
+ def self.included o
9
+ o.extend ClassMethods
10
+ end
11
+
12
+ module ClassMethods
13
+
14
+ def add_param_options
15
+ option [ "-p", "--param" ], "PARAM", [
16
+ "Parameter to use with the cloudformation, of the format Mame=Tag",
17
+ "Use multiple times to set multiple parameters.",
18
+ "See 'parameters' command to list the paramaters supported by the tempalte."
19
+ ].join("\n"), multivalued: true
20
+ option [ "-i", "--import" ], "FILE", "Import parameters from YAML file or HTTP URL.", :attribute_name => :param_file
21
+ option [ "-k", "--import-key" ], "KEY", [
22
+ "When loading parameters from a YAML file, use the specified key to load a named",
23
+ "map from the file, instead of using just the file itself as the parameter map"
24
+ ].join("\n"), :attribute_name => :param_key
25
+ end
26
+ end
27
+
28
+ def read_param_file(file)
29
+ param_uri = URI(file)
30
+ case param_uri.scheme
31
+ when /^http/
32
+ Net::HTTP.get(param_uri)
33
+ else
34
+ File.read(file)
35
+ end
36
+ end
37
+
38
+ def get_params
39
+ params = if param_file
40
+ yaml = YAML.load(read_param_file param_file).to_h
41
+ if param_key
42
+ raise "Missing parameter section '#{param_key}' in '#{param_file}'!" unless yaml[param_key].is_a? Hash
43
+ yaml[param_key]
44
+ else
45
+ yaml
46
+ end
47
+ else
48
+ Hash.new
49
+ end
50
+ # allow param_list to override parameters from the param file
51
+ param_list.inject(params) do |h, param|
52
+ k,v = param.split /\s*[=:]\s*/
53
+ h[k] = v
54
+ h
55
+ end
56
+ end
57
+
58
+ end
59
+ end
60
+ end
@@ -1,3 +1,3 @@
1
1
  module CloudFormationTool
2
- VERSION = '0.8.6'
2
+ VERSION = '0.9.0.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudformation-tool
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.6
4
+ version: 0.9.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oded Arbel
@@ -143,6 +143,7 @@ files:
143
143
  - lib/cloud_formation_tool/cli/main.rb
144
144
  - lib/cloud_formation_tool/cli/monitor.rb
145
145
  - lib/cloud_formation_tool/cli/output.rb
146
+ - lib/cloud_formation_tool/cli/param_support.rb
146
147
  - lib/cloud_formation_tool/cli/parameters.rb
147
148
  - lib/cloud_formation_tool/cli/recycle.rb
148
149
  - lib/cloud_formation_tool/cli/scale.rb
@@ -175,7 +176,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
175
176
  version: '0'
176
177
  requirements: []
177
178
  rubyforge_project:
178
- rubygems_version: 2.7.6
179
+ rubygems_version: 2.6.14
179
180
  signing_key:
180
181
  specification_version: 4
181
182
  summary: A pre-compiler tool for CloudFormation YAML templates