tiller 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/tiller +33 -2
- data/lib/tiller/data/defaults.rb +1 -1
- data/lib/tiller/logger.rb +4 -4
- data/lib/tiller/render.rb +12 -2
- data/lib/tiller/version.rb +2 -1
- 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: d19ad6cc81b20acaf13f251a62861df1bc3a7d50
|
4
|
+
data.tar.gz: 95c3cd5651079891d414743303672085eb901610
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6d9446383c8025ee6d0ea10da9b3078b0675d17332829e86e3b05106a6a5072152de8f6104ee0271486e99b230336a19b77d63a489436cc4a05e841f2a01fc9
|
7
|
+
data.tar.gz: ddf4ac3e4fedab07bfe8a4ef1452c86b0022dd74acf9357b2f1159def7c8817a0e369f1f53cb6f25fd06d062a078845596b3b18d1d520b1940d199efa9393014
|
data/bin/tiller
CHANGED
@@ -35,6 +35,10 @@ EXIT_SUCCESS = 0
|
|
35
35
|
module Tiller
|
36
36
|
|
37
37
|
puts "tiller v#{VERSION} (https://github.com/markround/tiller) <github@markround.com>"
|
38
|
+
if RUBY_VERSION < SUPPORTED_RUBY_VERSION
|
39
|
+
puts "Warning : Support for Ruby versions < #{SUPPORTED_RUBY_VERSION} is deprecated."
|
40
|
+
puts " See http://tiller.readthedocs.io/en/latest/requirements/"
|
41
|
+
end
|
38
42
|
|
39
43
|
class << self
|
40
44
|
attr_accessor :config, :log, :templates, :tiller
|
@@ -94,6 +98,35 @@ module Tiller
|
|
94
98
|
data_classes = loader(DataSource, config['data_sources'])
|
95
99
|
template_classes = loader(TemplateSource, config['template_sources'])
|
96
100
|
|
101
|
+
# dynamic_values in top-level config (https://github.com/markround/tiller/issues/58)
|
102
|
+
# We create a temporary copy of our config hash, and iterate over it, fetching values from each datasource in turn
|
103
|
+
# and then merging the values back into the main config hash as we go along.
|
104
|
+
# Due to needing binding functions only present in Ruby >= 2.1.0, this feature is not present on older Ruby versions.
|
105
|
+
# See See http://tiller.readthedocs.io/en/latest/requirements/ for Ruby support policy and background.
|
106
|
+
if config.assoc('dynamic_values') && RUBY_VERSION >= "2.1.0"
|
107
|
+
log.debug('Parsing top-level values for ERb syntax')
|
108
|
+
# Deep copy for our temp config
|
109
|
+
temp_config = Marshal.load(Marshal.dump(config))
|
110
|
+
data_classes.each do |data_class|
|
111
|
+
temp_config.deep_traverse do |path,value|
|
112
|
+
# We skip anything under environments block (Unless it's the "common" over-ride block) as these
|
113
|
+
# may contain values we want to replace with template-specific values later on.
|
114
|
+
next if path.include?('environments') and ! path.include?('common')
|
115
|
+
|
116
|
+
if value.is_a?(String) && value.include?('<%')
|
117
|
+
begin
|
118
|
+
parsed_value = Tiller::render(value, direct_render: true, namespace: data_class.new.global_values)
|
119
|
+
log.debug("Parsed ERb of #{path.join('/')} as #{parsed_value}", dedup: false)
|
120
|
+
config.deep_merge!((path + [parsed_value]).reverse.reduce { |s,e| { e => s } })
|
121
|
+
rescue NameError => e
|
122
|
+
# This happens if there is no value provided by the currently active datasource. If so,
|
123
|
+
# we simply catch the error and proceed without merging anything.
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
97
130
|
log.info('Template sources loaded ' + template_classes.to_s)
|
98
131
|
log.info('Data sources loaded ' + data_classes.to_s)
|
99
132
|
if (config.key?('helpers'))
|
@@ -323,6 +356,4 @@ module Tiller
|
|
323
356
|
|
324
357
|
end
|
325
358
|
|
326
|
-
|
327
|
-
|
328
359
|
end
|
data/lib/tiller/data/defaults.rb
CHANGED
@@ -26,7 +26,7 @@ class DefaultsDataSource < Tiller::DataSource
|
|
26
26
|
# If we have YAML files in defaults.d, also merge them
|
27
27
|
# We do this even if the main defaults were loaded from the v2 format config
|
28
28
|
if File.directory? defaults_dir
|
29
|
-
Dir.glob(File.join(defaults_dir,'*.yaml')).each do |d|
|
29
|
+
Dir.glob(File.join(defaults_dir,'*.yaml')).sort().each do |d|
|
30
30
|
yaml = YAML.load(open(d))
|
31
31
|
Tiller::log.debug("Loading defaults from #{d}")
|
32
32
|
@defaults_hash.deep_merge!(yaml) if yaml != false
|
data/lib/tiller/logger.rb
CHANGED
@@ -21,15 +21,15 @@ module Tiller
|
|
21
21
|
end
|
22
22
|
|
23
23
|
# Quick hack to remove duplicate informational messages
|
24
|
-
def info(msg)
|
24
|
+
def info(msg, options={})
|
25
25
|
super(msg) unless self.messages.include?(msg)
|
26
|
-
self.messages.push(msg)
|
26
|
+
self.messages.push(msg) if options.fetch(:dedup, true)
|
27
27
|
end
|
28
28
|
|
29
29
|
# Quick hack to remove duplicate informational messages
|
30
|
-
def debug(msg)
|
30
|
+
def debug(msg, options={})
|
31
31
|
super(msg) unless self.messages.include?(msg)
|
32
|
-
self.messages.push(msg)
|
32
|
+
self.messages.push(msg) if options.fetch(:dedup, true)
|
33
33
|
end
|
34
34
|
|
35
35
|
end
|
data/lib/tiller/render.rb
CHANGED
@@ -1,20 +1,30 @@
|
|
1
1
|
module Tiller
|
2
2
|
def self.render(template, options={})
|
3
3
|
|
4
|
+
# This is only ever used when we parse top-level values for ERb syntax, we pass in each
|
5
|
+
# datasource's global_values as a distinct namespace
|
6
|
+
if options.has_key?(:namespace)
|
7
|
+
b = binding
|
8
|
+
ns = options[:namespace]
|
9
|
+
ns.each { |k, v| b.local_variable_set(k, v) }
|
10
|
+
return ERB.new(template, nil, '-').result(ns.instance_eval { b })
|
11
|
+
end
|
12
|
+
|
13
|
+
ns = OpenStruct.new(Tiller::tiller)
|
14
|
+
|
4
15
|
# This is used for rendering content in dynamic configuration files
|
5
16
|
if options.has_key?(:direct_render)
|
6
17
|
content = template
|
7
|
-
ns = OpenStruct.new(Tiller::tiller)
|
8
18
|
return ERB.new(content, nil, '-').result(ns.instance_eval { binding })
|
9
19
|
end
|
10
20
|
|
11
21
|
if Tiller::templates.key?(template)
|
12
22
|
content = Tiller::templates[template]
|
13
|
-
ns = OpenStruct.new(Tiller::tiller)
|
14
23
|
ERB.new(content, nil, '-').result(ns.instance_eval { binding })
|
15
24
|
else
|
16
25
|
Tiller::log.warn("Warning : Requested render of non-existant template #{template}")
|
17
26
|
""
|
18
27
|
end
|
19
28
|
end
|
29
|
+
|
20
30
|
end
|
data/lib/tiller/version.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: 1.
|
4
|
+
version: 1.2.0
|
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: 2017-
|
11
|
+
date: 2017-06-09 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
|