aws-cfn-compiler 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NTljZDM3YzBkMWZhYzVhM2RhMDBkMjA4MjQ3MTljZjdlNjczZDUyYg==
4
+ YWY3NDI0YjQzMzJlNDM4MzI3ZmU3ZmRjYzQ1NDA3ZGFlYjZlYmJjZQ==
5
5
  data.tar.gz: !binary |-
6
- YWIzN2E1YTE3YTk3OWVlNDVlYTYyZGQzNWZiYjc5N2QzNDY1NjU5YQ==
6
+ OTE0NmMzOGU1MTY1MWE3MTcwOGRiMGI3ODI2MTdkMzYwOGM0OTZhZA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- Y2RhZTI5ODI1Y2MzODU2OTQzYjI3ODFlOGEzMDU4MjM2ZTJiMDU5MWIyODg3
10
- YWJmOGQwYTFlNDNiMWQ5Y2FjMmJhN2JiMzBlMTg1YTE3ZGQ5NDk3N2FiZTU5
11
- YTYyMjU0ZjU2YWY5MWUxYTMxOThmYzc5NjU3MDlhNjI0ZTQ2MjQ=
9
+ ZjRkNmYxY2E0ODliN2EwM2I2NjgyMjQwNjRiOGNjNjY4ZWU2MjI4MjBjMTEx
10
+ NDU5ZDgyMWQ0N2U0YTVkOGFkYWM3YTBhOTA0OWEzN2QzMTY4ODgzNjZiMzVk
11
+ YzNjNmQ3M2VjNTlkOWU5MTdlN2IyOGU4MDg1ZjJjMjIzNWFmYzM=
12
12
  data.tar.gz: !binary |-
13
- NDdkYjUyOTA4Y2U1MDM0YjZlZmM5YmZhN2E2NzIyMWZiZjQ1ODQwNWRmOGM2
14
- MTZjMzExOWVhNWE0MjM5YjQyZTc3ZGFmZDk1OTY5MTFmN2RlYmVmZjljMThj
15
- M2Q4YzIyNzJkNGFlZDFiMDFmYWRkOTdlZjYwNzcxNDhiN2ZhOWI=
13
+ ZGEwMzM1MDZjY2E1NmE4M2M0Mjc2NGFmZDdhMDBiNzI2MGY4YTViOGM4MzQ3
14
+ NmQxZGJjZmJkYjA0ZTg4YWNlYWE4NmM2NGY0YTFhNDgyMGYwYzcxMmQ5YTBj
15
+ NjAyMDYzMDRlZGU3MDU4YmJlNjY1OGNlNGY4ZGRjMjNlNDZmNjI=
@@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.add_dependency 'psych'
23
23
  spec.add_dependency 'json'
24
24
  spec.add_dependency 'slop'
25
+ spec.add_dependency 'inifile'
25
26
  spec.add_dependency 'aws-cfn-dsl', '>= 0.7.0', '~> 0.7'
26
27
  spec.add_dependency 'dldinternet-mixlib-cli', ">= 0.1.0", '~> 0.1'
27
28
  spec.add_dependency 'dldinternet-mixlib-logging', '>= 0.1.6', '~> 0.1'
@@ -77,6 +77,35 @@ module Aws
77
77
  sect = File.basename(sect) unless @config[:expandedpaths]
78
78
  save_section(dir, file, @config[:format], sect, hash, '', 'template')
79
79
 
80
+ parameters = []
81
+ if (@config[:parametersfile] or @config[:stackinifile]) and hash.has_key?('Parameters')
82
+ hash['Parameters'].each do |par,hsh|
83
+ # noinspection RubyStringKeysInHashInspection
84
+ parameters << {
85
+ 'ParameterKey' => par,
86
+ 'ParameterValue' => hsh.has_key?('Default') ? hsh['Default'] : '',
87
+ 'UsePreviousValue' => false,
88
+ }
89
+ end
90
+ end
91
+
92
+ if @config[:parametersfile] and parameters.size > 0
93
+ dir = File.dirname(@config[:parametersfile])
94
+ file = File.basename(@config[:parametersfile])
95
+ sect = dir == '.' ? Dir.pwd : dir
96
+ sect = File.basename(sect) unless @config[:expandedpaths]
97
+
98
+ save_section(dir, file, @config[:format], sect, parameters, '', 'parameters')
99
+ end
100
+
101
+ if @config[:stackinifile] and parameters.size > 0
102
+ dir = File.dirname(@config[:stackinifile])
103
+ file = File.basename(@config[:stackinifile])
104
+ sect = dir == '.' ? Dir.pwd : dir
105
+ sect = File.basename(sect) unless @config[:expandedpaths]
106
+
107
+ save_inifile(dir, file, sect, parameters, 'parameters')
108
+ end
80
109
  @logger.info ' Compiled file written.'
