chef-zero 4.3.0 → 4.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +201 -201
  3. data/README.md +155 -155
  4. data/Rakefile +31 -31
  5. data/bin/chef-zero +100 -100
  6. data/lib/chef_zero.rb +10 -10
  7. data/lib/chef_zero/chef_data/acl_path.rb +139 -139
  8. data/lib/chef_zero/chef_data/cookbook_data.rb +240 -240
  9. data/lib/chef_zero/chef_data/data_normalizer.rb +208 -207
  10. data/lib/chef_zero/chef_data/default_creator.rb +446 -446
  11. data/lib/chef_zero/data_store/data_already_exists_error.rb +29 -29
  12. data/lib/chef_zero/data_store/data_error.rb +31 -31
  13. data/lib/chef_zero/data_store/data_not_found_error.rb +28 -28
  14. data/lib/chef_zero/data_store/default_facade.rb +149 -149
  15. data/lib/chef_zero/data_store/interface_v1.rb +67 -67
  16. data/lib/chef_zero/data_store/interface_v2.rb +18 -18
  17. data/lib/chef_zero/data_store/memory_store.rb +33 -33
  18. data/lib/chef_zero/data_store/memory_store_v2.rb +155 -155
  19. data/lib/chef_zero/data_store/raw_file_store.rb +147 -147
  20. data/lib/chef_zero/data_store/v1_to_v2_adapter.rb +142 -142
  21. data/lib/chef_zero/data_store/v2_to_v1_adapter.rb +107 -107
  22. data/lib/chef_zero/endpoints/acl_endpoint.rb +38 -38
  23. data/lib/chef_zero/endpoints/acls_endpoint.rb +29 -29
  24. data/lib/chef_zero/endpoints/actor_endpoint.rb +94 -94
  25. data/lib/chef_zero/endpoints/actors_endpoint.rb +64 -64
  26. data/lib/chef_zero/endpoints/authenticate_user_endpoint.rb +31 -31
  27. data/lib/chef_zero/endpoints/container_endpoint.rb +22 -22
  28. data/lib/chef_zero/endpoints/containers_endpoint.rb +13 -13
  29. data/lib/chef_zero/endpoints/cookbook_endpoint.rb +39 -39
  30. data/lib/chef_zero/endpoints/cookbook_version_endpoint.rb +119 -119
  31. data/lib/chef_zero/endpoints/cookbooks_base.rb +65 -65
  32. data/lib/chef_zero/endpoints/cookbooks_endpoint.rb +19 -19
  33. data/lib/chef_zero/endpoints/data_bag_endpoint.rb +45 -45
  34. data/lib/chef_zero/endpoints/data_bag_item_endpoint.rb +25 -25
  35. data/lib/chef_zero/endpoints/data_bags_endpoint.rb +23 -23
  36. data/lib/chef_zero/endpoints/environment_cookbook_endpoint.rb +24 -24
  37. data/lib/chef_zero/endpoints/environment_cookbook_versions_endpoint.rb +123 -123
  38. data/lib/chef_zero/endpoints/environment_cookbooks_endpoint.rb +22 -22
  39. data/lib/chef_zero/endpoints/environment_endpoint.rb +33 -33
  40. data/lib/chef_zero/endpoints/environment_nodes_endpoint.rb +23 -23
  41. data/lib/chef_zero/endpoints/environment_recipes_endpoint.rb +22 -22
  42. data/lib/chef_zero/endpoints/environment_role_endpoint.rb +36 -36
  43. data/lib/chef_zero/endpoints/file_store_file_endpoint.rb +22 -22
  44. data/lib/chef_zero/endpoints/group_endpoint.rb +20 -20
  45. data/lib/chef_zero/endpoints/groups_endpoint.rb +13 -13
  46. data/lib/chef_zero/endpoints/license_endpoint.rb +25 -25
  47. data/lib/chef_zero/endpoints/node_endpoint.rb +17 -17
  48. data/lib/chef_zero/endpoints/node_identifiers_endpoint.rb +22 -22
  49. data/lib/chef_zero/endpoints/not_found_endpoint.rb +11 -11
  50. data/lib/chef_zero/endpoints/organization_association_request_endpoint.rb +22 -22
  51. data/lib/chef_zero/endpoints/organization_association_requests_endpoint.rb +30 -30
  52. data/lib/chef_zero/endpoints/organization_authenticate_user_endpoint.rb +26 -26
  53. data/lib/chef_zero/endpoints/organization_endpoint.rb +46 -46
  54. data/lib/chef_zero/endpoints/organization_user_base.rb +15 -15
  55. data/lib/chef_zero/endpoints/organization_user_endpoint.rb +26 -26
  56. data/lib/chef_zero/endpoints/organization_users_endpoint.rb +43 -43
  57. data/lib/chef_zero/endpoints/organization_validator_key_endpoint.rb +20 -20
  58. data/lib/chef_zero/endpoints/organizations_endpoint.rb +62 -62
  59. data/lib/chef_zero/endpoints/policies_endpoint.rb +151 -151
  60. data/lib/chef_zero/endpoints/principal_endpoint.rb +42 -42
  61. data/lib/chef_zero/endpoints/rest_list_endpoint.rb +42 -42
  62. data/lib/chef_zero/endpoints/rest_object_endpoint.rb +63 -63
  63. data/lib/chef_zero/endpoints/role_endpoint.rb +16 -16
  64. data/lib/chef_zero/endpoints/role_environments_endpoint.rb +14 -14
  65. data/lib/chef_zero/endpoints/sandbox_endpoint.rb +27 -27
  66. data/lib/chef_zero/endpoints/sandboxes_endpoint.rb +50 -50
  67. data/lib/chef_zero/endpoints/search_endpoint.rb +194 -194
  68. data/lib/chef_zero/endpoints/searches_endpoint.rb +18 -18
  69. data/lib/chef_zero/endpoints/server_api_version_endpoint.rb +14 -14
  70. data/lib/chef_zero/endpoints/system_recovery_endpoint.rb +30 -30
  71. data/lib/chef_zero/endpoints/user_association_request_endpoint.rb +40 -40
  72. data/lib/chef_zero/endpoints/user_association_requests_count_endpoint.rb +19 -19
  73. data/lib/chef_zero/endpoints/user_association_requests_endpoint.rb +19 -19
  74. data/lib/chef_zero/endpoints/user_organizations_endpoint.rb +22 -22
  75. data/lib/chef_zero/endpoints/version_endpoint.rb +12 -12
  76. data/lib/chef_zero/log.rb +7 -7
  77. data/lib/chef_zero/rest_base.rb +242 -242
  78. data/lib/chef_zero/rest_error_response.rb +11 -11
  79. data/lib/chef_zero/rest_request.rb +69 -69
  80. data/lib/chef_zero/rest_router.rb +45 -45
  81. data/lib/chef_zero/rspec.rb +308 -308
  82. data/lib/chef_zero/server.rb +642 -642
  83. data/lib/chef_zero/socketless_server_map.rb +92 -92
  84. data/lib/chef_zero/solr/query/binary_operator.rb +52 -52
  85. data/lib/chef_zero/solr/query/phrase.rb +23 -23
  86. data/lib/chef_zero/solr/query/range_query.rb +46 -46
  87. data/lib/chef_zero/solr/query/regexpable_query.rb +29 -29
  88. data/lib/chef_zero/solr/query/subquery.rb +37 -37
  89. data/lib/chef_zero/solr/query/term.rb +45 -45
  90. data/lib/chef_zero/solr/query/unary_operator.rb +43 -43
  91. data/lib/chef_zero/solr/solr_doc.rb +53 -53
  92. data/lib/chef_zero/solr/solr_parser.rb +203 -203
  93. data/lib/chef_zero/version.rb +3 -3
  94. data/spec/run_oc_pedant.rb +63 -63
  95. data/spec/search_spec.rb +32 -32
  96. data/spec/server_spec.rb +92 -92
  97. data/spec/socketless_server_map_spec.rb +76 -76
  98. data/spec/support/oc_pedant.rb +132 -132
  99. data/spec/support/stickywicket.pem +27 -27
  100. metadata +3 -3
