chef-zero 2.2 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/lib/chef_zero/cookbook_data.rb +1 -1
  3. data/lib/chef_zero/endpoints/actor_endpoint.rb +6 -6
  4. data/lib/chef_zero/endpoints/actors_endpoint.rb +4 -4
  5. data/lib/chef_zero/endpoints/authenticate_user_endpoint.rb +3 -3
  6. data/lib/chef_zero/endpoints/cookbook_endpoint.rb +1 -1
  7. data/lib/chef_zero/endpoints/cookbook_version_endpoint.rb +7 -7
  8. data/lib/chef_zero/endpoints/cookbooks_base.rb +1 -1
  9. data/lib/chef_zero/endpoints/data_bag_endpoint.rb +3 -3
  10. data/lib/chef_zero/endpoints/data_bag_item_endpoint.rb +3 -3
  11. data/lib/chef_zero/endpoints/data_bags_endpoint.rb +2 -2
  12. data/lib/chef_zero/endpoints/environment_cookbook_endpoint.rb +2 -2
  13. data/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb +5 -5
  14. data/lib/chef_zero/endpoints/environment_cookbooks_endpoint.rb +2 -2
  15. data/lib/chef_zero/endpoints/environment_endpoint.rb +3 -3
  16. data/lib/chef_zero/endpoints/environment_nodes_endpoint.rb +2 -2
  17. data/lib/chef_zero/endpoints/environment_recipes_endpoint.rb +3 -3
  18. data/lib/chef_zero/endpoints/environment_role_endpoint.rb +2 -2
  19. data/lib/chef_zero/endpoints/node_endpoint.rb +3 -3
  20. data/lib/chef_zero/endpoints/not_found_endpoint.rb +2 -2
  21. data/lib/chef_zero/endpoints/principal_endpoint.rb +2 -2
  22. data/lib/chef_zero/endpoints/rest_list_endpoint.rb +2 -2
  23. data/lib/chef_zero/endpoints/rest_object_endpoint.rb +5 -5
  24. data/lib/chef_zero/endpoints/role_endpoint.rb +3 -3
  25. data/lib/chef_zero/endpoints/role_environments_endpoint.rb +2 -2
  26. data/lib/chef_zero/endpoints/sandbox_endpoint.rb +2 -2
  27. data/lib/chef_zero/endpoints/sandboxes_endpoint.rb +4 -4
  28. data/lib/chef_zero/endpoints/search_endpoint.rb +3 -3
  29. data/lib/chef_zero/rest_base.rb +1 -1
  30. data/lib/chef_zero/server.rb +2 -2
  31. data/lib/chef_zero/version.rb +1 -1
  32. metadata +10 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1e812fceafd51d3dbba1d43446f13c67c12dfbee
4
- data.tar.gz: e6ec4a6756763c7fc69d10e4e76c309e91ad469e
3
+ metadata.gz: 34e265dc59ee4777d6ba4efdebaaf76a64c578f4
4
+ data.tar.gz: 35725b7a8b56e88b423602d8f437b610f0e9ea7c
5
5
  SHA512:
6
- metadata.gz: bdb9632a016a53427b3d1a977d7fa8ddb6a50f1e02c73001bfbdc192ef0b368798dda5beca6cb18e81394e63fc8132c5db125e08f5b4bb45155fca5dbf839f10
7
- data.tar.gz: 3b01505e14cefdee548abf5324d742742159a3d66ceaa604d2463095eed7b96c8f1eb5ae9c8ad93a90eea082e91b19d5008074b053926062a2ad42f48ad07874
6
+ metadata.gz: 052d0eefadf4f57e5cdc6de67f66707f8417af32bda63dee6287616ff0e940e67b491eb8b50b2903a3bbaf98b2a85cc4f2df303218f80d5d1e03a083ab287514
7
+ data.tar.gz: 1654216d04708f136e8d84b2ead621cd1eb061f039b8d9499eac3b4c29bcf10e834790ed6c7622c37528a66f5187994b08099e1416ea591bd2f00ededc271fa6
@@ -74,7 +74,7 @@ module ChefZero
74
74
  end
75
75
 
76
76
  def from_json(json)
77
- self.merge!(JSON.parse(json))
77
+ self.merge!(FFI_Yajl::Parser.parse(json))
78
78
  end
79
79
 
80
80
  private
@@ -1,4 +1,4 @@
1
- require 'json'
1
+ require 'ffi_yajl'
2
2
  require 'chef_zero/endpoints/rest_object_endpoint'
3
3
  require 'chef_zero/data_normalizer'
4
4
 
