chef-zero 5.0.0 → 5.1.0

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.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/lib/chef_zero/chef_data/data_normalizer.rb +2 -2
  3. data/lib/chef_zero/chef_data/default_creator.rb +44 -17
  4. data/lib/chef_zero/endpoints/acl_endpoint.rb +2 -2
  5. data/lib/chef_zero/endpoints/acls_endpoint.rb +12 -1
  6. data/lib/chef_zero/endpoints/actor_endpoint.rb +1 -1
  7. data/lib/chef_zero/endpoints/authenticate_user_endpoint.rb +2 -2
  8. data/lib/chef_zero/endpoints/container_endpoint.rb +1 -1
  9. data/lib/chef_zero/endpoints/cookbook_endpoint.rb +1 -1
  10. data/lib/chef_zero/endpoints/cookbook_version_endpoint.rb +4 -4
  11. data/lib/chef_zero/endpoints/data_bag_endpoint.rb +2 -2
  12. data/lib/chef_zero/endpoints/data_bag_item_endpoint.rb +1 -1
  13. data/lib/chef_zero/endpoints/data_bags_endpoint.rb +1 -1
  14. data/lib/chef_zero/endpoints/environment_cookbook_endpoint.rb +1 -1
  15. data/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb +4 -4
  16. data/lib/chef_zero/endpoints/environment_cookbooks_endpoint.rb +1 -1
  17. data/lib/chef_zero/endpoints/environment_endpoint.rb +1 -1
  18. data/lib/chef_zero/endpoints/environment_nodes_endpoint.rb +1 -1
  19. data/lib/chef_zero/endpoints/environment_recipes_endpoint.rb +2 -2
  20. data/lib/chef_zero/endpoints/environment_role_endpoint.rb +1 -1
  21. data/lib/chef_zero/endpoints/group_endpoint.rb +1 -1
  22. data/lib/chef_zero/endpoints/node_endpoint.rb +1 -1
  23. data/lib/chef_zero/endpoints/nodes_endpoint.rb +1 -1
  24. data/lib/chef_zero/endpoints/organization_association_request_endpoint.rb +1 -1
  25. data/lib/chef_zero/endpoints/organization_association_requests_endpoint.rb +1 -1
  26. data/lib/chef_zero/endpoints/organization_authenticate_user_endpoint.rb +2 -2
  27. data/lib/chef_zero/endpoints/organization_endpoint.rb +3 -3
  28. data/lib/chef_zero/endpoints/organization_user_endpoint.rb +2 -2
  29. data/lib/chef_zero/endpoints/organization_users_endpoint.rb +2 -2
  30. data/lib/chef_zero/endpoints/organization_validator_key_endpoint.rb +1 -1
  31. data/lib/chef_zero/endpoints/organizations_endpoint.rb +1 -1
  32. data/lib/chef_zero/endpoints/rest_list_endpoint.rb +1 -1
  33. data/lib/chef_zero/endpoints/rest_object_endpoint.rb +2 -2
  34. data/lib/chef_zero/endpoints/role_endpoint.rb +1 -1
  35. data/lib/chef_zero/endpoints/role_environments_endpoint.rb +1 -1
  36. data/lib/chef_zero/endpoints/sandbox_endpoint.rb +1 -1
  37. data/lib/chef_zero/endpoints/sandboxes_endpoint.rb +1 -1
  38. data/lib/chef_zero/endpoints/search_endpoint.rb +2 -2
  39. data/lib/chef_zero/endpoints/system_recovery_endpoint.rb +2 -2
  40. data/lib/chef_zero/endpoints/user_association_request_endpoint.rb +2 -2
  41. data/lib/chef_zero/endpoints/user_organizations_endpoint.rb +1 -1
  42. data/lib/chef_zero/rest_base.rb +1 -1
  43. data/lib/chef_zero/version.rb +1 -1
  44. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: af78d3b28c39a909122160ebeb4abe7086ba495d
4
- data.tar.gz: e151250b3435d68022ace2ea846f839e0bbeaddf
3
+ metadata.gz: 2b00232a363d25d0bd7a96ce90fe890da73e828c
4
+ data.tar.gz: 588b5fcd98c7df1f73df1a3c8e9b881bd992bfa1
5
5
  SHA512:
