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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/tiller +49 -15
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 86fc7d0cf3873002d5592553f0f5149cf252f09a
4
- data.tar.gz: b1d175a16e5ed95836d026b2c031d850a909dcd2
3
+ metadata.gz: 07e3b43a954c568746d1b2e987616ee2c02bac87
4
+ data.tar.gz: 04bba1376ebe4e065e69c6d7ce7a97b97e324d55
5
5
  SHA512:
6
- metadata.gz: 7014d7b4591b1611c949c8a9096f02310ebac01fde5b5ec6410390456be54dcf9c46765f242954cc59d1262d8b9493bc8e776671fc337e195d669c79f09397a7
7
- data.tar.gz: bc6d9b5e25f7844ff07ff5325d63623950fafe3eb57228109090d570844ebe9dbf84d4ad250db6417a65f17488ad1905c26f496d868f9ddfc552f9b06ef0f4fd
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.2'
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
- puts "Using configuration from #{config[:tiller_base]}"
51
- puts "Using plugins from #{config[:tiller_lib]}/tiller"
52
- puts "Using environment #{config[:environment]}"
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
- puts 'Template sources loaded ' + TemplateSource.subclasses.to_s
63
- puts 'Data sources loaded ' + DataSource.subclasses.to_s
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
- # All templates created, so let's handover to the replacement process then
151
- # it's home in time for tea and medals.
152
- puts 'Template generation completed, about to exec replacement process.'
153
- puts "Calling #{config[:common_config]['exec']}..."
154
- exec(config[:common_config]['exec'])
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.2
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-08-20 00:00:00.000000000 Z
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.