chef-zero 15.0.17 → 15.0.21
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 +4 -4
- data/Gemfile +36 -31
- data/LICENSE +201 -201
- data/Rakefile +73 -68
- data/bin/chef-zero +111 -111
- data/chef-zero.gemspec +34 -33
- data/lib/chef_zero/chef_data/acl_path.rb +140 -140
- data/lib/chef_zero/chef_data/cookbook_data.rb +237 -237
- data/lib/chef_zero/chef_data/data_normalizer.rb +276 -276
- data/lib/chef_zero/chef_data/default_creator.rb +476 -476
- data/lib/chef_zero/data_store/data_already_exists_error.rb +29 -29
- data/lib/chef_zero/data_store/data_error.rb +32 -32
- data/lib/chef_zero/data_store/data_not_found_error.rb +29 -29
- data/lib/chef_zero/data_store/default_facade.rb +143 -147
- data/lib/chef_zero/data_store/interface_v1.rb +67 -67
- data/lib/chef_zero/data_store/interface_v2.rb +18 -18
- data/lib/chef_zero/data_store/memory_store.rb +33 -33
- data/lib/chef_zero/data_store/memory_store_v2.rb +159 -159
- data/lib/chef_zero/data_store/raw_file_store.rb +143 -143
- data/lib/chef_zero/data_store/v1_to_v2_adapter.rb +150 -150
- data/lib/chef_zero/data_store/v2_to_v1_adapter.rb +105 -105
- data/lib/chef_zero/dist.rb +9 -9
- data/lib/chef_zero/endpoints/acl_endpoint.rb +39 -39
- data/lib/chef_zero/endpoints/acls_endpoint.rb +41 -41
- data/lib/chef_zero/endpoints/actor_default_key_endpoint.rb +78 -78
- data/lib/chef_zero/endpoints/actor_endpoint.rb +184 -184
- data/lib/chef_zero/endpoints/actor_key_endpoint.rb +62 -62
- data/lib/chef_zero/endpoints/actor_keys_endpoint.rb +129 -129
- data/lib/chef_zero/endpoints/actors_endpoint.rb +104 -104
- data/lib/chef_zero/endpoints/authenticate_user_endpoint.rb +32 -32
- data/lib/chef_zero/endpoints/container_endpoint.rb +22 -22
- data/lib/chef_zero/endpoints/containers_endpoint.rb +25 -25
- data/lib/chef_zero/endpoints/controls_endpoint.rb +16 -16
- data/lib/chef_zero/endpoints/cookbook_artifact_endpoint.rb +24 -24
- data/lib/chef_zero/endpoints/cookbook_artifact_identifier_endpoint.rb +68 -68
- data/lib/chef_zero/endpoints/cookbook_artifacts_endpoint.rb +34 -34
- data/lib/chef_zero/endpoints/cookbook_endpoint.rb +39 -39
- data/lib/chef_zero/endpoints/cookbook_version_endpoint.rb +136 -136
- data/lib/chef_zero/endpoints/cookbooks_base.rb +80 -80
- data/lib/chef_zero/endpoints/cookbooks_endpoint.rb +19 -19
- data/lib/chef_zero/endpoints/data_bag_endpoint.rb +45 -45
- data/lib/chef_zero/endpoints/data_bag_item_endpoint.rb +25 -25
- data/lib/chef_zero/endpoints/data_bags_endpoint.rb +23 -23
- data/lib/chef_zero/endpoints/dummy_endpoint.rb +29 -29
- data/lib/chef_zero/endpoints/environment_cookbook_endpoint.rb +24 -24
- data/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb +126 -126
- data/lib/chef_zero/endpoints/environment_cookbooks_endpoint.rb +22 -22
- data/lib/chef_zero/endpoints/environment_endpoint.rb +33 -33
- data/lib/chef_zero/endpoints/environment_nodes_endpoint.rb +23 -23
- data/lib/chef_zero/endpoints/environment_recipes_endpoint.rb +22 -22
- data/lib/chef_zero/endpoints/environment_role_endpoint.rb +36 -36
- data/lib/chef_zero/endpoints/file_store_file_endpoint.rb +22 -22
- data/lib/chef_zero/endpoints/group_endpoint.rb +20 -20
- data/lib/chef_zero/endpoints/groups_endpoint.rb +13 -13
- data/lib/chef_zero/endpoints/license_endpoint.rb +25 -25
- data/lib/chef_zero/endpoints/node_endpoint.rb +34 -34
- data/lib/chef_zero/endpoints/node_identifiers_endpoint.rb +22 -22
- data/lib/chef_zero/endpoints/nodes_endpoint.rb +34 -34
- data/lib/chef_zero/endpoints/not_found_endpoint.rb +11 -11
- data/lib/chef_zero/endpoints/organization_association_request_endpoint.rb +22 -22
- data/lib/chef_zero/endpoints/organization_association_requests_endpoint.rb +30 -30
- data/lib/chef_zero/endpoints/organization_authenticate_user_endpoint.rb +26 -26
- data/lib/chef_zero/endpoints/organization_endpoint.rb +47 -47
- data/lib/chef_zero/endpoints/organization_user_base.rb +15 -15
- data/lib/chef_zero/endpoints/organization_user_default_key_endpoint.rb +16 -16
- data/lib/chef_zero/endpoints/organization_user_endpoint.rb +26 -26
- data/lib/chef_zero/endpoints/organization_user_key_endpoint.rb +17 -17
- data/lib/chef_zero/endpoints/organization_user_keys_endpoint.rb +17 -17
- data/lib/chef_zero/endpoints/organization_users_endpoint.rb +43 -43
- data/lib/chef_zero/endpoints/organization_validator_key_endpoint.rb +20 -20
- data/lib/chef_zero/endpoints/organizations_endpoint.rb +61 -61
- data/lib/chef_zero/endpoints/policies_endpoint.rb +26 -26
- data/lib/chef_zero/endpoints/policy_endpoint.rb +24 -24
- data/lib/chef_zero/endpoints/policy_group_endpoint.rb +46 -46
- data/lib/chef_zero/endpoints/policy_group_policy_endpoint.rb +83 -83
- data/lib/chef_zero/endpoints/policy_groups_endpoint.rb +38 -38
- data/lib/chef_zero/endpoints/policy_revision_endpoint.rb +66 -66
- data/lib/chef_zero/endpoints/policy_revisions_endpoint.rb +15 -15
- data/lib/chef_zero/endpoints/principal_endpoint.rb +55 -55
- data/lib/chef_zero/endpoints/rest_list_endpoint.rb +42 -42
- data/lib/chef_zero/endpoints/rest_object_endpoint.rb +78 -78
- data/lib/chef_zero/endpoints/role_endpoint.rb +16 -16
- data/lib/chef_zero/endpoints/role_environments_endpoint.rb +14 -14
- data/lib/chef_zero/endpoints/sandbox_endpoint.rb +27 -27
- data/lib/chef_zero/endpoints/sandboxes_endpoint.rb +51 -51
- data/lib/chef_zero/endpoints/search_endpoint.rb +208 -208
- data/lib/chef_zero/endpoints/searches_endpoint.rb +18 -18
- data/lib/chef_zero/endpoints/server_api_version_endpoint.rb +14 -14
- data/lib/chef_zero/endpoints/system_recovery_endpoint.rb +30 -30
- data/lib/chef_zero/endpoints/universe_endpoint.rb +15 -15
- data/lib/chef_zero/endpoints/user_association_request_endpoint.rb +41 -41
- data/lib/chef_zero/endpoints/user_association_requests_count_endpoint.rb +19 -19
- data/lib/chef_zero/endpoints/user_association_requests_endpoint.rb +19 -19
- data/lib/chef_zero/endpoints/user_organizations_endpoint.rb +22 -22
- data/lib/chef_zero/endpoints/version_endpoint.rb +13 -13
- data/lib/chef_zero/log.rb +7 -7
- data/lib/chef_zero/rest_base.rb +332 -332
- data/lib/chef_zero/rest_error_response.rb +11 -11
- data/lib/chef_zero/rest_request.rb +84 -88
- data/lib/chef_zero/rest_router.rb +72 -72
- data/lib/chef_zero/rspec.rb +355 -355
- data/lib/chef_zero/server.rb +730 -730
- data/lib/chef_zero/socketless_server_map.rb +92 -93
- data/lib/chef_zero/solr/query/binary_operator.rb +52 -52
- data/lib/chef_zero/solr/query/phrase.rb +23 -23
- data/lib/chef_zero/solr/query/range_query.rb +46 -46
- data/lib/chef_zero/solr/query/regexpable_query.rb +30 -30
- data/lib/chef_zero/solr/query/subquery.rb +37 -37
- data/lib/chef_zero/solr/query/term.rb +45 -45
- data/lib/chef_zero/solr/query/unary_operator.rb +41 -41
- data/lib/chef_zero/solr/solr_doc.rb +53 -53
- data/lib/chef_zero/solr/solr_parser.rb +208 -208
- data/lib/chef_zero/version.rb +3 -3
- data/lib/chef_zero.rb +10 -10
- data/spec/run_oc_pedant.rb +226 -226
- data/spec/search_spec.rb +36 -36
- data/spec/server_spec.rb +96 -96
- data/spec/socketless_server_map_spec.rb +74 -74
- data/spec/support/oc_pedant.rb +149 -149
- data/spec/support/secrets.json +6 -6
- data/spec/support/stickywicket.pem +27 -27
- metadata +35 -18
@@ -1,150 +1,150 @@
|
|
1
|
-
require_relative "interface_v2"
|
2
|
-
|
3
|
-
module ChefZero
|
4
|
-
module DataStore
|
5
|
-
class V1ToV2Adapter < ChefZero::DataStore::InterfaceV2
|
6
|
-
def initialize(real_store, single_org, options = {})
|
7
|
-
@real_store = real_store
|
8
|
-
@single_org = single_org
|
9
|
-
@options = options
|
10
|
-
clear
|
11
|
-
end
|
12
|
-
|
13
|
-
attr_reader :real_store
|
14
|
-
attr_reader :single_org
|
15
|
-
|
16
|
-
def clear
|
17
|
-
real_store.clear if real_store.respond_to?(:clear)
|
18
|
-
end
|
19
|
-
|
20
|
-
def create_dir(path, name, *options)
|
21
|
-
raise DataNotFoundError.new(path) if skip_organizations?(path)
|
22
|
-
raise "Cannot create #{name} at #{path} with V1ToV2Adapter: only handles a single org named #{single_org}." if skip_organizations?(path, name)
|
23
|
-
raise DataAlreadyExistsError.new(path + [ name ]) if path.size < 2
|
24
|
-
|
25
|
-
fix_exceptions do
|
26
|
-
real_store.create_dir(path[2..-1], name, *options)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def create(path, name, data, *options)
|
31
|
-
raise DataNotFoundError.new(path) if skip_organizations?(path)
|
32
|
-
raise "Cannot create #{name} at #{path} with V1ToV2Adapter: only handles a single org named #{single_org}." if skip_organizations?(path, name)
|
33
|
-
raise DataAlreadyExistsError.new(path + [ name ]) if path.size < 2
|
34
|
-
|
35
|
-
fix_exceptions do
|
36
|
-
real_store.create(path[2..-1], name, data, *options)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def get(path, request = nil)
|
41
|
-
raise DataNotFoundError.new(path) if skip_organizations?(path)
|
42
|
-
|
43
|
-
fix_exceptions do
|
44
|
-
# Make it so build_uri will include /organizations/ORG inside the V1 data store
|
45
|
-
if request && request.rest_base_prefix.size == 0
|
46
|
-
old_base_uri = request.base_uri
|
47
|
-
request.base_uri = File.join(request.base_uri, "organizations", single_org)
|
48
|
-
end
|
49
|
-
begin
|
50
|
-
real_store.get(path[2..-1], request)
|
51
|
-
ensure
|
52
|
-
request.base_uri = old_base_uri if request && request.rest_base_prefix.size == 0
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def set(path, data, *options)
|
58
|
-
raise DataNotFoundError.new(path) if skip_organizations?(path)
|
59
|
-
|
60
|
-
fix_exceptions do
|
61
|
-
real_store.set(path[2..-1], data, *options)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def delete(path, *options)
|
66
|
-
raise DataNotFoundError.new(path) if skip_organizations?(path) && !options.include?(:recursive)
|
67
|
-
|
68
|
-
fix_exceptions do
|
69
|
-
real_store.delete(path[2..-1])
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
def delete_dir(path, *options)
|
74
|
-
raise DataNotFoundError.new(path) if skip_organizations?(path) && !options.include?(:recursive)
|
75
|
-
|
76
|
-
fix_exceptions do
|
77
|
-
real_store.delete_dir(path[2..-1], *options)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
def list(path)
|
82
|
-
raise DataNotFoundError.new(path) if skip_organizations?(path)
|
83
|
-
|
84
|
-
if path == []
|
85
|
-
[ "organizations" ]
|
86
|
-
elsif path == [ "organizations" ]
|
87
|
-
[ single_org ]
|
88
|
-
else
|
89
|
-
fix_exceptions do
|
90
|
-
real_store.list(path[2..-1])
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
def exists?(path)
|
96
|
-
return false if skip_organizations?(path)
|
97
|
-
|
98
|
-
fix_exceptions do
|
99
|
-
real_store.exists?(path[2..-1])
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
def exists_dir?(path)
|
104
|
-
return false if skip_organizations?(path)
|
105
|
-
|
106
|
-
if path == []
|
107
|
-
true
|
108
|
-
elsif path == [ "organizations" ] || path == [ "users" ]
|
109
|
-
true
|
110
|
-
else
|
111
|
-
return false if skip_organizations?(path)
|
112
|
-
|
113
|
-
fix_exceptions do
|
114
|
-
real_store.exists_dir?(path[2..-1])
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
private
|
120
|
-
|
121
|
-
def fix_exceptions
|
122
|
-
yield
|
123
|
-
rescue DataAlreadyExistsError => e
|
124
|
-
err = DataAlreadyExistsError.new([ "organizations", single_org ] + e.path, e)
|
125
|
-
err.set_backtrace(e.backtrace)
|
126
|
-
raise err
|
127
|
-
rescue DataNotFoundError => e
|
128
|
-
err = DataNotFoundError.new([ "organizations", single_org ] + e.path, e)
|
129
|
-
err.set_backtrace(e.backtrace)
|
130
|
-
raise e
|
131
|
-
end
|
132
|
-
|
133
|
-
def skip_organizations?(path, name = nil)
|
134
|
-
if path == []
|
135
|
-
false
|
136
|
-
elsif path[0] == "organizations"
|
137
|
-
if path.size == 1
|
138
|
-
false
|
139
|
-
elsif path.size >= 2 && path[1] != single_org
|
140
|
-
true
|
141
|
-
else
|
142
|
-
false
|
143
|
-
end
|
144
|
-
else
|
145
|
-
true
|
146
|
-
end
|
147
|
-
end
|
148
|
-
end
|
149
|
-
end
|
150
|
-
end
|
1
|
+
require_relative "interface_v2"
|
2
|
+
|
3
|
+
module ChefZero
|
4
|
+
module DataStore
|
5
|
+
class V1ToV2Adapter < ChefZero::DataStore::InterfaceV2
|
6
|
+
def initialize(real_store, single_org, options = {})
|
7
|
+
@real_store = real_store
|
8
|
+
@single_org = single_org
|
9
|
+
@options = options
|
10
|
+
clear
|
11
|
+
end
|
12
|
+
|
13
|
+
attr_reader :real_store
|
14
|
+
attr_reader :single_org
|
15
|
+
|
16
|
+
def clear
|
17
|
+
real_store.clear if real_store.respond_to?(:clear)
|
18
|
+
end
|
19
|
+
|
20
|
+
def create_dir(path, name, *options)
|
21
|
+
raise DataNotFoundError.new(path) if skip_organizations?(path)
|
22
|
+
raise "Cannot create #{name} at #{path} with V1ToV2Adapter: only handles a single org named #{single_org}." if skip_organizations?(path, name)
|
23
|
+
raise DataAlreadyExistsError.new(path + [ name ]) if path.size < 2
|
24
|
+
|
25
|
+
fix_exceptions do
|
26
|
+
real_store.create_dir(path[2..-1], name, *options)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def create(path, name, data, *options)
|
31
|
+
raise DataNotFoundError.new(path) if skip_organizations?(path)
|
32
|
+
raise "Cannot create #{name} at #{path} with V1ToV2Adapter: only handles a single org named #{single_org}." if skip_organizations?(path, name)
|
33
|
+
raise DataAlreadyExistsError.new(path + [ name ]) if path.size < 2
|
34
|
+
|
35
|
+
fix_exceptions do
|
36
|
+
real_store.create(path[2..-1], name, data, *options)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def get(path, request = nil)
|
41
|
+
raise DataNotFoundError.new(path) if skip_organizations?(path)
|
42
|
+
|
43
|
+
fix_exceptions do
|
44
|
+
# Make it so build_uri will include /organizations/ORG inside the V1 data store
|
45
|
+
if request && request.rest_base_prefix.size == 0
|
46
|
+
old_base_uri = request.base_uri
|
47
|
+
request.base_uri = File.join(request.base_uri, "organizations", single_org)
|
48
|
+
end
|
49
|
+
begin
|
50
|
+
real_store.get(path[2..-1], request)
|
51
|
+
ensure
|
52
|
+
request.base_uri = old_base_uri if request && request.rest_base_prefix.size == 0
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def set(path, data, *options)
|
58
|
+
raise DataNotFoundError.new(path) if skip_organizations?(path)
|
59
|
+
|
60
|
+
fix_exceptions do
|
61
|
+
real_store.set(path[2..-1], data, *options)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def delete(path, *options)
|
66
|
+
raise DataNotFoundError.new(path) if skip_organizations?(path) && !options.include?(:recursive)
|
67
|
+
|
68
|
+
fix_exceptions do
|
69
|
+
real_store.delete(path[2..-1])
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def delete_dir(path, *options)
|
74
|
+
raise DataNotFoundError.new(path) if skip_organizations?(path) && !options.include?(:recursive)
|
75
|
+
|
76
|
+
fix_exceptions do
|
77
|
+
real_store.delete_dir(path[2..-1], *options)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def list(path)
|
82
|
+
raise DataNotFoundError.new(path) if skip_organizations?(path)
|
83
|
+
|
84
|
+
if path == []
|
85
|
+
[ "organizations" ]
|
86
|
+
elsif path == [ "organizations" ]
|
87
|
+
[ single_org ]
|
88
|
+
else
|
89
|
+
fix_exceptions do
|
90
|
+
real_store.list(path[2..-1])
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def exists?(path)
|
96
|
+
return false if skip_organizations?(path)
|
97
|
+
|
98
|
+
fix_exceptions do
|
99
|
+
real_store.exists?(path[2..-1])
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def exists_dir?(path)
|
104
|
+
return false if skip_organizations?(path)
|
105
|
+
|
106
|
+
if path == []
|
107
|
+
true
|
108
|
+
elsif path == [ "organizations" ] || path == [ "users" ]
|
109
|
+
true
|
110
|
+
else
|
111
|
+
return false if skip_organizations?(path)
|
112
|
+
|
113
|
+
fix_exceptions do
|
114
|
+
real_store.exists_dir?(path[2..-1])
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
private
|
120
|
+
|
121
|
+
def fix_exceptions
|
122
|
+
yield
|
123
|
+
rescue DataAlreadyExistsError => e
|
124
|
+
err = DataAlreadyExistsError.new([ "organizations", single_org ] + e.path, e)
|
125
|
+
err.set_backtrace(e.backtrace)
|
126
|
+
raise err
|
127
|
+
rescue DataNotFoundError => e
|
128
|
+
err = DataNotFoundError.new([ "organizations", single_org ] + e.path, e)
|
129
|
+
err.set_backtrace(e.backtrace)
|
130
|
+
raise e
|
131
|
+
end
|
132
|
+
|
133
|
+
def skip_organizations?(path, name = nil)
|
134
|
+
if path == []
|
135
|
+
false
|
136
|
+
elsif path[0] == "organizations"
|
137
|
+
if path.size == 1
|
138
|
+
false
|
139
|
+
elsif path.size >= 2 && path[1] != single_org
|
140
|
+
true
|
141
|
+
else
|
142
|
+
false
|
143
|
+
end
|
144
|
+
else
|
145
|
+
true
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
@@ -1,105 +1,105 @@
|
|
1
|
-
#
|
2
|
-
# Author:: John Keiser (<jkeiser@opscode.com>)
|
3
|
-
# Copyright:: Copyright (c) 2014 Opscode, Inc.
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# https://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
require_relative "interface_v1"
|
20
|
-
|
21
|
-
module ChefZero
|
22
|
-
module DataStore
|
23
|
-
class V2ToV1Adapter < ChefZero::DataStore::InterfaceV1
|
24
|
-
def initialize
|
25
|
-
@single_org = "chef"
|
26
|
-
end
|
27
|
-
|
28
|
-
attr_reader :real_store
|
29
|
-
attr_reader :single_org
|
30
|
-
|
31
|
-
def clear
|
32
|
-
real_store.clear
|
33
|
-
real_store.create_dir([ "organizations" ], single_org, :recursive)
|
34
|
-
end
|
35
|
-
|
36
|
-
def create_dir(path, name, *options)
|
37
|
-
fix_exceptions do
|
38
|
-
real_store.create_dir(fix_path(path), name, *options)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def create(path, name, data, *options)
|
43
|
-
fix_exceptions do
|
44
|
-
real_store.create(fix_path(path), name, data, *options)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def get(path, request = nil)
|
49
|
-
fix_exceptions do
|
50
|
-
real_store.get(fix_path(path), request)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def set(path, data, *options)
|
55
|
-
fix_exceptions do
|
56
|
-
real_store.set(fix_path(path), data, *options)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
def delete(path)
|
61
|
-
fix_exceptions do
|
62
|
-
real_store.delete(fix_path(path))
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
def delete_dir(path, *options)
|
67
|
-
fix_exceptions do
|
68
|
-
real_store.delete_dir(fix_path(path), *options)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def list(path)
|
73
|
-
fix_exceptions do
|
74
|
-
real_store.list(fix_path(path))
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def exists?(path)
|
79
|
-
fix_exceptions do
|
80
|
-
real_store.exists?(fix_path(path))
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
def exists_dir?(path)
|
85
|
-
fix_exceptions do
|
86
|
-
real_store.exists_dir?(fix_path(path))
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
protected
|
91
|
-
|
92
|
-
def fix_exceptions
|
93
|
-
yield
|
94
|
-
rescue DataAlreadyExistsError => e
|
95
|
-
raise DataAlreadyExistsError.new(e.path[2..-1], e)
|
96
|
-
rescue DataNotFoundError => e
|
97
|
-
raise DataNotFoundError.new(e.path[2..-1], e)
|
98
|
-
end
|
99
|
-
|
100
|
-
def fix_path(path)
|
101
|
-
[ "organizations", single_org ] + path
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
1
|
+
#
|
2
|
+
# Author:: John Keiser (<jkeiser@opscode.com>)
|
3
|
+
# Copyright:: Copyright (c) 2014 Opscode, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require_relative "interface_v1"
|
20
|
+
|
21
|
+
module ChefZero
|
22
|
+
module DataStore
|
23
|
+
class V2ToV1Adapter < ChefZero::DataStore::InterfaceV1
|
24
|
+
def initialize
|
25
|
+
@single_org = "chef"
|
26
|
+
end
|
27
|
+
|
28
|
+
attr_reader :real_store
|
29
|
+
attr_reader :single_org
|
30
|
+
|
31
|
+
def clear
|
32
|
+
real_store.clear
|
33
|
+
real_store.create_dir([ "organizations" ], single_org, :recursive)
|
34
|
+
end
|
35
|
+
|
36
|
+
def create_dir(path, name, *options)
|
37
|
+
fix_exceptions do
|
38
|
+
real_store.create_dir(fix_path(path), name, *options)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def create(path, name, data, *options)
|
43
|
+
fix_exceptions do
|
44
|
+
real_store.create(fix_path(path), name, data, *options)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def get(path, request = nil)
|
49
|
+
fix_exceptions do
|
50
|
+
real_store.get(fix_path(path), request)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def set(path, data, *options)
|
55
|
+
fix_exceptions do
|
56
|
+
real_store.set(fix_path(path), data, *options)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def delete(path)
|
61
|
+
fix_exceptions do
|
62
|
+
real_store.delete(fix_path(path))
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def delete_dir(path, *options)
|
67
|
+
fix_exceptions do
|
68
|
+
real_store.delete_dir(fix_path(path), *options)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def list(path)
|
73
|
+
fix_exceptions do
|
74
|
+
real_store.list(fix_path(path))
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def exists?(path)
|
79
|
+
fix_exceptions do
|
80
|
+
real_store.exists?(fix_path(path))
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def exists_dir?(path)
|
85
|
+
fix_exceptions do
|
86
|
+
real_store.exists_dir?(fix_path(path))
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
protected
|
91
|
+
|
92
|
+
def fix_exceptions
|
93
|
+
yield
|
94
|
+
rescue DataAlreadyExistsError => e
|
95
|
+
raise DataAlreadyExistsError.new(e.path[2..-1], e)
|
96
|
+
rescue DataNotFoundError => e
|
97
|
+
raise DataNotFoundError.new(e.path[2..-1], e)
|
98
|
+
end
|
99
|
+
|
100
|
+
def fix_path(path)
|
101
|
+
[ "organizations", single_org ] + path
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
data/lib/chef_zero/dist.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
module ChefZero
|
2
|
-
class Dist
|
3
|
-
# When referencing a product directly
|
4
|
-
PRODUCT = "Chef Zero".freeze
|
5
|
-
|
6
|
-
# The binary alias
|
7
|
-
CLIENT = "chef-zero".freeze
|
8
|
-
end
|
9
|
-
end
|
1
|
+
module ChefZero
|
2
|
+
class Dist
|
3
|
+
# When referencing a product directly
|
4
|
+
PRODUCT = "Chef Zero".freeze
|
5
|
+
|
6
|
+
# The binary alias
|
7
|
+
CLIENT = "chef-zero".freeze
|
8
|
+
end
|
9
|
+
end
|
@@ -1,39 +1,39 @@
|
|
1
|
-
require "ffi_yajl" unless defined?(FFI_Yajl)
|
2
|
-
require_relative "../rest_base"
|
3
|
-
require_relative "../chef_data/acl_path"
|
4
|
-
|
5
|
-
module ChefZero
|
6
|
-
module Endpoints
|
7
|
-
# /organizations/ORG/<thing>/NAME/_acl/PERM
|
8
|
-
# Where thing is:
|
9
|
-
# clients, data, containers, cookbooks, environments
|
10
|
-
# groups, roles, nodes, users
|
11
|
-
# or
|
12
|
-
# /organizations/ORG/organization/_acl/PERM
|
13
|
-
# or
|
14
|
-
# /users/NAME/_acl/PERM
|
15
|
-
#
|
16
|
-
# Where PERM is create,read,update,delete,grant
|
17
|
-
class AclEndpoint < RestBase
|
18
|
-
def validate_request(request)
|
19
|
-
path = request.rest_path[0..-3] # Strip off _acl/PERM
|
20
|
-
path = path[0..1] if path.size == 3 && path[0] == "organizations" && %w{organization organizations}.include?(path[2])
|
21
|
-
acl_path = ChefData::AclPath.get_acl_data_path(path)
|
22
|
-
perm = request.rest_path[-1]
|
23
|
-
if !acl_path || !%w{read create update delete grant}.include?(perm)
|
24
|
-
raise RestErrorResponse.new(404, "Object not found: #{build_uri(request.base_uri, request.rest_path)}")
|
25
|
-
end
|
26
|
-
|
27
|
-
[acl_path, perm]
|
28
|
-
end
|
29
|
-
|
30
|
-
def put(request)
|
31
|
-
path, perm = validate_request(request)
|
32
|
-
acls = FFI_Yajl::Parser.parse(get_data(request, path))
|
33
|
-
acls[perm] = FFI_Yajl::Parser.parse(request.body)[perm]
|
34
|
-
set_data(request, path, FFI_Yajl::Encoder.encode(acls, pretty: true))
|
35
|
-
json_response(200, { "uri" => (build_uri(request.base_uri, request.rest_path)).to_s })
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
1
|
+
require "ffi_yajl" unless defined?(FFI_Yajl)
|
2
|
+
require_relative "../rest_base"
|
3
|
+
require_relative "../chef_data/acl_path"
|
4
|
+
|
5
|
+
module ChefZero
|
6
|
+
module Endpoints
|
7
|
+
# /organizations/ORG/<thing>/NAME/_acl/PERM
|
8
|
+
# Where thing is:
|
9
|
+
# clients, data, containers, cookbooks, environments
|
10
|
+
# groups, roles, nodes, users
|
11
|
+
# or
|
12
|
+
# /organizations/ORG/organization/_acl/PERM
|
13
|
+
# or
|
14
|
+
# /users/NAME/_acl/PERM
|
15
|
+
#
|
16
|
+
# Where PERM is create,read,update,delete,grant
|
17
|
+
class AclEndpoint < RestBase
|
18
|
+
def validate_request(request)
|
19
|
+
path = request.rest_path[0..-3] # Strip off _acl/PERM
|
20
|
+
path = path[0..1] if path.size == 3 && path[0] == "organizations" && %w{organization organizations}.include?(path[2])
|
21
|
+
acl_path = ChefData::AclPath.get_acl_data_path(path)
|
22
|
+
perm = request.rest_path[-1]
|
23
|
+
if !acl_path || !%w{read create update delete grant}.include?(perm)
|
24
|
+
raise RestErrorResponse.new(404, "Object not found: #{build_uri(request.base_uri, request.rest_path)}")
|
25
|
+
end
|
26
|
+
|
27
|
+
[acl_path, perm]
|
28
|
+
end
|
29
|
+
|
30
|
+
def put(request)
|
31
|
+
path, perm = validate_request(request)
|
32
|
+
acls = FFI_Yajl::Parser.parse(get_data(request, path))
|
33
|
+
acls[perm] = FFI_Yajl::Parser.parse(request.body)[perm]
|
34
|
+
set_data(request, path, FFI_Yajl::Encoder.encode(acls, pretty: true))
|
35
|
+
json_response(200, { "uri" => (build_uri(request.base_uri, request.rest_path)).to_s })
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|