spiceweasel 2.1.0 → 2.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -208,11 +208,11 @@ module Spiceweasel
208
208
  ARGV << "-h" if ARGV.empty?
209
209
  begin
210
210
  parse_options
211
- if Spiceweasel::Config[:knifeconfig]
212
- Spiceweasel::Config[:knife_options] = "-c #{Spiceweasel::Config[:knifeconfig]} "
211
+ if @config[:knifeconfig]
212
+ Spiceweasel::Config[:knife_options] = " -c #{@config[:knifeconfig]} "
213
213
  end
214
- if Spiceweasel::Config[:serverurl]
215
- Spiceweasel::Config[:knife_options] += "--server-url #{Spiceweasel::Config[:serverurl]} "
214
+ if @config[:serverurl]
215
+ Spiceweasel::Config[:knife_options] += "--server-url #{@config[:serverurl]} "
216
216
  end
217
217
  rescue OptionParser::InvalidOption => e
218
218
  STDERR.puts e.message
@@ -57,14 +57,19 @@ module Spiceweasel
57
57
  def validate(environment, cookbooks)
58
58
  file = %W(environments/#{environment}.rb environments/#{environment}.json).detect{|f| File.exists?(f)}
59
59
  if file
60
- if (Chef::Version.new(Chef::VERSION) < Chef::Version.new('11.0.0'))
61
- env = Chef::Environment.new(false)
62
- else
63
- env = Chef::Environment.new
60
+ case file
61
+ when /\.json$/
62
+ env = Chef::JSONCompat.from_json(IO.read(file))
63
+ when /\.rb$/
64
+ if (Chef::Version.new(Chef::VERSION) < Chef::Version.new('11.0.0'))
65
+ env = Chef::Environment.new(false)
66
+ else
67
+ env = Chef::Environment.new
68
+ end
69
+ env.from_file(file)
64
70
  end
65
- env.from_file(file)
66
71
  if(env.name != environment)
67
- STDERR.puts "ERROR: Environment '#{environment}' listed in the manifest does not match the name '#{name}' within the environments/#{environment}.rb file."
72
+ STDERR.puts "ERROR: Environment '#{environment}' listed in the manifest does not match the name '#{env.name}' within the #{file} file."
68
73
  exit(-1)
69
74
  end
70
75
  env.cookbook_versions.keys.each do |dep|
@@ -32,7 +32,8 @@ module Spiceweasel
32
32
  end
33
33
 
34
34
  # COOKBOOKS
35
- cookbooks = self.resolve_cookbooks(berksfile.cookbook_list)
35
+ cookbooks = berksfile ? self.resolve_cookbooks(berksfile.cookbook_list) : self.resolve_cookbooks
36
+
36
37
  objects['cookbooks'] = cookbooks unless cookbooks.empty?
37
38
 
38
39
  # ROLES
@@ -59,15 +59,20 @@ module Spiceweasel
59
59
  #validate the role passed in match the name of either the .rb or .json
60
60
  file = %W(roles/#{role}.rb roles/#{role}.json).detect{|f| File.exists?(f)}
61
61
  if(file)
62
- if(Chef::Version.new(Chef::VERSION) < Chef::Version.new('11.0.0'))
63
- c_role = Chef::Role.new(true)
64
- else
65
- c_role = Chef::Role.new
62
+ case file
63
+ when /\.json$/
64
+ c_role = Chef::JSONCompat.from_json(IO.read(file))
65
+ when /\.rb$/
66
+ if(Chef::Version.new(Chef::VERSION) < Chef::Version.new('11.0.0'))
67
+ c_role = Chef::Role.new(true)
68
+ else
69
+ c_role = Chef::Role.new
70
+ end
71
+ c_role.from_file(file)
66
72
  end
67
- c_role.from_file(file)
68
73
  Spiceweasel::Log.debug("role: '#{role}' name: '#{c_role.name}'")
69
74
  if !role.eql?(c_role.name)
70
- STDERR.puts "ERROR: Role '#{role}' listed in the manifest does not match the name '#{c_role.name}' within the roles/#{role}.rb file."
75
+ STDERR.puts "ERROR: Role '#{role}' listed in the manifest does not match the name '#{c_role.name}' within the #{file} file."
71
76
  exit(-1)
72
77
  end
73
78
  c_role.run_list.each do |runlist_item|
@@ -17,5 +17,5 @@
17
17
  #
18
18
 
19
19
  module Spiceweasel
20
- VERSION = '2.1.0'
20
+ VERSION = '2.1.2'
21
21
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spiceweasel
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-29 00:00:00.000000000 Z
12
+ date: 2013-04-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json