batali 0.2.32 → 0.3.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bb8be253084c752f62ea9022af64502013512df6
4
- data.tar.gz: 14c8943c92771c752d94825140352a39a544aec3
3
+ metadata.gz: 46854b296a6edbf19b102be8b154d07a7b12281a
4
+ data.tar.gz: 7ffcd5cb954a80a8f3fa3c03081b71eaef3ff614
5
5
  SHA512:
6
- metadata.gz: 8098dbc72989379d75e26ec694fad5be9c041dc659638c19cf4d85aa3bf68ebed4435c21d780cbaa0e0f207ca2525784f91da1e210fe86d2cd8ddf8896f30d53
7
- data.tar.gz: 3f6de6fe1e4cb254bbc8322673f398297f5b37e433e60d04ca355a07375b1a902a3bc261785caac0d162890fcb8dc858202d7ada8e62eed440c4766e765fab12
6
+ metadata.gz: 54d327a5d8968e97c5b015e69137a702b38cef1e46251d3e2ccd05ba59c7300ca5e6f0c0b1ea06f3b8f97bb290674c09525f151bd2b51a690bfdd240b2da1076
7
+ data.tar.gz: 545583f6bf2c2bebf1f12a5b0208b1b353b3bc3631aae38e1cb8e9823858acb44df9fc60049ea4158af3ea254a9a22ba44afe25f1620454e40159d0348736900
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # v0.3.0
2
+ * [enhancement] Properly restore BFile from serialized data
3
+ * [enhancement] Provide access to environment specific constraint usage
4
+
1
5
  # v0.2.32
2
6
  * [fix] Skip constraint merging when entry is non-site sourced
3
7
  * [enhancement] Support dry run in infrastructure resolve
data/bin/batali CHANGED
@@ -44,6 +44,7 @@ Bogo::Cli::Setup.define do
44
44
  on :i, 'install', 'Install cookbooks after update', :default => true
45
45
  on :p, 'path=', 'Cookbook install path'
46
46
  on :I, 'infrastructure', 'Resolve infrastructure cookbooks'
47
+ on :e, 'environment=', 'Restrict auto-discovery to named environment'
47
48
 
48
49
  run do |opts, args|
49
50
  Batali::Command::Update.new({:update => opts.to_hash}, args).execute!
@@ -56,6 +57,7 @@ Bogo::Cli::Setup.define do
56
57
  on :d, 'dry-run', 'Print changes'
57
58
  on :l, 'least-impact', 'Update cookbooks with minimal version impact', :default => true
58
59
  on :I, 'infrastructure', 'Resolve infrastructure cookbooks'
60
+ on :e, 'environment=', 'Restrict auto-discovery to named environment'
59
61
 
60
62
  run do |opts, args|
61
63
  Batali::Command::Resolve.new({:resolve => opts.to_hash}, args).execute!
data/lib/batali/b_file.rb CHANGED
@@ -91,15 +91,19 @@ module Batali
91
91
  def self.cookbook_coerce
92
92
  proc do |v|
93
93
  v = [v].flatten.compact
94
- name, args = v.first, v.slice(1, v.size)
95
- if(args.empty?)
96
- args = Smash.new
97
- elsif(args.size == 1 && args.first.is_a?(Hash))
98
- args = args.first
94
+ if(v.size == 1 && v.first.is_a?(Hash))
95
+ Cookbook.new(v.first)
99
96
  else
100
- args = Smash.new(:constraint => args.map(&:to_s))
97
+ name, args = v.first, v.slice(1, v.size)
98
+ if(args.empty?)
99
+ args = Smash.new
100
+ elsif(args.size == 1 && args.first.is_a?(Hash))
101
+ args = args.first
102
+ else
103
+ args = Smash.new(:constraint => args.map(&:to_s))
104
+ end
105
+ Cookbook.new(Smash.new(:name => name).merge(args))
101
106
  end
102
- Cookbook.new(Smash.new(:name => name).merge(args))
103
107
  end
