tiller 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/tiller +49 -15
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07e3b43a954c568746d1b2e987616ee2c02bac87
|
4
|
+
data.tar.gz: 04bba1376ebe4e065e69c6d7ce7a97b97e324d55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d431b978f3ae55d9cc9e0e24ad265440a0e2c8e806b88767d61a1c054c2779e7baca9ee796359351b191ff930dd709c0c9790d0965199504301f486eab2441c1
|
7
|
+
data.tar.gz: 9165c94883002d36df0020e211be9771a20b28e1a82054c1a8073615d1e3a29a5f516071e126f49bd363f26632916d87dfa07c39f0af21b3f63149027755a648
|
data/bin/tiller
CHANGED
@@ -4,12 +4,13 @@
|
|
4
4
|
# didn't have an existing gem named after it!
|
5
5
|
# Mark Round <github@markround.com>
|
6
6
|
|
7
|
-
VERSION = '0.1.
|
7
|
+
VERSION = '0.1.3'
|
8
8
|
|
9
9
|
require 'erb'
|
10
10
|
require 'ostruct'
|
11
11
|
require 'yaml'
|
12
12
|
require 'fileutils'
|
13
|
+
require 'optparse'
|
13
14
|
require 'pp'
|
14
15
|
|
15
16
|
# This is needed so we can enumarate all the loaded plugins later
|
@@ -37,6 +38,29 @@ module Tiller
|
|
37
38
|
:environment => (ENV['environment'].nil?) ? 'production' : ENV['environment']
|
38
39
|
}
|
39
40
|
|
41
|
+
# Parse command-line arguments
|
42
|
+
config[:no_exec] = false
|
43
|
+
config[:verbose] = false
|
44
|
+
|
45
|
+
optparse = OptionParser.new do |opts|
|
46
|
+
opts.on('-n', '--no-exec', 'Do not execute a replacement process') do
|
47
|
+
config[:no_exec] = true
|
48
|
+
end
|
49
|
+
opts.on('-v', '--verbose', 'Display verbose output') do
|
50
|
+
config[:verbose] = true
|
51
|
+
end
|
52
|
+
opts.on('-h', '--help', 'Display this screen') do
|
53
|
+
puts opts
|
54
|
+
puts 'Tiller also uses the environment variables tiller_base and tiller_lib.'
|
55
|
+
puts 'See https://github.com/markround/tiller for documentation and usage.'
|
56
|
+
puts 'Current configuration hash follows :'
|
57
|
+
pp config
|
58
|
+
exit
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
optparse.parse!
|
63
|
+
|
40
64
|
# Add tiller_lib to the LOAD PATH so we can pull in user-defined plugins
|
41
65
|
$LOAD_PATH.unshift(config[:tiller_lib]) unless $LOAD_PATH.include?(config[:tiller_lib])
|
42
66
|
|
@@ -47,9 +71,12 @@ module Tiller
|
|
47
71
|
config[:common_config] = YAML.load(open(File.join(config[:tiller_base], 'common.yaml')))
|
48
72
|
|
49
73
|
puts "tiller v#{VERSION} (https://github.com/markround/tiller) <github@markround.com>"
|
50
|
-
|
51
|
-
|
52
|
-
|
74
|
+
|
75
|
+
if config[:verbose]
|
76
|
+
puts "Using configuration from #{config[:tiller_base]}"
|
77
|
+
puts "Using plugins from #{config[:tiller_lib]}/tiller"
|
78
|
+
puts "Using environment #{config[:environment]}"
|
79
|
+
end
|
53
80
|
|
54
81
|
# Now load all our plugins
|
55
82
|
template_sources = Array.new
|
@@ -59,8 +86,10 @@ module Tiller
|
|
59
86
|
template_sources.each { |t| require "tiller/template/#{t}.rb" }
|
60
87
|
data_sources.each { |t| require "tiller/data/#{t}.rb" }
|
61
88
|
|
62
|
-
|
63
|
-
|
89
|
+
if config[:verbose]
|
90
|
+
puts 'Template sources loaded ' + TemplateSource.subclasses.to_s
|
91
|
+
puts 'Data sources loaded ' + DataSource.subclasses.to_s
|
92
|
+
end
|
64
93
|
|
65
94
|
# Get all Templates for the given environment
|
66
95
|
templates = Hash.new
|
@@ -71,7 +100,7 @@ module Tiller
|
|
71
100
|
end
|
72
101
|
end
|
73
102
|
|
74
|
-
puts "Templates to build #{templates.keys}"
|
103
|
+
puts "Templates to build #{templates.keys}" if config[:verbose]
|
75
104
|
|
76
105
|
# Now go through all our data sources and start to assemble our global_values
|
77
106
|
# hash. As hashes are getting merged, new values will take precedence over
|
@@ -111,7 +140,7 @@ module Tiller
|
|
111
140
|
next if target_values.empty?
|
112
141
|
|
113
142
|
# Now, we build the template
|
114
|
-
puts "Building template #{template}"
|
143
|
+
puts "Building template #{template}" if config[:verbose]
|
115
144
|
tiller = values.merge(global_values) do |key, old, new|
|
116
145
|
warn_merge(key, old, new, 'global and local', 'merged configuration')
|
117
146
|
end
|
@@ -132,7 +161,7 @@ module Tiller
|
|
132
161
|
|
133
162
|
# Set permissions if we are running as root
|
134
163
|
if Process::Sys.geteuid == 0
|
135
|
-
puts "Setting ownership/permissions on #{target_values['target']}"
|
164
|
+
puts "Setting ownership/permissions on #{target_values['target']}" if config[:verbose]
|
136
165
|
if target_values.key?('perms')
|
137
166
|
FileUtils.chmod(target_values['perms'], target_values['target'])
|
138
167
|
end
|
@@ -142,14 +171,19 @@ module Tiller
|
|
142
171
|
target_values['target'])
|
143
172
|
else
|
144
173
|
puts 'Not running as root, so not setting ownership/permissions on ' \
|
145
|
-
"#{target_values['target']}"
|
174
|
+
"#{target_values['target']}" if config[:verbose]
|
146
175
|
end
|
147
176
|
|
148
177
|
end
|
149
178
|
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
179
|
+
puts 'Template generation completed'
|
180
|
+
|
181
|
+
if config[:no_exec] == false && config[:common_config].key?('exec')
|
182
|
+
# All templates created, so let's handover to the replacement process then
|
183
|
+
# it's home in time for tea and medals.
|
184
|
+
puts "Executing #{config[:common_config]['exec']}..."
|
185
|
+
exec(config[:common_config]['exec'])
|
186
|
+
end
|
187
|
+
|
188
|
+
|
155
189
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tiller
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Round
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A tool to create configuration files in Docker containers from a variety
|
14
14
|
of sources. See https://github.com/markround/tiller for examples and documentation.
|