diff options
Diffstat (limited to 'lib/chef/chef_fs/data_handler')
16 files changed, 140 insertions, 140 deletions
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 6096b6e43c..91e48101c4 100644 --- a/lib/chef/chef_fs/data_handler/acl_data_handler.rb +++ b/lib/chef/chef_fs/data_handler/acl_data_handler.rb @@ -1,4 +1,4 @@ -require 'chef/chef_fs/data_handler/data_handler_base' +require "chef/chef_fs/data_handler/data_handler_base" class Chef module ChefFS @@ -7,16 +7,16 @@ class Chef def normalize(acl, entry) # Normalize the order of the keys for easier reading result = normalize_hash(acl, { - 'create' => {}, - 'read' => {}, - 'update' => {}, - 'delete' => {}, - 'grant' => {}, + "create" => {}, + "read" => {}, + "update" => {}, + "delete" => {}, + "grant" => {}, },) result.keys.each do |key| - result[key] = normalize_hash(result[key], { 'actors' => [], 'groups' => [] }) - result[key]['actors'] = result[key]['actors'].sort - result[key]['groups'] = result[key]['groups'].sort + result[key] = normalize_hash(result[key], { "actors" => [], "groups" => [] }) + result[key]["actors"] = result[key]["actors"].sort + result[key]["groups"] = result[key]["groups"].sort end result 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 421a463c2f..5e120035ac 100644 --- a/lib/chef/chef_fs/data_handler/client_data_handler.rb +++ b/lib/chef/chef_fs/data_handler/client_data_handler.rb @@ -1,5 +1,5 @@ -require 'chef/chef_fs/data_handler/data_handler_base' -require 'chef/api_client' +require "chef/chef_fs/data_handler/data_handler_base" +require "chef/api_client" class Chef module ChefFS @@ -7,25 +7,25 @@ class Chef class ClientDataHandler < DataHandlerBase def normalize(client, entry) defaults = { - 'name' => remove_dot_json(entry.name), - 'clientname' => remove_dot_json(entry.name), - 'admin' => false, - 'validator' => false, - 'chef_type' => 'client', + "name" => remove_dot_json(entry.name), + "clientname" => remove_dot_json(entry.name), + "admin" => false, + "validator" => false, + "chef_type" => "client", } # Handle the fact that admin/validator have changed type from string -> boolean - client['admin'] = (client['admin'] == 'true') if client['admin'].is_a?(String) - client['validator'] = (client['validator'] == 'true') if client['validator'].is_a?(String) + client["admin"] = (client["admin"] == "true") if client["admin"].is_a?(String) + client["validator"] = (client["validator"] == "true") if client["validator"].is_a?(String) if entry.respond_to?(:org) && entry.org - defaults['orgname'] = entry.org + defaults["orgname"] = entry.org end result = normalize_hash(client, defaults) - result.delete('json_class') + result.delete("json_class") result end def preserve_key?(key) - return key == 'name' + return key == "name" end def chef_class 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 f03005f947..d1e8d2f3af 100644 --- a/lib/chef/chef_fs/data_handler/container_data_handler.rb +++ b/lib/chef/chef_fs/data_handler/container_data_handler.rb @@ -1,4 +1,4 @@ -require 'chef/chef_fs/data_handler/data_handler_base' +require "chef/chef_fs/data_handler/data_handler_base" class Chef module ChefFS @@ -6,18 +6,18 @@ class Chef class ContainerDataHandler < DataHandlerBase def normalize(container, entry) normalize_hash(container, { - 'containername' => remove_dot_json(entry.name), - 'containerpath' => remove_dot_json(entry.name), + "containername" => remove_dot_json(entry.name), + "containerpath" => remove_dot_json(entry.name), },) end def preserve_key?(key) - return key == 'containername' + return key == "containername" end def verify_integrity(object, entry, &on_error) base_name = remove_dot_json(entry.name) - if object['containername'] != base_name + if object["containername"] != base_name on_error.call("Name in #{entry.path_for_printing} must be '#{base_name}' (is '#{object['name']}')") end end 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 0f2cad7983..f75f96f773 100644 --- a/lib/chef/chef_fs/data_handler/cookbook_data_handler.rb +++ b/lib/chef/chef_fs/data_handler/cookbook_data_handler.rb @@ -1,5 +1,5 @@ -require 'chef/chef_fs/data_handler/data_handler_base' -require 'chef/cookbook/metadata' +require "chef/chef_fs/data_handler/data_handler_base" +require "chef/cookbook/metadata" class Chef module ChefFS @@ -9,22 +9,22 @@ class Chef version = entry.name name = entry.parent.name result = normalize_hash(cookbook, { - 'name' => "#{name}-#{version}", - 'version' => version, - 'cookbook_name' => name, - 'json_class' => 'Chef::CookbookVersion', - 'chef_type' => 'cookbook_version', - 'frozen?' => false, - 'metadata' => {}, + "name" => "#{name}-#{version}", + "version" => version, + "cookbook_name" => name, + "json_class" => "Chef::CookbookVersion", + "chef_type" => "cookbook_version", + "frozen?" => false, + "metadata" => {}, },) - result['metadata'] = normalize_hash(result['metadata'], { - 'version' => version, - 'name' => name, + result["metadata"] = normalize_hash(result["metadata"], { + "version" => version, + "name" => name, },) end def preserve_key?(key) - return key == 'cookbook_name' || key == 'version' + return key == "cookbook_name" || key == "version" end def chef_class 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 e2d0f43de2..d56f662c5c 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 @@ -1,5 +1,5 @@ -require 'chef/chef_fs/data_handler/data_handler_base' -require 'chef/data_bag_item' +require "chef/chef_fs/data_handler/data_handler_base" +require "chef/data_bag_item" class Chef module ChefFS @@ -7,19 +7,19 @@ class Chef class DataBagItemDataHandler < DataHandlerBase def normalize(data_bag_item, entry) # If it's wrapped with raw_data, unwrap it. - if data_bag_item['json_class'] == 'Chef::DataBagItem' && data_bag_item['raw_data'] - data_bag_item = data_bag_item['raw_data'] + 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 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) + "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'] + 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)}", @@ -35,7 +35,7 @@ class Chef end def preserve_key?(key) - return key == 'id' + return key == "id" end def chef_class @@ -44,7 +44,7 @@ class Chef def verify_integrity(object, entry, &on_error) base_name = remove_dot_json(entry.name) - if object['raw_data']['id'] != base_name + if object["raw_data"]["id"] != base_name on_error.call("ID in #{entry.path_for_printing} must be '#{base_name}' (is '#{object['raw_data']['id']}')") end end 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 a3dc92405c..53936979e3 100644 --- a/lib/chef/chef_fs/data_handler/data_handler_base.rb +++ b/lib/chef/chef_fs/data_handler/data_handler_base.rb @@ -147,7 +147,7 @@ class Chef # environment "desert"' # def to_ruby_keys(object, keys) - result = '' + result = "" keys.each do |key| if object[key] if object[key].is_a?(Hash) @@ -158,7 +158,7 @@ class Chef if first first = false else - result << ' '*key.length + result << " "*key.length end result << " #{k.inspect} => #{v.inspect}\n" end @@ -191,7 +191,7 @@ class Chef # def verify_integrity(object, entry, &on_error) base_name = remove_dot_json(entry.name) - if object['name'] != base_name + if object["name"] != base_name on_error.call("Name must be '#{base_name}' (is '#{object['name']}')") end end 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 5152a01e39..2480415f85 100644 --- a/lib/chef/chef_fs/data_handler/environment_data_handler.rb +++ b/lib/chef/chef_fs/data_handler/environment_data_handler.rb @@ -1,5 +1,5 @@ -require 'chef/chef_fs/data_handler/data_handler_base' -require 'chef/environment' +require "chef/chef_fs/data_handler/data_handler_base" +require "chef/environment" class Chef module ChefFS @@ -7,18 +7,18 @@ class Chef class EnvironmentDataHandler < DataHandlerBase def normalize(environment, entry) normalize_hash(environment, { - 'name' => remove_dot_json(entry.name), - 'description' => '', - 'cookbook_versions' => {}, - 'default_attributes' => {}, - 'override_attributes' => {}, - 'json_class' => 'Chef::Environment', - 'chef_type' => 'environment', + "name" => remove_dot_json(entry.name), + "description" => "", + "cookbook_versions" => {}, + "default_attributes" => {}, + "override_attributes" => {}, + "json_class" => "Chef::Environment", + "chef_type" => "environment", },) end def preserve_key?(key) - return key == 'name' + return key == "name" end def chef_class @@ -27,8 +27,8 @@ class Chef def to_ruby(object) result = to_ruby_keys(object, %w(name description default_attributes override_attributes)) - if object['cookbook_versions'] - object['cookbook_versions'].each_pair do |name, version| + if object["cookbook_versions"] + object["cookbook_versions"].each_pair do |name, version| result << "cookbook #{name.inspect}, #{version.inspect}" end end 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 40cb57b78a..7f38784826 100644 --- a/lib/chef/chef_fs/data_handler/group_data_handler.rb +++ b/lib/chef/chef_fs/data_handler/group_data_handler.rb @@ -1,5 +1,5 @@ -require 'chef/chef_fs/data_handler/data_handler_base' -require 'chef/api_client' +require "chef/chef_fs/data_handler/data_handler_base" +require "chef/api_client" class Chef module ChefFS @@ -7,32 +7,32 @@ class Chef class GroupDataHandler < DataHandlerBase def normalize(group, entry) defaults = { - 'name' => remove_dot_json(entry.name), - 'groupname' => remove_dot_json(entry.name), - 'users' => [], - 'clients' => [], - 'groups' => [], + "name" => remove_dot_json(entry.name), + "groupname" => remove_dot_json(entry.name), + "users" => [], + "clients" => [], + "groups" => [], } if entry.org - defaults['orgname'] = entry.org + defaults["orgname"] = entry.org end result = normalize_hash(group, defaults) - if result['actors'] && result['actors'].sort.uniq == (result['users'] + result['clients']).sort.uniq - result.delete('actors') + if result["actors"] && result["actors"].sort.uniq == (result["users"] + result["clients"]).sort.uniq + result.delete("actors") end result end def normalize_for_put(group, entry) result = super(group, entry) - result['actors'] = { - 'users' => result['users'], - 'clients' => result['clients'], - 'groups' => result['groups'], + result["actors"] = { + "users" => result["users"], + "clients" => result["clients"], + "groups" => result["groups"], } - result.delete('users') - result.delete('clients') - result.delete('groups') + result.delete("users") + result.delete("clients") + result.delete("groups") result end @@ -41,7 +41,7 @@ class Chef end def preserve_key?(key) - return key == 'name' + return key == "name" end def chef_class 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 c4910b55b9..fcec74d2fb 100644 --- a/lib/chef/chef_fs/data_handler/node_data_handler.rb +++ b/lib/chef/chef_fs/data_handler/node_data_handler.rb @@ -1,5 +1,5 @@ -require 'chef/chef_fs/data_handler/data_handler_base' -require 'chef/node' +require "chef/chef_fs/data_handler/data_handler_base" +require "chef/node" class Chef module ChefFS @@ -7,22 +7,22 @@ class Chef class NodeDataHandler < DataHandlerBase def normalize(node, entry) result = normalize_hash(node, { - 'name' => remove_dot_json(entry.name), - 'json_class' => 'Chef::Node', - 'chef_type' => 'node', - 'chef_environment' => '_default', - 'override' => {}, - 'normal' => {}, - 'default' => {}, - 'automatic' => {}, - 'run_list' => [], + "name" => remove_dot_json(entry.name), + "json_class" => "Chef::Node", + "chef_type" => "node", + "chef_environment" => "_default", + "override" => {}, + "normal" => {}, + "default" => {}, + "automatic" => {}, + "run_list" => [], },) - result['run_list'] = normalize_run_list(result['run_list']) + result["run_list"] = normalize_run_list(result["run_list"]) result end def preserve_key?(key) - return key == 'name' + return key == "name" end def chef_class diff --git a/lib/chef/chef_fs/data_handler/organization_data_handler.rb b/lib/chef/chef_fs/data_handler/organization_data_handler.rb index 7b1bcc4c6c..d9f97b29ac 100644 --- a/lib/chef/chef_fs/data_handler/organization_data_handler.rb +++ b/lib/chef/chef_fs/data_handler/organization_data_handler.rb @@ -1,4 +1,4 @@ -require 'chef/chef_fs/data_handler/data_handler_base' +require "chef/chef_fs/data_handler/data_handler_base" class Chef module ChefFS @@ -6,21 +6,21 @@ class Chef class OrganizationDataHandler < DataHandlerBase def normalize(organization, entry) result = normalize_hash(organization, { - 'name' => entry.org, - 'full_name' => entry.org, - 'org_type' => 'Business', - 'clientname' => "#{entry.org}-validator", - 'billing_plan' => 'platform-free', + "name" => entry.org, + "full_name" => entry.org, + "org_type" => "Business", + "clientname" => "#{entry.org}-validator", + "billing_plan" => "platform-free", },) result end def preserve_key?(key) - return key == 'name' + return key == "name" end def verify_integrity(object, entry, &on_error) - if entry.org != object['name'] + if entry.org != object["name"] on_error.call("Name must be '#{entry.org}' (is '#{object['name']}')") end end diff --git a/lib/chef/chef_fs/data_handler/organization_invites_data_handler.rb b/lib/chef/chef_fs/data_handler/organization_invites_data_handler.rb index db56ecc504..c5a5f873c5 100644 --- a/lib/chef/chef_fs/data_handler/organization_invites_data_handler.rb +++ b/lib/chef/chef_fs/data_handler/organization_invites_data_handler.rb @@ -1,11 +1,11 @@ -require 'chef/chef_fs/data_handler/data_handler_base' +require "chef/chef_fs/data_handler/data_handler_base" class Chef module ChefFS module DataHandler class OrganizationInvitesDataHandler < DataHandlerBase def normalize(invites, entry) - invites.map { |invite| invite.is_a?(Hash) ? invite['username'] : invite }.sort.uniq + invites.map { |invite| invite.is_a?(Hash) ? invite["username"] : invite }.sort.uniq end def minimize(invites, entry) diff --git a/lib/chef/chef_fs/data_handler/organization_members_data_handler.rb b/lib/chef/chef_fs/data_handler/organization_members_data_handler.rb index afa331775c..8e452a413c 100644 --- a/lib/chef/chef_fs/data_handler/organization_members_data_handler.rb +++ b/lib/chef/chef_fs/data_handler/organization_members_data_handler.rb @@ -1,11 +1,11 @@ -require 'chef/chef_fs/data_handler/data_handler_base' +require "chef/chef_fs/data_handler/data_handler_base" class Chef module ChefFS module DataHandler class OrganizationMembersDataHandler < DataHandlerBase def normalize(members, entry) - members.map { |member| member.is_a?(Hash) ? member['user']['username'] : member }.sort.uniq + members.map { |member| member.is_a?(Hash) ? member["user"]["username"] : member }.sort.uniq end def minimize(members, entry) diff --git a/lib/chef/chef_fs/data_handler/policy_data_handler.rb b/lib/chef/chef_fs/data_handler/policy_data_handler.rb index 32a7a791f7..477d2bf637 100644 --- a/lib/chef/chef_fs/data_handler/policy_data_handler.rb +++ b/lib/chef/chef_fs/data_handler/policy_data_handler.rb @@ -1,4 +1,4 @@ -require 'chef/chef_fs/data_handler/data_handler_base' +require "chef/chef_fs/data_handler/data_handler_base" class Chef module ChefFS @@ -10,7 +10,7 @@ class Chef if name =~ /^(.*)-([^-]*)$/ name, revision_id = $1, $2 end - revision_id ||= '0.0.0' + revision_id ||= "0.0.0" [ name, revision_id ] end @@ -18,21 +18,21 @@ class Chef # foo-1.0.0 = foo, 1.0.0 name, revision_id = name_and_revision(entry.name) defaults = { - 'name' => name, - 'revision_id' => revision_id, - 'run_list' => [], - 'cookbook_locks' => {}, + "name" => name, + "revision_id" => revision_id, + "run_list" => [], + "cookbook_locks" => {}, } normalize_hash(policy, defaults) end def verify_integrity(object_data, entry, &on_error) name, revision = name_and_revision(entry.name) - if object_data['name'] != name + if object_data["name"] != name on_error.call("Object name '#{object_data['name']}' doesn't match entry '#{entry.name}'.") end - if object_data['revision_id'] != revision + if object_data["revision_id"] != revision on_error.call("Object revision ID '#{object_data['revision']}' doesn't match entry '#{entry.name}'.") end end diff --git a/lib/chef/chef_fs/data_handler/policy_group_data_handler.rb b/lib/chef/chef_fs/data_handler/policy_group_data_handler.rb index 10de6abb42..e5c430ab64 100644 --- a/lib/chef/chef_fs/data_handler/policy_group_data_handler.rb +++ b/lib/chef/chef_fs/data_handler/policy_group_data_handler.rb @@ -1,4 +1,4 @@ -require 'chef/chef_fs/data_handler/data_handler_base' +require "chef/chef_fs/data_handler/data_handler_base" class Chef module ChefFS 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 d7530f0b9b..a3a1a31dc7 100644 --- a/lib/chef/chef_fs/data_handler/role_data_handler.rb +++ b/lib/chef/chef_fs/data_handler/role_data_handler.rb @@ -1,5 +1,5 @@ -require 'chef/chef_fs/data_handler/data_handler_base' -require 'chef/role' +require "chef/chef_fs/data_handler/data_handler_base" +require "chef/role" class Chef module ChefFS @@ -7,24 +7,24 @@ class Chef class RoleDataHandler < DataHandlerBase def normalize(role, entry) result = normalize_hash(role, { - 'name' => remove_dot_json(entry.name), - 'description' => '', - 'json_class' => 'Chef::Role', - 'chef_type' => 'role', - 'default_attributes' => {}, - 'override_attributes' => {}, - 'run_list' => [], - 'env_run_lists' => {}, + "name" => remove_dot_json(entry.name), + "description" => "", + "json_class" => "Chef::Role", + "chef_type" => "role", + "default_attributes" => {}, + "override_attributes" => {}, + "run_list" => [], + "env_run_lists" => {}, },) - result['run_list'] = normalize_run_list(result['run_list']) - result['env_run_lists'].each_pair do |env, run_list| - result['env_run_lists'][env] = normalize_run_list(run_list) + result["run_list"] = normalize_run_list(result["run_list"]) + result["env_run_lists"].each_pair do |env, run_list| + result["env_run_lists"][env] = normalize_run_list(run_list) end result end def preserve_key?(key) - return key == 'name' + return key == "name" end def chef_class 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 01c673b460..392e67f822 100644 --- a/lib/chef/chef_fs/data_handler/user_data_handler.rb +++ b/lib/chef/chef_fs/data_handler/user_data_handler.rb @@ -1,4 +1,4 @@ -require 'chef/chef_fs/data_handler/data_handler_base' +require "chef/chef_fs/data_handler/data_handler_base" class Chef module ChefFS @@ -6,20 +6,20 @@ class Chef class UserDataHandler < DataHandlerBase def normalize(user, entry) normalize_hash(user, { - 'name' => remove_dot_json(entry.name), - 'username' => remove_dot_json(entry.name), - 'display_name' => remove_dot_json(entry.name), - 'admin' => false, - 'json_class' => 'Chef::WebUIUser', - 'chef_type' => 'webui_user', - 'salt' => nil, - 'password' => nil, - 'openid' => nil, + "name" => remove_dot_json(entry.name), + "username" => remove_dot_json(entry.name), + "display_name" => remove_dot_json(entry.name), + "admin" => false, + "json_class" => "Chef::WebUIUser", + "chef_type" => "webui_user", + "salt" => nil, + "password" => nil, + "openid" => nil, },) end def preserve_key?(key) - return key == 'name' + return key == "name" end # There is no chef_class for users, nor does to_ruby work. |