6
- metadata.gz: 65df47af4dcf486c45c84285ba99ec247c15bdb5d4fa83d1b827d12831e29fa47e88bb02da82a78b129554fcde26a621dc2b4495ef87c1af4892d5594ddb8da3
7
- data.tar.gz: 9ab659ccb4ad813a3a9cde3cdd3496ae448f97bd7129b0ef8c2a44c258078503e5980ca4b6954019344f57028a52133ef58697bcc8738abe26bc6a7b8cacff2b
6
+ metadata.gz: 9563e75f68e99b6d113778834468f4c5bd40a705fccfc6007432a0c390d9494d8669b245f12f04aae0d250d01551f27c67bc9c4c4075846076cd0835e5c8c45a
7
+ data.tar.gz: 6c669dac6b41d749bd5a99e515caf6cc95099925e890ceff4b98ade5a0b3db8e09dee999d54324789caafc9b88b6d67d509ca95753cb963ee01d065cee727d03
@@ -14,8 +14,8 @@ module ChefZero
14
14
  # is the final list of actors that a subsequent GET will
15
15
  # provide. Each list is guaranteed to be unique, but the
16
16
  # combined list is not.
17
- acls[perm]["actors"] = acls[perm].delete("users").uniq +
18
- acls[perm].delete("clients").uniq
17
+ acls[perm]["actors"] = acls[perm]["clients"].uniq +
18
+ acls[perm]["users"].uniq
19
19
  else
20
20
  # this gets doubled sometimes, for reasons.
21
21
  (acls[perm]["actors"] ||= []).uniq!
@@ -240,11 +240,11 @@ module ChefZero
240
240
 
241
241
  when "groups/admins"
242
242
  admins = data.list(path[0..1] + [ "users" ]).select do |name|
243
- user = FFI_Yajl::Parser.parse(data.get(path[0..1] + [ "users", name ]), :create_additions => false)
243
+ user = FFI_Yajl::Parser.parse(data.get(path[0..1] + [ "users", name ]))
244
244
  user["admin"]
245
245
  end
246
246
  admins += data.list(path[0..1] + [ "clients" ]).select do |name|
247
- client = FFI_Yajl::Parser.parse(data.get(path[0..1] + [ "clients", name ]), :create_additions => false)
247
+ client = FFI_Yajl::Parser.parse(data.get(path[0..1] + [ "clients", name ]))
248
248
  client["admin"]
249
249
  end
250
250
  admins += @creators[path[0..1]] if @creators[path[0..1]]
@@ -346,57 +346,83 @@ module ChefZero
346
346
  end
347
347
 
348
348
  def get_owners(acl_path)
349
- owners = []
350
-
349
+ unknown_owners = []
351
350
  path = AclPath.get_object_path(acl_path)
352
351
  if path
353
352
 
354
353
  # Non-validator clients own themselves.
355
354
  if path.size == 4 && path[0] == "organizations" && path[2] == "clients"
356
355
  begin
357
- client = FFI_Yajl::Parser.parse(data.get(path), :create_additions => false)
356
+ client = FFI_Yajl::Parser.parse(data.get(path))
358
357
  if !client["validator"]
359
- owners |= [ path[3] ]
358
+ unknown_owners |= [ path[3] ]
360
359
  end
361
360
  rescue
362
- owners |= [ path[3] ]
361
+ unknown_owners |= [ path[3] ]
363
362
  end
364
363
 
365
364
  # Add creators as owners (except any validator clients).
366
365
  if @creators[path]
367
366
  @creators[path].each do |creator|
368
367
  begin
369
- client = FFI_Yajl::Parser.parse(data.get(path[0..2] + [ creator ]), :create_additions => false)
368
+ client = FFI_Yajl::Parser.parse(data.get(path[0..2] + [ creator ]))
370
369
  next if client["validator"]
371
370
  rescue
372
371
  end
373
- owners |= [ creator ]
372
+ unknown_owners |= [ creator ]
374
373
  end
375
374
  end
376
375
  else
377
- owners |= @creators[path] if @creators[path]
376
+ unknown_owners |= @creators[path] if @creators[path]
378
377
  end
378
+ owners = filter_owners(path, unknown_owners)
379
379
 
380
380
  #ANGRY
381
381
  # Non-default containers do not get superusers added to them,
382
382
  # because reasons.
383
383
  unless path.size == 4 && path[0] == "organizations" && path[2] == "containers" && !exists?(path)
384
- owners += superusers
384
+ owners[:users] += superusers
385
385
  end
386
+ else
387
+ owners = { clients: [], users: [] }
386
388
  end
387
389
 