@@ -8,7 +8,7 @@ module ChefZero
8
8
  class ActorEndpoint < RestObjectEndpoint
9
9
  def put(request)
10
10
  # Find out if we're updating the public key.
11
- request_body = JSON.parse(request.body, :create_additions => false)
11
+ request_body = FFI_Yajl::Parser.parse(request.body, :create_additions => false)
12
12
  if request_body['public_key'].nil?
13
13
  # If public_key is null, then don't overwrite it. Weird patchiness.
14
14
  body_modified = true
@@ -29,7 +29,7 @@ module ChefZero
29
29
  end
30
30
 
31
31
  # Save request
32
- request.body = JSON.pretty_generate(request_body) if body_modified
32
+ request.body = FFI_Yajl::Encoder.encode(request_body, :pretty => true) if body_modified
33
33
 
34
34
  # PUT /clients is patchy
35
35
  request.body = patch_request_body(request)
@@ -38,7 +38,7 @@ module ChefZero
38
38
 
39
39
  # Inject private_key into response, delete public_key/password if applicable
40
40
  if result[0] == 200 || result[0] == 201
41
- response = JSON.parse(result[2], :create_additions => false)
41
+ response = FFI_Yajl::Parser.parse(result[2], :create_additions => false)
42
42
  response['private_key'] = private_key if private_key
43
43
  response.delete('public_key') if !updating_public_key && request.rest_path[2] == 'users'
44
44
  response.delete('password')
@@ -49,13 +49,13 @@ module ChefZero
49
49
  end
50
50
 
51
51
  def populate_defaults(request, response_json)
52
- response = JSON.parse(response_json, :create_additions => false)
52
+ response = FFI_Yajl::Parser.parse(response_json, :create_additions => false)
53
53
  if request.rest_path[2] == 'clients'
54
54
  response = DataNormalizer.normalize_client(response, request.rest_path[3])
55
55
  else
56
56
  response = DataNormalizer.normalize_user(response, request.rest_path[3])
57
57
  end
58
- JSON.pretty_generate(response)
58
+ FFI_Yajl::Encoder.encode(response, :pretty => true)
59
59
  end
60
60
  end
61
61
  end
@@ -1,4 +1,4 @@
1
- require 'json'
1
+ require 'ffi_yajl'
2
2
  require 'chef_zero/endpoints/rest_list_endpoint'
3
3
 
4
4
  module ChefZero
@@ -8,18 +8,18 @@ module ChefZero
8
8
  def post(request)
9
9
  # First, find out if the user actually posted a public key. If not, make
10
10
  # one.
11
- request_body = JSON.parse(request.body, :create_additions => false)
11
+ request_body = FFI_Yajl::Parser.parse(request.body, :create_additions => false)
12
12
  public_key = request_body['public_key']
13
13
  if !public_key
14
14
  private_key, public_key = server.gen_key_pair
15
15
  request_body['public_key'] = public_key
16
- request.body = JSON.pretty_generate(request_body)
16
+ request.body = FFI_Yajl::Encoder.encode(request_body, :pretty => true)
17
17
  end
18
18
 
19
19
  result = super(request)
20
20
  if result[0] == 201
21
21
  # If we generated a key, stuff it in the response.
22
- response = JSON.parse(result[2], :create_additions => false)
22
+ response = FFI_Yajl::Parser.parse(result[2], :create_additions => false)
23
23
  response['private_key'] = private_key if private_key
24
24
  response['public_key'] = public_key
25
25
  json_response(201, response)
@@ -1,4 +1,4 @@
1
- require 'json'
1
+ require 'ffi_yajl'
2
2
  require 'chef_zero/rest_base'
3
3
 
4
4
  module ChefZero
@@ -6,12 +6,12 @@ module ChefZero
6
6
  # /authenticate_user
7
7
  class AuthenticateUserEndpoint < RestBase
8
8
  def post(request)
9
- request_json = JSON.parse(request.body, :create_additions => false)
9
+ request_json = FFI_Yajl::Parser.parse(request.body, :create_additions => false)
10
10
  name = request_json['name']
11
11
  password = request_json['password']
12
12
  begin
13
13
  user = data_store.get(request.rest_path[0..1] + ['users', name])
14
- verified = JSON.parse(user, :create_additions => false)['password'] == password
14
+ verified = FFI_Yajl::Parser.parse(user, :create_additions => false)['password'] == password
15
15
  rescue DataStore::DataNotFoundError
16
16
  verified = false
17
17
  end
@@ -19,7 +19,7 @@ module ChefZero
19
19
  result = []
20
20
  filter_cookbooks(all_cookbooks_list(request), {}, 1) do |name, versions|