81
110
  rescue
82
111
  abort! "!!! Could not write compiled file: #{$!}"
@@ -14,15 +14,18 @@ module Aws
14
14
  @opts.on :f, :formatversion=, 'The AWS Template format version. ', {as: String,
15
15
  default: '2010-09-09'
16
16
  }
17
- @opts.on :D, :description=, "The AWS Template description. Default: template name", { as: String }
18
- @opts.on :p, :precedence=, 'The precedence of template component types. Default: rb,ruby,yaml,yml,json,js', { as: String,
17
+ @opts.on :D, :description=, 'The AWS Template description. Default: template name', { as: String }
18
+ @opts.on :p, :parametersfile=, 'The parameters file for the template', { as: String }
19
+ @opts.on :i, :stackinifile=, 'The INI file for the stack builder == build.py', { as: String }
20
+ @opts.on :P, :precedence=, 'The precedence of template component types. Default: rb,ruby,yaml,yml,json,js', { as: String,
19
21
  default: 'rb,ruby,yaml,yml,json,js', }
20
22
 
21
23
  @opts.parse!
22
24
 
23
25
  if ARGV.size > 0
24
26
  puts @opts
25
- abort! "Extra arguments! #{ARGV}"
27
+ puts "Extra arguments! #{ARGV}"
28
+ exit 1
26
29
  end
27
30
  end
28
31
 
@@ -1,8 +1,39 @@
1
+ require 'inifile'
1
2
  module Aws
2
3
  module Cfn
3
4
  module Compiler
4
5
  module Save
5
6
 
7
+ def save_inifile(dir, file, section, parameters, brick=nil)
8
+ brick ||= "INI #{section}"
9
+ path = File.join(File.expand_path(dir), file)
10
+ filn = if @config[:expandedpaths]
11
+ path
12
+ else
13
+ File.join(dir, file)
14
+ end
15
+ logStep "Saving #{brick} to #{filn} "
16
+
17
+ if i_am_maintainer(path) or @config[:force]
18
+ begin
19
+ ini = IniFile.new
20
+
21
+ # noinspection RubyStringKeysInHashInspection
22
+ parms = {
23
+ 'region' => 'us-east-1'
24
+ }
25
+ parameters.map{ |p| parms[p['ParameterKey']] = p['ParameterValue'] }
26
+ ini['<StackName>'] = parms
27
+ ini.write( filename: path )
28
+ @logger.info " saved #{filn}."
29
+ rescue
30
+ abort! "!!! Could not write file #{path}: #{$!}"
31
+ end
32
+ else
33
+ @logger.warn " Did not overwrite #{filn}."
34
+ end
35
+ end
36
+
6
37
  def save_section(dir, file, format, section, hash, join='/', brick=nil)
7
38
  brick ||= "brick #{hash.keys[0]}"
8
39
  path = File.join(File.expand_path(dir), file)
@@ -39,9 +70,9 @@ module Aws
39
70
  end
40
71
  f.close
41
72
  end
42
- @logger.info " decompiled #{filn}."
73
+ @logger.info " saved #{filn}."
43
74
  rescue
44
- abort! "!!! Could not write compiled file #{path}: #{$!}"
75
+ abort! "!!! Could not write file #{path}: #{$!}"
45
76
  end
46
77
  else
47
78
  @logger.warn " Did not overwrite #{filn}."
@@ -1,7 +1,7 @@
1
1
  module Aws
2
2
  module Cfn
3
3
  module Compiler
4
- VERSION = '0.7.0'
4
+ VERSION = '0.8.0'
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-cfn-compiler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - PKinney
@@ -72,6 +72,20 @@ dependencies:
72
72
  - - ! '>='
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: inifile
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ! '>='
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ type: :runtime
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ! '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
75
89
  - !ruby/object:Gem::Dependency
76
90
  name: aws-cfn-dsl
77
91
  requirement: !ruby/object:Gem::Requirement