388
- # we don't de-dup this list, because pedant expects to see ["pivotal", "pivotal"] in some cases.
390
+ owners[:users].uniq!
391
+ owners[:clients].uniq!
392
+ owners
393
+ end
394
+
395
+ # Figures out if an object was created by a user or client.
396
+ # If the object does not exist in the context
397
+ # of an organization, it can only be a user
398
+ #
399
+ # This isn't perfect, because we are never explicitly told
400
+ # if a requestor creating an object is a user or client -
401
+ # but it gets us reasonably close
402
+ def filter_owners(path, unknown_owners)
403
+ owners = { clients: [], users: [] }
404
+ unknown_owners.each do |entity|
405
+ if path[0] == "organizations" && path.length > 2
406
+ begin
407
+ data.get(["organizations", path[1], "clients", entity])
408
+ owners[:clients] |= [ entity ]
409
+ rescue
410
+ owners[:users] |= [ entity ]
411
+ end
412
+ else
413
+ owners[:users] |= [ entity ]
414
+ end
415
+ end
389
416
  owners
390
417
  end
391
418
 
392
419
  def default_acl(acl_path, acl = {})
393
- owners = nil
420
+ owners = get_owners(acl_path)
394
421
  container_acl = nil
395
422
  PERMISSIONS.each do |perm|
396
423
  acl[perm] ||= {}
397
- acl[perm]["actors"] ||= begin
398
- owners ||= get_owners(acl_path)
399
- end
424
+ acl[perm]["users"] = owners[:users]
425
+ acl[perm]["clients"] = owners[:clients]
400
426
  acl[perm]["groups"] ||= begin
401
427
  # When we create containers, we don't merge groups (not sure why).
402
428
  if acl_path[0] == "organizations" && acl_path[3] == "containers"
@@ -406,6 +432,7 @@ module ChefZero
406
432
  (container_acl[perm] ? container_acl[perm]["groups"] : []) || []
407
433
  end
408
434
  end
435
+ acl[perm]["actors"] = acl[perm]["clients"] + acl[perm]["users"]
409
436
  end
410
437
  acl
411
438
  end
@@ -413,7 +440,7 @@ module ChefZero
413
440
  def get_container_acl(acl_path)
414
441
  parent_path = AclPath.parent_acl_data_path(acl_path)
415
442
  if parent_path
416
- FFI_Yajl::Parser.parse(data.get(parent_path), :create_additions => false)
443
+ FFI_Yajl::Parser.parse(data.get(parent_path))
417
444
  else
418
445
  nil
419
446
  end
@@ -28,8 +28,8 @@ module ChefZero
28
28
 
29
29
  def put(request)
30
30
  path, perm = validate_request(request)
31
- acls = FFI_Yajl::Parser.parse(get_data(request, path), :create_additions => false)
32
- acls[perm] = FFI_Yajl::Parser.parse(request.body, :create_additions => false)[perm]
31
+ acls = FFI_Yajl::Parser.parse(get_data(request, path))
32
+ acls[perm] = FFI_Yajl::Parser.parse(request.body)[perm]
33
33
  set_data(request, path, FFI_Yajl::Encoder.encode(acls, :pretty => true))
34
34
  json_response(200, { "uri" => "#{build_uri(request.base_uri, request.rest_path)}" })
35
35
  end
@@ -20,8 +20,19 @@ module ChefZero
20
20
  if !acl_path
21
21
  raise RestErrorResponse.new(404, "Object not found: #{build_uri(request.base_uri, request.rest_path)}")
22
22
  end
23
- acls = FFI_Yajl::Parser.parse(get_data(request, acl_path), :create_additions => false)
23
+ acls = FFI_Yajl::Parser.parse(get_data(request, acl_path))
24
24
  acls = ChefData::DataNormalizer.normalize_acls(acls)
25
+ if request.query_params["detail"] == "granular"
26
+ acls.each do |perm, ace|
27
+ acls[perm]["actors"] = []
28
+ end
29
+ else
30
+ acls.each do |perm, ace|
31
+ acls[perm].delete("clients")
32
+ acls[perm].delete("users")
33
+ end
34
+ end
35
+
25
36
  json_response(200, acls)
26
37
  end
27
38
  end
@@ -36,7 +36,7 @@ module ChefZero
36
36
 
37
37
  def put(request)
38
38
  # Find out if we're updating the public key.
39
- request_body = FFI_Yajl::Parser.parse(request.body, :create_additions => false)
39
+ request_body = FFI_Yajl::Parser.parse(request.body)
40
40
 
