knife-essentials 1.0.0.beta2 → 1.0.0.beta3
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.
- data/lib/chef_fs/data_handler/data_bag_item_data_handler.rb +10 -0
- data/lib/chef_fs/file_system/chef_server_root_dir.rb +2 -1
- data/lib/chef_fs/file_system/containers_dir.rb +33 -0
- data/lib/chef_fs/file_system/data_bag_dir.rb +0 -5
- data/lib/chef_fs/file_system/rest_list_entry.rb +6 -2
- data/lib/chef_fs/knife.rb +1 -1
- data/lib/chef_fs/parallelizer.rb +1 -1
- data/lib/chef_fs/version.rb +1 -1
- metadata +3 -3
- data/lib/chef_fs/file_system/data_bag_item.rb +0 -63
@@ -18,6 +18,16 @@ module ChefFS
|
|
18
18
|
})
|
19
19
|
end
|
20
20
|
|
21
|
+
def normalize_for_put(data_bag_item, entry)
|
22
|
+
{
|
23
|
+
"name" => "data_bag_item_#{entry.parent.name}_#{entry.name}",
|
24
|
+
"json_class" => "Chef::DataBagItem",
|
25
|
+
"chef_type" => "data_bag_item",
|
26
|
+
"data_bag" => entry.parent.name,
|
27
|
+
"raw_data" => normalize(data_bag_item)
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
21
31
|
def preserve_key(key)
|
22
32
|
return key == 'id'
|
23
33
|
end
|
@@ -19,6 +19,7 @@
|
|
19
19
|
require 'chef_fs/file_system/acls_dir'
|
20
20
|
require 'chef_fs/file_system/base_fs_dir'
|
21
21
|
require 'chef_fs/file_system/rest_list_dir'
|
22
|
+
require 'chef_fs/file_system/containers_dir'
|
22
23
|
require 'chef_fs/file_system/cookbooks_dir'
|
23
24
|
require 'chef_fs/file_system/data_bags_dir'
|
24
25
|
require 'chef_fs/file_system/nodes_dir'
|
@@ -85,7 +86,7 @@ module ChefFS
|
|
85
86
|
result += [
|
86
87
|
AclsDir.new(self),
|
87
88
|
RestListDir.new("clients", self, nil, ChefFS::DataHandler::ClientDataHandler.new),
|
88
|
-
|
89
|
+
ContainersDir.new(self),
|
89
90
|
RestListDir.new("groups", self, nil, ChefFS::DataHandler::GroupDataHandler.new),
|
90
91
|
NodesDir.new(self)
|
91
92
|
]
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#
|
2
|
+
# Author:: John Keiser (<jkeiser@opscode.com>)
|
3
|
+
# Copyright:: Copyright (c) 2012 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_fs/file_system/rest_list_entry'
|
20
|
+
|
21
|
+
module ChefFS
|
22
|
+
module FileSystem
|
23
|
+
class ContainersDir < RestListDir
|
24
|
+
def initialize(parent)
|
25
|
+
super("containers", parent, nil, ChefFS::DataHandler::ContainerDataHandler.new)
|
26
|
+
end
|
27
|
+
|
28
|
+
def identity_key
|
29
|
+
'containername'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -17,7 +17,6 @@
|
|
17
17
|
#
|
18
18
|
|
19
19
|
require 'chef_fs/file_system/rest_list_dir'
|
20
|
-
require 'chef_fs/file_system/data_bag_item'
|
21
20
|
require 'chef_fs/file_system/not_found_error'
|
22
21
|
require 'chef_fs/file_system/must_delete_recursively_error'
|
23
22
|
require 'chef_fs/data_handler/data_bag_item_data_handler'
|
@@ -50,10 +49,6 @@ module ChefFS
|
|
50
49
|
'id'
|
51
50
|
end
|
52
51
|
|
53
|
-
def _make_child_entry(name, exists = nil)
|
54
|
-
DataBagItem.new(name, self, exists)
|
55
|
-
end
|
56
|
-
|
57
52
|
def delete(recurse)
|
58
53
|
if !recurse
|
59
54
|
raise NotFoundError.new(self) if !exists?
|
@@ -141,6 +141,10 @@ module ChefFS
|
|
141
141
|
parent.rest
|
142
142
|
end
|
143
143
|
|
144
|
+
def identity_key
|
145
|
+
parent.identity_key
|
146
|
+
end
|
147
|
+
|
144
148
|
def write(file_contents)
|
145
149
|
begin
|
146
150
|
#object = Chef::JSONCompat.from_json(file_contents).to_hash
|
@@ -153,8 +157,8 @@ module ChefFS
|
|
153
157
|
object = data_handler.normalize_for_put(object, self)
|
154
158
|
end
|
155
159
|
|
156
|
-
base_name = name[0,name.length-5]
|
157
|
-
if object[
|
160
|
+
base_name = name[0,name.length-5] # Strip ".json"
|
161
|
+
if object[identity_key] != base_name
|
158
162
|
raise ChefFS::FileSystem::OperationFailedError.new(:write, self), "Name in #{path_for_printing}/#{name} must be '#{base_name}' (is '#{object['name']}')"
|
159
163
|
end
|
160
164
|
|
data/lib/chef_fs/knife.rb
CHANGED
@@ -73,7 +73,7 @@ module ChefFS
|
|
73
73
|
|
74
74
|
# Default to getting *everything* from the server.
|
75
75
|
if !Chef::Config[:repo_mode]
|
76
|
-
if Chef::Config[:chef_server_url] =~
|
76
|
+
if Chef::Config[:chef_server_url] =~ /\/+organizations\/.+/
|
77
77
|
Chef::Config[:repo_mode] = 'hosted_everything'
|
78
78
|
else
|
79
79
|
Chef::Config[:repo_mode] = 'everything'
|
data/lib/chef_fs/parallelizer.rb
CHANGED
data/lib/chef_fs/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-essentials
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.beta3
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: chef-zero
|
@@ -87,13 +87,13 @@ files:
|
|
87
87
|
- lib/chef_fs/file_system/chef_repository_file_system_entry.rb
|
88
88
|
- lib/chef_fs/file_system/chef_repository_file_system_root_dir.rb
|
89
89
|
- lib/chef_fs/file_system/chef_server_root_dir.rb
|
90
|
+
- lib/chef_fs/file_system/containers_dir.rb
|
90
91
|
- lib/chef_fs/file_system/cookbook_dir.rb
|
91
92
|
- lib/chef_fs/file_system/cookbook_file.rb
|
92
93
|
- lib/chef_fs/file_system/cookbook_subdir.rb
|
93
94
|
- lib/chef_fs/file_system/cookbooks_acl_dir.rb
|
94
95
|
- lib/chef_fs/file_system/cookbooks_dir.rb
|
95
96
|
- lib/chef_fs/file_system/data_bag_dir.rb
|
96
|
-
- lib/chef_fs/file_system/data_bag_item.rb
|
97
97
|
- lib/chef_fs/file_system/data_bags_dir.rb
|
98
98
|
- lib/chef_fs/file_system/default_environment_cannot_be_modified_error.rb
|
99
99
|
- lib/chef_fs/file_system/environments_dir.rb
|
@@ -1,63 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: John Keiser (<jkeiser@opscode.com>)
|
3
|
-
# Copyright:: Copyright (c) 2012 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_fs/file_system/rest_list_entry'
|
20
|
-
|
21
|
-
module ChefFS
|
22
|
-
module FileSystem
|
23
|
-
class DataBagItem < RestListEntry
|
24
|
-
def initialize(name, parent, exists = nil)
|
25
|
-
super(name, parent, exists)
|
26
|
-
end
|
27
|
-
|
28
|
-
def write(file_contents)
|
29
|
-
# Write is just a little tiny bit different for data bags:
|
30
|
-
# you set raw_data in the JSON instead of putting the items
|
31
|
-
# in the top level.
|
32
|
-
json = Chef::JSONCompat.from_json(file_contents).to_hash
|
33
|
-
id = name[0,name.length-5] # Strip off the .json from the end
|
34
|
-
if json['id'] != id
|
35
|
-
raise "Id in #{path_for_printing}/#{name} must be '#{id}' (is '#{json['id']}')"
|
36
|
-
end
|
37
|
-
begin
|
38
|
-
data_bag = parent.name
|
39
|
-
json = {
|
40
|
-
"name" => "data_bag_item_#{data_bag}_#{id}",
|
41
|
-
"json_class" => "Chef::DataBagItem",
|
42
|
-
"chef_type" => "data_bag_item",
|
43
|
-
"data_bag" => data_bag,
|
44
|
-
"raw_data" => json
|
45
|
-
}
|
46
|
-
rest.put_rest(api_path, json)
|
47
|
-
rescue Net::HTTPServerException
|
48
|
-
if $!.response.code == "404"
|
49
|
-
raise ChefFS::FileSystem::NotFoundError.new(self, $!)
|
50
|
-
else
|
51
|
-
raise
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def normalize_value(value)
|
57
|
-
data_handler.minimize(
|
58
|
-
data_handler.normalize(value, parent.name, api_child_name),
|
59
|
-
parent.name, api_child_name)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|