chef-zero 1.6.3 → 1.7.beta.1

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: ab2212b0f762b019319fc6ab562aa117df0835e1
4
- data.tar.gz: ef6125fd415f0d38f2040b29170cbf18d435d470
3
+ metadata.gz: 9d8f6de63322dfa150bf6c96c90123f53987b230
4
+ data.tar.gz: 716d2b989782680c7910a640badfac8f579fb208
5
5
  SHA512:
6
- metadata.gz: 79cba74de00ae3293ca0e19f947734227cfeee66ef26c4f7af2eae0d55d0559d0f3e6a6da7b57b7d44c804a4543e58d04130c43c7095e2c87ee118707305b7e5
7
- data.tar.gz: 860b7e96f72fa3d2dd330e9baead3881d15ab1ab14ffbe3d7120ecd998d1650a15d98c19a0bde0eb84a2558e4dbccb9c39a74df1f99b5bcd39e7ff762556a429
6
+ metadata.gz: 1c6ab04cd6a08f77135691c87469a0d65a5179db0b1e28c76848a67599026ee46f4b3f3bc19fc80c227c3732848d1edb07304d1ece9508c2e64c89147aad4f16
7
+ data.tar.gz: ec2b872272e594b12f1fc71492b7674db4a95d16c36d46e5454be43db7cf3127c1a43d2de40bc180801ef609aea51b2ecf084633d0c79c05449bff3ebdfb920b
@@ -73,8 +73,8 @@ module ChefZero
73
73
  end
74
74
  end
75
75
 
76
- def from_json(json)
77
- self.merge!(JSON.parse(json))
76
+ def from_json(filepath)
77
+ self.merge!(JSON.parse(File.read(filepath)))
78
78
  end
79
79
 
80
80
  private
@@ -6,6 +6,7 @@ module ChefZero
6
6
  module Endpoints
7
7
  # /environments/NAME/cookbook_versions
8
8
  class EnvironmentCookbookVersionsEndpoint < RestBase
9
+
9
10
  def post(request)
10
11
  cookbook_names = list_data(request, ['cookbooks'])
11
12
 
@@ -35,7 +36,14 @@ module ChefZero
35
36
  # Depsolve!
36
37
  solved = depsolve(request, desired_versions.keys, desired_versions, environment_constraints)
37
38
  if !solved
38
- return raise RestErrorResponse.new(412, "Unsolvable versions!")
39
+ if @last_missing_dep && !cookbook_names.include?(@last_missing_dep)
40
+ return raise RestErrorResponse.new(412, "No such cookbook: #{@last_missing_dep}")
41
+ elsif @last_constraint_failure
42
+ return raise RestErrorResponse.new(412, "Could not satisfy version constraints for: #{@last_constraint_failure}")
43
+ else
44
+
45
+ return raise RestErrorResponse.new(412, "Unsolvable versions!")
46
+ end
39
47
  end
40
48
 
41
49
  result = {}
@@ -47,7 +55,12 @@ module ChefZero
47
55
  end
48
56
 
49
57
  def depsolve(request, unsolved, desired_versions, environment_constraints)
50
- return nil if desired_versions.values.any? { |versions| versions.empty? }
58
+ desired_versions.each do |cb, ver|
59
+ if ver.empty?
60
+ @last_constraint_failure = cb
61
+ return nil
62
+ end
63
+ end
51
64
 
52
65
  # If everything is already
53
66
  solve_for = unsolved[0]
@@ -72,6 +85,7 @@ module ChefZero
72
85
  new_unsolved = new_unsolved + [dep_name]
73
86
  # If the dep is missing, we will try other versions of the cookbook that might not have the bad dep.
74
87
  if !exists_data_dir?(request, ['cookbooks', dep_name])
88
+ @last_missing_dep = dep_name.to_s
75
89
  dep_not_found = true
76
90
  break
77
91
  end
@@ -17,9 +17,9 @@
17
17
  #
18
18
 
19
19
  require 'openssl'
20
- require 'puma'
21
20
  require 'rubygems'
22
21
  require 'timeout'
22
+ require 'stringio'
23
23
 
24
24
  require 'chef_zero'
25
25
  require 'chef_zero/cookbook_data'
@@ -67,40 +67,79 @@ module ChefZero
67
67
 
68
68
  def initialize(options = {})
69
69
  options = DEFAULT_OPTIONS.merge(options)
70
+ @options = options
70
71
  @url = "http://#{options[:host]}:#{options[:port]}"
71
72
  @generate_real_keys = options[:generate_real_keys]
72
73
 
73
74
  ChefZero::Log.level = options[:log_level].to_sym
74
75
 
75
- @server = Puma::Server.new(make_app, Puma::Events.new(STDERR, STDOUT))
76
- if options[:socket]
77
- @server.add_unix_listener(options[:socket])
78
- else
79
- @server.add_tcp_listener(options[:host], options[:port])
76
+ begin
77
+ require 'puma'
78
+ @server = Puma::Server.new(make_app, Puma::Events.new(STDERR, STDOUT))
79
+ if options[:socket]
80
+ @server.add_unix_listener(options[:socket])
81
+ else
82
+ @server.add_tcp_listener(options[:host], options[:port])
83
+ end
84
+ @server_type = :puma
85
+ rescue LoadError
86
+ require 'rack'
87
+ @server_type = :webrick
80
88
  end
81
89
 
82
-
83
90
  @data_store = options[:data_store] || DataStore::MemoryStore.new
84
91
  end
85
92
 
93
+ attr_reader :options
86
94
  attr_reader :server
87
95
  attr_reader :data_store
88
96
  attr_reader :url
89
97
 
90
98
  include ChefZero::Endpoints