41
41
  if request_body["public_key"].nil?
42
42
  # If public_key is null, then don't overwrite it. Weird patchiness.
@@ -6,7 +6,7 @@ module ChefZero
6
6
  # /authenticate_user
7
7
  class AuthenticateUserEndpoint < RestBase
8
8
  def post(request)
9
- request_json = FFI_Yajl::Parser.parse(request.body, :create_additions => false)
9
+ request_json = FFI_Yajl::Parser.parse(request.body)
10
10
  name = request_json["username"]
11
11
  password = request_json["password"]
12
12
  begin
@@ -14,7 +14,7 @@ module ChefZero
14
14
  rescue ChefZero::DataStore::DataNotFoundError
15
15
  raise RestErrorResponse.new(401, "Bad username or password")
16
16
  end
17
- user = FFI_Yajl::Parser.parse(user, :create_additions => false)
17
+ user = FFI_Yajl::Parser.parse(user)
18
18
  user = ChefData::DataNormalizer.normalize_user(user, name, [ "username" ], server.options[:osc_compat])
19
19
  if user["password"] != password
20
20
  raise RestErrorResponse.new(401, "Bad username or password")
@@ -13,7 +13,7 @@ module ChefZero
13
13
  undef_method(:put)
14
14
 
15
15
  def populate_defaults(request, response_json)
16
- container = FFI_Yajl::Parser.parse(response_json, :create_additions => false)
16
+ container = FFI_Yajl::Parser.parse(response_json)
17
17
  container = ChefData::DataNormalizer.normalize_container(container, request.rest_path[3])
18
18
  FFI_Yajl::Encoder.encode(container, :pretty => true)
19
19
  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 = FFI_Yajl::Parser.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]]))
23
23
  result += recipe_names(name, cookbook)
24
24
  end
25
25
  end
@@ -22,13 +22,13 @@ module ChefZero
22
22
 
23
23
  # Honor frozen
24
24
  if existing_cookbook
25
- existing_cookbook_json = FFI_Yajl::Parser.parse(existing_cookbook, :create_additions => false)
25
+ existing_cookbook_json = FFI_Yajl::Parser.parse(existing_cookbook)
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 = FFI_Yajl::Parser.parse(request.body, :create_additions => false)
31
+ request_body = FFI_Yajl::Parser.parse(request.body)
32
32
  if !request_body["frozen?"]
33
33
  request_body["frozen?"] = true
34
34
  request.body = FFI_Yajl::Encoder.encode(request_body, :pretty => true)
@@ -71,7 +71,7 @@ module ChefZero
71
71
 
72
72
  def get_checksums(cookbook)
73
73
  result = []
74
- FFI_Yajl::Parser.parse(cookbook, :create_additions => false).each_pair do |key, value|
74
+ FFI_Yajl::Parser.parse(cookbook).each_pair do |key, value|
75
75
  if value.is_a?(Array)
76
76
  value.each do |file|
77
77
  if file.is_a?(Hash) && file.has_key?("checksum")
@@ -118,7 +118,7 @@ module ChefZero
118
118
 
119
119
  def populate_defaults(request, response_json)
120
120
  # Inject URIs into each cookbook file
121
- cookbook = FFI_Yajl::Parser.parse(response_json, :create_additions => false)
121
+ cookbook = FFI_Yajl::Parser.parse(response_json)
122
122
  cookbook = ChefData::DataNormalizer.normalize_cookbook(self, request.rest_path[0..1], cookbook, request.rest_path[3], request.rest_path[4], request.base_uri, request.method)
123
123
  FFI_Yajl::Encoder.encode(cookbook, :pretty => true)
124
124
  end
@@ -12,7 +12,7 @@ module ChefZero
12
12
  end
13
13
 
14
14
  def post(request)
15
- json = FFI_Yajl::Parser.parse(request.body, :create_additions => false)
15
+ json = FFI_Yajl::Parser.parse(request.body)
16
16
  key = identity_keys.map { |k| json[k] }.select { |v| v }.first
17
17
  response = super(request)
18
18
  if response[0] == 201
@@ -23,7 +23,7 @@ module ChefZero
23
23
  end
24
24
 
25
25
  def get_key(contents)
26
- data_bag_item = FFI_Yajl::Parser.parse(contents, :create_additions => false)
26
+ data_bag_item = FFI_Yajl::Parser.parse(contents)
27
27
  if data_bag_item["json_class"] == "Chef::DataBagItem" && data_bag_item["raw_data"]
