chef-zero 2.1.4 → 2.1.5
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/rest_base.rb +1 -1
- data/lib/chef_zero/server.rb +29 -22
- data/lib/chef_zero/version.rb +1 -1
- data/spec/run.rb +8 -3
- data/spec/support/pedant.rb +5 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 322a85c869fafa6c722e5b54697fc5daa9aa669e
|
4
|
+
data.tar.gz: 4b436b5ea2f219f7b17988d4832a2aa9f72bf64d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89a0555f5a959b8593d27f07783ba18e297e6f7f76ae9915775abdcb82adc2e159a4bc10968797aebc25a1dc4ebadf9c3179248bf90cc732a701608c624bda83
|
7
|
+
data.tar.gz: cd000b0a319f0ac6cab623f93fd306678ea1dbd7aa5f41e3b3f44f711a738cde5616c5d178afa00449cd13a0f6498c7374535b6e19453222dd59ff225334bcee
|
data/lib/chef_zero/rest_base.rb
CHANGED
@@ -123,7 +123,7 @@ module ChefZero
|
|
123
123
|
def build_uri(base_uri, rest_path)
|
124
124
|
if server.options[:single_org]
|
125
125
|
# Strip off /organizations/chef if we are in single org mode
|
126
|
-
if rest_path[0..1] != [ 'organizations',
|
126
|
+
if rest_path[0..1] != [ 'organizations', server.options[:single_org] ]
|
127
127
|
raise "Unexpected URL #{rest_path[0..1]} passed to build_uri in single org mode"
|
128
128
|
end
|
129
129
|
"#{base_uri}/#{rest_path[2..-1].join('/')}"
|
data/lib/chef_zero/server.rb
CHANGED
@@ -386,35 +386,42 @@ module ChefZero
|
|
386
386
|
router.not_found = NotFoundEndpoint.new
|
387
387
|
|
388
388
|
if options[:single_org]
|
389
|
-
rest_base_prefix = [ 'organizations',
|
389
|
+
rest_base_prefix = [ 'organizations', options[:single_org] ]
|
390
390
|
else
|
391
391
|
rest_base_prefix = []
|
392
392
|
end
|
393
393
|
return proc do |env|
|
394
|
-
|
395
|
-
|
396
|
-
@on_request_proc
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
response
|
404
|
-
|
405
|
-
|
406
|
-
@on_response_proc
|
407
|
-
|
394
|
+
begin
|
395
|
+
request = RestRequest.new(env, rest_base_prefix)
|
396
|
+
if @on_request_proc
|
397
|
+
@on_request_proc.call(request)
|
398
|
+
end
|
399
|
+
response = nil
|
400
|
+
if @request_handler
|
401
|
+
response = @request_handler.call(request)
|
402
|
+
end
|
403
|
+
unless response
|
404
|
+
response = router.call(request)
|
405
|
+
end
|
406
|
+
if @on_response_proc
|
407
|
+
@on_response_proc.call(request, response)
|
408
|
+
end
|
408
409
|
|
409
|
-
|
410
|
-
|
410
|
+
# Insert Server header
|
411
|
+
response[1]['Server'] = 'chef-zero'
|
411
412
|
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
413
|
+
# Puma expects the response to be an array (chunked responses). Since
|
414
|
+
# we are statically generating data, we won't ever have said chunked
|
415
|
+
# response, so fake it.
|
416
|
+
response[-1] = Array(response[-1])
|
416
417
|
|
417
|
-
|
418
|
+
response
|
419
|
+
rescue
|
420
|
+
if options[:log_level] == :debug
|
421
|
+
STDERR.puts "Request Error: #{$!}"
|
422
|
+
STDERR.puts $!.backtrace.join("\n")
|
423
|
+
end
|
424
|
+
end
|
418
425
|
end
|
419
426
|
end
|
420
427
|
|
data/lib/chef_zero/version.rb
CHANGED
data/spec/run.rb
CHANGED
@@ -7,7 +7,7 @@ require 'rspec/core'
|
|
7
7
|
|
8
8
|
tmpdir = nil
|
9
9
|
|
10
|
-
def
|
10
|
+
def start_local_server(chef_repo_path)
|
11
11
|
Dir.mkdir(chef_repo_path) if !File.exists?(chef_repo_path)
|
12
12
|
|
13
13
|
# 11.6 and below had a bug where it couldn't create the repo children automatically
|
@@ -43,10 +43,15 @@ begin
|
|
43
43
|
chef_repo_path = "#{tmpdir}/repo"
|
44
44
|
|
45
45
|
# Capture setup data into master_chef_repo_path
|
46
|
-
server =
|
46
|
+
server = start_local_server(chef_repo_path)
|
47
|
+
|
48
|
+
elsif ENV['SINGLE_ORG']
|
49
|
+
server = ChefZero::Server.new(:port => 8889, :single_org => 'singleorg')
|
50
|
+
server.start_background
|
47
51
|
|
48
52
|
else
|
49
|
-
server = ChefZero::Server.new(:port => 8889)
|
53
|
+
server = ChefZero::Server.new(:port => 8889, :single_org => false)
|
54
|
+
server.data_store.create_dir([ 'organizations' ], 'pedant')
|
50
55
|
server.start_background
|
51
56
|
end
|
52
57
|
|
data/spec/support/pedant.rb
CHANGED
@@ -21,7 +21,11 @@
|
|
21
21
|
################################################################################
|
22
22
|
# You MUST specify the address of the server the API requests will be
|
23
23
|
# sent to. Only specify protocol, hostname, and port.
|
24
|
-
|
24
|
+
if ENV['SINGLE_ORG']
|
25
|
+
chef_server 'http://127.0.0.1:8889'
|
26
|
+
else
|
27
|
+
chef_server 'http://127.0.0.1:8889/organizations/pedant'
|
28
|
+
end
|
25
29
|
|
26
30
|
# If you are doing development testing, you can specify the address of
|
27
31
|
# the Solr server. The presence of this parameter will enable tests
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef-zero
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.5
|
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-
|
11
|
+
date: 2014-06-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mixlib-log
|