tiller 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d19ad6cc81b20acaf13f251a62861df1bc3a7d50
4
- data.tar.gz: 95c3cd5651079891d414743303672085eb901610
3
+ metadata.gz: 32429bd0fb6b6c9f3c012e74bb55f0ff52ba7c24
4
+ data.tar.gz: a8758eef551cca3b0df1fc548700e9f8b9f6c712
5
5
  SHA512:
6
- metadata.gz: a6d9446383c8025ee6d0ea10da9b3078b0675d17332829e86e3b05106a6a5072152de8f6104ee0271486e99b230336a19b77d63a489436cc4a05e841f2a01fc9
7
- data.tar.gz: ddf4ac3e4fedab07bfe8a4ef1452c86b0022dd74acf9357b2f1159def7c8817a0e369f1f53cb6f25fd06d062a078845596b3b18d1d520b1940d199efa9393014
6
+ metadata.gz: 68551eaa414c82d97bcaed63412d8ea8cfbcd50a43b83536801f9160fecca459556b63b44cb729613ac613fd9e283a019e1769f4070d0520e6b9570f90855699
7
+ data.tar.gz: d6ba1f1b0ddd4a921bb314e268b325a44f60502d9d08186dccb611cc354f3910e91e470f712f88410677cad8fa80fb629666427826de780c941c1cf85d0a4780
data/bin/tiller CHANGED
@@ -212,7 +212,7 @@ module Tiller
212
212
  # Proper Ruby voodoo here.
213
213
  # See http://stackoverflow.com/questions/19304135/deep-nest-a-value-into-a-hash-given-a-path-array for
214
214
  # explanation.
215
- tiller.merge!((path + [parsed_value]).reverse.reduce { |s,e| { e => s } })
215
+ tiller.deep_merge!((path + [parsed_value]).reverse.reduce { |s,e| { e => s } })
216
216
  end
217
217
  end
218
218
  target_values.each do |key ,value|
@@ -2,6 +2,8 @@ require 'tiller/datasource'
2
2
 
3
3
  class EnvironmentDataSource < Tiller::DataSource
4
4
 
5
+ @plugin_api_versions = [ 1, 2 ]
6
+
5
7
  def setup
6
8
  @plugin_config = Tiller::Environment.defaults
7
9
  if Tiller::config.has_key? 'environment' and Tiller::config['environment'].is_a? Hash
@@ -1,6 +1,9 @@
1
1
  require 'yaml'
2
2
 
3
3
  class FileDataSource < Tiller::DataSource
4
+
5
+ @plugin_api_versions = [1, 2]
6
+
4
7
  # Open and parse the environment file. Tries from v2 format common.yaml first, if that
5
8
  # failes, then it looks for separate environment files.
6
9
  def setup
@@ -41,11 +44,26 @@ class FileDataSource < Tiller::DataSource
41
44
  end
42
45
 
43
46
  def values(template_name)
44
- @config_hash.key?(template_name) ? @config_hash[template_name]['config'] : {}
47
+ if (Tiller::config['plugin_api_version'] == 2)
48
+ # Everything comes from the values method in V2
49
+ if @config_hash.key?(template_name)
50
+ all_values=[]
51
+ @config_hash[template_name].each { |values| all_values << values }
52
+ return all_values
53
+ end
54
+ else
55
+ return @config_hash.key?(template_name) ? @config_hash[template_name]['config'] : {}
56
+ end
57
+
45
58
  end
46
59
 
47
60
  def target_values(template_name)
48
- # The config element is redundant (not a target value)
49
- @config_hash.key?(template_name) ? @config_hash[template_name] : {}
61
+ if (Tiller::config['plugin_api_version'] == 2)
62
+ Tiller::log.fatal("Deprecated : We should never get here")
63
+ exit
64
+ else
65
+ return @config_hash.key?(template_name) ? @config_hash[template_name] : {}
66
+ end
50
67
  end
68
+
51
69
  end
@@ -1,3 +1,5 @@
1
+ require 'tiller/util.rb'
2
+
1
3
  # Tiller data source base class.
2
4
  module Tiller
3
5
  # Subclasses provide global_values and/or values (things local to a specific
@@ -5,6 +7,10 @@ module Tiller
5
7
  # location, permissions, owner and so on)
6
8
  class DataSource
7
9
 