28
28
  data_bag_item["raw_data"]["id"]
29
29
  else
@@ -16,7 +16,7 @@ module ChefZero
16
16
  end
17
17
 
18
18
  def self.populate_defaults(request, response_json, data_bag, data_bag_item)
19
- response = FFI_Yajl::Parser.parse(response_json, :create_additions => false)
19
+ response = FFI_Yajl::Parser.parse(response_json)
20
20
  response = ChefData::DataNormalizer.normalize_data_bag_item(response, data_bag, data_bag_item, request.method)
21
21
  FFI_Yajl::Encoder.encode(response, :pretty => true)
22
22
  end
@@ -7,7 +7,7 @@ module ChefZero
7
7
  class DataBagsEndpoint < RestListEndpoint
8
8
  def post(request)
9
9
  contents = request.body
10
- json = FFI_Yajl::Parser.parse(contents, :create_additions => false)
10
+ json = FFI_Yajl::Parser.parse(contents)
11
11
  name = identity_keys.map { |k| json[k] }.select { |v| v }.first
12
12
  if name.nil?
13
13
  error(400, "Must specify #{identity_keys.map { |k| k.inspect }.join(' or ')} in JSON")
@@ -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 = FFI_Yajl::Parser.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]))
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"
@@ -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 = FFI_Yajl::Parser.parse(request.body, :create_additions => false)["run_list"]
15
+ run_list = FFI_Yajl::Parser.parse(request.body)["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 = FFI_Yajl::Parser.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]))
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 = FFI_Yajl::Parser.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]]))
52
52
  result[name] = ChefData::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 = FFI_Yajl::Parser.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]))
78
78
  cookbook_metadata = cookbook_obj["metadata"] || {}
79
79
  cookbook_dependencies = cookbook_metadata["dependencies"] || {}
80
80
  dep_not_found = false
@@ -6,7 +6,7 @@ module ChefZero
6
6
  # /environments/NAME/cookbooks
7
7
  class EnvironmentCookbooksEndpoint < CookbooksBase
8
8
  def get(request)
9
- environment = FFI_Yajl::Parser.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]))
10
10
  constraints = environment["cookbook_versions"] || {}
11
11
  if request.query_params["num_versions"] == "all"
12
12
  num_versions = nil
@@ -24,7 +24,7 @@ module ChefZero
24
24
  end
25
25
 
26
26
  def populate_defaults(request, response_json)
27
- response = FFI_Yajl::Parser.parse(response_json, :create_additions => false)
27
+ response = FFI_Yajl::Parser.parse(response_json)
28
28
  response = ChefData::DataNormalizer.normalize_environment(response, request.rest_path[3])
29
29
  FFI_Yajl::Encoder.encode(response, :pretty => true)
30
30
  end
@@ -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 = FFI_Yajl::Parser.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]))
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
@@ -6,12 +6,12 @@ module ChefZero
6
6
  # /environment/NAME/recipes
7
7
  class EnvironmentRecipesEndpoint < CookbooksBase
8
8
  def get(request)
9
- environment = FFI_Yajl::Parser.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]))
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 = FFI_Yajl::Parser.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]]))
15
15
  result += recipe_names(name, cookbook)
16
16
  end
17
17
  end
@@ -18,7 +18,7 @@ module ChefZero
18
18
  # Verify that the environment exists
19
19
  get_data(request, environment_path)
20
20
 
21
- role = FFI_Yajl::Parser.parse(get_data(request, role_path), :create_additions => false)
21
+ role = FFI_Yajl::Parser.parse(get_data(request, role_path))
22
22
  environment_name = environment_path[3]
23
23
  if environment_name == "_default"
24
24
  run_list = role["run_list"]
@@ -11,7 +11,7 @@ module ChefZero
11
11
  end
12
12
 
13
13
  def populate_defaults(request, response_json)
14
- group = FFI_Yajl::Parser.parse(response_json, :create_additions => false)
14
+ group = FFI_Yajl::Parser.parse(response_json)
15
15
  group = ChefData::DataNormalizer.normalize_group(group, request.rest_path[3], request.rest_path[1])
16
16
  FFI_Yajl::Encoder.encode(group, :pretty => true)
17
17
  end
@@ -21,7 +21,7 @@ module ChefZero
21
21
  end
22
22
 
23
23
  def populate_defaults(request, response_json)