21
21
  if versions.size > 0
22
- cookbook = JSON.parse(get_data(request, request.rest_path[0..1] + ['cookbooks', name, versions[0]]), :create_additions => false)
22
+ cookbook = FFI_Yajl::Parser.parse(get_data(request, request.rest_path[0..1] + ['cookbooks', name, versions[0]]), :create_additions => false)
23
23
  result += recipe_names(name, cookbook)
24
24
  end
25
25
  end
@@ -1,4 +1,4 @@
1
- require 'json'
1
+ require 'ffi_yajl'
2
2
  require 'chef_zero/endpoints/rest_object_endpoint'
3
3
  require 'chef_zero/rest_error_response'
4
4
  require 'chef_zero/data_normalizer'
@@ -22,16 +22,16 @@ module ChefZero
22
22
 
23
23
  # Honor frozen
24
24
  if existing_cookbook
25
- existing_cookbook_json = JSON.parse(existing_cookbook, :create_additions => false)
25
+ existing_cookbook_json = FFI_Yajl::Parser.parse(existing_cookbook, :create_additions => false)
26
26
  if existing_cookbook_json['frozen?']
27
27
  if request.query_params['force'] != "true"
28
28
  raise RestErrorResponse.new(409, "The cookbook #{name} at version #{version} is frozen. Use the 'force' option to override.")
29
29
  end
30
30
  # For some reason, you are forever unable to modify "frozen?" on a frozen cookbook.
31
- request_body = JSON.parse(request.body, :create_additions => false)
31
+ request_body = FFI_Yajl::Parser.parse(request.body, :create_additions => false)
32
32
  if !request_body['frozen?']
33
33
  request_body['frozen?'] = true
34
- request.body = JSON.pretty_generate(request_body)
34
+ request.body = FFI_Yajl::Encoder.encode(request_body, :pretty => true)
35
35
  end
36
36
  end
37
37
  end
@@ -70,7 +70,7 @@ module ChefZero
70
70
 
71
71
  def get_checksums(cookbook)
72
72
  result = []
73
- JSON.parse(cookbook, :create_additions => false).each_pair do |key, value|
73
+ FFI_Yajl::Parser.parse(cookbook, :create_additions => false).each_pair do |key, value|
74
74
  if value.is_a?(Array)
75
75
  value.each do |file|
76
76
  if file.is_a?(Hash) && file.has_key?('checksum')
@@ -104,9 +104,9 @@ module ChefZero
104
104
 
105
105
  def populate_defaults(request, response_json)
106
106
  # Inject URIs into each cookbook file
107
- cookbook = JSON.parse(response_json, :create_additions => false)
107
+ cookbook = FFI_Yajl::Parser.parse(response_json, :create_additions => false)
108
108
  cookbook = DataNormalizer.normalize_cookbook(self, request.rest_path[0..1], cookbook, request.rest_path[3], request.rest_path[4], request.base_uri, request.method)
109
- JSON.pretty_generate(cookbook)
109
+ FFI_Yajl::Encoder.encode(cookbook, :pretty => true)
110
110
  end
111
111
 
112
112
  def latest_version(versions)
@@ -1,4 +1,4 @@
1
- require 'json'
1
+ require 'ffi_yajl'
2
2
  require 'chef_zero/rest_base'
3
3
  require 'chef_zero/data_normalizer'
4
4
 
@@ -1,4 +1,4 @@
1
- require 'json'
1
+ require 'ffi_yajl'
2
2
  require 'chef_zero/endpoints/rest_list_endpoint'
3
3
  require 'chef_zero/endpoints/data_bag_item_endpoint'
4
4
  require 'chef_zero/rest_error_response'
@@ -12,7 +12,7 @@ module ChefZero
12
12
  end
13
13
 
14
14
  def post(request)
15
- key = JSON.parse(request.body, :create_additions => false)[identity_key]
15
+ key = FFI_Yajl::Parser.parse(request.body, :create_additions => false)[identity_key]
16
16
  response = super(request)
17
17
  if response[0] == 201
18
18
  already_json_response(201, DataBagItemEndpoint::populate_defaults(request, request.body, request.rest_path[3], key))
@@ -22,7 +22,7 @@ module ChefZero
22
22
  end
23
23
 
24
24
  def get_key(contents)
25
- data_bag_item = JSON.parse(contents, :create_additions => false)
25
+ data_bag_item = FFI_Yajl::Parser.parse(contents, :create_additions => false)
26
26
  if data_bag_item['json_class'] == 'Chef::DataBagItem' && data_bag_item['raw_data']
27
27
  data_bag_item['raw_data']['id']