@@ -1,29 +1,29 @@
1
- #
2
- # Author:: John Keiser (<jkeiser@opscode.com>)
3
- # Copyright:: Copyright (c) 2013 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
- # http://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 'chef_zero/data_store/data_error'
20
-
21
- module ChefZero
22
- module DataStore
23
- class DataAlreadyExistsError < DataError
24
- def initialize(path, cause = nil)
25
- super
26
- end
27
- end
28
- end
29
- end
1
+ #
2
+ # Author:: John Keiser (<jkeiser@opscode.com>)
3
+ # Copyright:: Copyright (c) 2013 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
+ # http://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 'chef_zero/data_store/data_error'
20
+
21
+ module ChefZero
22
+ module DataStore
23
+ class DataAlreadyExistsError < DataError
24
+ def initialize(path, cause = nil)
25
+ super
26
+ end
27
+ end
28
+ end
29
+ end
@@ -1,31 +1,31 @@
1
- #
2
- # Author:: John Keiser (<jkeiser@opscode.com>)
3
- # Copyright:: Copyright (c) 2013 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
- # http://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
- module ChefZero
20
- module DataStore
21
- class DataError < StandardError
22
- def initialize(path, cause = nil)
23
- @path = path
24
- @cause = cause
25
- end
26
-
27
- attr_reader :path
28
- attr_reader :cause
29
- end
30
- end
31
- end
1
+ #
2
+ # Author:: John Keiser (<jkeiser@opscode.com>)
3
+ # Copyright:: Copyright (c) 2013 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
+ # http://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
+ module ChefZero
20
+ module DataStore
21
+ class DataError < StandardError
22
+ def initialize(path, cause = nil)
23
+ @path = path
24
+ @cause = cause
25
+ end
26
+
27
+ attr_reader :path
28
+ attr_reader :cause
29
+ end
30
+ end
31
+ end
@@ -1,29 +1,29 @@
1
- #
2
- # Author:: John Keiser (<jkeiser@opscode.com>)
3
- # Copyright:: Copyright (c) 2013 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
- # http://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 'chef_zero/data_store/data_error'
20
-
21
- module ChefZero
22
- module DataStore
23
- class DataNotFoundError < DataError
24
- def initialize(path, cause = nil)
25
- super
26
- end
27
- end
28
- end
1
+ #
2
+ # Author:: John Keiser (<jkeiser@opscode.com>)
3
+ # Copyright:: Copyright (c) 2013 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
+ # http://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 'chef_zero/data_store/data_error'
20
+
21
+ module ChefZero
22
+ module DataStore
23
+ class DataNotFoundError < DataError
24
+ def initialize(path, cause = nil)
25
+ super
26
+ end
27
+ end
28
+ end
29
29
  end
