diff options
author | John Keiser <jkeiser@opscode.com> | 2013-06-12 09:00:16 -0700 |
---|---|---|
committer | John Keiser <jkeiser@opscode.com> | 2013-06-12 09:00:16 -0700 |
commit | de4d8e66be3dee3ccd9ac027e6332e0eb37f532e (patch) | |
tree | a5e0a5446eb8ce58430ec25e4ed556a1ec8fc864 /lib | |
parent | 74a8fb235aca3891e9e46630ce5db0a4230947ef (diff) | |
download | chef-de4d8e66be3dee3ccd9ac027e6332e0eb37f532e.tar.gz |
CHEF-4233: get rid of extra chef_type/data_bag keys added to data bag in knife upload
Diffstat (limited to 'lib')
12 files changed, 19 insertions, 22 deletions
diff --git a/lib/chef/chef_fs/chef_fs_data_store.rb b/lib/chef/chef_fs/chef_fs_data_store.rb index bd8226b92f..c1c5a81e04 100644 --- a/lib/chef/chef_fs/chef_fs_data_store.rb +++ b/lib/chef/chef_fs/chef_fs_data_store.rb @@ -36,11 +36,7 @@ class Chef "Reading and writing data to #{chef_fs.fs_description}" end - def chef_fs - @chef_fs.call - end - - MEMORY_PATHS = %w(sandboxes file_store) + attr_reader :chef_fs def create_dir(path, name, *options) if use_memory_store?(path) diff --git a/lib/chef/chef_fs/data_handler/acl_data_handler.rb b/lib/chef/chef_fs/data_handler/acl_data_handler.rb index 64fed7cac6..5ce4e335f4 100644 --- a/lib/chef/chef_fs/data_handler/acl_data_handler.rb +++ b/lib/chef/chef_fs/data_handler/acl_data_handler.rb @@ -6,7 +6,7 @@ class Chef class AclDataHandler < DataHandlerBase def normalize(node, entry) # Normalize the order of the keys for easier reading - result = super(node, { + result = normalize_hash(node, { 'create' => {}, 'read' => {}, 'update' => {}, @@ -14,7 +14,7 @@ class Chef 'grant' => {} }) result.keys.each do |key| - result[key] = super(result[key], { 'actors' => [], 'groups' => [] }) + result[key] = normalize_hash(result[key], { 'actors' => [], 'groups' => [] }) result[key]['actors'] = result[key]['actors'].sort result[key]['groups'] = result[key]['groups'].sort end diff --git a/lib/chef/chef_fs/data_handler/client_data_handler.rb b/lib/chef/chef_fs/data_handler/client_data_handler.rb index a92e486782..2db3fa897f 100644 --- a/lib/chef/chef_fs/data_handler/client_data_handler.rb +++ b/lib/chef/chef_fs/data_handler/client_data_handler.rb @@ -17,7 +17,7 @@ class Chef if entry.org defaults['orgname'] = entry.org end - result = super(client, defaults) + result = normalize_hash(client, defaults) # You can NOT send json_class, or it will fail result.delete('json_class') result diff --git a/lib/chef/chef_fs/data_handler/container_data_handler.rb b/lib/chef/chef_fs/data_handler/container_data_handler.rb index 714f83824a..8b108bcf73 100644 --- a/lib/chef/chef_fs/data_handler/container_data_handler.rb +++ b/lib/chef/chef_fs/data_handler/container_data_handler.rb @@ -5,7 +5,7 @@ class Chef module DataHandler class ContainerDataHandler < DataHandlerBase def normalize(container, entry) - super(container, { + normalize_hash(container, { 'containername' => remove_dot_json(entry.name), 'containerpath' => remove_dot_json(entry.name) }) diff --git a/lib/chef/chef_fs/data_handler/cookbook_data_handler.rb b/lib/chef/chef_fs/data_handler/cookbook_data_handler.rb index d0333db48f..d2e2a3ef6c 100644 --- a/lib/chef/chef_fs/data_handler/cookbook_data_handler.rb +++ b/lib/chef/chef_fs/data_handler/cookbook_data_handler.rb @@ -8,7 +8,7 @@ class Chef def normalize(cookbook, entry) version = entry.name name = entry.parent.name - result = super(cookbook, { + result = normalize_hash(cookbook, { 'name' => "#{name}-#{version}", 'version' => version, 'cookbook_name' => name, @@ -17,7 +17,7 @@ class Chef 'frozen?' => false, 'metadata' => {} }) - result['metadata'] = super(result['metadata'], { + result['metadata'] = normalize_hash(result['metadata'], { 'version' => version, 'name' => name }) diff --git a/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb b/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb index 1f466ec5ac..240a42756d 100644 --- a/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb +++ b/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb @@ -10,16 +10,17 @@ class Chef if data_bag_item['json_class'] == 'Chef::DataBagItem' && data_bag_item['raw_data'] data_bag_item = data_bag_item['raw_data'] end - # chef_type and data_bag only come back from PUT and POST, but we'll - # normalize them in in case someone is comparing with those results. - super(data_bag_item, { - 'chef_type' => 'data_bag_item', - 'data_bag' => entry.parent.name, + # chef_type and data_bag come back in PUT and POST results, but we don't + # use those in knife-essentials. + normalize_hash(data_bag_item, { 'id' => remove_dot_json(entry.name) }) end def normalize_for_post(data_bag_item, entry) + if data_bag_item['json_class'] == 'Chef::DataBagItem' && data_bag_item['raw_data'] + data_bag_item = data_bag_item['raw_data'] + end { "name" => "data_bag_item_#{entry.parent.name}_#{remove_dot_json(entry.name)}", "json_class" => "Chef::DataBagItem", diff --git a/lib/chef/chef_fs/data_handler/data_handler_base.rb b/lib/chef/chef_fs/data_handler/data_handler_base.rb index 11e5bae31c..a9bbc0bf1b 100644 --- a/lib/chef/chef_fs/data_handler/data_handler_base.rb +++ b/lib/chef/chef_fs/data_handler/data_handler_base.rb @@ -27,7 +27,7 @@ class Chef normalize({}, entry) end - def normalize(object, defaults) + def normalize_hash(object, defaults) # Make a normalized result in the specified order for diffing result = {} defaults.each_pair do |key, default| diff --git a/lib/chef/chef_fs/data_handler/environment_data_handler.rb b/lib/chef/chef_fs/data_handler/environment_data_handler.rb index 6b13615968..9da10ebfa5 100644 --- a/lib/chef/chef_fs/data_handler/environment_data_handler.rb +++ b/lib/chef/chef_fs/data_handler/environment_data_handler.rb @@ -6,7 +6,7 @@ class Chef module DataHandler class EnvironmentDataHandler < DataHandlerBase def normalize(environment, entry) - super(environment, { + normalize_hash(environment, { 'name' => remove_dot_json(entry.name), 'description' => '', 'cookbook_versions' => {}, diff --git a/lib/chef/chef_fs/data_handler/group_data_handler.rb b/lib/chef/chef_fs/data_handler/group_data_handler.rb index b27bf87c50..619822fe70 100644 --- a/lib/chef/chef_fs/data_handler/group_data_handler.rb +++ b/lib/chef/chef_fs/data_handler/group_data_handler.rb @@ -16,7 +16,7 @@ class Chef if entry.org defaults['orgname'] = entry.org end - result = super(group, defaults) + result = normalize_hash(group, defaults) if result['actors'] && result['actors'].sort.uniq == (result['users'] + result['clients']).sort.uniq result.delete('actors') end diff --git a/lib/chef/chef_fs/data_handler/node_data_handler.rb b/lib/chef/chef_fs/data_handler/node_data_handler.rb index 13e60e4fc1..f2c97c734f 100644 --- a/lib/chef/chef_fs/data_handler/node_data_handler.rb +++ b/lib/chef/chef_fs/data_handler/node_data_handler.rb @@ -6,7 +6,7 @@ class Chef module DataHandler class NodeDataHandler < DataHandlerBase def normalize(node, entry) - result = super(node, { + result = normalize_hash(node, { 'name' => remove_dot_json(entry.name), 'json_class' => 'Chef::Node', 'chef_type' => 'node', diff --git a/lib/chef/chef_fs/data_handler/role_data_handler.rb b/lib/chef/chef_fs/data_handler/role_data_handler.rb index c803449862..bc1c076280 100644 --- a/lib/chef/chef_fs/data_handler/role_data_handler.rb +++ b/lib/chef/chef_fs/data_handler/role_data_handler.rb @@ -6,7 +6,7 @@ class Chef module DataHandler class RoleDataHandler < DataHandlerBase def normalize(role, entry) - result = super(role, { + result = normalize_hash(role, { 'name' => remove_dot_json(entry.name), 'description' => '', 'json_class' => 'Chef::Role', diff --git a/lib/chef/chef_fs/data_handler/user_data_handler.rb b/lib/chef/chef_fs/data_handler/user_data_handler.rb index 7bbb87645b..66a780690a 100644 --- a/lib/chef/chef_fs/data_handler/user_data_handler.rb +++ b/lib/chef/chef_fs/data_handler/user_data_handler.rb @@ -5,7 +5,7 @@ class Chef module DataHandler class UserDataHandler < DataHandlerBase def normalize(user, entry) - super(user, { + normalize_hash(user, { 'name' => remove_dot_json(entry.name), 'admin' => false, 'json_class' => 'Chef::WebUIUser', |