28
28
  else
@@ -1,4 +1,4 @@
1
- require 'json'
1
+ require 'ffi_yajl'
2
2
  require 'chef_zero/endpoints/rest_object_endpoint'
3
3
  require 'chef_zero/endpoints/data_bag_item_endpoint'
4
4
  require 'chef_zero/data_normalizer'
@@ -16,9 +16,9 @@ module ChefZero
16
16
  end
17
17
 
18
18
  def self.populate_defaults(request, response_json, data_bag, data_bag_item)
19
- response = JSON.parse(response_json, :create_additions => false)
19
+ response = FFI_Yajl::Parser.parse(response_json, :create_additions => false)
20
20
  response = DataNormalizer.normalize_data_bag_item(response, data_bag, data_bag_item, request.method)
21
- JSON.pretty_generate(response)
21
+ FFI_Yajl::Encoder.encode(response, :pretty => true)
22
22
  end
23
23
  end
24
24
  end
@@ -1,4 +1,4 @@
1
- require 'json'
1
+ require 'ffi_yajl'
2
2
  require 'chef_zero/endpoints/rest_list_endpoint'
3
3
 
4
4
  module ChefZero
@@ -7,7 +7,7 @@ module ChefZero
7
7
  class DataBagsEndpoint < RestListEndpoint
8
8
  def post(request)
9
9
  contents = request.body
10
- name = JSON.parse(contents, :create_additions => false)[identity_key]
10
+ name = FFI_Yajl::Parser.parse(contents, :create_additions => false)[identity_key]
11
11
  if name.nil?
12
12
  error(400, "Must specify '#{identity_key}' in JSON")
13
13
  elsif exists_data_dir?(request, request.rest_path[0..1] + ['data', name])
@@ -1,4 +1,4 @@
1
- require 'json'
1
+ require 'ffi_yajl'
2
2
  require 'chef_zero/endpoints/cookbooks_base'
3
3
 
4
4
  module ChefZero
@@ -7,7 +7,7 @@ module ChefZero
7
7
  class EnvironmentCookbookEndpoint < CookbooksBase
8
8
  def get(request)
9
9
  cookbook_name = request.rest_path[5]
10
- environment = JSON.parse(get_data(request, request.rest_path[0..3]), :create_additions => false)
10
+ environment = FFI_Yajl::Parser.parse(get_data(request, request.rest_path[0..3]), :create_additions => false)
11
11
  constraints = environment['cookbook_versions'] || {}
12
12
  cookbook_versions = list_data(request, request.rest_path[0..1] + request.rest_path[4..5])
13
13
  if request.query_params['num_versions'] == 'all'
@@ -1,4 +1,4 @@
1
- require 'json'
1
+ require 'ffi_yajl'
2
2
  require 'chef_zero/rest_base'
3
3
  require 'chef_zero/rest_error_response'
4
4
 
@@ -12,7 +12,7 @@ module ChefZero
12
12
 
13
13
  # Get the list of cookbooks and versions desired by the runlist
14
14
  desired_versions = {}
15
- run_list = JSON.parse(request.body, :create_additions => false)['run_list']
15
+ run_list = FFI_Yajl::Parser.parse(request.body, :create_additions => false)['run_list']
16
16
  run_list.each do |run_list_entry|
17
17
  if run_list_entry =~ /(.+)::.+\@(.+)/ || run_list_entry =~ /(.+)\@(.+)/
18
18
  raise RestErrorResponse.new(412, "No such cookbook: #{$1}") if !cookbook_names.include?($1)
@@ -26,7 +26,7 @@ module ChefZero
26
26
  end
27
27
 
28
28
  # Filter by environment constraints
29
- environment = JSON.parse(get_data(request, request.rest_path[0..3]), :create_additions => false)
29
+ environment = FFI_Yajl::Parser.parse(get_data(request, request.rest_path[0..3]), :create_additions => false)
30
30
  environment_constraints = environment['cookbook_versions'] || {}
31
31
 
32
32
  desired_versions.each_key do |name|
@@ -48,7 +48,7 @@ module ChefZero
48
48
 
49
49
  result = {}
50
50
  solved.each_pair do |name, versions|
51
- cookbook = JSON.parse(get_data(request, request.rest_path[0..1] + ['cookbooks', name, versions[0]]), :create_additions => false)
51
+ cookbook = FFI_Yajl::Parser.parse(get_data(request, request.rest_path[0..1] + ['cookbooks', name, versions[0]]), :create_additions => false)
52
52
  result[name] = DataNormalizer.normalize_cookbook(self, request.rest_path[0..1], cookbook, name, versions[0], request.base_uri, 'MIN')
