chef-zero 2.1.4 → 2.1.5

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: f291a4a186e5685eb19dec4304d71bd06c7fc7da
4
- data.tar.gz: bb94f240005505442e01f81c43c21fe30ce663e6
3
+ metadata.gz: 322a85c869fafa6c722e5b54697fc5daa9aa669e
4
+ data.tar.gz: 4b436b5ea2f219f7b17988d4832a2aa9f72bf64d
5
5
  SHA512:
6
- metadata.gz: 04e07c10506e832d398d02139eae21f250cf730297629bee478c0b0b65bb2292ff3ad7bef1933ae7033a8334e7a7091cebdc92da290e5aa3741613d0e088c300
7
- data.tar.gz: b8ff8228beb4c2845020f929ff612f70165902cf6ed8d0b2557b8282a6c98ad9310b764ba7621e426d58db7b7936839f4228bfe5e4218af3d5d2442a1522e49c
6
+ metadata.gz: 89a0555f5a959b8593d27f07783ba18e297e6f7f76ae9915775abdcb82adc2e159a4bc10968797aebc25a1dc4ebadf9c3179248bf90cc732a701608c624bda83
7
+ data.tar.gz: cd000b0a319f0ac6cab623f93fd306678ea1dbd7aa5f41e3b3f44f711a738cde5616c5d178afa00449cd13a0f6498c7374535b6e19453222dd59ff225334bcee
@@ -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', 'chef' ]
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('/')}"
@@ -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', 'chef' ]
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
- request = RestRequest.new(env, rest_base_prefix)
395
- if @on_request_proc
396
- @on_request_proc.call(request)
397
- end
398
- response = nil
399
- if @request_handler
400
- response = @request_handler.call(request)
401
- end
402
- unless response
403
- response = router.call(request)
404
- end
405
- if @on_response_proc
406
- @on_response_proc.call(request, response)
407
- end
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
- # Insert Server header
410
- response[1]['Server'] = 'chef-zero'
410
+ # Insert Server header
411
+ response[1]['Server'] = 'chef-zero'
411
412
 
412
- # Puma expects the response to be an array (chunked responses). Since
413
- # we are statically generating data, we won't ever have said chunked
414
- # response, so fake it.
415
- response[-1] = Array(response[-1])
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
- response
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
 
@@ -1,3 +1,3 @@
1
1
  module ChefZero
2
- VERSION = '2.1.4'
2
+ VERSION = '2.1.5'
3
3
  end
data/spec/run.rb CHANGED
@@ -7,7 +7,7 @@ require 'rspec/core'
7
7
 
8
8
  tmpdir = nil
9
9
 
10
- def start_server(chef_repo_path)
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 = start_server(chef_repo_path)
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
 
@@ -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
- chef_server 'http://127.0.0.1:8889'
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
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-05-28 00:00:00.000000000 Z
11
+ date: 2014-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mixlib-log