24
- node = FFI_Yajl::Parser.parse(response_json, :create_additions => false)
24
+ node = FFI_Yajl::Parser.parse(response_json)
25
25
  node = ChefData::DataNormalizer.normalize_node(node, request.rest_path[3])
26
26
  FFI_Yajl::Encoder.encode(node, :pretty => true)
27
27
  end
@@ -25,7 +25,7 @@ module ChefZero
25
25
  end
26
26
 
27
27
  def populate_defaults(request, response_json)
28
- node = FFI_Yajl::Parser.parse(response_json, :create_additions => false)
28
+ node = FFI_Yajl::Parser.parse(response_json)
29
29
  node = ChefData::DataNormalizer.normalize_node(node, request.rest_path[3])
30
30
  FFI_Yajl::Encoder.encode(node, :pretty => true)
31
31
  end
@@ -13,7 +13,7 @@ module ChefZero
13
13
  end
14
14
  username = $1
15
15
  path = request.rest_path[0..-2] + [username]
16
- data = FFI_Yajl::Parser.parse(get_data(request, path), :create_additions => false)
16
+ data = FFI_Yajl::Parser.parse(get_data(request, path))
17
17
  delete_data(request, path)
18
18
  json_response(200, { "id" => id, "username" => username })
19
19
  end
@@ -6,7 +6,7 @@ module ChefZero
6
6
  # /organizations/ORG/association_requests
7
7
  class OrganizationAssociationRequestsEndpoint < RestBase
8
8
  def post(request)
9
- json = FFI_Yajl::Parser.parse(request.body, :create_additions => false)
9
+ json = FFI_Yajl::Parser.parse(request.body)
10
10
  username = json["user"]
11
11
  orgname = request.rest_path[1]
12
12
  id = "#{username}-#{orgname}"
@@ -6,12 +6,12 @@ module ChefZero
6
6
  # /organizations/NAME/authenticate_user
7
7
  class OrganizationAuthenticateUserEndpoint < RestBase
8
8
  def post(request)
9
- request_json = FFI_Yajl::Parser.parse(request.body, :create_additions => false)
9
+ request_json = FFI_Yajl::Parser.parse(request.body)
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..-2] + ["users", name])
14
- user = FFI_Yajl::Parser.parse(user, :create_additions => false)
14
+ user = FFI_Yajl::Parser.parse(user)
15
15
  verified = user["password"] == password
16
16
  rescue DataStore::DataNotFoundError
17
17
  verified = false
@@ -11,8 +11,8 @@ module ChefZero
11
11
  end
12
12
 
13
13
  def put(request)
14
- org = FFI_Yajl::Parser.parse(get_data(request, request.rest_path + [ "org" ]), :create_additions => false)
15
- new_org = FFI_Yajl::Parser.parse(request.body, :create_additions => false)
14
+ org = FFI_Yajl::Parser.parse(get_data(request, request.rest_path + [ "org" ]))
15
+ new_org = FFI_Yajl::Parser.parse(request.body)
16
16
  new_org.each do |key, value|
17
17
  org[key] = value
18
18
  end
@@ -37,7 +37,7 @@ module ChefZero
37
37
  end
38
38
 
39
39
  def populate_defaults(request, response_json)
40
- org = FFI_Yajl::Parser.parse(response_json, :create_additions => false)
40
+ org = FFI_Yajl::Parser.parse(response_json)
41
41
  org = ChefData::DataNormalizer.normalize_organization(org, request.rest_path[1])
42
42
  FFI_Yajl::Encoder.encode(org, :pretty => true)
43
43
  end
@@ -9,14 +9,14 @@ module ChefZero
9
9
  username = request.rest_path[3]
10
10
  get_data(request) # 404 if user is not in org
11
11
  user = get_data(request, [ "users", username ])
12
- user = FFI_Yajl::Parser.parse(user, :create_additions => false)
12
+ user = FFI_Yajl::Parser.parse(user)
13
13
  json_response(200, ChefData::DataNormalizer.normalize_user(user, username, ["username"], server.options[:osc_compat], request.method))
14
14
  end
15
15
 
16
16
  def delete(request)
17
17
  user = get_data(request)
18
18
  delete_data(request)
19
- user = FFI_Yajl::Parser.parse(user, :create_additions => false)
19
+ user = FFI_Yajl::Parser.parse(user)
20
20
  json_response(200, ChefData::DataNormalizer.normalize_user(user, request.rest_path[3], ["username"], server.options[:osc_compat]))