53
53
  end
54
54
  json_response(200, result)
@@ -74,7 +74,7 @@ module ChefZero
74
74
  new_unsolved = unsolved[1..-1]
75
75
 
76
76
  # Pick this cookbook, and add dependencies
77
- cookbook_obj = JSON.parse(get_data(request, request.rest_path[0..1] + ['cookbooks', solve_for, desired_version]), :create_additions => false)
77
+ cookbook_obj = FFI_Yajl::Parser.parse(get_data(request, request.rest_path[0..1] + ['cookbooks', solve_for, desired_version]), :create_additions => false)
78
78
  cookbook_metadata = cookbook_obj['metadata'] || {}
79
79
  cookbook_dependencies = cookbook_metadata['dependencies'] || {}
80
80
  dep_not_found = false
@@ -1,4 +1,4 @@
1
- require 'json'
1
+ require 'ffi_yajl'
2
2
  require 'chef_zero/endpoints/cookbooks_base'
3
3
 
4
4
  module ChefZero
@@ -6,7 +6,7 @@ module ChefZero
6
6
  # /environments/NAME/cookbooks
7
7
  class EnvironmentCookbooksEndpoint < CookbooksBase
8
8
  def get(request)
9
- environment = JSON.parse(get_data(request, request.rest_path[0..3]), :create_additions => false)
9
+ environment = FFI_Yajl::Parser.parse(get_data(request, request.rest_path[0..3]), :create_additions => false)
10
10
  constraints = environment['cookbook_versions'] || {}
11
11
  if request.query_params['num_versions'] == 'all'
12
12
  num_versions = nil
@@ -1,4 +1,4 @@
1
- require 'json'
1
+ require 'ffi_yajl'
2
2
  require 'chef_zero/endpoints/rest_object_endpoint'
3
3
  require 'chef_zero/data_normalizer'
4
4
 
@@ -24,9 +24,9 @@ module ChefZero
24
24
  end
25
25
 
26
26
  def populate_defaults(request, response_json)
27
- response = JSON.parse(response_json, :create_additions => false)
27
+ response = FFI_Yajl::Parser.parse(response_json, :create_additions => false)
28
28
  response = DataNormalizer.normalize_environment(response, request.rest_path[3])
29
- JSON.pretty_generate(response)
29
+ FFI_Yajl::Encoder.encode(response, :pretty => true)
30
30
  end
31
31
  end
32
32
  end
@@ -1,4 +1,4 @@
1
- require 'json'
1
+ require 'ffi_yajl'
2
2
  require 'chef_zero/rest_base'
3
3
 
4
4
  module ChefZero
@@ -11,7 +11,7 @@ module ChefZero
11
11
 
12
12
  result = {}
13
13
  list_data(request, request.rest_path[0..1] + ['nodes']).each do |name|
14
- node = JSON.parse(get_data(request, request.rest_path[0..1] + ['nodes', name]), :create_additions => false)
14
+ node = FFI_Yajl::Parser.parse(get_data(request, request.rest_path[0..1] + ['nodes', name]), :create_additions => false)
15
15
  if node['chef_environment'] == request.rest_path[3]
16
16
  result[name] = build_uri(request.base_uri, request.rest_path[0..1] + ['nodes', name])
17
17
  end
@@ -1,4 +1,4 @@
1
- require 'json'
1
+ require 'ffi_yajl'
2
2
  require 'chef_zero/endpoints/cookbooks_base'
3
3
 
4
4
  module ChefZero
@@ -6,12 +6,12 @@ module ChefZero
6
6
  # /environment/NAME/recipes
7
7
  class EnvironmentRecipesEndpoint < CookbooksBase
8
8
  def get(request)
9
- environment = JSON.parse(get_data(request, request.rest_path[0..3]), :create_additions => false)
9
+ environment = FFI_Yajl::Parser.parse(get_data(request, request.rest_path[0..3]), :create_additions => false)
10
10
  constraints = environment['cookbook_versions'] || {}
11
11
  result = []
12
12
  filter_cookbooks(all_cookbooks_list(request), constraints, 1) do |name, versions|
13
13
  if versions.size > 0
14
- cookbook = JSON.parse(get_data(request, request.rest_path[0..1] + ['cookbooks', name, versions[0]]), :create_additions => false)
14
+ cookbook = FFI_Yajl::Parser.parse(get_data(request, request.rest_path[0..1] + ['cookbooks', name, versions[0]]), :create_additions => false)
15
15
  result += recipe_names(name, cookbook)
16
16
  end
17
17
  end
