chef-zero 4.8.0 → 4.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +8 -4
- data/Rakefile +20 -10
- data/bin/chef-zero +12 -12
- data/chef-zero.gemspec +24 -24
- data/lib/chef_zero.rb +1 -1
- data/lib/chef_zero/chef_data/acl_path.rb +16 -16
- data/lib/chef_zero/chef_data/cookbook_data.rb +24 -24
- data/lib/chef_zero/chef_data/data_normalizer.rb +120 -120
- data/lib/chef_zero/chef_data/default_creator.rb +145 -145
- data/lib/chef_zero/data_store/data_already_exists_error.rb +1 -1
- data/lib/chef_zero/data_store/data_not_found_error.rb +2 -2
- data/lib/chef_zero/data_store/default_facade.rb +5 -5
- data/lib/chef_zero/data_store/interface_v1.rb +1 -1
- data/lib/chef_zero/data_store/interface_v2.rb +1 -1
- data/lib/chef_zero/data_store/memory_store.rb +4 -4
- data/lib/chef_zero/data_store/memory_store_v2.rb +8 -8
- data/lib/chef_zero/data_store/raw_file_store.rb +10 -10
- data/lib/chef_zero/data_store/v1_to_v2_adapter.rb +9 -9
- data/lib/chef_zero/data_store/v2_to_v1_adapter.rb +5 -5
- data/lib/chef_zero/endpoints/acl_endpoint.rb +6 -6
- data/lib/chef_zero/endpoints/acls_endpoint.rb +5 -5
- data/lib/chef_zero/endpoints/actor_default_key_endpoint.rb +1 -1
- data/lib/chef_zero/endpoints/actor_endpoint.rb +20 -20
- data/lib/chef_zero/endpoints/actor_key_endpoint.rb +1 -1
- data/lib/chef_zero/endpoints/actor_keys_endpoint.rb +5 -6
- data/lib/chef_zero/endpoints/actors_endpoint.rb +12 -12
- data/lib/chef_zero/endpoints/authenticate_user_endpoint.rb +10 -10
- data/lib/chef_zero/endpoints/container_endpoint.rb +4 -4
- data/lib/chef_zero/endpoints/containers_endpoint.rb +3 -3
- data/lib/chef_zero/endpoints/cookbook_artifact_endpoint.rb +1 -1
- data/lib/chef_zero/endpoints/cookbook_artifact_identifier_endpoint.rb +1 -1
- data/lib/chef_zero/endpoints/cookbook_artifacts_endpoint.rb +1 -1
- data/lib/chef_zero/endpoints/cookbook_endpoint.rb +5 -5
- data/lib/chef_zero/endpoints/cookbook_version_endpoint.rb +20 -16
- data/lib/chef_zero/endpoints/cookbooks_base.rb +13 -13
- data/lib/chef_zero/endpoints/cookbooks_endpoint.rb +4 -4
- data/lib/chef_zero/endpoints/data_bag_endpoint.rb +12 -12
- data/lib/chef_zero/endpoints/data_bag_item_endpoint.rb +6 -6
- data/lib/chef_zero/endpoints/data_bags_endpoint.rb +5 -5
- data/lib/chef_zero/endpoints/dummy_endpoint.rb +0 -2
- data/lib/chef_zero/endpoints/environment_cookbook_endpoint.rb +6 -6
- data/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb +16 -16
- data/lib/chef_zero/endpoints/environment_cookbooks_endpoint.rb +6 -6
- data/lib/chef_zero/endpoints/environment_endpoint.rb +3 -3
- data/lib/chef_zero/endpoints/environment_nodes_endpoint.rb +6 -6
- data/lib/chef_zero/endpoints/environment_recipes_endpoint.rb +4 -4
- data/lib/chef_zero/endpoints/environment_role_endpoint.rb +8 -8
- data/lib/chef_zero/endpoints/file_store_file_endpoint.rb +2 -2
- data/lib/chef_zero/endpoints/group_endpoint.rb +4 -4
- data/lib/chef_zero/endpoints/groups_endpoint.rb +3 -3
- data/lib/chef_zero/endpoints/license_endpoint.rb +5 -5
- data/lib/chef_zero/endpoints/node_endpoint.rb +3 -4
- data/lib/chef_zero/endpoints/node_identifiers_endpoint.rb +7 -7
- data/lib/chef_zero/endpoints/nodes_endpoint.rb +3 -4
- data/lib/chef_zero/endpoints/not_found_endpoint.rb +2 -2
- data/lib/chef_zero/endpoints/organization_association_request_endpoint.rb +2 -2
- data/lib/chef_zero/endpoints/organization_association_requests_endpoint.rb +6 -6
- data/lib/chef_zero/endpoints/organization_authenticate_user_endpoint.rb +8 -8
- data/lib/chef_zero/endpoints/organization_endpoint.rb +10 -10
- data/lib/chef_zero/endpoints/organization_user_base.rb +2 -2
- data/lib/chef_zero/endpoints/organization_user_default_key_endpoint.rb +1 -1
- data/lib/chef_zero/endpoints/organization_user_endpoint.rb +5 -5
- data/lib/chef_zero/endpoints/organization_user_key_endpoint.rb +2 -2
- data/lib/chef_zero/endpoints/organization_user_keys_endpoint.rb +1 -1
- data/lib/chef_zero/endpoints/organization_users_endpoint.rb +12 -12
- data/lib/chef_zero/endpoints/organization_validator_key_endpoint.rb +6 -6
- data/lib/chef_zero/endpoints/organizations_endpoint.rb +12 -13
- data/lib/chef_zero/endpoints/policies_endpoint.rb +2 -2
- data/lib/chef_zero/endpoints/policy_endpoint.rb +1 -1
- data/lib/chef_zero/endpoints/policy_group_endpoint.rb +6 -6
- data/lib/chef_zero/endpoints/policy_group_policy_endpoint.rb +3 -4
- data/lib/chef_zero/endpoints/policy_groups_endpoint.rb +4 -4
- data/lib/chef_zero/endpoints/policy_revision_endpoint.rb +1 -1
- data/lib/chef_zero/endpoints/policy_revisions_endpoint.rb +1 -1
- data/lib/chef_zero/endpoints/principal_endpoint.rb +15 -15
- data/lib/chef_zero/endpoints/rest_list_endpoint.rb +4 -4
- data/lib/chef_zero/endpoints/rest_object_endpoint.rb +4 -4
- data/lib/chef_zero/endpoints/role_endpoint.rb +3 -3
- data/lib/chef_zero/endpoints/role_environments_endpoint.rb +3 -3
- data/lib/chef_zero/endpoints/sandbox_endpoint.rb +8 -8
- data/lib/chef_zero/endpoints/sandboxes_endpoint.rb +9 -9
- data/lib/chef_zero/endpoints/search_endpoint.rb +51 -49
- data/lib/chef_zero/endpoints/searches_endpoint.rb +2 -2
- data/lib/chef_zero/endpoints/server_api_version_endpoint.rb +2 -2
- data/lib/chef_zero/endpoints/system_recovery_endpoint.rb +8 -8
- data/lib/chef_zero/endpoints/user_association_request_endpoint.rb +12 -12
- data/lib/chef_zero/endpoints/user_association_requests_count_endpoint.rb +4 -4
- data/lib/chef_zero/endpoints/user_association_requests_endpoint.rb +4 -4
- data/lib/chef_zero/endpoints/user_organizations_endpoint.rb +5 -5
- data/lib/chef_zero/endpoints/version_endpoint.rb +1 -1
- data/lib/chef_zero/log.rb +1 -1
- data/lib/chef_zero/rest_base.rb +25 -25
- data/lib/chef_zero/rest_request.rb +11 -11
- data/lib/chef_zero/rest_router.rb +30 -30
- data/lib/chef_zero/rspec.rb +33 -33
- data/lib/chef_zero/server.rb +188 -189
- data/lib/chef_zero/socketless_server_map.rb +2 -3
- data/lib/chef_zero/solr/query/binary_operator.rb +8 -8
- data/lib/chef_zero/solr/query/phrase.rb +1 -1
- data/lib/chef_zero/solr/query/range_query.rb +2 -2
- data/lib/chef_zero/solr/query/regexpable_query.rb +1 -0
- data/lib/chef_zero/solr/query/term.rb +5 -5
- data/lib/chef_zero/solr/query/unary_operator.rb +4 -4
- data/lib/chef_zero/solr/solr_doc.rb +4 -4
- data/lib/chef_zero/solr/solr_parser.rb +34 -33
- data/lib/chef_zero/version.rb +1 -1
- data/spec/run_oc_pedant.rb +61 -60
- data/spec/search_spec.rb +11 -11
- data/spec/server_spec.rb +35 -35
- data/spec/socketless_server_map_spec.rb +1 -3
- data/spec/support/oc_pedant.rb +20 -21
- metadata +2 -2
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "ffi_yajl"
|
2
|
+
require "chef_zero/endpoints/rest_list_endpoint"
|
3
3
|
|
4
4
|
module ChefZero
|
5
5
|
module Endpoints
|
@@ -11,11 +11,11 @@ module ChefZero
|
|
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")
|
14
|
-
elsif exists_data_dir?(request, request.rest_path[0..1] + [
|
14
|
+
elsif exists_data_dir?(request, request.rest_path[0..1] + ["data", name])
|
15
15
|
error(409, "Object already exists")
|
16
16
|
else
|
17
|
-
create_data_dir(request, request.rest_path[0..1] + [
|
18
|
-
json_response(201, {"uri" => "#{build_uri(request.base_uri, request.rest_path + [name])}"})
|
17
|
+
create_data_dir(request, request.rest_path[0..1] + ["data"], name, :recursive)
|
18
|
+
json_response(201, { "uri" => "#{build_uri(request.base_uri, request.rest_path + [name])}" })
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -7,7 +7,6 @@ module ChefZero
|
|
7
7
|
# called by #direct_solr_query, once each for roles, nodes, and data bag items. each RSpec example makes
|
8
8
|
# 3 calls, with the expected sequence of return values [0, 1, 0].
|
9
9
|
def get(request)
|
10
|
-
|
11
10
|
# this could be made less brittle, but if things change to have more than 3 cycles, we should really
|
12
11
|
# be notified by a spec failure.
|
13
12
|
@mock_values ||= ([0, 1, 0] * 3).map { |val| make_response(val) }
|
@@ -28,4 +27,3 @@ module ChefZero
|
|
28
27
|
end
|
29
28
|
end
|
30
29
|
end
|
31
|
-
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "ffi_yajl"
|
2
|
+
require "chef_zero/endpoints/cookbooks_base"
|
3
3
|
|
4
4
|
module ChefZero
|
5
5
|
module Endpoints
|
@@ -8,12 +8,12 @@ module ChefZero
|
|
8
8
|
def get(request)
|
9
9
|
cookbook_name = request.rest_path[5]
|
10
10
|
environment = FFI_Yajl::Parser.parse(get_data(request, request.rest_path[0..3]), :create_additions => false)
|
11
|
-
constraints = environment[
|
11
|
+
constraints = environment["cookbook_versions"] || {}
|
12
12
|
cookbook_versions = list_data(request, request.rest_path[0..1] + request.rest_path[4..5])
|
13
|
-
if request.query_params[
|
13
|
+
if request.query_params["num_versions"] == "all"
|
14
14
|
num_versions = nil
|
15
|
-
elsif request.query_params[
|
16
|
-
num_versions = request.query_params[
|
15
|
+
elsif request.query_params["num_versions"]
|
16
|
+
num_versions = request.query_params["num_versions"].to_i
|
17
17
|
else
|
18
18
|
num_versions = nil
|
19
19
|
end
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require "ffi_yajl"
|
2
|
+
require "chef_zero/rest_base"
|
3
|
+
require "chef_zero/rest_error_response"
|
4
4
|
|
5
5
|
module ChefZero
|
6
6
|
module Endpoints
|
@@ -8,26 +8,26 @@ module ChefZero
|
|
8
8
|
class EnvironmentCookbookVersionsEndpoint < RestBase
|
9
9
|
|
10
10
|
def post(request)
|
11
|
-
cookbook_names = list_data(request, request.rest_path[0..1] + [
|
11
|
+
cookbook_names = list_data(request, request.rest_path[0..1] + ["cookbooks"])
|
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)[
|
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)
|
19
|
-
raise RestErrorResponse.new(412, "No such cookbook version for cookbook #{$1}: #{$2}") if !list_data(request, request.rest_path[0..1] + [
|
19
|
+
raise RestErrorResponse.new(412, "No such cookbook version for cookbook #{$1}: #{$2}") if !list_data(request, request.rest_path[0..1] + ["cookbooks", $1]).include?($2)
|
20
20
|
desired_versions[$1] = [ $2 ]
|
21
21
|
else
|
22
|
-
desired_cookbook = run_list_entry.split(
|
22
|
+
desired_cookbook = run_list_entry.split("::")[0]
|
23
23
|
raise RestErrorResponse.new(412, "No such cookbook: #{desired_cookbook}") if !cookbook_names.include?(desired_cookbook)
|
24
|
-
desired_versions[desired_cookbook] = list_data(request, request.rest_path[0..1] + [
|
24
|
+
desired_versions[desired_cookbook] = list_data(request, request.rest_path[0..1] + ["cookbooks", desired_cookbook])
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
# Filter by environment constraints
|
29
29
|
environment = FFI_Yajl::Parser.parse(get_data(request, request.rest_path[0..3]), :create_additions => false)
|
30
|
-
environment_constraints = environment[
|
30
|
+
environment_constraints = environment["cookbook_versions"] || {}
|
31
31
|
|
32
32
|
desired_versions.each_key do |name|
|
33
33
|
desired_versions = filter_by_constraint(desired_versions, name, environment_constraints[name])
|
@@ -48,8 +48,8 @@ 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] + [
|
52
|
-
result[name] = ChefData::DataNormalizer.normalize_cookbook(self, request.rest_path[0..1], cookbook, name, versions[0], request.base_uri,
|
51
|
+
cookbook = FFI_Yajl::Parser.parse(get_data(request, request.rest_path[0..1] + ["cookbooks", name, versions[0]]), :create_additions => false)
|
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)
|
55
55
|
end
|
@@ -74,9 +74,9 @@ 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] + [
|
78
|
-
cookbook_metadata = cookbook_obj[
|
79
|
-
cookbook_dependencies = cookbook_metadata[
|
77
|
+
cookbook_obj = FFI_Yajl::Parser.parse(get_data(request, request.rest_path[0..1] + ["cookbooks", solve_for, desired_version]), :create_additions => false)
|
78
|
+
cookbook_metadata = cookbook_obj["metadata"] || {}
|
79
|
+
cookbook_dependencies = cookbook_metadata["dependencies"] || {}
|
80
80
|
dep_not_found = false
|
81
81
|
cookbook_dependencies.each_pair do |dep_name, dep_constraint|
|
82
82
|
# If the dep is not already in the list, add it to the list to solve
|
@@ -84,12 +84,12 @@ module ChefZero
|
|
84
84
|
if !new_desired_versions.has_key?(dep_name)
|
85
85
|
new_unsolved = new_unsolved + [dep_name]
|
86
86
|
# If the dep is missing, we will try other versions of the cookbook that might not have the bad dep.
|
87
|
-
if !exists_data_dir?(request, request.rest_path[0..1] + [
|
87
|
+
if !exists_data_dir?(request, request.rest_path[0..1] + ["cookbooks", dep_name])
|
88
88
|
@last_missing_dep = dep_name.to_s
|
89
89
|
dep_not_found = true
|
90
90
|
break
|
91
91
|
end
|
92
|
-
new_desired_versions[dep_name] = list_data(request, request.rest_path[0..1] + [
|
92
|
+
new_desired_versions[dep_name] = list_data(request, request.rest_path[0..1] + ["cookbooks", dep_name])
|
93
93
|
new_desired_versions = filter_by_constraint(new_desired_versions, dep_name, environment_constraints[dep_name])
|
94
94
|
end
|
95
95
|
new_desired_versions = filter_by_constraint(new_desired_versions, dep_name, dep_constraint)
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "ffi_yajl"
|
2
|
+
require "chef_zero/endpoints/cookbooks_base"
|
3
3
|
|
4
4
|
module ChefZero
|
5
5
|
module Endpoints
|
@@ -7,11 +7,11 @@ module ChefZero
|
|
7
7
|
class EnvironmentCookbooksEndpoint < CookbooksBase
|
8
8
|
def get(request)
|
9
9
|
environment = FFI_Yajl::Parser.parse(get_data(request, request.rest_path[0..3]), :create_additions => false)
|
10
|
-
constraints = environment[
|
11
|
-
if request.query_params[
|
10
|
+
constraints = environment["cookbook_versions"] || {}
|
11
|
+
if request.query_params["num_versions"] == "all"
|
12
12
|
num_versions = nil
|
13
|
-
elsif request.query_params[
|
14
|
-
num_versions = request.query_params[
|
13
|
+
elsif request.query_params["num_versions"]
|
14
|
+
num_versions = request.query_params["num_versions"].to_i
|
15
15
|
else
|
16
16
|
num_versions = 1
|
17
17
|
end
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require "ffi_yajl"
|
2
|
+
require "chef_zero/endpoints/rest_object_endpoint"
|
3
|
+
require "chef_zero/chef_data/data_normalizer"
|
4
4
|
|
5
5
|
module ChefZero
|
6
6
|
module Endpoints
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "ffi_yajl"
|
2
|
+
require "chef_zero/rest_base"
|
3
3
|
|
4
4
|
module ChefZero
|
5
5
|
module Endpoints
|
@@ -10,10 +10,10 @@ module ChefZero
|
|
10
10
|
get_data(request, request.rest_path[0..3])
|
11
11
|
|
12
12
|
result = {}
|
13
|
-
list_data(request, request.rest_path[0..1] + [
|
14
|
-
node = FFI_Yajl::Parser.parse(get_data(request, request.rest_path[0..1] + [
|
15
|
-
if node[
|
16
|
-
result[name] = build_uri(request.base_uri, request.rest_path[0..1] + [
|
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)
|
15
|
+
if node["chef_environment"] == request.rest_path[3]
|
16
|
+
result[name] = build_uri(request.base_uri, request.rest_path[0..1] + ["nodes", name])
|
17
17
|
end
|
18
18
|
end
|
19
19
|
json_response(200, result)
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "ffi_yajl"
|
2
|
+
require "chef_zero/endpoints/cookbooks_base"
|
3
3
|
|
4
4
|
module ChefZero
|
5
5
|
module Endpoints
|
@@ -7,11 +7,11 @@ module ChefZero
|
|
7
7
|
class EnvironmentRecipesEndpoint < CookbooksBase
|
8
8
|
def get(request)
|
9
9
|
environment = FFI_Yajl::Parser.parse(get_data(request, request.rest_path[0..3]), :create_additions => false)
|
10
|
-
constraints = environment[
|
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] + [
|
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,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "ffi_yajl"
|
2
|
+
require "chef_zero/endpoints/cookbooks_base"
|
3
3
|
|
4
4
|
module ChefZero
|
5
5
|
module Endpoints
|
@@ -8,7 +8,7 @@ module ChefZero
|
|
8
8
|
class EnvironmentRoleEndpoint < CookbooksBase
|
9
9
|
def get(request)
|
10
10
|
# 404 if environment does not exist
|
11
|
-
if request.rest_path[2] ==
|
11
|
+
if request.rest_path[2] == "environments"
|
12
12
|
environment_path = request.rest_path[0..1] + request.rest_path[2..3]
|
13
13
|
role_path = request.rest_path[0..1] + request.rest_path[4..5]
|
14
14
|
else
|
@@ -20,16 +20,16 @@ module ChefZero
|
|
20
20
|
|
21
21
|
role = FFI_Yajl::Parser.parse(get_data(request, role_path), :create_additions => false)
|
22
22
|
environment_name = environment_path[3]
|
23
|
-
if environment_name ==
|
24
|
-
run_list = role[
|
23
|
+
if environment_name == "_default"
|
24
|
+
run_list = role["run_list"]
|
25
25
|
else
|
26
|
-
if role[
|
27
|
-
run_list = role[
|
26
|
+
if role["env_run_lists"]
|
27
|
+
run_list = role["env_run_lists"][environment_name]
|
28
28
|
else
|
29
29
|
run_list = nil
|
30
30
|
end
|
31
31
|
end
|
32
|
-
json_response(200, {
|
32
|
+
json_response(200, { "run_list" => run_list })
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "chef_zero/rest_base"
|
2
2
|
|
3
3
|
module ChefZero
|
4
4
|
module Endpoints
|
@@ -10,7 +10,7 @@ module ChefZero
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def get(request)
|
13
|
-
[200, {"Content-Type" =>
|
13
|
+
[200, { "Content-Type" => "application/x-binary" }, get_data(request) ]
|
14
14
|
end
|
15
15
|
|
16
16
|
def put(request)
|
@@ -1,13 +1,13 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require "ffi_yajl"
|
2
|
+
require "chef_zero/endpoints/rest_object_endpoint"
|
3
|
+
require "chef_zero/chef_data/data_normalizer"
|
4
4
|
|
5
5
|
module ChefZero
|
6
6
|
module Endpoints
|
7
7
|
# /organizations/ORG/groups/NAME
|
8
8
|
class GroupEndpoint < RestObjectEndpoint
|
9
9
|
def initialize(server)
|
10
|
-
super(server, %w
|
10
|
+
super(server, %w{id groupname})
|
11
11
|
end
|
12
12
|
|
13
13
|
def populate_defaults(request, response_json)
|
@@ -1,12 +1,12 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "ffi_yajl"
|
2
|
+
require "chef_zero/endpoints/rest_list_endpoint"
|
3
3
|
|
4
4
|
module ChefZero
|
5
5
|
module Endpoints
|
6
6
|
# /organizations/ORG/groups/NAME
|
7
7
|
class GroupsEndpoint < RestListEndpoint
|
8
8
|
def initialize(server)
|
9
|
-
super(server, %w
|
9
|
+
super(server, %w{id groupname})
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "ffi_yajl"
|
2
|
+
require "chef_zero/rest_base"
|
3
3
|
|
4
4
|
module ChefZero
|
5
5
|
module Endpoints
|
@@ -9,15 +9,15 @@ module ChefZero
|
|
9
9
|
|
10
10
|
def get(request)
|
11
11
|
node_count = 0
|
12
|
-
list_data(request, [
|
13
|
-
node_count += list_data(request, [
|
12
|
+
list_data(request, [ "organizations" ]).each do |orgname|
|
13
|
+
node_count += list_data(request, [ "organizations", orgname, "nodes" ]).size
|
14
14
|
end
|
15
15
|
|
16
16
|
json_response(200, {
|
17
17
|
"limit_exceeded" => (node_count > MAX_NODE_COUNT) ? true : false,
|
18
18
|
"node_license" => MAX_NODE_COUNT,
|
19
19
|
"node_count" => node_count,
|
20
|
-
"upgrade_url" =>
|
20
|
+
"upgrade_url" => "http://blah.com",
|
21
21
|
})
|
22
22
|
end
|
23
23
|
end
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require "ffi_yajl"
|
2
|
+
require "chef_zero/endpoints/rest_object_endpoint"
|
3
|
+
require "chef_zero/chef_data/data_normalizer"
|
4
4
|
|
5
5
|
module ChefZero
|
6
6
|
module Endpoints
|
@@ -28,4 +28,3 @@ module ChefZero
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
31
|
-
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require "ffi_yajl"
|
2
|
+
require "chef_zero/rest_base"
|
3
|
+
require "uuidtools"
|
4
4
|
|
5
5
|
module ChefZero
|
6
6
|
module Endpoints
|
@@ -8,10 +8,10 @@ module ChefZero
|
|
8
8
|
class NodeIdentifiersEndpoint < RestBase
|
9
9
|
def get(request)
|
10
10
|
if get_data(request, request.rest_path[0..3])
|
11
|
-
result = {
|
12
|
-
:id => UUIDTools::UUID.parse_raw(request.rest_path[0..4].to_s).to_s.
|
13
|
-
:authz_id =>
|
14
|
-
:org_id => UUIDTools::UUID.parse_raw(request.rest_path[0..1].to_s).to_s.
|
11
|
+
result = {
|
12
|
+
:id => UUIDTools::UUID.parse_raw(request.rest_path[0..4].to_s).to_s.delete("-"),
|
13
|
+
:authz_id => "0" * 32,
|
14
|
+
:org_id => UUIDTools::UUID.parse_raw(request.rest_path[0..1].to_s).to_s.delete("-") }
|
15
15
|
json_response(200, result)
|
16
16
|
else
|
17
17
|
raise RestErrorResponse.new(404, "Object not found: #{build_uri(request.base_uri, request.rest_path)}")
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require "ffi_yajl"
|
2
|
+
require "chef_zero/endpoints/rest_object_endpoint"
|
3
|
+
require "chef_zero/chef_data/data_normalizer"
|
4
4
|
|
5
5
|
module ChefZero
|
6
6
|
module Endpoints
|
@@ -32,4 +32,3 @@ module ChefZero
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
35
|
-
|
@@ -1,10 +1,10 @@
|
|
1
|
-
require
|
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"}, FFI_Yajl::Encoder.encode({"error" => ["Object not found: #{request.env['REQUEST_PATH']}"]}, :pretty => true)]
|
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,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "ffi_yajl"
|
2
|
+
require "chef_zero/rest_base"
|
3
3
|
|
4
4
|
module ChefZero
|
5
5
|
module Endpoints
|
@@ -7,22 +7,22 @@ module ChefZero
|
|
7
7
|
class OrganizationAssociationRequestsEndpoint < RestBase
|
8
8
|
def post(request)
|
9
9
|
json = FFI_Yajl::Parser.parse(request.body, :create_additions => false)
|
10
|
-
username = json[
|
10
|
+
username = json["user"]
|
11
11
|
orgname = request.rest_path[1]
|
12
12
|
id = "#{username}-#{orgname}"
|
13
13
|
|
14
|
-
if exists_data?(request, [
|
14
|
+
if exists_data?(request, [ "organizations", orgname, "users", username ])
|
15
15
|
raise RestErrorResponse.new(409, "User #{username} is already in organization #{orgname}")
|
16
16
|
end
|
17
17
|
|
18
|
-
create_data(request, request.rest_path, username,
|
18
|
+
create_data(request, request.rest_path, username, "{}")
|
19
19
|
json_response(201, { "uri" => build_uri(request.base_uri, request.rest_path + [ id ]) })
|
20
20
|
end
|
21
21
|
|
22
22
|
def get(request)
|
23
23
|
orgname = request.rest_path[1]
|
24
24
|
ChefZero::Endpoints::OrganizationUserBase.get(self, request) do |username|
|
25
|
-
{ "id" => "#{username}-#{orgname}",
|
25
|
+
{ "id" => "#{username}-#{orgname}", "username" => username }
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|