10
+ include ClassLevelInheritableAttributes
11
+ inheritable_attributes :plugin_api_versions
12
+ @plugin_api_versions = [ 1 ]
13
+
8
14
  def initialize
9
15
  setup
10
16
  end
@@ -13,7 +13,8 @@ module Tiller
13
13
  'md5sum' => false,
14
14
  'md5sum_noexec' => false,
15
15
  'deep_merge' => false,
16
- 'api_port' => 6275
16
+ 'api_port' => 6275,
17
+ 'plugin_api_version' => 1
17
18
  }
18
19
  end
19
20
 
@@ -25,6 +25,16 @@ def loader(type,sources)
25
25
  classes |= type.subclasses
26
26
  end
27
27
 
28
+ # Versioning check - if any of the loaded modules do not support the specified API version, we stop immediately.
29
+ classes.each do |c|
30
+ api_version = Tiller::config['plugin_api_version']
31
+ if ! c.plugin_api_versions.include?(api_version)
32
+ Tiller::log.fatal("ERROR : Plugin #{c} does not support specified API version #{api_version}")
33
+ exit(EXIT_FAIL)
34
+ end
35
+ end
36
+
37
+
28
38
  classes
29
39
  end
30
40
 
@@ -33,6 +33,9 @@ def parse_options(config)
33
33
  opts.on('--md5sum-noexec', 'Do not execute a process if no templates were written or changed') do
34
34
  config['md5sum_noexec'] = true
35
35
  end
36
+ opts.on('--plugin-api-version [VERS]', 'Specify the plugin API version to use') do |plugin_api_version|
37
+ config['plugin_api_version'] = plugin_api_version
38
+ end
36
39
 
37
40
  opts.on('-h', '--help', 'Display this screen') do
38
41
  puts opts
@@ -1,4 +1,7 @@
1
1
  class FileTemplateSource < Tiller::TemplateSource
2
+
3
+ @plugin_api_versions = [ 1, 2 ]
4
+
2
5
  def initialize
3
6
  super
4
7
  @template_dir = File.join(Tiller::config[:tiller_base], 'templates/')
@@ -1,9 +1,15 @@
1
+ require 'tiller/util'
2
+
1
3
  # Tiller template source base class
2
4
  module Tiller
3
5
  # Subclasses provide templates (an array), and individual template contents
4
6
  # (a string containing ERB data)
5
7
  class TemplateSource
6
8
 
9
+ include ClassLevelInheritableAttributes
10
+ inheritable_attributes :plugin_api_versions
11
+ @plugin_api_versions = [ 1 ]
12
+
7
13
  def initialize
8
14
  setup
9
15
  end
@@ -68,4 +68,31 @@ def launch(cmd)
68
68
  end
69
69
 
70
70
  pid
71
+ end
72
+
73
+ # Module for inheritable attributes in data sources (e.g. api_version)
74
+ module ClassLevelInheritableAttributes
75
+ def self.included(base)
76
+ base.extend(ClassMethods)
77
+ end
78
+
79
+ module ClassMethods
80
+ def inheritable_attributes(*args)
81
+ @inheritable_attributes ||= [:inheritable_attributes]
82
+ @inheritable_attributes += args
83
+ args.each do |arg|
84
+ class_eval %(
85
+ class << self; attr_accessor :#{arg} end
86
+ )
87
+ end
88
+ @inheritable_attributes
89
+ end
90
+
91
+ def inherited(subclass)
92
+ @inheritable_attributes.each do |inheritable_attribute|
93
+ instance_var = "@#{inheritable_attribute}"
94
+ subclass.instance_variable_set(instance_var, instance_variable_get(instance_var))
95
+ end
96
+ end
97
+ end
71
98
  end
@@ -1,3 +1,3 @@
1
1
  # http://semver.org/
2
- VERSION="1.2.0"
2
+ VERSION="1.3.0"
3
3
  SUPPORTED_RUBY_VERSION="2.2.0"
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.2.0
4
+ version: 1.3.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-06-09 00:00:00.000000000 Z
11
+ date: 2018-04-10 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
@@ -80,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
80
80
  version: '0'
81
81
  requirements: []
82
82
  rubyforge_project:
83
- rubygems_version: 2.5.1
83
+ rubygems_version: 2.6.14
84
84
  signing_key:
85
85
  specification_version: 4
86
86
  summary: Dynamic configuration file generation