91
99
 
92
- def start(options = {})
93
- if options[:publish]
100
+ def start(start_options = {})
101
+ if start_options[:publish]
94
102
  puts ">> Starting Chef Zero (v#{ChefZero::VERSION})..."
95
- puts ">> Puma (v#{Puma::Const::PUMA_VERSION}) is listening at #{url}"
103
+ case @server_type
104
+ when :puma
105
+ puts ">> Puma (v#{Puma::Const::PUMA_VERSION}) is listening at #{url}"
106
+ when :webrick
107
+ puts ">> WEBrick (v#{WEBrick::VERSION}) on Rack (v#{Rack.release}) is listening at #{url}"
108
+ end
96
109
  puts ">> Press CTRL+C to stop"
97
110
  end
98
111
 
99
112
  begin
100
- thread = server.run.join
113
+ case @server_type
114
+ when :puma
115
+ server.run.join
116
+ when :webrick
117
+ Rack::Handler::WEBrick.run(
118
+ make_app,
119
+ :BindAddress => @options[:host],
120
+ :Port => @options[:port],
121
+ :AccessLog => [],
122
+ :Logger => WEBrick::Log::new(StringIO.new, 7)
123
+ ) do |server|
124
+ @server = server
125
+ end
126
+ end
101
127
  rescue Object, Interrupt
102
- puts "\n>> Stopping Puma..."
103
- server.stop(true) if running?
128
+ if running?
129
+ puts "\n>> Stopping Chef Zero ..."
130
+ case @server_type
131
+ when :puma
132
+ server.stop(true)
133
+ when :webrick
134
+ server.shutdown
135
+ end
136
+ end
137
+ ensure
138
+ case @server_type
139
+ when :webrick
140
+ @server = nil
141
+ else
142
+ end
104
143
  end
105
144
  end
106
145
 
@@ -125,17 +164,32 @@ module ChefZero
125
164
  end
126
165
 
127
166
  def running?
128
- !!server.running
167
+ case @server_type
168
+ when :puma
169
+ !!server.running
170
+ when :webrick
171
+ !!(server && server.status == :Running)
172
+ end
129
173
  end
130
174
 
131
175
  def stop(wait = 5)
132
- server.stop(true)
176
+ case @server_type
177
+ when :puma
178
+ server.stop(true)
179
+ when :webrick
180
+ server.shutdown
181
+ @server
182
+ end
133
183
  if @thread
134
- @thread.join(wait)
184
+ begin
185
+ @thread.join(wait) if @thread
186
+ rescue
187
+ if @thread
188
+ ChefZero::Log.error "Server did not stop within #{wait} seconds. Killing..."
189
+ @thread.kill
190
+ end
191
+ end
135
192
  end
136
- rescue
137
- ChefZero::Log.error "Server did not stop within #{wait} seconds. Killing..."
138
- @thread.kill if @thread
139
193
  ensure
140
194
  @thread = nil
141
195
  end
@@ -1,3 +1,3 @@
1
1
  module ChefZero
2
- VERSION = '1.6.3'
2
+ VERSION = '1.7.beta.1'
3
3
  end
data/spec/run.rb CHANGED
@@ -17,7 +17,8 @@ unless ENV['SKIP_PEDANT']
17
17
  Pedant.setup([
18
18
  '--skip-validation',
19
19
  '--skip-authentication',
20
- '--skip-authorization'
20
+ '--skip-authorization',
21
+ '--skip-omnibus'
21
22
  ])
22
23
 
23
24
  result = RSpec::Core::Runner.run(Pedant.config.rspec_args)
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-zero
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.3
4
+ version: 1.7.beta.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Keiser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-10 00:00:00.000000000 Z
11
+ date: 2013-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: puma
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ~>
18
- - !ruby/object:Gem::Version
19
- version: '1.6'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ~>
25
- - !ruby/object:Gem::Version
26
- version: '1.6'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: mixlib-log
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -80,6 +66,20 @@ dependencies:
80
66
  - - '>='
81
67
  - !ruby/object:Gem::Version
82
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rack
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rake
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -119,8 +119,6 @@ files:
119
119
  - LICENSE
120
120
  - README.md
121
121
  - Rakefile
122
- - bin/chef-zero
123
- - lib/chef_zero.rb
124
122
  - lib/chef_zero/cookbook_data.rb
125
123
  - lib/chef_zero/data_normalizer.rb
126
124
  - lib/chef_zero/data_store/data_already_exists_error.rb
@@ -173,10 +171,12 @@ files:
173
171
  - lib/chef_zero/solr/solr_doc.rb
174
172
  - lib/chef_zero/solr/solr_parser.rb
175
173
  - lib/chef_zero/version.rb
174
+ - lib/chef_zero.rb
176
175
  - spec/run.rb
177
176
  - spec/search_spec.rb
178
177
  - spec/support/pedant.rb
179
178
  - spec/support/stickywicket.pem
179
+ - bin/chef-zero
180
180
  homepage: http://www.opscode.com
181
181
  licenses:
182
182
  - Apache 2.0
@@ -192,12 +192,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
192
192
  version: '0'
193
193
  required_rubygems_version: !ruby/object:Gem::Requirement
194
194
  requirements:
195
- - - '>='
195
+ - - '>'
196
196
  - !ruby/object:Gem::Version
197
- version: '0'
197
+ version: 1.3.1
198
198
  requirements: []
199
199
  rubyforge_project:
200
- rubygems_version: 2.2.1
200
+ rubygems_version: 2.0.3
201
201
  signing_key:
202
202
  specification_version: 4
203
203
  summary: Self-contained, easy-setup, fast-start in-memory Chef server for testing