21
21
  end
22
22
 
@@ -8,7 +8,7 @@ module ChefZero
8
8
  class OrganizationUsersEndpoint < RestBase
9
9
  def post(request)
10
10
  orgname = request.rest_path[1]
11
- json = FFI_Yajl::Parser.parse(request.body, :create_additions => false)
11
+ json = FFI_Yajl::Parser.parse(request.body)
12
12
  username = json["username"]
13
13
 
14
14
  if exists_data?(request, [ "organizations", orgname, "users", username ])
@@ -16,7 +16,7 @@ module ChefZero
16
16
  end
17
17
 
18
18
  users = get_data(request, [ "organizations", orgname, "groups", "users" ])
19
- users = FFI_Yajl::Parser.parse(users, :create_additions => false)
19
+ users = FFI_Yajl::Parser.parse(users)
20
20
 
21
21
  create_data(request, request.rest_path, username, "{}")
22
22
 
@@ -9,7 +9,7 @@ module ChefZero
9
9
  def post(request)
10
10
  org_name = request.rest_path[-2]
11
11
  validator_path = [ "organizations", org_name, "clients", "#{org_name}-validator"]
12
- validator = FFI_Yajl::Parser.parse(get_data(request, validator_path), :create_additions => false)
12
+ validator = FFI_Yajl::Parser.parse(get_data(request, validator_path))
13
13
  private_key, public_key = server.gen_key_pair
14
14
  validator["public_key"] = public_key
15
15
  set_data(request, validator_path, FFI_Yajl::Encoder.encode(validator, :pretty => true))
@@ -15,7 +15,7 @@ module ChefZero
15
15
  end
16
16
 
17
17
  def post(request)
18
- contents = FFI_Yajl::Parser.parse(request.body, :create_additions => false)
18
+ contents = FFI_Yajl::Parser.parse(request.body)
19
19
  name = contents["name"]
20
20
  full_name = contents["full_name"]
21
21
  if name.nil?
@@ -34,7 +34,7 @@ module ChefZero
34
34
  end
35
35
 
36
36
  def get_key(contents)
37
- json = FFI_Yajl::Parser.parse(contents, :create_additions => false)
37
+ json = FFI_Yajl::Parser.parse(contents)
38
38
  identity_keys.map { |k| json[k] }.select { |v| v }.first
39
39
  end
40
40
  end
@@ -48,8 +48,8 @@ module ChefZero
48
48
  def patch_request_body(request)
49
49
  existing_value = get_data(request, nil, :nil)
50
50
  if existing_value
51
- request_json = FFI_Yajl::Parser.parse(request.body, :create_additions => false)
52
- existing_json = FFI_Yajl::Parser.parse(existing_value, :create_additions => false)
51
+ request_json = FFI_Yajl::Parser.parse(request.body)
52
+ existing_json = FFI_Yajl::Parser.parse(existing_value)
53
53
  merged_json = existing_json.merge(request_json)
54
54
  if merged_json.size > request_json.size
55
55
  return FFI_Yajl::Encoder.encode(merged_json, :pretty => true)
@@ -7,7 +7,7 @@ module ChefZero
7
7
  # /roles/NAME
8
8
  class RoleEndpoint < RestObjectEndpoint
9
9
  def populate_defaults(request, response_json)
10
- role = FFI_Yajl::Parser.parse(response_json, :create_additions => false)
10
+ role = FFI_Yajl::Parser.parse(response_json)
11
11
  role = ChefData::DataNormalizer.normalize_role(role, request.rest_path[3])
12
12
  FFI_Yajl::Encoder.encode(role, :pretty => true)
13
13
  end
@@ -6,7 +6,7 @@ module ChefZero
6
6
  # /roles/NAME/environments
7
7
  class RoleEnvironmentsEndpoint < RestBase
8
8
  def get(request)
9
- role = FFI_Yajl::Parser.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]))
10
10
  json_response(200, [ "_default" ] + (role["env_run_lists"].keys || []))
11
11
  end
12
12
  end
@@ -7,7 +7,7 @@ module ChefZero
7
7
  # /sandboxes/ID
8
8
  class SandboxEndpoint < RestBase
9
9
  def put(request)
10
- existing_sandbox = FFI_Yajl::Parser.parse(get_data(request), :create_additions => false)
10
+ existing_sandbox = FFI_Yajl::Parser.parse(get_data(request))
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}")
@@ -13,7 +13,7 @@ module ChefZero
13
13
  def post(request)
