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 +4 -4
- data/lib/chef_zero/cookbook_data.rb +2 -2
- data/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb +16 -2
- data/lib/chef_zero/server.rb +73 -19
- data/lib/chef_zero/version.rb +1 -1
- data/spec/run.rb +2 -1
- metadata +21 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d8f6de63322dfa150bf6c96c90123f53987b230
|
4
|
+
data.tar.gz: 716d2b989782680c7910a640badfac8f579fb208
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c6ab04cd6a08f77135691c87469a0d65a5179db0b1e28c76848a67599026ee46f4b3f3bc19fc80c227c3732848d1edb07304d1ece9508c2e64c89147aad4f16
|
7
|
+
data.tar.gz: ec2b872272e594b12f1fc71492b7674db4a95d16c36d46e5454be43db7cf3127c1a43d2de40bc180801ef609aea51b2ecf084633d0c79c05449bff3ebdfb920b
|
@@ -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
|
-
|
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
|
-
|
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
|
data/lib/chef_zero/server.rb
CHANGED
@@ -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
|
-
|
76
|
-
|
77
|
-
@server.
|
78
|
-
|
79
|
-
|
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(
|
93
|
-
if
|
100
|
+
def start(start_options = {})
|
101
|
+
if start_options[:publish]
|
94
102
|
puts ">> Starting Chef Zero (v#{ChefZero::VERSION})..."
|
95
|
-
|
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
|
-
|
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
|
-
|
103
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
data/lib/chef_zero/version.rb
CHANGED
data/spec/run.rb
CHANGED
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.
|
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:
|
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:
|
197
|
+
version: 1.3.1
|
198
198
|
requirements: []
|
199
199
|
rubyforge_project:
|
200
|
-
rubygems_version: 2.
|
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
|