104
108
  end
105
109
 
@@ -123,28 +127,44 @@ module Batali
123
127
 
124
128
  attribute :discover, [TrueClass, FalseClass], :required => true, :default => false
125
129
  attribute :restrict, Restriction, :multiple => true, :coerce => lambda{|v|
126
- Restriction.new(:cookbook => v.first, :source => v.last.to_smash[:source])
130
+ if(v.is_a?(Hash))
131
+ Restriction.new(v)
132
+ else
133
+ Restriction.new(:cookbook => v.first, :source => v.last.to_smash[:source])
134
+ end
127
135
  }
128
136
  attribute :source, Origin::RemoteSite, :multiple => true, :default => [], :coerce => lambda{|v|
129
- args = Smash.new(:endpoint => v.first)
130
- if(v.last.is_a?(Hash))
131
- args.merge!(v.last)
137
+ if(v.is_a?(Hash))
138
+ args = v
139
+ else
140
+ args = Smash.new(:endpoint => v.first)
141
+ if(v.last.is_a?(Hash))
142
+ args.merge!(v.last)
143
+ end
132
144
  end
133
145
  Origin::RemoteSite.new(args)
134
146
  }
135
147
  attribute :chef_server, Origin::ChefServer, :multiple => true, :default => [], :coerce => lambda{|v|
136
- args = Smash.new(:endpoint => v.first)
137
- if(v.last.is_a?(Hash))
138
- args.merge!(v.last)
148
+ if(v.is_a?(Hash))
149
+ args = v
150
+ else
151
+ args = Smash.new(:endpoint => v.first)
152
+ if(v.last.is_a?(Hash))
153
+ args.merge!(v.last)
154
+ end
139
155
  end
140
156
  Origin::ChefServer.new(args)
141
157
  }
142
- attribute :group, Group, :multiple => true, :coerce => lambda{|v| Group.new()}
158
+ attribute :group, Group, :multiple => true, :coerce => lambda{|v| Group.new(v)}
143
159
  attribute :cookbook, Cookbook, :multiple => true, :coerce => BFile.cookbook_coerce, :default => []
144
160
  attribute :metadata, Cookbook, :coerce => lambda{ |v, b_file|
145
- dir = Pathname.new(File.dirname(b_file.path)).relative_path_from(Pathname.new(Dir.pwd)).to_path
146
- m_unit = Origin::Path.new(:name => 'metadata', :path => dir).units.first
147
- ckbk = Cookbook.new(:name => m_unit.name, :version => m_unit.version, :path => dir)
161
+ if(v.is_a?(Hash))
162
+ ckbk = Cookbook.new(v)
163
+ else
164
+ dir = Pathname.new(File.dirname(b_file.path)).relative_path_from(Pathname.new(Dir.pwd)).to_path
165
+ m_unit = Origin::Path.new(:name => 'metadata', :path => dir).units.first
166
+ ckbk = Cookbook.new(:name => m_unit.name, :version => m_unit.version, :path => dir)
167
+ end
148
168
  unless(b_file.cookbook.map(&:name).include?(ckbk.name))
149
169
  b_file.cookbook.push ckbk
150
170
  end
@@ -30,7 +30,7 @@ module Batali
30
30
  ui.verbose "Loading Batali file from: #{path}"
31
31
  bfile = BFile.new(path)
32
32
  if(bfile.discover)
33
- bfile.auto_discover!
33
+ bfile.auto_discover!(config[:environment])
34
34
  end
35
35
  bfile.data.keys.each do |key|
36
36
  unless(bfile.respond_to?(key))
@@ -1,4 +1,4 @@
1
1
  module Batali
2
2
  # Current version
3
- VERSION = Gem::Version.new('0.2.32')
3
+ VERSION = Gem::Version.new('0.3.0')
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: batali
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.32
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Roberts
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-21 00:00:00.000000000 Z
11
+ date: 2015-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: attribute_struct