@@ -1,4 +1,4 @@
1
- require 'json'
1
+ require 'ffi_yajl'
2
2
  require 'chef_zero/endpoints/cookbooks_base'
3
3
 
4
4
  module ChefZero
@@ -18,7 +18,7 @@ module ChefZero
18
18
  # Verify that the environment exists
19
19
  get_data(request, environment_path)
20
20
 
21
- role = JSON.parse(get_data(request, role_path), :create_additions => false)
21
+ role = FFI_Yajl::Parser.parse(get_data(request, role_path), :create_additions => false)
22
22
  environment_name = environment_path[3]
23
23
  if environment_name == '_default'
24
24
  run_list = role['run_list']
@@ -1,4 +1,4 @@
1
- require 'json'
1
+ require 'ffi_yajl'
2
2
  require 'chef_zero/endpoints/rest_object_endpoint'
3
3
  require 'chef_zero/data_normalizer'
4
4
 
@@ -7,9 +7,9 @@ module ChefZero
7
7
  # /nodes/ID
8
8
  class NodeEndpoint < RestObjectEndpoint
9
9
  def populate_defaults(request, response_json)
10
- node = JSON.parse(response_json, :create_additions => false)
10
+ node = FFI_Yajl::Parser.parse(response_json, :create_additions => false)
11
11
  node = DataNormalizer.normalize_node(node, request.rest_path[3])
12
- JSON.pretty_generate(node)
12
+ FFI_Yajl::Encoder.encode(node, :pretty => true)
13
13
  end
14
14
  end
15
15
  end
@@ -1,10 +1,10 @@
1
- require 'json'
1
+ require 'ffi_yajl'
2
2
 
3
3
  module ChefZero
4
4
  module Endpoints
5
5
  class NotFoundEndpoint
6
6
  def call(request)
7
- return [404, {"Content-Type" => "application/json"}, JSON.pretty_generate({"error" => ["Object not found: #{request.env['REQUEST_PATH']}"]})]
7
+ return [404, {"Content-Type" => "application/json"}, FFI_Yajl::Encoder.encode({"error" => ["Object not found: #{request.env['REQUEST_PATH']}"]}, :pretty => true)]
8
8
  end
9
9
  end
10
10
  end
@@ -1,4 +1,4 @@
1
- require 'json'
1
+ require 'ffi_yajl'
2
2
  require 'chef_zero'
3
3
  require 'chef_zero/rest_base'
4
4
 
@@ -19,7 +19,7 @@ module ChefZero
19
19
  json_response(200, {
20
20
  'name' => name,
21
21
  'type' => type,
22
- 'public_key' => JSON.parse(json)['public_key'] || PUBLIC_KEY
22
+ 'public_key' => FFI_Yajl::Parser.parse(json)['public_key'] || PUBLIC_KEY
23
23
  })
24
24
  else
25
25
  error(404, 'Principal not found')
@@ -1,4 +1,4 @@
1
- require 'json'
1
+ require 'ffi_yajl'
2
2
  require 'chef_zero/rest_base'
3
3
 
4
4
  module ChefZero
@@ -33,7 +33,7 @@ module ChefZero
33
33
  end
34
34
 
35
35
  def get_key(contents)
36
- JSON.parse(contents, :create_additions => false)[identity_key]
36
+ FFI_Yajl::Parser.parse(contents, :create_additions => false)[identity_key]
37
37
  end
38
38
  end
39
39
  end
@@ -1,4 +1,4 @@
1
- require 'json'
1
+ require 'ffi_yajl'
2
2
  require 'chef_zero/rest_base'
3
3
  require 'chef_zero/rest_error_response'
4
4
 
@@ -20,7 +20,7 @@ module ChefZero
20
20
  def put(request)
21
21
  # We grab the old body to trigger a 404 if it doesn't exist
22
22
  old_body = get_data(request)
23
- request_json = JSON.parse(request.body, :create_additions => false)
23
+ request_json = FFI_Yajl::Parser.parse(request.body, :create_additions => false)
24
24
  key = request_json[identity_key] || request.rest_path[-1]
25
25
  # If it's a rename, check for conflict and delete the old value
26
26
  rename = key != request.rest_path[-1]
@@ -47,11 +47,11 @@ module ChefZero
47
47
  def patch_request_body(request)
48
48
  existing_value = get_data(request, nil, :nil)
49
49
  if existing_value
50
- request_json = JSON.parse(request.body, :create_additions => false)
51
- existing_json = JSON.parse(existing_value, :create_additions => false)
50
+ request_json = FFI_Yajl::Parser.parse(request.body, :create_additions => false)
51
+ existing_json = FFI_Yajl::Parser.parse(existing_value, :create_additions => false)
52
52
  merged_json = existing_json.merge(request_json)
