cfn-toml 1.0.3 → 1.0.4
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 +35 -13
- data/lib/cfn_toml.rb +18 -0
- data/lib/cfn_toml/version.rb +1 -1
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae9bc1c1b290518289f35114d0bcb93699f1b36c782efe0bcf5774d562e75a00
|
4
|
+
data.tar.gz: b37be42117520546fcf181d85dbb245420a49f8f9ce9d709d20c4519084f8e58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40a1f5c6b1569b58e360bfba8e06df90549f852f32205af9ba14d4a6b587d2a2c0df343d3baf1b56db9c571264eec1cad0c3deb4b560ade655509f0fd8994bc2
|
7
|
+
data.tar.gz: a86cd3a80aee41f5f74fca6db84995cf49de56978cca04160beeb13956c8b9cdaca525ba1eb02a7cd19783c4e89c5d92510acd2e636ae33b25e02790d938945a
|
data/bin/cfn-toml
CHANGED
@@ -3,6 +3,8 @@ $LOAD_PATH << File.expand_path('lib')
|
|
3
3
|
|
4
4
|
require 'optparse'
|
5
5
|
require 'cfn_toml'
|
6
|
+
require 'pry'
|
7
|
+
require 'pathname'
|
6
8
|
|
7
9
|
def show_version
|
8
10
|
puts "CfnToml v#{CfnToml::VERSION}"
|
@@ -11,25 +13,35 @@ end
|
|
11
13
|
|
12
14
|
def show_help
|
13
15
|
puts <<~HELP
|
14
|
-
Usage: toml
|
16
|
+
Usage: cfn-toml [options]
|
15
17
|
Options:
|
16
18
|
-t, --toml path to toml file
|
17
|
-
-
|
18
|
-
|
19
|
+
-p, --profile profile name (only used with cfn-toml init)
|
20
|
+
-v, --version show version
|
21
|
+
|
22
|
+
Initialize:
|
23
|
+
cfn-toml init mystack --profile myprofile
|
19
24
|
|
25
|
+
Bash Examples:
|
26
|
+
REGION=$(cfn-toml key deploy.region)
|
27
|
+
PARAMETERS=$(cfn-toml params v1)
|
28
|
+
OVERRIDE_PARAMETERS=$(cfn-toml params v2)
|
29
|
+
BUCKET=$(cfn-toml key bucket --tom /path/to/conf.prod.toml)
|
30
|
+
HELP
|
20
31
|
exit 0
|
21
32
|
end
|
22
33
|
|
23
34
|
options = {}
|
24
35
|
|
25
|
-
arg1 = ARGV[0]
|
26
|
-
arg2 = ARGV[1]
|
27
|
-
|
28
36
|
parser = OptionParser.new do|opts|
|
29
|
-
opts.on('--toml PATH') do |path|
|
37
|
+
opts.on('-t PATH', '--toml PATH') do |path|
|
30
38
|
options[:toml_filepath] = path
|
31
39
|
end
|
32
40
|
|
41
|
+
opts.on('-p NAME', '--profile NAME') do |name|
|
42
|
+
options[:profile] = name
|
43
|
+
end
|
44
|
+
|
33
45
|
opts.on('-h', '--help') do
|
34
46
|
show_help
|
35
47
|
end
|
@@ -39,19 +51,29 @@ end
|
|
39
51
|
begin
|
40
52
|
parser.parse!
|
41
53
|
|
42
|
-
|
54
|
+
arg1 = ARGV[0]
|
55
|
+
arg2 = ARGV[1]
|
43
56
|
|
44
57
|
# Defaults
|
45
|
-
options[:toml_filepath] ||=
|
58
|
+
options[:toml_filepath] ||= "config.toml"
|
59
|
+
options[:toml_filepath] = File.expand_path options[:toml_filepath]
|
60
|
+
options[:profile] ||= 'default'
|
46
61
|
|
47
|
-
result =
|
48
62
|
if arg1 == 'key'
|
49
|
-
CfnToml.key options[:toml_filepath], arg2
|
63
|
+
result = CfnToml.key options[:toml_filepath], arg2
|
64
|
+
STDOUT.puts result
|
50
65
|
elsif arg1 == 'params'
|
51
|
-
CfnToml.params options[:toml_filepath], arg2
|
66
|
+
result = CfnToml.params options[:toml_filepath], arg2
|
67
|
+
STDOUT.puts result
|
68
|
+
elsif arg1 == 'init'
|
69
|
+
# arg2 - stackname
|
70
|
+
# arg3 - profile
|
71
|
+
stackname = nil
|
72
|
+
stackname = arg2 if !arg2.nil? || !arg2 == ''
|
73
|
+
CfnToml.init options[:toml_filepath], arg2, options[:profile]
|
74
|
+
STDOUT.puts options[:toml_filepath]
|
52
75
|
end
|
53
76
|
|
54
|
-
STDOUT.puts result
|
55
77
|
|
56
78
|
exit 0
|
57
79
|
rescue => e
|
data/lib/cfn_toml.rb
CHANGED
@@ -1,6 +1,24 @@
|
|
1
1
|
require 'toml-rb'
|
2
|
+
require 'fileutils'
|
2
3
|
|
3
4
|
module CfnToml
|
5
|
+
def self.init toml_filepath, stackname, profile
|
6
|
+
region = `aws configure get region --profile #{profile}`
|
7
|
+
region ||= 'us-east-1'
|
8
|
+
stackname ||= 'stackname'
|
9
|
+
|
10
|
+
toml_path = File.dirname toml_filepath
|
11
|
+
FileUtils.mkpath(toml_path) unless File.exists?(toml_path)
|
12
|
+
|
13
|
+
File.open(toml_filepath, "w") do |f|
|
14
|
+
f.write "[deploy]\n"
|
15
|
+
f.write "profile = '#{profile}'\n"
|
16
|
+
f.write "stack_name = '#{stackname}'\n"
|
17
|
+
f.write "region = '#{region.chomp}'\n\n"
|
18
|
+
f.write "[parameters]\n"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
4
22
|
def self.key toml_filepath, key
|
5
23
|
data = TomlRB.load_file(toml_filepath)
|
6
24
|
namespace, key = key.split('.')
|
data/lib/cfn_toml/version.rb
CHANGED
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.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Brown
|
@@ -10,6 +10,20 @@ 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'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: toml-rb
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|