cfn-toml 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/cfn-toml +19 -4
- data/lib/cfn_toml/version.rb +1 -1
- data/lib/cfn_toml.rb +25 -2
- metadata +1 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7799a8f712a8d5f32a51dc93058499ff8d72304c599578fe82604305118dde62
|
4
|
+
data.tar.gz: 60d55ee3765aff414549de3f8b6758cc6113220778437c34fd0b53470ab31461
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bc93943f00f72790d3d040abc488f6b1737b3170927987c0bd11e92fea23bbba3416cd54c46f0fc15040a5855b1d0da52d0aba00a3ccade8c5fdb0a21cdc05d
|
7
|
+
data.tar.gz: 3e1e1772b899fa24b1225b1519baf1fc566daa81ec84146399be4a35c3b83163b5ff85a7efb8e7eb063d1c99185af3635a44f340b22a68d6b0b4cef067974ab0
|
data/bin/cfn-toml
CHANGED
@@ -15,9 +15,10 @@ def show_help
|
|
15
15
|
puts <<~HELP
|
16
16
|
Usage: cfn-toml [options]
|
17
17
|
Options:
|
18
|
-
-t, --toml
|
18
|
+
-t, --toml path to toml file
|
19
19
|
-p, --profile profile name (only used with cfn-toml init)
|
20
|
-
-
|
20
|
+
-f, --cloudformation-template populate toml parameters (only used with cfn-toml init)
|
21
|
+
-v, --version show version
|
21
22
|
|
22
23
|
Initialize:
|
23
24
|
cfn-toml init mystack --profile myprofile
|
@@ -26,7 +27,7 @@ def show_help
|
|
26
27
|
REGION=$(cfn-toml key deploy.region)
|
27
28
|
PARAMETERS=$(cfn-toml params v1)
|
28
29
|
OVERRIDE_PARAMETERS=$(cfn-toml params v2)
|
29
|
-
BUCKET=$(cfn-toml key bucket --
|
30
|
+
BUCKET=$(cfn-toml key bucket --toml /path/to/conf.prod.toml)
|
30
31
|
HELP
|
31
32
|
exit 0
|
32
33
|
end
|
@@ -42,6 +43,10 @@ parser = OptionParser.new do|opts|
|
|
42
43
|
options[:profile] = name
|
43
44
|
end
|
44
45
|
|
46
|
+
opts.on('-f PATH', '--cloudformation-template PATH') do |path|
|
47
|
+
options[:cfn_filepath] = path
|
48
|
+
end
|
49
|
+
|
45
50
|
opts.on('-h', '--help') do
|
46
51
|
show_help
|
47
52
|
end
|
@@ -59,6 +64,16 @@ begin
|
|
59
64
|
options[:toml_filepath] = File.expand_path options[:toml_filepath]
|
60
65
|
options[:profile] ||= 'default'
|
61
66
|
|
67
|
+
if options[:cfn_filepath].nil?
|
68
|
+
if File.exists?(File.expand_path('template.yaml'))
|
69
|
+
options[:cfn_filepath] = "template.yaml"
|
70
|
+
elsif File.exists?(File.expand_path('template.yml'))
|
71
|
+
options[:cfn_filepath] = "template.yml"
|
72
|
+
end
|
73
|
+
options[:cfn_filepath] ||= "template.yaml"
|
74
|
+
end
|
75
|
+
options[:cfn_filepath] = File.expand_path options[:cfn_filepath]
|
76
|
+
|
62
77
|
if arg1 == 'key'
|
63
78
|
result = CfnToml.key options[:toml_filepath], arg2
|
64
79
|
STDOUT.puts result
|
@@ -70,7 +85,7 @@ begin
|
|
70
85
|
# arg3 - profile
|
71
86
|
stackname = nil
|
72
87
|
stackname = arg2 if !arg2.nil? || !arg2 == ''
|
73
|
-
CfnToml.init options[:toml_filepath], arg2, options[:profile]
|
88
|
+
CfnToml.init options[:toml_filepath], options[:cfn_filepath], arg2, options[:profile]
|
74
89
|
STDOUT.puts options[:toml_filepath]
|
75
90
|
end
|
76
91
|
|
data/lib/cfn_toml/version.rb
CHANGED
data/lib/cfn_toml.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
require 'toml-rb'
|
2
2
|
require 'fileutils'
|
3
|
+
require 'yaml'
|
3
4
|
|
4
5
|
module CfnToml
|
5
|
-
def self.init toml_filepath, stackname, profile
|
6
|
+
def self.init toml_filepath, cfn_filepath, stackname, profile
|
6
7
|
region = `aws configure get region --profile #{profile}`
|
7
|
-
region
|
8
|
+
region = 'us-east-1' if region.nil? || region == ''
|
8
9
|
stackname ||= 'stackname'
|
9
10
|
|
10
11
|
toml_path = File.dirname toml_filepath
|
@@ -16,6 +17,28 @@ module CfnToml
|
|
16
17
|
f.write "stack_name = '#{stackname}'\n"
|
17
18
|
f.write "region = '#{region.chomp}'\n\n"
|
18
19
|
f.write "[parameters]\n"
|
20
|
+
self.init_parameters f, cfn_filepath
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.init_parameters f, cfn_filepath
|
25
|
+
return unless File.exists?(cfn_filepath)
|
26
|
+
contents = File.open(cfn_filepath).read
|
27
|
+
hash = YAML.load(contents)
|
28
|
+
return unless hash.key?('Parameters')
|
29
|
+
|
30
|
+
hash['Parameters'].each do |name, values|
|
31
|
+
if values.key?('Description')
|
32
|
+
lines = values['Description'].split("\n")
|
33
|
+
lines.each do |line|
|
34
|
+
f.write "# #{line} \n"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
if values.key?('Default')
|
38
|
+
f.write "#{name} = '#{values['Default']}' # #{values['Type']}\n"
|
39
|
+
else
|
40
|
+
f.write "##{name} = '' # #{values['Type']}\n"
|
41
|
+
end
|
19
42
|
end
|
20
43
|
end
|
21
44
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cfn-toml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Brown
|
@@ -10,20 +10,6 @@ bindir: bin
|
|
10
10
|
cert_chain: []
|
11
11
|
date: 2021-01-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: pry
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: toml-rb
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|