14
14
  sandbox_checksums = []
15
15
 
16
- needed_checksums = FFI_Yajl::Parser.parse(request.body, :create_additions => false)["checksums"]
16
+ needed_checksums = FFI_Yajl::Parser.parse(request.body)["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] + %w{file_store checksums}).include?(needed_checksum)
@@ -21,7 +21,7 @@ module ChefZero
21
21
  def post(request)
22
22
  orgname = request.rest_path[1]
23
23
  full_results = search(request, orgname)
24
- keys = FFI_Yajl::Parser.parse(request.body, :create_additions => false)
24
+ keys = FFI_Yajl::Parser.parse(request.body)
25
25
  partial_results = full_results["rows"].map do |name, uri, doc, search_value|
26
26
  data = {}
27
27
  keys.each_pair do |key, path|
@@ -124,7 +124,7 @@ module ChefZero
124
124
  result = []
125
125
  list_data(request, container).each do |name|
126
126
  value = get_data(request, container + [name])
127
- expanded = expander.call(FFI_Yajl::Parser.parse(value, :create_additions => false), name)
127
+ expanded = expander.call(FFI_Yajl::Parser.parse(value), name)
128
128
  result << [ name, build_uri(request.base_uri, container + [name]), expanded, expand_for_indexing(expanded, index, name) ]
129
129
  end
130
130
  result = result.select do |name, uri, value, search_value|
@@ -6,7 +6,7 @@ module ChefZero
6
6
  # /system_recovery
7
7
  class SystemRecoveryEndpoint < RestBase
8
8
  def post(request)
9
- request_json = FFI_Yajl::Parser.parse(request.body, :create_additions => false)
9
+ request_json = FFI_Yajl::Parser.parse(request.body)
10
10
  name = request_json["username"]
11
11
  password = request_json["password"]
12
12
  user = get_data(request, request.rest_path[0..-2] + ["users", name], :nil)
@@ -14,7 +14,7 @@ module ChefZero
14
14
  raise RestErrorResponse.new(403, "Nonexistent user")
15
15
  end
16
16
 
17
- user = FFI_Yajl::Parser.parse(user, :create_additions => false)
17
+ user = FFI_Yajl::Parser.parse(user)
18
18
  user = ChefData::DataNormalizer.normalize_user(user, name, [ "username" ], server.options[:osc_compat])
19
19
  if !user["recovery_authentication_enabled"]
20
20
  raise RestErrorResponse.new(403, "Only users with recovery_authentication_enabled=true may use /system_recovery to log in")
@@ -13,11 +13,11 @@ module ChefZero
13
13
  end
14
14
  orgname = $1
15
15
 
16
- json = FFI_Yajl::Parser.parse(request.body, :create_additions => false)
16
+ json = FFI_Yajl::Parser.parse(request.body)
17
17
  association_request_path = [ "organizations", orgname, "association_requests", username ]
18
18
  if json["response"] == "accept"
19
19
  users = get_data(request, [ "organizations", orgname, "groups", "users" ])
20
- users = FFI_Yajl::Parser.parse(users, :create_additions => false)
20
+ users = FFI_Yajl::Parser.parse(users)
21
21
 
22
22
  delete_data(request, association_request_path)
23
23
  create_data(request, [ "organizations", orgname, "users" ], username, "{}")
@@ -12,7 +12,7 @@ module ChefZero
12
12
  end
13
13
  result = result.map do |orgname|
14
14
  org = get_data(request, [ "organizations", orgname, "org" ])
15
- org = FFI_Yajl::Parser.parse(org, :create_additions => false)
15
+ org = FFI_Yajl::Parser.parse(org)
16
16
  { "organization" => ChefData::DataNormalizer.normalize_organization(org, orgname) }
17
17
  end
18
18
  json_response(200, result)
@@ -285,7 +285,7 @@ module ChefZero
285
285
  end
286
286
 
287
287
  def parse_json(json)
288
- FFI_Yajl::Parser.parse(json, create_additions: false)
288
+ FFI_Yajl::Parser.parse(json)
289
289
  end
290
290
 
291
291
  def to_json(data)
@@ -1,3 +1,3 @@
1
1
  module ChefZero
2
- VERSION = "5.0.0"
2
+ VERSION = "5.1.0"
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: 5.0.0
4
+ version: 5.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Keiser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-24 00:00:00.000000000 Z
11
+ date: 2016-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mixlib-log