@@ -1,149 +1,149 @@
1
- require 'chef_zero/data_store/interface_v2'
2
- require 'chef_zero/chef_data/default_creator'
3
-
4
- module ChefZero
5
- module DataStore
6
- #
7
- # The DefaultFacade exists to layer defaults on top of an existing data
8
- # store. When you create an org, you just create the directory itself:
9
- # the rest of the org (such as environments/_default) will not actually
10
- # exist anywhere, but when you get(/organizations/org/environments/_default),
11
- # the DefaultFacade will create one for you on the fly.
12
- #
13
- # acls in particular are instantiated on the fly using this method.
14
- #
15
- class DefaultFacade < ChefZero::DataStore::InterfaceV2
16
- def initialize(real_store, single_org, osc_compat, superusers = nil)
17
- @real_store = real_store
18
- @default_creator = ChefData::DefaultCreator.new(self, single_org, osc_compat, superusers)
19
- clear
20
- end
21
-
22
- attr_reader :real_store
23
- attr_reader :default_creator
24
-
25
- def clear
26
- real_store.clear if real_store.respond_to?(:clear)
27
- default_creator.clear
28
- end
29
-
30
- def create_dir(path, name, *options)
31
- if default_creator.exists?(path + [ name ]) && !options.include?(:recursive)
32
- raise DataAlreadyExistsError.new(path + [name])
33
- end
34
-
35
- begin
36
- real_store.create_dir(path, name, *options)
37
- rescue DataNotFoundError
38
- if default_creator.exists?(path)
39
- real_store.create_dir(path, name, :recursive, *options)
40
- else
41
- raise
42
- end
43
- end
44
-
45
- options_hash = options.last.is_a?(Hash) ? options.last : {}
46
- default_creator.created(path + [ name ], options_hash[:requestor], options.include?(:recursive))
47
- end
48
-
49
- def create(path, name, data, *options)
50
- if default_creator.exists?(path + [ name ]) && !options.include?(:create_dir)
51
- raise DataAlreadyExistsError.new(path + [name])
52
- end
53
-
54
- begin
55
- real_store.create(path, name, data, *options)
56
- rescue DataNotFoundError
57
- if default_creator.exists?(path)
58
- real_store.create(path, name, data, :create_dir, *options)
59
- else
60
- raise
61
- end
62
- end
63
-
64
- options_hash = options.last.is_a?(Hash) ? options.last : {}
65
- default_creator.created(path + [ name ], options_hash[:requestor], options.include?(:recursive))
66
- end
67
-
68
- def get(path, request=nil)
69
- begin
70
- real_store.get(path, request)
71
- rescue DataNotFoundError
72
- result = default_creator.get(path)
73
- if result
74
- FFI_Yajl::Encoder.encode(result, :pretty => true)
75
- else
76
- raise
77
- end
78
- end
79
- end
80
-
81
- def set(path, data, *options)
82
- begin
83
- real_store.set(path, data, *options)
84
- rescue DataNotFoundError
85
- if options.include?(:create_dir) ||
86
- options.include?(:create) && default_creator.exists?(path[0..-2]) ||
87
- default_creator.exists?(path)
88
- real_store.set(path, data, :create, :create_dir, *options)
89
- else
90
- raise
91
- end
92
- end
93
-
94
- if options.include?(:create)
95
- options_hash = options.last.is_a?(Hash) ? options.last : {}
96
- default_creator.created(path, options_hash[:requestor], options.include?(:create_dir))
97
- end
98
- end
99
-
100
- def delete(path, *options)
101
- deleted = default_creator.deleted(path)
102
- begin
103
- real_store.delete(path)
104
- rescue DataNotFoundError
105
- if !deleted
106
- raise
107
- end
108
- end
109
- end
110
-
111
- def delete_dir(path, *options)
112
- deleted = default_creator.deleted(path)
113
- begin
114
- real_store.delete_dir(path, *options)
115
- rescue DataNotFoundError
116
- if !deleted
117
- raise
118
- end
119
- end
120
- end
121
-
122
- def list(path)
123
- default_results = default_creator.list(path)
124
- begin
125
- real_results = real_store.list(path)
126
- if default_results
127
- (real_results + default_results).uniq
128
- else
129
- real_results
130
- end
131
- rescue DataNotFoundError
132
- if default_results
133
- default_results
134
- else
135
- raise
136
- end
137
- end
138
- end
139
-
140
- def exists?(path)
141
- real_store.exists?(path) || default_creator.exists?(path)
142
- end
143
-
144
- def exists_dir?(path)
145
- real_store.exists_dir?(path) || default_creator.exists?(path)
146
- end
147
- end
148
- end
149
- end
1
+ require 'chef_zero/data_store/interface_v2'
2
+ require 'chef_zero/chef_data/default_creator'
3
+
4
+ module ChefZero
5
+ module DataStore
6
+ #
7
+ # The DefaultFacade exists to layer defaults on top of an existing data
8
+ # store. When you create an org, you just create the directory itself:
9
+ # the rest of the org (such as environments/_default) will not actually
10
+ # exist anywhere, but when you get(/organizations/org/environments/_default),
11
+ # the DefaultFacade will create one for you on the fly.
12
+ #
13
+ # acls in particular are instantiated on the fly using this method.
14
+ #
15
+ class DefaultFacade < ChefZero::DataStore::InterfaceV2
16
+ def initialize(real_store, single_org, osc_compat, superusers = nil)
17
+ @real_store = real_store
18
+ @default_creator = ChefData::DefaultCreator.new(self, single_org, osc_compat, superusers)
19
+ clear
20
+ end
21
+
22
+ attr_reader :real_store
23
+ attr_reader :default_creator
24
+
25
+ def clear
26
+ real_store.clear if real_store.respond_to?(:clear)
27
+ default_creator.clear
28
+ end
29
+
30
+ def create_dir(path, name, *options)
31
+ if default_creator.exists?(path + [ name ]) && !options.include?(:recursive)
32
+ raise DataAlreadyExistsError.new(path + [name])
33
+ end
34
+
35
+ begin
36
+ real_store.create_dir(path, name, *options)
37
+ rescue DataNotFoundError
38
+ if default_creator.exists?(path)
39
+ real_store.create_dir(path, name, :recursive, *options)
40
+ else
41
+ raise
42
+ end
43
+ end
44
+
45
+ options_hash = options.last.is_a?(Hash) ? options.last : {}
46
+ default_creator.created(path + [ name ], options_hash[:requestor], options.include?(:recursive))
47
+ end
48
+
49
+ def create(path, name, data, *options)
50
+ if default_creator.exists?(path + [ name ]) && !options.include?(:create_dir)
51
+ raise DataAlreadyExistsError.new(path + [name])
52
+ end
53
+
54
+ begin
55
+ real_store.create(path, name, data, *options)
56
+ rescue DataNotFoundError
57
+ if default_creator.exists?(path)
58
+ real_store.create(path, name, data, :create_dir, *options)
59
+ else
60
+ raise
61
+ end
62
+ end
63
+
64
+ options_hash = options.last.is_a?(Hash) ? options.last : {}
65
+ default_creator.created(path + [ name ], options_hash[:requestor], options.include?(:recursive))
66
+ end
67
+
68
+ def get(path, request=nil)
69
+ begin
70
+ real_store.get(path, request)
71
+ rescue DataNotFoundError
72
+ result = default_creator.get(path)
73
+ if result
74
+ FFI_Yajl::Encoder.encode(result, :pretty => true)
75
+ else
76
+ raise
77
+ end
78
+ end
79
+ end
80
+
81
+ def set(path, data, *options)
82
+ begin
83
+ real_store.set(path, data, *options)
84
+ rescue DataNotFoundError
85
+ if options.include?(:create_dir) ||
86
+ options.include?(:create) && default_creator.exists?(path[0..-2]) ||
87
+ default_creator.exists?(path)
88
+ real_store.set(path, data, :create, :create_dir, *options)
89
+ else
90
+ raise
91
+ end
92
+ end
93
+
94
+ if options.include?(:create)
95
+ options_hash = options.last.is_a?(Hash) ? options.last : {}
96
+ default_creator.created(path, options_hash[:requestor], options.include?(:create_dir))
97
+ end
98
+ end
99
+
100
+ def delete(path, *options)
101
+ deleted = default_creator.deleted(path)
102
+ begin
103
+ real_store.delete(path)
104
+ rescue DataNotFoundError
105
+ if !deleted
106
+ raise
107
+ end
108
+ end
109
+ end
110
+
111
+ def delete_dir(path, *options)
112
+ deleted = default_creator.deleted(path)
113
+ begin
114
+ real_store.delete_dir(path, *options)
115
+ rescue DataNotFoundError
116
+ if !deleted
117
+ raise
118
+ end
119
+ end
120
+ end
121
+
122
+ def list(path)
123
+ default_results = default_creator.list(path)
124
+ begin
125
+ real_results = real_store.list(path)
126
+ if default_results
127
+ (real_results + default_results).uniq
128
+ else
129
+ real_results
130
+ end
131
+ rescue DataNotFoundError
132
+ if default_results
133
+ default_results
134
+ else
135
+ raise
136
+ end
137
+ end
138
+ end
139
+
140
+ def exists?(path)
141
+ real_store.exists?(path) || default_creator.exists?(path)
142
+ end
143
+
144
+ def exists_dir?(path)
145
+ real_store.exists_dir?(path) || default_creator.exists?(path)
146
+ end
147
+ end
148
+ end
149
+ end