tiller 0.0.4 → 0.0.5

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: e822f04c4956fa8ddbc156465643fcbc481fb58d
4
- data.tar.gz: b23183f8d51f4435d20e4dbd4fb02193d819ae03
3
+ metadata.gz: c4ca53cc681827456c07f791d7d58e558014cc7e
4
+ data.tar.gz: cae787837375bc7ba3b54eaf784e90b33c762385
5
5
  SHA512:
6
- metadata.gz: d8cb6c32dd9eb1fb87652ec26e001e9c1fa44a9804e85457f55c6ed1b256d7569a7271601e6811bccba1371d3a62c1f7f157e77e0cf326245c5db43f8fbd8935
7
- data.tar.gz: b4ddcae0335c162a4ed0673faa4fb8e8727479ae81c2015eea2d3cd68f8dff62cb3159517e0ad49277d17f04f00ba9874907dd759d7c2a0af8fbad7ed4d6580a
6
+ metadata.gz: c75b645fd91e5225352848b1443eaf2dbee36d8d352d5bab64e3a46fc2d098bbbdc00abce8bfd57a6895cb9840517e4bfb5688ddd2c3596bde1a1c51c849d197
7
+ data.tar.gz: d0a19d94b88af5e848f5d53147aeb50d3a49a788c6b567e536cc3e54bdbaf9ea418e89c6750dbf586c5157ab26e57a62154ff8bbce83fefec839a58c2eda5e37
data/bin/tiller CHANGED
@@ -3,7 +3,7 @@
3
3
  # Named from the first ship-building (Docker) related term I could find that didn't have an existing gem named after it!
4
4
  # Mark Round <github@markround.com>
5
5
 
6
- VERSION='0.0.4'
6
+ VERSION='0.0.5'
7
7
 
8
8
  require 'erb'
9
9
  require 'ostruct'
@@ -100,6 +100,10 @@ module Tiller
100
100
  end
101
101
  end
102
102
 
103
+ # If our data source returned no values (e.g. we don't build this template for this environment)
104
+ # We move onto the next one.
105
+ next if target_values.empty?
106
+
103
107
  # Now, we build the template
104
108
  tiller = values.merge(global_values) do |key, old, new|
105
109
  warn_merge(key, old, new, 'global and local', 'merged configuration')
@@ -120,7 +124,8 @@ module Tiller
120
124
  # Set permissions if we are running as root
121
125
  if Process::Sys.geteuid == 0 then
122
126
  puts "Setting ownership/permissions on #{target_values['target']}"
123
- FileUtils.chmod(target_values['perms'], target_values['target']) if target_values.has_key('perms')
127
+ FileUtils.chmod(target_values['perms'], target_values['target']) if target_values.has_key?('perms')
128
+ # Don't need to check for the presence of these, as they're ignored if null.
124
129
  FileUtils.chown(target_values['user'], target_values['group'], target_values['target'])
125
130
  else
126
131
  puts "Not running as root, so not setting ownership/permissions on #{target_values['target']}"
@@ -9,16 +9,16 @@ class FileDataSource < Tiller::DataSource
9
9
  # We don't provide any global values, just ones specific to a template.
10
10
  def initialize(config)
11
11
  super
12
- env_file = File.join(@@config[:tiller_base] , "environments" , "#{@@config[:environment]}.yaml")
12
+ env_file = File.join(@@config[:tiller_base], "environments", "#{@@config[:environment]}.yaml")
13
13
  @config_hash = YAML::load(open(env_file))
14
14
  end
15
15
 
16
16
  def values(template_name)
17
- @config_hash[template_name]['config']
17
+ @config_hash.has_key?(template_name) ? @config_hash[template_name]['config'] : Hash.new
18
18
  end
19
19
 
20
20
  def target_values(template_name)
21
- @config_hash[template_name]
21
+ @config_hash.has_key?(template_name) ? @config_hash[template_name]['config'] : Hash.new
22
22
  end
23
23
 
24
24
  end
@@ -4,7 +4,7 @@
4
4
  # about a template, e.g. target location, permissions, owner and so on)
5
5
 
6
6
  module Tiller
7
- class DataSource
7
+ class DataSource
8
8
 
9
9
  # All subclasses get this, which is a hash containing tiller_base, tiller_lib and environment.
10
10
  @@config = Array.new
@@ -16,6 +16,7 @@ module Tiller
16
16
 
17
17
  attr_reader :global_values
18
18
 
19
+ # We should always return a hash; if we have no data for the given template, just return an empty hash.
19
20
  def values(template_name)
20
21
  Hash.new
21
22
  end
@@ -27,6 +28,7 @@ module Tiller
27
28
  # 'group' => 'root',
28
29
  # 'perms' => '0644'
29
30
  #}
31
+ # Again, we should always return a hash; if we have no data for the given template, just return an empty hash.
30
32
  def target_values(template_name)
31
33
  Hash.new
32
34
  end
@@ -35,5 +37,5 @@ module Tiller
35
37
  "ping!" + @@config.to_s
36
38
  end
37
39
 
38
- end
40
+ end
39
41
  end
@@ -5,20 +5,20 @@ class FileTemplateSource < Tiller::TemplateSource
5
5
 
6
6
  def initialize(config)
7
7
  super
8
- @template_dir = File.join(@@config[:tiller_base] , 'templates/')
8
+ @template_dir = File.join(@@config[:tiller_base], 'templates/')
9
9
  end
10
10
 
11
11
  # Simply return a list of all the templates in the $tiller_base/templates directory
12
12
  # With the preceeding directory path stripped off
13
13
  def templates
14
- Dir.glob(File.join(@template_dir , '**' , '*.erb')).each do |t|
15
- t.sub!(@template_dir , '')
14
+ Dir.glob(File.join(@template_dir, '**', '*.erb')).each do |t|
15
+ t.sub!(@template_dir, '')
16
16
  end
17
17
  end
18
18
 
19
19
  # Just open and return the file
20
20
  def template(template_name)
21
- open(File.join(@template_dir , template_name)).read
21
+ open(File.join(@template_dir, template_name)).read
22
22
  end
23
23
 
24
24
  end
@@ -2,7 +2,7 @@
2
2
  # Subclasses provide templates (an array), and individual template contents (a string containing ERB data)
3
3
 
4
4
  module Tiller
5
- class TemplateSource
5
+ class TemplateSource
6
6
 
7
7
  # All subclasses get this, which is a hash containing tiller_base, tiller_lib and environment.
8
8
  @@config = Array.new
@@ -22,5 +22,5 @@ module Tiller
22
22
  def ping
23
23
  "ping!" + @@config.to_s
24
24
  end
25
- end
25
+ end
26
26
  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.0.4
4
+ version: 0.0.5
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-07-18 00:00:00.000000000 Z
11
+ date: 2014-07-21 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.