53
53
  if merged_json.size > request_json.size
54
- return JSON.pretty_generate(merged_json)
54
+ return FFI_Yajl::Encoder.encode(merged_json, :pretty => true)
55
55
  end
56
56
  end
57
57
  request.body
@@ -1,4 +1,4 @@
1
- require 'json'
1
+ require 'ffi_yajl'
2
2
  require 'chef_zero/endpoints/rest_object_endpoint'
3
3
  require 'chef_zero/data_normalizer'
4
4
 
@@ -7,9 +7,9 @@ module ChefZero
7
7
  # /roles/NAME
8
8
  class RoleEndpoint < RestObjectEndpoint
9
9
  def populate_defaults(request, response_json)
10
- role = JSON.parse(response_json, :create_additions => false)
10
+ role = FFI_Yajl::Parser.parse(response_json, :create_additions => false)
11
11
  role = DataNormalizer.normalize_role(role, request.rest_path[3])
12
- JSON.pretty_generate(role)
12
+ FFI_Yajl::Encoder.encode(role, :pretty => true)
13
13
  end
14
14
  end
15
15
  end
@@ -1,4 +1,4 @@
1
- require 'json'
1
+ require 'ffi_yajl'
2
2
  require 'chef_zero/rest_base'
3
3
 
4
4
  module ChefZero
@@ -6,7 +6,7 @@ module ChefZero
6
6
  # /roles/NAME/environments
7
7
  class RoleEnvironmentsEndpoint < RestBase
8
8
  def get(request)
9
- role = JSON.parse(get_data(request, request.rest_path[0..3]), :create_additions => false)
9
+ role = FFI_Yajl::Parser.parse(get_data(request, request.rest_path[0..3]), :create_additions => false)
10
10
  json_response(200, [ '_default' ] + (role['env_run_lists'].keys || []))
11
11
  end
12
12
  end
@@ -1,13 +1,13 @@
1
1
  require 'chef_zero/rest_base'
2
2
  require 'chef_zero/rest_error_response'
3
- require 'json'
3
+ require 'ffi_yajl'
4
4
 
5
5
  module ChefZero
6
6
  module Endpoints
7
7
  # /sandboxes/ID
8
8
  class SandboxEndpoint < RestBase
9
9
  def put(request)
10
- existing_sandbox = JSON.parse(get_data(request), :create_additions => false)
10
+ existing_sandbox = FFI_Yajl::Parser.parse(get_data(request), :create_additions => false)
11
11
  existing_sandbox['checksums'].each do |checksum|
12
12
  if !exists_data?(request, request.rest_path[0..1] + ['file_store', 'checksums', checksum])
13
13
  raise RestErrorResponse.new(503, "Checksum not uploaded: #{checksum}")
@@ -1,4 +1,4 @@
1
- require 'json'
1
+ require 'ffi_yajl'
2
2
  require 'chef_zero/rest_base'
3
3
 
4
4
  module ChefZero
@@ -13,7 +13,7 @@ module ChefZero
13
13
  def post(request)
14
14
  sandbox_checksums = []
15
15
 
16
- needed_checksums = JSON.parse(request.body, :create_additions => false)['checksums']
16
+ needed_checksums = FFI_Yajl::Parser.parse(request.body, :create_additions => false)['checksums']
17
17
  result_checksums = {}
18
18
  needed_checksums.keys.each do |needed_checksum|
19
19
  if list_data(request, request.rest_path[0..1] + ['file_store', 'checksums']).include?(needed_checksum)
@@ -34,10 +34,10 @@ module ChefZero
34
34
  time_str = Time.now.utc.strftime('%Y-%m-%dT%H:%M:%S%z')
35
35
  time_str = "#{time_str[0..21]}:#{time_str[22..23]}"
36
36
 
37
- create_data(request, request.rest_path, id, JSON.pretty_generate({
37
+ create_data(request, request.rest_path, id, FFI_Yajl::Encoder.encode({
38
38
  :create_time => time_str,
39
39
  :checksums => sandbox_checksums
40
- }))
40
+ }, :pretty => true))
41
41
 
