tiller 0.7.9 → 0.7.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/tiller +36 -2
- data/lib/tiller/data/consul.rb +1 -0
- data/lib/tiller/data/defaults.rb +1 -0
- data/lib/tiller/data/environment.rb +16 -4
- data/lib/tiller/data/environment_json.rb +1 -4
- data/lib/tiller/data/file.rb +8 -2
- data/lib/tiller/data/http.rb +1 -0
- data/lib/tiller/data/random.rb +2 -2
- data/lib/tiller/data/xml_file.rb +1 -0
- data/lib/tiller/data/zookeeper.rb +1 -0
- data/lib/tiller/defaults.rb +11 -0
- data/lib/tiller/options.rb +6 -0
- data/lib/tiller/template/consul.rb +2 -1
- data/lib/tiller/template/file.rb +0 -2
- data/lib/tiller/template/zookeeper.rb +2 -0
- 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: 87543dcddd7ffe3367e1917fccedb35065d13f56
|
4
|
+
data.tar.gz: 26180fa0c8340cfaf5dc257f8b4bab72119eebc5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 807408260d5299ab564fba2d7f84f255eb51de4a060e95203c9dbccc09c923c031fcc135c8f856bb29b4a3ec5abe5bacf06bd8601dca3301d10ff831b9e19bc1
|
7
|
+
data.tar.gz: ec485ee8ecc83048a7e769c42b8dd308a4125aa4686cc72e0c3dc21942d73745abea01e9679a058d176274b04775941fe496018ce9333521a1bdc7037796db11
|
data/bin/tiller
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
#
|
9
9
|
# Mark Dastmalchi-Round <github@markround.com>
|
10
10
|
|
11
|
-
VERSION = '0.7.
|
11
|
+
VERSION = '0.7.10'
|
12
12
|
|
13
13
|
require 'erb'
|
14
14
|
require 'ostruct'
|
@@ -26,6 +26,9 @@ require 'tiller/util'
|
|
26
26
|
require 'tiller/templatesource'
|
27
27
|
require 'tiller/datasource'
|
28
28
|
require 'tiller/logger'
|
29
|
+
require 'digest/md5'
|
30
|
+
|
31
|
+
EXIT_SUCCESS = 0
|
29
32
|
|
30
33
|
# And we're on our way...
|
31
34
|
module Tiller
|
@@ -104,7 +107,10 @@ module Tiller
|
|
104
107
|
|
105
108
|
# Now we go through each template we've identified, and get the
|
106
109
|
# values for each one.
|
107
|
-
all_templates
|
110
|
+
all_templates = {}
|
111
|
+
skipped_templates = 0
|
112
|
+
updated_templates = 0
|
113
|
+
|
108
114
|
templates.each do |template, content|
|
109
115
|
|
110
116
|
# Start with a hash of our global values
|
@@ -145,10 +151,28 @@ module Tiller
|
|
145
151
|
# doesn't exist.
|
146
152
|
target_path = File.dirname(target_values['target'])
|
147
153
|
FileUtils.mkdir_p(target_path) unless File.directory?(target_path)
|
154
|
+
|
155
|
+
filename = target_values['target']
|
156
|
+
|
157
|
+
# MD5 checksum of templates
|
158
|
+
if config['md5sum'] && File.exists?(filename)
|
159
|
+
template_md5 = Digest::MD5.hexdigest(parsed_template)
|
160
|
+
log.debug("MD5 of #{template} is #{template_md5}")
|
161
|
+
file_md5 = Digest::MD5.hexdigest(File.read(filename))
|
162
|
+
log.debug("MD5 of #{filename} is #{file_md5}")
|
163
|
+
if template_md5 == file_md5
|
164
|
+
log.info("Content unchanged for #{template}, not writing anything")
|
165
|
+
skipped_templates += 1
|
166
|
+
next
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
148
170
|
target = open(target_values['target'], 'w')
|
149
171
|
target.puts(parsed_template)
|
150
172
|
target.close
|
151
173
|
|
174
|
+
updated_templates += 1
|
175
|
+
|
152
176
|
# config is redundant in target_values, remove it for the final status hash.
|
153
177
|
all_templates[template] = {
|
154
178
|
'merged_values' => tiller,
|
@@ -172,6 +196,10 @@ module Tiller
|
|
172
196
|
|
173
197
|
end
|
174
198
|
|
199
|
+
if config['md5sum']
|
200
|
+
log.info("[#{updated_templates}/#{templates.size}] templates written, [#{skipped_templates}] skipped with no change")
|
201
|
+
end
|
202
|
+
|
175
203
|
puts 'Template generation completed'
|
176
204
|
|
177
205
|
# Final status structure for API
|
@@ -187,6 +215,12 @@ module Tiller
|
|
187
215
|
config['exec'] = config[:alt_exec]
|
188
216
|
end
|
189
217
|
|
218
|
+
# If no templates were generated and md5sum_noexec is enabled, stop here.
|
219
|
+
if config['md5sum'] && config['md5sum_noexec'] && skipped_templates == templates.size
|
220
|
+
log.info("No templates written, stopping without exec")
|
221
|
+
exit EXIT_SUCCESS
|
222
|
+
end
|
223
|
+
|
190
224
|
if config[:no_exec] == false && config.key?('exec')
|
191
225
|
# All templates created, so let's start the replacement process
|
192
226
|
puts "Executing #{config['exec']}..."
|
data/lib/tiller/data/consul.rb
CHANGED
data/lib/tiller/data/defaults.rb
CHANGED
@@ -1,10 +1,22 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
# preceeding them with env_. E.G. env_home, env_logname and so on.
|
1
|
+
require 'tiller/datasource'
|
2
|
+
|
4
3
|
class EnvironmentDataSource < Tiller::DataSource
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@plugin_config = Tiller::Environment.defaults
|
7
|
+
if @config.has_key? 'environment' and @config['environment'].is_a? Hash
|
8
|
+
@plugin_config.merge!(@config['environment'])
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
|
5
13
|
def global_values
|
6
14
|
values = Hash.new
|
7
|
-
|
15
|
+
if @plugin_config['lowercase']
|
16
|
+
ENV.each { |k, v| values["#{@plugin_config['prefix']}#{k.downcase}"] = v }
|
17
|
+
else
|
18
|
+
ENV.each { |k, v| values["#{@plugin_config['prefix']}#{k}"] = v }
|
19
|
+
end
|
8
20
|
values
|
9
21
|
end
|
10
22
|
end
|
@@ -1,7 +1,4 @@
|
|
1
|
-
|
2
|
-
# tiller_json environment variable and merges the resulting hash data
|
3
|
-
# structure into the global_values available to templates.
|
4
|
-
|
1
|
+
require 'tiller/datasource'
|
5
2
|
require 'json'
|
6
3
|
require 'pp'
|
7
4
|
|
data/lib/tiller/data/file.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'yaml'
|
2
|
-
# File datasource for Tiller.
|
3
2
|
|
4
3
|
class FileDataSource < Tiller::DataSource
|
5
4
|
# Open and parse the environment file. Tries from v2 format common.yaml first, if that
|
@@ -9,7 +8,14 @@ class FileDataSource < Tiller::DataSource
|
|
9
8
|
# Try and load from v2 format common.yaml
|
10
9
|
if @config['environments'].has_key?(@config[:environment])
|
11
10
|
@log.debug("#{self} : Using values from v2 format common.yaml")
|
12
|
-
|
11
|
+
if @config['environments'][@config[:environment]].is_a? Hash
|
12
|
+
@config_hash = @config['environments'][@config[:environment]]
|
13
|
+
else
|
14
|
+
# This permits "stub"" environments, where all the config is provided by another module e.g. defaults
|
15
|
+
# See https://github.com/markround/tiller/issues/29
|
16
|
+
@log.info("Using stub environment for #{@config[:environment]}")
|
17
|
+
@config_hash = Hash.new
|
18
|
+
end
|
13
19
|
else
|
14
20
|
abort("Error : Could not load environment #{@config[:environment]} from common.yaml")
|
15
21
|
end
|
data/lib/tiller/data/http.rb
CHANGED
data/lib/tiller/data/random.rb
CHANGED
data/lib/tiller/data/xml_file.rb
CHANGED
data/lib/tiller/defaults.rb
CHANGED
@@ -10,6 +10,8 @@ module Tiller
|
|
10
10
|
:no_exec => false,
|
11
11
|
:verbose => false,
|
12
12
|
'api_enable' => false,
|
13
|
+
'md5sum' => false,
|
14
|
+
'md5sum_noexec' => false,
|
13
15
|
'api_port' => 6275
|
14
16
|
}
|
15
17
|
end
|
@@ -68,3 +70,12 @@ module Tiller::Consul
|
|
68
70
|
end
|
69
71
|
end
|
70
72
|
|
73
|
+
module Tiller::Environment
|
74
|
+
def self.defaults
|
75
|
+
{
|
76
|
+
'prefix' => 'env_',
|
77
|
+
'lowercase' => true
|
78
|
+
}
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
data/lib/tiller/options.rb
CHANGED
@@ -27,6 +27,12 @@ def parse_options(config)
|
|
27
27
|
opts.on('-x', '--exec [EXEC]', 'Override the \'exec\' variable from common.yaml') do |exec|
|
28
28
|
config[:alt_exec] = exec
|
29
29
|
end
|
30
|
+
opts.on('--md5sum', 'Only write templates if MD5 checksum for content has changed') do
|
31
|
+
config['md5sum'] = true
|
32
|
+
end
|
33
|
+
opts.on('--md5sum-noexec', 'Do not execute a process if no templates were written or changed') do
|
34
|
+
config['md5sum_noexec'] = true
|
35
|
+
end
|
30
36
|
|
31
37
|
opts.on('-h', '--help', 'Display this screen') do
|
32
38
|
puts opts
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'pp'
|
2
2
|
require 'diplomat'
|
3
|
+
require 'tiller/templatesource'
|
3
4
|
require 'tiller/consul.rb'
|
4
5
|
|
5
6
|
class ConsulTemplateSource < Tiller::TemplateSource
|
@@ -12,7 +13,7 @@ class ConsulTemplateSource < Tiller::TemplateSource
|
|
12
13
|
templates = Diplomat::Kv.get(path, {:keys => true, :dc => @consul_config['dc']}, :return)
|
13
14
|
|
14
15
|
if templates.is_a? Array
|
15
|
-
templates.map{|t| File.basename(t)}
|
16
|
+
templates.map { |t| File.basename(t) }
|
16
17
|
else
|
17
18
|
@log.warn("Consul : No templates could be fetched from #{path}")
|
18
19
|
[]
|
data/lib/tiller/template/file.rb
CHANGED
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.7.
|
4
|
+
version: 0.7.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Dastmalchi-Round
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-19 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A tool to create configuration files from a variety of sources, particularly
|
14
14
|
useful for Docker containers. See https://github.com/markround/tiller for examples
|