42
42
  json_response(201, {
43
43
  :uri => build_uri(request.base_uri, request.rest_path + [id]),
@@ -1,4 +1,4 @@
1
- require 'json'
1
+ require 'ffi_yajl'
2
2
  require 'chef_zero/endpoints/rest_object_endpoint'
3
3
  require 'chef_zero/data_normalizer'
4
4
  require 'chef_zero/rest_error_response'
@@ -17,7 +17,7 @@ module ChefZero
17
17
 
18
18
  def post(request)
19
19
  full_results = search(request)
20
- keys = JSON.parse(request.body, :create_additions => false)
20
+ keys = FFI_Yajl::Parser.parse(request.body, :create_additions => false)
21
21
  partial_results = full_results['rows'].map do |name, uri, doc, search_value|
22
22
  data = {}
23
23
  keys.each_pair do |key, path|
@@ -110,7 +110,7 @@ module ChefZero
110
110
  result = []
111
111
  list_data(request, container).each do |name|
112
112
  value = get_data(request, container + [name])
113
- expanded = expander.call(JSON.parse(value, :create_additions => false), name)
113
+ expanded = expander.call(FFI_Yajl::Parser.parse(value, :create_additions => false), name)
114
114
  result << [ name, build_uri(request.base_uri, container + [name]), expanded, expand_for_indexing(expanded, index, name) ]
115
115
  end
116
116
  result = result.select do |name, uri, value, search_value|
@@ -112,7 +112,7 @@ module ChefZero
112
112
  end
113
113
 
114
114
  def json_response(response_code, json)
115
- already_json_response(response_code, JSON.pretty_generate(json))
115
+ already_json_response(response_code, FFI_Yajl::Encoder.encode(json, :pretty => true))
116
116
  end
117
117
 
118
118
  def already_json_response(response_code, json_text)
@@ -351,7 +351,7 @@ module ChefZero
351
351
  end
352
352
  raise "No version specified" if !cookbook_data[:version]
353
353
  data_store.create_dir(['organizations', org_name, 'cookbooks'], cookbook_data[:cookbook_name], :recursive)
354
- data_store.set(['organizations', org_name, 'cookbooks', cookbook_data[:cookbook_name], cookbook_data[:version]], JSON.pretty_generate(cookbook_data), :create)
354
+ data_store.set(['organizations', org_name, 'cookbooks', cookbook_data[:cookbook_name], cookbook_data[:version]], FFI_Yajl::Encoder.encode(cookbook_data, :pretty => true), :create)
355
355
  cookbook_data.values.each do |files|
356
356
  next unless files.is_a? Array
357
357
  files.each do |file|
@@ -467,7 +467,7 @@ module ChefZero
467
467
  def dejsonize_children(hash)
468
468
  result = {}
469
469
  hash.each_pair do |key, value|
470
- result[key] = value.is_a?(Hash) ? JSON.pretty_generate(value) : value
470
+ result[key] = value.is_a?(Hash) ? FFI_Yajl::Encoder.encode(value, :pretty => true) : value
471
471
  end
472
472
  result
473
473
  end
@@ -1,3 +1,3 @@
1
1
  module ChefZero
2
- VERSION = '2.2'
2
+ VERSION = '2.2.1'
3
3
  end
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.2'
4
+ version: 2.2.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-06-18 00:00:00.000000000 Z
11
+ date: 2014-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mixlib-log
@@ -39,19 +39,19 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '2.0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: json
42
+ name: ffi-yajl
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '1.1'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '1.1'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rack
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -105,8 +105,6 @@ files:
105
105
  - LICENSE
106
106
  - README.md
107
107
  - Rakefile
108
- - bin/chef-zero
109
- - lib/chef_zero.rb
110
108
  - lib/chef_zero/cookbook_data.rb
111
109
  - lib/chef_zero/data_normalizer.rb
112
110
  - lib/chef_zero/data_store/data_already_exists_error.rb
@@ -164,11 +162,13 @@ files:
164
162
  - lib/chef_zero/solr/solr_doc.rb
165
163
  - lib/chef_zero/solr/solr_parser.rb
166
164
  - lib/chef_zero/version.rb
165
+ - lib/chef_zero.rb
167
166
  - spec/run.rb
168
167
  - spec/search_spec.rb
169
168
  - spec/server_spec.rb
170
169
  - spec/support/pedant.rb
171
170
  - spec/support/stickywicket.pem
171
+ - bin/chef-zero
172
172
  homepage: http://www.opscode.com
173
173
  licenses:
174
174
  - Apache 2.0
@@ -189,10 +189,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
189
189
  version: '0'
190
190
  requirements: []
191
191
  rubyforge_project:
192
- rubygems_version: 2.2.2
192
+ rubygems_version: 2.1.11
193
193
  signing_key:
194
194
  specification_version: 4
195
195
  summary: Self-contained, easy-setup, fast-start in-memory Chef server for testing
196
196
  and solo setup purposes
197
197
  test_files: []
198
- has_rdoc: