summaryrefslogtreecommitdiff
path: root/lib/chef
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef')
-rw-r--r--lib/chef/application/solo.rb2
-rw-r--r--lib/chef/application/windows_service.rb2
-rw-r--r--lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb2
-rw-r--r--lib/chef/chef_fs/file_system/chef_server/policy_group_entry.rb13
-rw-r--r--lib/chef/chef_fs/file_system/chef_server/versioned_cookbook_dir.rb2
-rw-r--r--lib/chef/cookbook/chefignore.rb2
-rw-r--r--lib/chef/cookbook/metadata.rb40
-rw-r--r--lib/chef/data_bag.rb8
-rw-r--r--lib/chef/data_bag_item.rb10
-rw-r--r--lib/chef/data_collector/messages.rb64
-rw-r--r--lib/chef/data_collector/resource_report.rb18
-rw-r--r--lib/chef/dsl/resources.rb2
-rw-r--r--lib/chef/encrypted_data_bag_item/decryptor.rb77
-rw-r--r--lib/chef/environment.rb2
-rw-r--r--lib/chef/formatters/error_inspectors/api_error_formatting.rb16
-rw-r--r--lib/chef/formatters/error_inspectors/cookbook_resolve_error_inspector.rb4
-rw-r--r--lib/chef/formatters/error_inspectors/node_load_error_inspector.rb12
-rw-r--r--lib/chef/formatters/error_inspectors/registration_error_inspector.rb28
-rw-r--r--lib/chef/formatters/error_inspectors/run_list_expansion_error_inspector.rb12
-rw-r--r--lib/chef/http/socketless_chef_zero_client.rb16
-rw-r--r--lib/chef/knife/configure.rb2
-rw-r--r--lib/chef/knife/cookbook_upload.rb2
-rw-r--r--lib/chef/knife/core/cookbook_scm_repo.rb2
-rw-r--r--lib/chef/knife/core/gem_glob_loader.rb4
-rw-r--r--lib/chef/knife/core/node_presenter.rb16
-rw-r--r--lib/chef/knife/key_create.rb2
-rw-r--r--lib/chef/knife/key_edit.rb2
-rw-r--r--lib/chef/knife/key_list.rb2
-rw-r--r--lib/chef/knife/ssl_check.rb6
-rw-r--r--lib/chef/knife/ssl_fetch.rb2
-rw-r--r--lib/chef/mixin/api_version_request_handling.rb2
-rw-r--r--lib/chef/mixin/xml_escape.rb12
-rw-r--r--lib/chef/node_map.rb4
-rw-r--r--lib/chef/provider/cron.rb6
-rw-r--r--lib/chef/provider/git.rb36
-rw-r--r--lib/chef/provider/package/apt.rb6
-rw-r--r--lib/chef/provider/package/chocolatey.rb2
-rw-r--r--lib/chef/provider/package/dnf/python_helper.rb4
-rw-r--r--lib/chef/provider/package/dpkg.rb6
-rw-r--r--lib/chef/provider/package/portage.rb2
-rw-r--r--lib/chef/provider/package/rubygems.rb2
-rw-r--r--lib/chef/provider/package/yum/rpm_utils.rb20
-rw-r--r--lib/chef/provider/powershell_script.rb4
-rw-r--r--lib/chef/provider/route.rb66
-rw-r--r--lib/chef/provider/service/aixinit.rb2
-rw-r--r--lib/chef/provider/service/debian.rb4
-rw-r--r--lib/chef/provider/service/redhat.rb4
-rw-r--r--lib/chef/provider/service/upstart.rb2
-rw-r--r--lib/chef/provider/subversion.rb2
-rw-r--r--lib/chef/provider/windows_task.rb30
-rw-r--r--lib/chef/resource/build_essential.rb2
-rw-r--r--lib/chef/resource/windows_certificate.rb6
-rw-r--r--lib/chef/resource_collection/resource_set.rb6
-rw-r--r--lib/chef/run_context.rb2
-rw-r--r--lib/chef/run_list/run_list_item.rb8
-rw-r--r--lib/chef/shell.rb2
-rw-r--r--lib/chef/version_constraint.rb2
57 files changed, 306 insertions, 310 deletions
diff --git a/lib/chef/application/solo.rb b/lib/chef/application/solo.rb
index ee7d1530ed..763d52226a 100644
--- a/lib/chef/application/solo.rb
+++ b/lib/chef/application/solo.rb
@@ -321,7 +321,7 @@ class Chef::Application::Solo < Chef::Application
Early contributor to Chef
Kind hearted open source advocate
Rest in peace, Ezra.
-EOH
+ EOH
end
def interval_run_chef_client
diff --git a/lib/chef/application/windows_service.rb b/lib/chef/application/windows_service.rb
index 3c73a4925d..26154f8b1e 100644
--- a/lib/chef/application/windows_service.rb
+++ b/lib/chef/application/windows_service.rb
@@ -207,7 +207,7 @@ class Chef
Chef::Log.error(<<-EOF)
Your chef-client run timed out. You can increase the time chef-client is given
to complete by configuring windows_service.watchdog_timeout in your client.rb.
- EOF
+ EOF
rescue Mixlib::ShellOut::ShellCommandFailed => e
Chef::Log.warn "Not able to start chef-client in new process (#{e})"
rescue => e
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 3b1fb53da6..1254d8543c 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
@@ -5,7 +5,7 @@ class Chef
module ChefFS
module DataHandler
class DataBagItemDataHandler < DataHandlerBase
- RESERVED_NAMES = /^(node|role|environment|client)$/
+ RESERVED_NAMES = /^(node|role|environment|client)$/.freeze
def normalize(data_bag_item, entry)
# If it's wrapped with raw_data, unwrap it.
diff --git a/lib/chef/chef_fs/file_system/chef_server/policy_group_entry.rb b/lib/chef/chef_fs/file_system/chef_server/policy_group_entry.rb
index 2a8ebd1f5a..f0d51a692f 100644
--- a/lib/chef/chef_fs/file_system/chef_server/policy_group_entry.rb
+++ b/lib/chef/chef_fs/file_system/chef_server/policy_group_entry.rb
@@ -1,6 +1,6 @@
#
# Author:: John Keiser (<jkeiser@chef.io>)
-# Copyright:: Copyright 2012-2016, Chef Software Inc.
+# Copyright:: Copyright 2012-2019, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -77,11 +77,12 @@ class Chef
object["policies"].each do |policy_name, policy_data|
policy_path = "/policies/#{policy_name}/revisions/#{policy_data["revision_id"]}"
- get_data = begin
- rest.get(policy_path)
- rescue Net::HTTPClientException => e
- raise "Could not find policy '#{policy_name}'' with revision '#{policy_data["revision_id"]}'' on the server"
- end
+ get_data =
+ begin
+ rest.get(policy_path)
+ rescue Net::HTTPClientException => e
+ raise "Could not find policy '#{policy_name}'' with revision '#{policy_data["revision_id"]}'' on the server"
+ end
# GET policy data
server_policy_data = Chef::JSONCompat.parse(get_data)
diff --git a/lib/chef/chef_fs/file_system/chef_server/versioned_cookbook_dir.rb b/lib/chef/chef_fs/file_system/chef_server/versioned_cookbook_dir.rb
index b7c96c42e1..ae4422b82e 100644
--- a/lib/chef/chef_fs/file_system/chef_server/versioned_cookbook_dir.rb
+++ b/lib/chef/chef_fs/file_system/chef_server/versioned_cookbook_dir.rb
@@ -25,7 +25,7 @@ class Chef
class VersionedCookbookDir < CookbookDir
# See Erchef code
# https://github.com/chef/chef_objects/blob/968a63344d38fd507f6ace05f73d53e9cd7fb043/src/chef_regex.erl#L94
- VALID_VERSIONED_COOKBOOK_NAME = /^([.a-zA-Z0-9_-]+)-(\d+\.\d+\.\d+)$/
+ VALID_VERSIONED_COOKBOOK_NAME = /^([.a-zA-Z0-9_-]+)-(\d+\.\d+\.\d+)$/.freeze
def initialize(name, parent, options = {})
super(name, parent)
diff --git a/lib/chef/cookbook/chefignore.rb b/lib/chef/cookbook/chefignore.rb
index 00dc7c0939..27f0bcaadb 100644
--- a/lib/chef/cookbook/chefignore.rb
+++ b/lib/chef/cookbook/chefignore.rb
@@ -20,7 +20,7 @@ class Chef
class Cookbook
class Chefignore
- COMMENTS_AND_WHITESPACE = /^\s*(?:#.*)?$/
+ COMMENTS_AND_WHITESPACE = /^\s*(?:#.*)?$/.freeze
attr_reader :ignores
diff --git a/lib/chef/cookbook/metadata.rb b/lib/chef/cookbook/metadata.rb
index b4d6ab6936..a14518e2fb 100644
--- a/lib/chef/cookbook/metadata.rb
+++ b/lib/chef/cookbook/metadata.rb
@@ -467,24 +467,24 @@ class Chef
def to_h
{
- NAME => name,
- DESCRIPTION => description,
- LONG_DESCRIPTION => long_description,
- MAINTAINER => maintainer,
- MAINTAINER_EMAIL => maintainer_email,
- LICENSE => license,
- PLATFORMS => platforms,
- DEPENDENCIES => dependencies,
- PROVIDING => providing,
- ATTRIBUTES => attributes,
- RECIPES => recipes,
- VERSION => version,
- SOURCE_URL => source_url,
- ISSUES_URL => issues_url,
- PRIVACY => privacy,
- CHEF_VERSIONS => gem_requirements_to_array(*chef_versions),
- OHAI_VERSIONS => gem_requirements_to_array(*ohai_versions),
- GEMS => gems,
+ NAME => name,
+ DESCRIPTION => description,
+ LONG_DESCRIPTION => long_description,
+ MAINTAINER => maintainer,
+ MAINTAINER_EMAIL => maintainer_email,
+ LICENSE => license,
+ PLATFORMS => platforms,
+ DEPENDENCIES => dependencies,
+ PROVIDING => providing,
+ ATTRIBUTES => attributes,
+ RECIPES => recipes,
+ VERSION => version,
+ SOURCE_URL => source_url,
+ ISSUES_URL => issues_url,
+ PRIVACY => privacy,
+ CHEF_VERSIONS => gem_requirements_to_array(*chef_versions),
+ OHAI_VERSIONS => gem_requirements_to_array(*ohai_versions),
+ GEMS => gems,
}
end
@@ -659,7 +659,7 @@ class Chef
Called by: #{caller_name} '#{dep_name}', #{version_constraints.map { |vc| vc.inspect }.join(", ")}
Called from:
#{caller[0...5].map { |line| " " + line }.join("\n")}
-OBSOLETED
+ OBSOLETED
raise Exceptions::ObsoleteDependencySyntax, msg
end
end
@@ -678,7 +678,7 @@ OBSOLETED
Called by: #{caller_name} '#{dep_name}', '#{constraint_str}'
Called from:
#{caller[0...5].map { |line| " " + line }.join("\n")}
-INVALID
+ INVALID
raise Exceptions::InvalidVersionConstraint, msg
end
diff --git a/lib/chef/data_bag.rb b/lib/chef/data_bag.rb
index 35b014905f..2533eb2f4a 100644
--- a/lib/chef/data_bag.rb
+++ b/lib/chef/data_bag.rb
@@ -32,8 +32,8 @@ class Chef
include Chef::Mixin::FromFile
include Chef::Mixin::ParamsValidate
- VALID_NAME = /^[\.\-[:alnum:]_]+$/
- RESERVED_NAMES = /^(node|role|environment|client)$/
+ VALID_NAME = /^[\.\-[:alnum:]_]+$/.freeze
+ RESERVED_NAMES = /^(node|role|environment|client)$/.freeze
def self.validate_name!(name)
unless name =~ VALID_NAME
@@ -60,9 +60,9 @@ class Chef
def to_h
result = {
- "name" => @name,
+ "name" => @name,
"json_class" => self.class.name,
- "chef_type" => "data_bag",
+ "chef_type" => "data_bag",
}
result
end
diff --git a/lib/chef/data_bag_item.rb b/lib/chef/data_bag_item.rb
index 9804c271c4..2a02ada605 100644
--- a/lib/chef/data_bag_item.rb
+++ b/lib/chef/data_bag_item.rb
@@ -36,7 +36,7 @@ class Chef
include Chef::Mixin::FromFile
include Chef::Mixin::ParamsValidate
- VALID_ID = /^[\.\-[:alnum:]_]+$/
+ VALID_ID = /^[\.\-[:alnum:]_]+$/.freeze
def self.validate_id!(id_str)
if id_str.nil? || ( id_str !~ VALID_ID )
@@ -113,11 +113,11 @@ class Chef
# Serialize this object as a hash
def to_json(*a)
result = {
- "name" => object_name,
+ "name" => object_name,
"json_class" => self.class.name,
- "chef_type" => "data_bag_item",
- "data_bag" => data_bag,
- "raw_data" => raw_data,
+ "chef_type" => "data_bag_item",
+ "data_bag" => data_bag,
+ "raw_data" => raw_data,
}
Chef::JSONCompat.to_json(result, *a)
end
diff --git a/lib/chef/data_collector/messages.rb b/lib/chef/data_collector/messages.rb
index b4e30e8b5a..c375475c72 100644
--- a/lib/chef/data_collector/messages.rb
+++ b/lib/chef/data_collector/messages.rb
@@ -36,16 +36,16 @@ class Chef
#
def self.run_start_message(run_status)
{
- "chef_server_fqdn" => chef_server_fqdn,
- "entity_uuid" => node_uuid,
- "id" => run_status.run_id,
- "message_version" => "1.0.0",
- "message_type" => "run_start",
- "node_name" => run_status.node.name,
+ "chef_server_fqdn" => chef_server_fqdn,
+ "entity_uuid" => node_uuid,
+ "id" => run_status.run_id,
+ "message_version" => "1.0.0",
+ "message_type" => "run_start",
+ "node_name" => run_status.node.name,
"organization_name" => organization,
- "run_id" => run_status.run_id,
- "source" => collector_source,
- "start_time" => run_status.start_time.utc.iso8601,
+ "run_id" => run_status.run_id,
+ "source" => collector_source,
+ "start_time" => run_status.start_time.utc.iso8601,
}
end
@@ -61,34 +61,34 @@ class Chef
run_status = reporter_data[:run_status]
message = {
- "chef_server_fqdn" => chef_server_fqdn,
- "entity_uuid" => node_uuid,
- "expanded_run_list" => reporter_data[:expanded_run_list],
- "id" => run_status.run_id,
- "message_version" => "1.1.0",
- "message_type" => "run_converge",
- "node" => run_status.node,
- "node_name" => run_status.node.name,
- "organization_name" => organization,
- "resources" => reporter_data[:resources].map(&:report_data),
- "run_id" => run_status.run_id,
- "run_list" => run_status.node.run_list.for_json,
- "policy_name" => run_status.node.policy_name,
- "policy_group" => run_status.node.policy_group,
- "start_time" => run_status.start_time.utc.iso8601,
- "end_time" => run_status.end_time.utc.iso8601,
- "source" => collector_source,
- "status" => reporter_data[:status],
- "total_resource_count" => reporter_data[:resources].count,
+ "chef_server_fqdn" => chef_server_fqdn,
+ "entity_uuid" => node_uuid,
+ "expanded_run_list" => reporter_data[:expanded_run_list],
+ "id" => run_status.run_id,
+ "message_version" => "1.1.0",
+ "message_type" => "run_converge",
+ "node" => run_status.node,
+ "node_name" => run_status.node.name,
+ "organization_name" => organization,
+ "resources" => reporter_data[:resources].map(&:report_data),
+ "run_id" => run_status.run_id,
+ "run_list" => run_status.node.run_list.for_json,
+ "policy_name" => run_status.node.policy_name,
+ "policy_group" => run_status.node.policy_group,
+ "start_time" => run_status.start_time.utc.iso8601,
+ "end_time" => run_status.end_time.utc.iso8601,
+ "source" => collector_source,
+ "status" => reporter_data[:status],
+ "total_resource_count" => reporter_data[:resources].count,
"updated_resource_count" => reporter_data[:resources].select { |r| r.report_data["status"] == "updated" }.count,
- "deprecations" => reporter_data[:deprecations],
+ "deprecations" => reporter_data[:deprecations],
}
if run_status.exception
message["error"] = {
- "class" => run_status.exception.class,
- "message" => run_status.exception.message,
- "backtrace" => run_status.exception.backtrace,
+ "class" => run_status.exception.class,
+ "message" => run_status.exception.message,
+ "backtrace" => run_status.exception.backtrace,
"description" => reporter_data[:error_descriptions],
}
end
diff --git a/lib/chef/data_collector/resource_report.rb b/lib/chef/data_collector/resource_report.rb
index 6d63595cc2..9a99747f7f 100644
--- a/lib/chef/data_collector/resource_report.rb
+++ b/lib/chef/data_collector/resource_report.rb
@@ -67,16 +67,16 @@ class Chef
def to_h
hash = {
- "type" => new_resource.resource_name.to_sym,
- "name" => new_resource.name.to_s,
- "id" => resource_identity,
- "after" => new_resource_state_reporter,
- "before" => current_resource_state_reporter,
- "duration" => elapsed_time_in_milliseconds.to_s,
- "delta" => new_resource.respond_to?(:diff) && potentially_changed? ? new_resource.diff : "",
+ "type" => new_resource.resource_name.to_sym,
+ "name" => new_resource.name.to_s,
+ "id" => resource_identity,
+ "after" => new_resource_state_reporter,
+ "before" => current_resource_state_reporter,
+ "duration" => elapsed_time_in_milliseconds.to_s,
+ "delta" => new_resource.respond_to?(:diff) && potentially_changed? ? new_resource.diff : "",
"ignore_failure" => new_resource.ignore_failure,
- "result" => action.to_s,
- "status" => status,
+ "result" => action.to_s,
+ "status" => status,
}
if new_resource.cookbook_name
diff --git a/lib/chef/dsl/resources.rb b/lib/chef/dsl/resources.rb
index 9010edc5f7..4e404b44ed 100644
--- a/lib/chef/dsl/resources.rb
+++ b/lib/chef/dsl/resources.rb
@@ -35,7 +35,7 @@ class Chef
def #{dsl_name}(args = nil, &block)
declare_resource(#{dsl_name.inspect}, args, created_at: caller[0], &block)
end
- EOM
+ EOM
end
def self.remove_resource_dsl(dsl_name)
diff --git a/lib/chef/encrypted_data_bag_item/decryptor.rb b/lib/chef/encrypted_data_bag_item/decryptor.rb
index f35611d185..59911c7ca7 100644
--- a/lib/chef/encrypted_data_bag_item/decryptor.rb
+++ b/lib/chef/encrypted_data_bag_item/decryptor.rb
@@ -1,6 +1,6 @@
#
# Author:: Seth Falcon (<seth@chef.io>)
-# Copyright:: Copyright 2010-2016, Chef Software Inc.
+# Copyright:: Copyright 2010-2019, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -88,13 +88,14 @@ class Chef::EncryptedDataBagItem
end
def decrypted_data
- @decrypted_data ||= begin
- plaintext = openssl_decryptor.update(encrypted_bytes)
- plaintext << openssl_decryptor.final
- rescue OpenSSL::Cipher::CipherError => e
- # if the key length is less than 255 characters, and it contains slashes, we think it may be a path.
- raise DecryptionFailure, "Error decrypting data bag value: '#{e.message}'. Most likely the provided key is incorrect. #{(@key.length < 255 && @key.include?('/')) ? 'You may need to use --secret-file rather than --secret.' : ''}"
- end
+ @decrypted_data ||=
+ begin
+ plaintext = openssl_decryptor.update(encrypted_bytes)
+ plaintext << openssl_decryptor.final
+ rescue OpenSSL::Cipher::CipherError => e
+ # if the key length is less than 255 characters, and it contains slashes, we think it may be a path.
+ raise DecryptionFailure, "Error decrypting data bag value: '#{e.message}'. Most likely the provided key is incorrect. #{(@key.length < 255 && @key.include?('/')) ? 'You may need to use --secret-file rather than --secret.' : ''}"
+ end
end
def encrypted_bytes
@@ -102,12 +103,13 @@ class Chef::EncryptedDataBagItem
end
def openssl_decryptor
- @openssl_decryptor ||= begin
- d = OpenSSL::Cipher.new(algorithm)
- d.decrypt
- d.pkcs5_keyivgen(key)
- d
- end
+ @openssl_decryptor ||=
+ begin
+ d = OpenSSL::Cipher.new(algorithm)
+ d.decrypt
+ d.pkcs5_keyivgen(key)
+ d
+ end
end
end
@@ -139,25 +141,27 @@ class Chef::EncryptedDataBagItem
end
def decrypted_data
- @decrypted_data ||= begin
- plaintext = openssl_decryptor.update(encrypted_bytes)
- plaintext << openssl_decryptor.final
- rescue OpenSSL::Cipher::CipherError => e
- # if the key length is less than 255 characters, and it contains slashes, we think it may be a path.
- raise DecryptionFailure, "Error decrypting data bag value: '#{e.message}'. Most likely the provided key is incorrect. #{( @key.length < 255 && @key.include?('/')) ? 'You may need to use --secret-file rather than --secret.' : ''}"
- end
+ @decrypted_data ||=
+ begin
+ plaintext = openssl_decryptor.update(encrypted_bytes)
+ plaintext << openssl_decryptor.final
+ rescue OpenSSL::Cipher::CipherError => e
+ # if the key length is less than 255 characters, and it contains slashes, we think it may be a path.
+ raise DecryptionFailure, "Error decrypting data bag value: '#{e.message}'. Most likely the provided key is incorrect. #{( @key.length < 255 && @key.include?('/')) ? 'You may need to use --secret-file rather than --secret.' : ''}"
+ end
end
def openssl_decryptor
- @openssl_decryptor ||= begin
- assert_valid_cipher!(@encrypted_data["cipher"], algorithm)
- d = OpenSSL::Cipher.new(algorithm)
- d.decrypt
- # We must set key before iv: https://bugs.ruby-lang.org/issues/8221
- d.key = OpenSSL::Digest::SHA256.digest(key)
- d.iv = iv
- d
- end
+ @openssl_decryptor ||=
+ begin
+ assert_valid_cipher!(@encrypted_data["cipher"], algorithm)
+ d = OpenSSL::Cipher.new(algorithm)
+ d.decrypt
+ # We must set key before iv: https://bugs.ruby-lang.org/issues/8221
+ d.key = OpenSSL::Digest::SHA256.digest(key)
+ d.iv = iv
+ d
+ end
end
end
@@ -213,12 +217,13 @@ class Chef::EncryptedDataBagItem
end
def openssl_decryptor
- @openssl_decryptor ||= begin
- d = super
- d.auth_tag = auth_tag
- d.auth_data = ""
- d
- end
+ @openssl_decryptor ||=
+ begin
+ d = super
+ d.auth_tag = auth_tag
+ d.auth_data = ""
+ d
+ end
end
end
diff --git a/lib/chef/environment.rb b/lib/chef/environment.rb
index 1ca035e594..ec3361adfb 100644
--- a/lib/chef/environment.rb
+++ b/lib/chef/environment.rb
@@ -34,7 +34,7 @@ class Chef
include Chef::Mixin::ParamsValidate
include Chef::Mixin::FromFile
- COMBINED_COOKBOOK_CONSTRAINT = /(.+)(?:[\s]+)((?:#{Chef::VersionConstraint::OPS.join('|')})(?:[\s]+).+)$/
+ COMBINED_COOKBOOK_CONSTRAINT = /(.+)(?:[\s]+)((?:#{Chef::VersionConstraint::OPS.join('|')})(?:[\s]+).+)$/.freeze
def initialize(chef_server_rest: nil)
@name = ""
diff --git a/lib/chef/formatters/error_inspectors/api_error_formatting.rb b/lib/chef/formatters/error_inspectors/api_error_formatting.rb
index a4a97ebb95..4ecdec7105 100644
--- a/lib/chef/formatters/error_inspectors/api_error_formatting.rb
+++ b/lib/chef/formatters/error_inspectors/api_error_formatting.rb
@@ -30,10 +30,10 @@ class Chef
#{exception.message}
Your chef_server_url may be misconfigured, or the network could be down.
-E
+ E
error_description.section("Relevant Config Settings:", <<~E)
chef_server_url "#{server_url}"
-E
+ E
end
def describe_eof_error(error_description)
@@ -78,11 +78,11 @@ E
Failed to authenticate to the chef server (http 401).
The request failed because your clock has drifted by more than 15 minutes.
Syncing your clock to an NTP Time source should resolve the issue.
-E
+ E
else
error_description.section("Authentication Error:", <<~E)
Failed to authenticate to the chef server (http 401).
-E
+ E
error_description.section("Server Response:", format_rest_error)
error_description.section("Relevant Config Settings:", <<~E)
@@ -92,14 +92,14 @@ E
If these settings are correct, your client_key may be invalid, or
you may have a chef user with the same client name as this node.
-E
+ E
end
end
def describe_400_error(error_description)
error_description.section("Invalid Request Data:", <<~E)
The data in your request was invalid (HTTP 400).
-E
+ E
error_description.section("Server Response:", format_rest_error)
end
@@ -115,7 +115,7 @@ E
The server supports a min API version of #{min_server_version} and a max API version of #{max_server_version}.
Chef just made a request with an API version of #{client_api_version}.
Please either update your Chef client or server to be a compatible set.
-E
+ E
else
describe_http_error(error_description)
end
@@ -124,7 +124,7 @@ E
def describe_500_error(error_description)
error_description.section("Unknown Server Error:", <<~E)
The server had a fatal error attempting to load the node data.
-E
+ E
error_description.section("Server Response:", format_rest_error)
end
diff --git a/lib/chef/formatters/error_inspectors/cookbook_resolve_error_inspector.rb b/lib/chef/formatters/error_inspectors/cookbook_resolve_error_inspector.rb
index e87ef0da70..6801884aac 100644
--- a/lib/chef/formatters/error_inspectors/cookbook_resolve_error_inspector.rb
+++ b/lib/chef/formatters/error_inspectors/cookbook_resolve_error_inspector.rb
@@ -62,7 +62,7 @@ class Chef
To access its cookbooks, a client needs to be able to read its environment and
all of the cookbooks in its expanded run list.
-E
+ E
error_description.section("Expanded Run List:", expanded_run_list_ul)
error_description.section("Server Response:", format_rest_error)
when Net::HTTPPreconditionFailed
@@ -120,7 +120,7 @@ E
1-) Removing cookbook versions that depend on deleted cookbooks.
2-) Removing unused cookbook versions.
3-) Pinning exact cookbook versions using environments.
-EOM
+ EOM
error_description.section("Cookbook dependency resolution error:", explanation)
end
diff --git a/lib/chef/formatters/error_inspectors/node_load_error_inspector.rb b/lib/chef/formatters/error_inspectors/node_load_error_inspector.rb
index 7b2ccf0d9a..9617f729c1 100644
--- a/lib/chef/formatters/error_inspectors/node_load_error_inspector.rb
+++ b/lib/chef/formatters/error_inspectors/node_load_error_inspector.rb
@@ -46,10 +46,10 @@ class Chef
error_description.section("Private Key Not Found:", <<~E)
Your private key could not be loaded. If the key file exists, ensure that it is
readable by chef-client.
-E
+ E
error_description.section("Relevant Config Settings:", <<~E)
client_key "#{api_key}"
-E
+ E
when EOFError
describe_eof_error(error_description)
when *NETWORK_ERROR_CLASSES
@@ -71,12 +71,12 @@ E
# * could be no read on the node
error_description.section("Authorization Error", <<~E)
Your client is not authorized to load the node data (HTTP 403).
-E
+ E
error_description.section("Server Response:", format_rest_error)
error_description.section("Possible Causes:", <<~E)
* Your client (#{username}) may have misconfigured authorization permissions.
-E
+ E
when Net::HTTPBadRequest
describe_400_error(error_description)
when Net::HTTPNotFound
@@ -99,10 +99,10 @@ E
def describe_404_error(error_description)
error_description.section("Resource Not Found:", <<~E)
The server returned a HTTP 404. This usually indicates that your chef_server_url is incorrect.
-E
+ E
error_description.section("Relevant Config Settings:", <<~E)
chef_server_url "#{server_url}"
-E
+ E
end
def username
diff --git a/lib/chef/formatters/error_inspectors/registration_error_inspector.rb b/lib/chef/formatters/error_inspectors/registration_error_inspector.rb
index 4ca08ca120..002870abeb 100644
--- a/lib/chef/formatters/error_inspectors/registration_error_inspector.rb
+++ b/lib/chef/formatters/error_inspectors/registration_error_inspector.rb
@@ -29,24 +29,24 @@ class Chef
error_description.section("Network Error:", <<~E)
There was a network error connecting to the Chef Server:
#{exception.message}
-E
+ E
error_description.section("Relevant Config Settings:", <<~E)
chef_server_url "#{server_url}"
If your chef_server_url is correct, your network could be down.
-E
+ E
when Chef::Exceptions::PrivateKeyMissing
error_description.section("Private Key Not Found:", <<~E)
Your private key could not be loaded. If the key file exists, ensure that it is
readable by chef-client.
-E
+ E
error_description.section("Relevant Config Settings:", <<~E)
validation_key "#{api_key}"
-E
+ E
when Chef::Exceptions::InvalidRedirect
error_description.section("Invalid Redirect:", <<~E)
Change your server location in client.rb to the server's FQDN to avoid unwanted redirections.
-E
+ E
when EOFError
describe_eof_error(error_description)
else
@@ -63,11 +63,11 @@ E
Failed to authenticate to the chef server (http 401).
The request failed because your clock has drifted by more than 15 minutes.
Syncing your clock to an NTP Time source should resolve the issue.
-E
+ E
else
error_description.section("Authentication Error:", <<~E)
Failed to authenticate to the chef server (http 401).
-E
+ E
error_description.section("Server Response:", format_rest_error)
error_description.section("Relevant Config Settings:", <<~E)
@@ -76,34 +76,34 @@ E
validation_key "#{api_key}"
If these settings are correct, your validation_key may be invalid.
-E
+ E
end
when Net::HTTPForbidden
error_description.section("Authorization Error:", <<~E)
Your validation client is not authorized to create the client for this node (HTTP 403).
-E
+ E
error_description.section("Possible Causes:", <<~E)
* There may already be a client named "#{config[:node_name]}"
* Your validation client (#{username}) may have misconfigured authorization permissions.
-E
+ E
when Net::HTTPBadRequest
error_description.section("Invalid Request Data:", <<~E)
The data in your request was invalid (HTTP 400).
-E
+ E
error_description.section("Server Response:", format_rest_error)
when Net::HTTPNotFound
error_description.section("Resource Not Found:", <<~E)
The server returned a HTTP 404. This usually indicates that your chef_server_url is incorrect.
-E
+ E
error_description.section("Relevant Config Settings:", <<~E)
chef_server_url "#{server_url}"
-E
+ E
when Net::HTTPNotAcceptable
describe_406_error(error_description, response)
when Net::HTTPInternalServerError
error_description.section("Unknown Server Error:", <<~E)
The server had a fatal error attempting to load the node data.
-E
+ E
error_description.section("Server Response:", format_rest_error)
when Net::HTTPBadGateway, Net::HTTPServiceUnavailable
error_description.section("Server Unavailable", "The Chef Server is temporarily unavailable")
diff --git a/lib/chef/formatters/error_inspectors/run_list_expansion_error_inspector.rb b/lib/chef/formatters/error_inspectors/run_list_expansion_error_inspector.rb
index ac7304df13..3efb1d4d45 100644
--- a/lib/chef/formatters/error_inspectors/run_list_expansion_error_inspector.rb
+++ b/lib/chef/formatters/error_inspectors/run_list_expansion_error_inspector.rb
@@ -40,7 +40,7 @@ class Chef
#{exception.message}
Your chef_server_url may be misconfigured, or the network could be down.
-E
+ E
when Net::HTTPClientException, Net::HTTPFatalError
humanize_http_exception(error_description)
when Chef::Exceptions::MissingRole
@@ -78,7 +78,7 @@ E
when Net::HTTPUnauthorized
error_description.section("Authentication Error:", <<~E)
Failed to authenticate to the chef server (http 401).
-E
+ E
error_description.section("Server Response:", format_rest_error)
error_description.section("Relevant Config Settings:", <<~E)
@@ -87,25 +87,25 @@ E
client_key "#{api_key}"
If these settings are correct, your client_key may be invalid.
-E
+ E
when Net::HTTPForbidden
# TODO: we're rescuing errors from Node.find_or_create
# * could be no write on nodes container
# * could be no read on the node
error_description.section("Authorization Error", <<~E)
Your client is not authorized to load one or more of your roles (HTTP 403).
-E
+ E
error_description.section("Server Response:", format_rest_error)
error_description.section("Possible Causes:", <<~E)
* Your client (#{username}) may have misconfigured authorization permissions.
-E
+ E
when Net::HTTPNotAcceptable
describe_406_error(error_description, response)
when Net::HTTPInternalServerError
error_description.section("Unknown Server Error:", <<~E)
The server had a fatal error attempting to load a role.
-E
+ E
error_description.section("Server Response:", format_rest_error)
when Net::HTTPBadGateway, Net::HTTPServiceUnavailable
error_description.section("Server Unavailable", "The Chef Server is temporarily unavailable")
diff --git a/lib/chef/http/socketless_chef_zero_client.rb b/lib/chef/http/socketless_chef_zero_client.rb
index 6484a6d540..e3823481d4 100644
--- a/lib/chef/http/socketless_chef_zero_client.rb
+++ b/lib/chef/http/socketless_chef_zero_client.rb
@@ -163,16 +163,16 @@ class Chef
def req_to_rack(method, url, body, headers)
body_str = body || ""
{
- "SCRIPT_NAME" => "",
- "SERVER_NAME" => "localhost",
- "REQUEST_METHOD" => method.to_s.upcase,
- "PATH_INFO" => url.path,
- "QUERY_STRING" => url.query,
- "SERVER_PORT" => url.port,
- "HTTP_HOST" => "localhost:#{url.port}",
+ "SCRIPT_NAME" => "",
+ "SERVER_NAME" => "localhost",
+ "REQUEST_METHOD" => method.to_s.upcase,
+ "PATH_INFO" => url.path,
+ "QUERY_STRING" => url.query,
+ "SERVER_PORT" => url.port,
+ "HTTP_HOST" => "localhost:#{url.port}",
"HTTP_X_OPS_SERVER_API_VERSION" => headers["X-Ops-Server-API-Version"],
"rack.url_scheme" => "chefzero",
- "rack.input" => StringIO.new(body_str),
+ "rack.input" => StringIO.new(body_str),
}
end
diff --git a/lib/chef/knife/configure.rb b/lib/chef/knife/configure.rb
index 18cec044a6..e24958e1fc 100644
--- a/lib/chef/knife/configure.rb
+++ b/lib/chef/knife/configure.rb
@@ -80,7 +80,7 @@ class Chef
client_name = '#{new_client_name}'
client_key = '#{new_client_key}'
chef_server_url = '#{chef_server}'
-EOH
+ EOH
end
if config[:initial]
diff --git a/lib/chef/knife/cookbook_upload.rb b/lib/chef/knife/cookbook_upload.rb
index 02bea271b2..57a63c7b47 100644
--- a/lib/chef/knife/cookbook_upload.rb
+++ b/lib/chef/knife/cookbook_upload.rb
@@ -26,7 +26,7 @@ class Chef
class CookbookUpload < Knife
CHECKSUM = "checksum".freeze
- MATCH_CHECKSUM = /[0-9a-f]{32,}/
+ MATCH_CHECKSUM = /[0-9a-f]{32,}/.freeze
deps do
require "chef/exceptions"
diff --git a/lib/chef/knife/core/cookbook_scm_repo.rb b/lib/chef/knife/core/cookbook_scm_repo.rb
index f583f0bd8e..ba3a40207a 100644
--- a/lib/chef/knife/core/cookbook_scm_repo.rb
+++ b/lib/chef/knife/core/cookbook_scm_repo.rb
@@ -22,7 +22,7 @@ class Chef
class Knife
class CookbookSCMRepo
- DIRTY_REPO = /^[\s]+M/
+ DIRTY_REPO = /^[\s]+M/.freeze
include Chef::Mixin::ShellOut
diff --git a/lib/chef/knife/core/gem_glob_loader.rb b/lib/chef/knife/core/gem_glob_loader.rb
index c4523d69ad..987aef754f 100644
--- a/lib/chef/knife/core/gem_glob_loader.rb
+++ b/lib/chef/knife/core/gem_glob_loader.rb
@@ -22,8 +22,8 @@ class Chef
class Knife
class SubcommandLoader
class GemGlobLoader < Chef::Knife::SubcommandLoader
- MATCHES_CHEF_GEM = %r{/chef-[\d]+\.[\d]+\.[\d]+}
- MATCHES_THIS_CHEF_GEM = %r{/chef-#{Chef::VERSION}(-\w+)?(-\w+)?/}
+ MATCHES_CHEF_GEM = %r{/chef-[\d]+\.[\d]+\.[\d]+}.freeze
+ MATCHES_THIS_CHEF_GEM = %r{/chef-#{Chef::VERSION}(-\w+)?(-\w+)?/}.freeze
def subcommand_files
@subcommand_files ||= (gem_and_builtin_subcommands.values + site_subcommands).flatten.uniq
diff --git a/lib/chef/knife/core/node_presenter.rb b/lib/chef/knife/core/node_presenter.rb
index 7cb0e4d6fe..5072cc4ae2 100644
--- a/lib/chef/knife/core/node_presenter.rb
+++ b/lib/chef/knife/core/node_presenter.rb
@@ -100,38 +100,38 @@ class Chef
summarized = <<~SUMMARY
#{ui.color('Node Name:', :bold)} #{ui.color(node.name, :bold)}
-SUMMARY
+ SUMMARY
show_policy = !(node.policy_name.nil? && node.policy_group.nil?)
if show_policy
summarized << <<~POLICY
#{key('Policy Name:')} #{node.policy_name}
#{key('Policy Group:')} #{node.policy_group}
-POLICY
+ POLICY
else
summarized << <<~ENV
#{key('Environment:')} #{node.chef_environment}
-ENV
+ ENV
end
summarized << <<~SUMMARY
#{key('FQDN:')} #{node[:fqdn]}
#{key('IP:')} #{ip}
#{key('Run List:')} #{node.run_list}
-SUMMARY
+ SUMMARY
unless show_policy
summarized << <<~ROLES
#{key('Roles:')} #{Array(node[:roles]).join(', ')}
-ROLES
+ ROLES
end
summarized << <<~SUMMARY
#{key('Recipes:')} #{Array(node[:recipes]).join(', ')}
#{key('Platform:')} #{node[:platform]} #{node[:platform_version]}
#{key('Tags:')} #{node.tags.join(', ')}
-SUMMARY
+ SUMMARY
if config[:medium_output] || config[:long_output]
summarized += <<~MORE
#{key('Attributes:')}
#{text_format(node.normal_attrs)}
-MORE
+ MORE
end
if config[:long_output]
summarized += <<~MOST
@@ -141,7 +141,7 @@ MORE
#{text_format(node.override_attrs)}
#{key('Automatic Attributes (Ohai Data):')}
#{text_format(node.automatic_attrs)}
-MOST
+ MOST
end
summarized
else
diff --git a/lib/chef/knife/key_create.rb b/lib/chef/knife/key_create.rb
index 395bbc4bfd..f278af8b77 100644
--- a/lib/chef/knife/key_create.rb
+++ b/lib/chef/knife/key_create.rb
@@ -44,7 +44,7 @@ class Chef
You must pass either --public-key or --key-name, or both.
If you only pass --public-key, a key name will be generated from the fingerprint of your key.
If you only pass --key-name, a key pair will be generated by the server.
-EOS
+ EOS
end
def edit_data(key)
diff --git a/lib/chef/knife/key_edit.rb b/lib/chef/knife/key_edit.rb
index d05ee11d1c..4e36bdfded 100644
--- a/lib/chef/knife/key_edit.rb
+++ b/lib/chef/knife/key_edit.rb
@@ -46,7 +46,7 @@ class Chef
Do not pass either if you do not want to change the public_key field of your key.
Pass --public-key if you want to update the public_key field of your key from a specific public key.
Pass --create-key if you want the server to generate a new key and use that to update the public_key field of your key.
-EOS
+ EOS
end
def edit_data(key)
diff --git a/lib/chef/knife/key_list.rb b/lib/chef/knife/key_list.rb
index 9d3a2c0c26..3078ca44d3 100644
--- a/lib/chef/knife/key_list.rb
+++ b/lib/chef/knife/key_list.rb
@@ -43,7 +43,7 @@ class Chef
<<~EOS
You cannot pass both --only-expired and --only-non-expired.
Please pass one or none.
-EOS
+ EOS
end
def display_info(string)
diff --git a/lib/chef/knife/ssl_check.rb b/lib/chef/knife/ssl_check.rb
index 858ab3cf89..6508c5f02d 100644
--- a/lib/chef/knife/ssl_check.rb
+++ b/lib/chef/knife/ssl_check.rb
@@ -171,7 +171,7 @@ class Chef
using SSH/SCP or some other secure method, then re-run this command to confirm
that the server's certificate is now trusted.
-BAD_CERTS
+ BAD_CERTS
# @TODO: ^ needs URL once documentation is posted.
end
@@ -200,7 +200,7 @@ BAD_CERTS
using SSH/SCP or some other secure method, then re-run this command to confirm
that the server's certificate is now trusted.
-ADVICE
+ ADVICE
end
def debug_invalid_host
@@ -222,7 +222,7 @@ ADVICE
If you are not able to connect to the server using the hostname #{cn}
you will have to update the certificate on the server to use the correct hostname.
-ADVICE
+ ADVICE
end
def debug_ssl_settings
diff --git a/lib/chef/knife/ssl_fetch.rb b/lib/chef/knife/ssl_fetch.rb
index 88eb95e97d..9e1579a5f8 100644
--- a/lib/chef/knife/ssl_fetch.rb
+++ b/lib/chef/knife/ssl_fetch.rb
@@ -137,7 +137,7 @@ class Chef
Knife has no means to verify these are the correct certificates. You should
verify the authenticity of these certificates after downloading.
-TRUST_TRUST
+ TRUST_TRUST
remote_cert_chain.each do |cert|
write_cert(cert)
end
diff --git a/lib/chef/mixin/api_version_request_handling.rb b/lib/chef/mixin/api_version_request_handling.rb
index a706e10618..a4e657ac9e 100644
--- a/lib/chef/mixin/api_version_request_handling.rb
+++ b/lib/chef/mixin/api_version_request_handling.rb
@@ -56,7 +56,7 @@ class Chef
User keys are now managed via the key rotation commmands.
Please refer to the documentation on how to manage your keys via the key rotation commands:
https://docs.chef.io/server_security.html#key-rotation
-EOH
+ EOH
end
end
diff --git a/lib/chef/mixin/xml_escape.rb b/lib/chef/mixin/xml_escape.rb
index 7011ff4f56..b591b09db0 100644
--- a/lib/chef/mixin/xml_escape.rb
+++ b/lib/chef/mixin/xml_escape.rb
@@ -73,8 +73,8 @@ class Chef
137 => 8240, # per mille sign
138 => 352, # latin capital letter s with caron
139 => 8249, # single left-pointing angle quotation mark
- 140 => 338, # latin capital ligature oe
- 142 => 381, # latin capital letter z with caron
+ 140 => 338, # latin capital ligature oe
+ 142 => 381, # latin capital letter z with caron
145 => 8216, # left single quotation mark
146 => 8217, # right single quotation mark
147 => 8220, # left double quotation mark
@@ -86,16 +86,16 @@ class Chef
153 => 8482, # trade mark sign
154 => 353, # latin small letter s with caron
155 => 8250, # single right-pointing angle quotation mark
- 156 => 339, # latin small ligature oe
- 158 => 382, # latin small letter z with caron
- 159 => 376 # latin capital letter y with diaeresis
+ 156 => 339, # latin small ligature oe
+ 158 => 382, # latin small letter z with caron
+ 159 => 376, # latin capital letter y with diaeresis
}.freeze
# http://www.w3.org/TR/REC-xml/#dt-chardata
PREDEFINED = {
38 => "&amp;", # ampersand
60 => "&lt;", # left angle bracket
- 62 => "&gt;" # right angle bracket
+ 62 => "&gt;", # right angle bracket
}.freeze
# http://www.w3.org/TR/REC-xml/#charsets
diff --git a/lib/chef/node_map.rb b/lib/chef/node_map.rb
index ac60b590b6..50a763f686 100644
--- a/lib/chef/node_map.rb
+++ b/lib/chef/node_map.rb
@@ -40,12 +40,12 @@ class Chef
COLLISION_WARNING_14 = <<~EOH.gsub(/\s+/, " ").strip
%{type_caps} %{key} from a cookbook is overriding the %{type} from the client. Please upgrade your cookbook
or remove the cookbook from your run_list before the next major release of Chef.
-EOH
+ EOH
COLLISION_WARNING_15 = <<~EOH.gsub(/\s+/, " ").strip
%{type_caps} %{key} from the client is overriding the %{type} from a cookbook. Please upgrade your cookbook
or remove the cookbook from your run_list.
-EOH
+ EOH
#
# Set a key/value pair on the map with a filter. The filter must be true
diff --git a/lib/chef/provider/cron.rb b/lib/chef/provider/cron.rb
index f25a58a789..79245df475 100644
--- a/lib/chef/provider/cron.rb
+++ b/lib/chef/provider/cron.rb
@@ -29,9 +29,9 @@ class Chef
CRON_ATTRIBUTES = [:minute, :hour, :day, :month, :weekday, :time, :command, :mailto, :path, :shell, :home, :environment].freeze
WEEKDAY_SYMBOLS = [:sunday, :monday, :tuesday, :wednesday, :thursday, :friday, :saturday].freeze
- CRON_PATTERN = /\A([-0-9*,\/]+)\s([-0-9*,\/]+)\s([-0-9*,\/]+)\s([-0-9*,\/]+|[a-zA-Z]{3})\s([-0-9*,\/]+|[a-zA-Z]{3})\s(.*)/
- SPECIAL_PATTERN = /\A(@(#{SPECIAL_TIME_VALUES.join('|')}))\s(.*)/
- ENV_PATTERN = /\A(\S+)=(\S*)/
+ CRON_PATTERN = /\A([-0-9*,\/]+)\s([-0-9*,\/]+)\s([-0-9*,\/]+)\s([-0-9*,\/]+|[a-zA-Z]{3})\s([-0-9*,\/]+|[a-zA-Z]{3})\s(.*)/.freeze
+ SPECIAL_PATTERN = /\A(@(#{SPECIAL_TIME_VALUES.join('|')}))\s(.*)/.freeze
+ ENV_PATTERN = /\A(\S+)=(\S*)/.freeze
def initialize(new_resource, run_context)
super(new_resource, run_context)
diff --git a/lib/chef/provider/git.rb b/lib/chef/provider/git.rb
index 5845f869d8..4d27e1a52e 100644
--- a/lib/chef/provider/git.rb
+++ b/lib/chef/provider/git.rb
@@ -1,6 +1,6 @@
#
# Author:: Daniel DeLeo (<dan@kallistec.com>)
-# Copyright:: Copyright 2008-2017, Chef Software Inc.
+# Copyright:: Copyright 2008-2019, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -234,13 +234,14 @@ class Chef
end
def target_revision
- @target_revision ||= begin
- if sha_hash?(new_resource.revision)
- @target_revision = new_resource.revision
- else
- @target_revision = remote_resolve_reference
+ @target_revision ||=
+ begin
+ if sha_hash?(new_resource.revision)
+ @target_revision = new_resource.revision
+ else
+ @target_revision = remote_resolve_reference
+ end
end
- end
end
alias :revision_slug :target_revision
@@ -311,17 +312,18 @@ class Chef
# Certain versions of `git` misbehave if git configuration is
# inaccessible in $HOME. We need to ensure $HOME matches the
# user who is executing `git` not the user running Chef.
- env["HOME"] = begin
- require "etc"
- case new_resource.user
- when Integer
- Etc.getpwuid(new_resource.user).dir
- else
- Etc.getpwnam(new_resource.user.to_s).dir
+ env["HOME"] =
+ begin
+ require "etc"
+ case new_resource.user
+ when Integer
+ Etc.getpwuid(new_resource.user).dir
+ else
+ Etc.getpwnam(new_resource.user.to_s).dir
+ end
+ rescue ArgumentError # user not found
+ raise Chef::Exceptions::User, "Could not determine HOME for specified user '#{new_resource.user}' for resource '#{new_resource.name}'"
end
- rescue ArgumentError # user not found
- raise Chef::Exceptions::User, "Could not determine HOME for specified user '#{new_resource.user}' for resource '#{new_resource.name}'"
- end
end
run_opts[:group] = new_resource.group if new_resource.group
env["GIT_SSH"] = new_resource.ssh_wrapper if new_resource.ssh_wrapper
diff --git a/lib/chef/provider/package/apt.rb b/lib/chef/provider/package/apt.rb
index de1b106d45..dfc7e602dd 100644
--- a/lib/chef/provider/package/apt.rb
+++ b/lib/chef/provider/package/apt.rb
@@ -237,9 +237,9 @@ class Chef
end
{
- current_version: current_version,
- candidate_version: candidate_version,
- virtual: virtual,
+ current_version: current_version,
+ candidate_version: candidate_version,
+ virtual: virtual,
}
end
diff --git a/lib/chef/provider/package/chocolatey.rb b/lib/chef/provider/package/chocolatey.rb
index 4c35d13a07..20831ac891 100644
--- a/lib/chef/provider/package/chocolatey.rb
+++ b/lib/chef/provider/package/chocolatey.rb
@@ -37,7 +37,7 @@ class Chef
If Chocolatey is installed, ensure that the 'ChocolateyInstall' environment
variable is correctly set. You can verify this with the PowerShell command
'#{PATHFINDING_POWERSHELL_COMMAND}'.
-EOS
+ EOS
# Responsible for building the current_resource.
#
diff --git a/lib/chef/provider/package/dnf/python_helper.rb b/lib/chef/provider/package/dnf/python_helper.rb
index 56706764d0..7cb4047f53 100644
--- a/lib/chef/provider/package/dnf/python_helper.rb
+++ b/lib/chef/provider/package/dnf/python_helper.rb
@@ -132,9 +132,7 @@ class Chef
def drain_stderr
output = ""
- until IO.select([stderr], nil, nil, 0).nil?
- output += stderr.sysread(4096).chomp
- end
+ output += stderr.sysread(4096).chomp until IO.select([stderr], nil, nil, 0).nil?
output
rescue
# we must rescue EOFError, and we don't much care about errors on stderr anyway
diff --git a/lib/chef/provider/package/dpkg.rb b/lib/chef/provider/package/dpkg.rb
index de5b2858e7..38129c8931 100644
--- a/lib/chef/provider/package/dpkg.rb
+++ b/lib/chef/provider/package/dpkg.rb
@@ -23,9 +23,9 @@ class Chef
class Provider
class Package
class Dpkg < Chef::Provider::Package
- DPKG_REMOVED = /^Status: deinstall ok config-files/
- DPKG_INSTALLED = /^Status: install ok installed/
- DPKG_VERSION = /^Version: (.+)$/
+ DPKG_REMOVED = /^Status: deinstall ok config-files/.freeze
+ DPKG_INSTALLED = /^Status: install ok installed/.freeze
+ DPKG_VERSION = /^Version: (.+)$/.freeze
provides :dpkg_package
diff --git a/lib/chef/provider/package/portage.rb b/lib/chef/provider/package/portage.rb
index 11cbe99d18..d9fc801225 100644
--- a/lib/chef/provider/package/portage.rb
+++ b/lib/chef/provider/package/portage.rb
@@ -28,7 +28,7 @@ class Chef
provides :package, platform: "gentoo"
provides :portage_package
- PACKAGE_NAME_PATTERN = %r{(?:([^/]+)/)?([^/]+)}
+ PACKAGE_NAME_PATTERN = %r{(?:([^/]+)/)?([^/]+)}.freeze
def load_current_resource
@current_resource = Chef::Resource::PortagePackage.new(new_resource.name)
diff --git a/lib/chef/provider/package/rubygems.rb b/lib/chef/provider/package/rubygems.rb
index cd595e64f4..dc882e426c 100644
--- a/lib/chef/provider/package/rubygems.rb
+++ b/lib/chef/provider/package/rubygems.rb
@@ -281,7 +281,7 @@ class Chef
end
class AlternateGemEnvironment < GemEnvironment
- JRUBY_PLATFORM = /(:?universal|x86_64|x86)\-java\-[0-9\.]+/
+ JRUBY_PLATFORM = /(:?universal|x86_64|x86)\-java\-[0-9\.]+/.freeze
def self.gempath_cache
@gempath_cache ||= {}
diff --git a/lib/chef/provider/package/yum/rpm_utils.rb b/lib/chef/provider/package/yum/rpm_utils.rb
index eefc0b95b2..22c0ff807b 100644
--- a/lib/chef/provider/package/yum/rpm_utils.rb
+++ b/lib/chef/provider/package/yum/rpm_utils.rb
@@ -133,9 +133,7 @@ class Chef
while (x_pos <= x_pos_max) && (isalnum(x[x_pos]) == false)
x_pos += 1 # +1 over pos_max if end of string
end
- while (y_pos <= y_pos_max) && (isalnum(y[y_pos]) == false)
- y_pos += 1
- end
+ y_pos += 1 while (y_pos <= y_pos_max) && (isalnum(y[y_pos]) == false)
# if we hit the end of either we are done matching segments
if (x_pos == x_pos_max + 1) || (y_pos == y_pos_max + 1)
@@ -154,29 +152,21 @@ class Chef
x_seg_pos += 1
# gather up our digits
- while (x_seg_pos <= x_pos_max) && isdigit(x[x_seg_pos])
- x_seg_pos += 1
- end
+ x_seg_pos += 1 while (x_seg_pos <= x_pos_max) && isdigit(x[x_seg_pos])
# copy the segment but not the unmatched character that x_seg_pos will
# refer to
x_comp = x[x_pos, x_seg_pos - x_pos]
- while (y_seg_pos <= y_pos_max) && isdigit(y[y_seg_pos])
- y_seg_pos += 1
- end
+ y_seg_pos += 1 while (y_seg_pos <= y_pos_max) && isdigit(y[y_seg_pos])
y_comp = y[y_pos, y_seg_pos - y_pos]
else
# we are comparing strings
x_seg_is_num = false
- while (x_seg_pos <= x_pos_max) && isalpha(x[x_seg_pos])
- x_seg_pos += 1
- end
+ x_seg_pos += 1 while (x_seg_pos <= x_pos_max) && isalpha(x[x_seg_pos])
x_comp = x[x_pos, x_seg_pos - x_pos]
- while (y_seg_pos <= y_pos_max) && isalpha(y[y_seg_pos])
- y_seg_pos += 1
- end
+ y_seg_pos += 1 while (y_seg_pos <= y_pos_max) && isalpha(y[y_seg_pos])
y_comp = y[y_pos, y_seg_pos - y_pos]
end
diff --git a/lib/chef/provider/powershell_script.rb b/lib/chef/provider/powershell_script.rb
index 529ae409d8..a903f83107 100644
--- a/lib/chef/provider/powershell_script.rb
+++ b/lib/chef/provider/powershell_script.rb
@@ -89,7 +89,7 @@ class Chef
{
#{new_resource.code}
}
-EOH
+ EOH
user_script_file.puts user_code_wrapped_in_powershell_script_block
# A .close or explicit .flush required to ensure the file is
@@ -215,7 +215,7 @@ EOH
# launched with -Command, it will be 0 if $exitstatus was 0,
# 1 (i.e. failed) otherwise.
exit $exitstatus
-EOH
+ EOH
end
end
diff --git a/lib/chef/provider/route.rb b/lib/chef/provider/route.rb
index b8af9e55b8..e20102e2f3 100644
--- a/lib/chef/provider/route.rb
+++ b/lib/chef/provider/route.rb
@@ -28,39 +28,39 @@ class Chef
attr_accessor :is_running
- MASK = { "0.0.0.0" => "0",
- "128.0.0.0" => "1",
- "192.0.0.0" => "2",
- "224.0.0.0" => "3",
- "240.0.0.0" => "4",
- "248.0.0.0" => "5",
- "252.0.0.0" => "6",
- "254.0.0.0" => "7",
- "255.0.0.0" => "8",
- "255.128.0.0" => "9",
- "255.192.0.0" => "10",
- "255.224.0.0" => "11",
- "255.240.0.0" => "12",
- "255.248.0.0" => "13",
- "255.252.0.0" => "14",
- "255.254.0.0" => "15",
- "255.255.0.0" => "16",
- "255.255.128.0" => "17",
- "255.255.192.0" => "18",
- "255.255.224.0" => "19",
- "255.255.240.0" => "20",
- "255.255.248.0" => "21",
- "255.255.252.0" => "22",
- "255.255.254.0" => "23",
- "255.255.255.0" => "24",
- "255.255.255.128" => "25",
- "255.255.255.192" => "26",
- "255.255.255.224" => "27",
- "255.255.255.240" => "28",
- "255.255.255.248" => "29",
- "255.255.255.252" => "30",
- "255.255.255.254" => "31",
- "255.255.255.255" => "32" }.freeze
+ MASK = { "0.0.0.0" => "0",
+ "128.0.0.0" => "1",
+ "192.0.0.0" => "2",
+ "224.0.0.0" => "3",
+ "240.0.0.0" => "4",
+ "248.0.0.0" => "5",
+ "252.0.0.0" => "6",
+ "254.0.0.0" => "7",
+ "255.0.0.0" => "8",
+ "255.128.0.0" => "9",
+ "255.192.0.0" => "10",
+ "255.224.0.0" => "11",
+ "255.240.0.0" => "12",
+ "255.248.0.0" => "13",
+ "255.252.0.0" => "14",
+ "255.254.0.0" => "15",
+ "255.255.0.0" => "16",
+ "255.255.128.0" => "17",
+ "255.255.192.0" => "18",
+ "255.255.224.0" => "19",
+ "255.255.240.0" => "20",
+ "255.255.248.0" => "21",
+ "255.255.252.0" => "22",
+ "255.255.254.0" => "23",
+ "255.255.255.0" => "24",
+ "255.255.255.128" => "25",
+ "255.255.255.192" => "26",
+ "255.255.255.224" => "27",
+ "255.255.255.240" => "28",
+ "255.255.255.248" => "29",
+ "255.255.255.252" => "30",
+ "255.255.255.254" => "31",
+ "255.255.255.255" => "32" }.freeze
def hex2ip(hex_data)
# Cleanup hex data
diff --git a/lib/chef/provider/service/aixinit.rb b/lib/chef/provider/service/aixinit.rb
index dd8514cf20..43e6b3ac1b 100644
--- a/lib/chef/provider/service/aixinit.rb
+++ b/lib/chef/provider/service/aixinit.rb
@@ -22,7 +22,7 @@ class Chef
class Provider
class Service
class AixInit < Chef::Provider::Service::Init
- RC_D_SCRIPT_NAME = /\/etc\/rc.d\/rc2.d\/([SK])(\d\d|)/i
+ RC_D_SCRIPT_NAME = /\/etc\/rc.d\/rc2.d\/([SK])(\d\d|)/i.freeze
def initialize(new_resource, run_context)
super
diff --git a/lib/chef/provider/service/debian.rb b/lib/chef/provider/service/debian.rb
index 351075111b..b6a938a7e8 100644
--- a/lib/chef/provider/service/debian.rb
+++ b/lib/chef/provider/service/debian.rb
@@ -26,8 +26,8 @@ class Chef
Chef::Platform::ServiceHelpers.service_resource_providers.include?(:debian)
end
- UPDATE_RC_D_ENABLED_MATCHES = /\/rc[\dS].d\/S|not installed/i
- UPDATE_RC_D_PRIORITIES = /\/rc([\dS]).d\/([SK])(\d\d)/i
+ UPDATE_RC_D_ENABLED_MATCHES = /\/rc[\dS].d\/S|not installed/i.freeze
+ UPDATE_RC_D_PRIORITIES = /\/rc([\dS]).d\/([SK])(\d\d)/i.freeze
def self.supports?(resource, action)
Chef::Platform::ServiceHelpers.config_for_service(resource.service_name).include?(:initd)
diff --git a/lib/chef/provider/service/redhat.rb b/lib/chef/provider/service/redhat.rb
index 18ef245083..9e8ff30216 100644
--- a/lib/chef/provider/service/redhat.rb
+++ b/lib/chef/provider/service/redhat.rb
@@ -32,8 +32,8 @@ class Chef
Chef::Platform::ServiceHelpers.service_resource_providers.include?(:redhat)
end
- CHKCONFIG_ON = /\d:on/
- CHKCONFIG_MISSING = /No such/
+ CHKCONFIG_ON = /\d:on/.freeze
+ CHKCONFIG_MISSING = /No such/.freeze
def self.supports?(resource, action)
Chef::Platform::ServiceHelpers.config_for_service(resource.service_name).include?(:initd)
diff --git a/lib/chef/provider/service/upstart.rb b/lib/chef/provider/service/upstart.rb
index 68f97d1ff2..96ed16dc8f 100644
--- a/lib/chef/provider/service/upstart.rb
+++ b/lib/chef/provider/service/upstart.rb
@@ -32,7 +32,7 @@ class Chef
Chef::Platform::ServiceHelpers.service_resource_providers.include?(:upstart)
end
- UPSTART_STATE_FORMAT = /\S+ \(?(start|stop)?\)? ?[\/ ](\w+)/
+ UPSTART_STATE_FORMAT = /\S+ \(?(start|stop)?\)? ?[\/ ](\w+)/.freeze
# Returns true if the configs for the service name has upstart variable
def self.supports?(resource, action)
diff --git a/lib/chef/provider/subversion.rb b/lib/chef/provider/subversion.rb
index dec9e06f87..adea6a6428 100644
--- a/lib/chef/provider/subversion.rb
+++ b/lib/chef/provider/subversion.rb
@@ -29,7 +29,7 @@ class Chef
provides :subversion
- SVN_INFO_PATTERN = /^([\w\s]+): (.+)$/
+ SVN_INFO_PATTERN = /^([\w\s]+): (.+)$/.freeze
include ChefConfig::Mixin::FuzzyHostnameMatcher
diff --git a/lib/chef/provider/windows_task.rb b/lib/chef/provider/windows_task.rb
index 1d77c6867b..c656506138 100644
--- a/lib/chef/provider/windows_task.rb
+++ b/lib/chef/provider/windows_task.rb
@@ -347,21 +347,21 @@ class Chef
flag = true
else
flag = true if start_day_updated?(current_task_trigger, new_task_trigger) == true ||
- start_time_updated?(current_task_trigger, new_task_trigger) == true ||
- current_task_trigger[:trigger_type] != new_task_trigger[:trigger_type] ||
- current_task_trigger[:type] != new_task_trigger[:type] ||
- current_task_trigger[:random_minutes_interval].to_i != new_task_trigger[:random_minutes_interval].to_i ||
- current_task_trigger[:minutes_interval].to_i != new_task_trigger[:minutes_interval].to_i ||
- task.account_information.to_s.casecmp(new_resource.user.to_s) != 0 ||
- task.application_name != new_resource.command ||
- description_needs_update?(task) ||
- task.parameters != new_resource.command_arguments.to_s ||
- task.working_directory != new_resource.cwd.to_s ||
- task.principals[:logon_type] != logon_type ||
- task.principals[:run_level] != run_level ||
- PRIORITY[task.priority] != new_resource.priority ||
- task.settings[:disallow_start_if_on_batteries] != new_resource.disallow_start_if_on_batteries ||
- task.settings[:stop_if_going_on_batteries] != new_resource.stop_if_going_on_batteries
+ start_time_updated?(current_task_trigger, new_task_trigger) == true ||
+ current_task_trigger[:trigger_type] != new_task_trigger[:trigger_type] ||
+ current_task_trigger[:type] != new_task_trigger[:type] ||
+ current_task_trigger[:random_minutes_interval].to_i != new_task_trigger[:random_minutes_interval].to_i ||
+ current_task_trigger[:minutes_interval].to_i != new_task_trigger[:minutes_interval].to_i ||
+ task.account_information.to_s.casecmp(new_resource.user.to_s) != 0 ||
+ task.application_name != new_resource.command ||
+ description_needs_update?(task) ||
+ task.parameters != new_resource.command_arguments.to_s ||
+ task.working_directory != new_resource.cwd.to_s ||
+ task.principals[:logon_type] != logon_type ||
+ task.principals[:run_level] != run_level ||
+ PRIORITY[task.priority] != new_resource.priority ||
+ task.settings[:disallow_start_if_on_batteries] != new_resource.disallow_start_if_on_batteries ||
+ task.settings[:stop_if_going_on_batteries] != new_resource.stop_if_going_on_batteries
if trigger_type == TaskScheduler::MONTHLYDATE
flag = true if current_task_trigger[:run_on_last_day_of_month] != new_task_trigger[:run_on_last_day_of_month]
end
diff --git a/lib/chef/resource/build_essential.rb b/lib/chef/resource/build_essential.rb
index d9d75fb83b..c10be4b6a1 100644
--- a/lib/chef/resource/build_essential.rb
+++ b/lib/chef/resource/build_essential.rb
@@ -112,7 +112,7 @@ class Chef
Chef::Log.warn <<-EOH
The build_essential resource does not currently support the '#{node['platform_family']}'
platform family. Skipping...
- EOH
+ EOH
end
end
diff --git a/lib/chef/resource/windows_certificate.rb b/lib/chef/resource/windows_certificate.rb
index 9a2f4bda26..2057855b2c 100644
--- a/lib/chef/resource/windows_certificate.rb
+++ b/lib/chef/resource/windows_certificate.rb
@@ -200,7 +200,7 @@ class Chef
<<-EOH
$hash = #{hash}
Test-Path "Cert:\\#{cert_location}\\#{new_resource.store_name}\\$hash"
- EOH
+ EOH
end
def within_store_script
@@ -210,7 +210,7 @@ class Chef
$store.Open([System.Security.Cryptography.X509Certificates.OpenFlags]::ReadWrite)
#{inner_script}
$store.Close()
- EOH
+ EOH
end
def acl_script(hash)
@@ -233,7 +233,7 @@ class Chef
$userSID = $currentUser.Translate([System.Security.Principal.SecurityIdentifier]).Value
$fullpath = "$Env:ProgramData\\Microsoft\\Crypto\\RSA\\$userSID\\$keyname"
}
- EOH
+ EOH
new_resource.private_key_acl.each do |name|
set_acl_script << "$uname='#{name}'; icacls $fullpath /grant $uname`:RX\n"
end
diff --git a/lib/chef/resource_collection/resource_set.rb b/lib/chef/resource_collection/resource_set.rb
index 6ff29247a0..637ba48030 100644
--- a/lib/chef/resource_collection/resource_set.rb
+++ b/lib/chef/resource_collection/resource_set.rb
@@ -26,14 +26,14 @@ class Chef
# Matches a multiple resource lookup specification,
# e.g., "service[nginx,unicorn]"
- MULTIPLE_RESOURCE_MATCH = /^(.+)\[(.+?),(.+)\]$/
+ MULTIPLE_RESOURCE_MATCH = /^(.+)\[(.+?),(.+)\]$/.freeze
# Matches a single resource lookup specification,
# e.g., "service[nginx]"
- SINGLE_RESOURCE_MATCH = /^(.+)\[(.*)\]$/
+ SINGLE_RESOURCE_MATCH = /^(.+)\[(.*)\]$/.freeze
# Matches e.g. "apt_update" with no name
- NAMELESS_RESOURCE_MATCH = /^([^\[\]\s]+)$/
+ NAMELESS_RESOURCE_MATCH = /^([^\[\]\s]+)$/.freeze
def initialize
@resources_by_key = Hash.new
diff --git a/lib/chef/run_context.rb b/lib/chef/run_context.rb
index 657caf0f81..b940bfecbd 100644
--- a/lib/chef/run_context.rb
+++ b/lib/chef/run_context.rb
@@ -337,7 +337,7 @@ class Chef
is not a dependency of any cookbook in the run_list. To load this recipe,
first add a dependency on cookbook '#{cookbook_name}' in the cookbook you're
including it from in that cookbook's metadata.
-ERROR_MESSAGE
+ ERROR_MESSAGE
end
if loaded_fully_qualified_recipe?(cookbook_name, recipe_short_name)
diff --git a/lib/chef/run_list/run_list_item.rb b/lib/chef/run_list/run_list_item.rb
index 74b4741eba..f5aec6de5e 100644
--- a/lib/chef/run_list/run_list_item.rb
+++ b/lib/chef/run_list/run_list_item.rb
@@ -18,10 +18,10 @@
class Chef
class RunList
class RunListItem
- QUALIFIED_RECIPE = %r{^recipe\[([^\]@]+)(@([0-9]+(\.[0-9]+){1,2}))?\]$}
- QUALIFIED_ROLE = %r{^role\[([^\]]+)\]$}
- VERSIONED_UNQUALIFIED_RECIPE = %r{^([^@]+)(@([0-9]+(\.[0-9]+){1,2}))$}
- FALSE_FRIEND = %r{[\[\]]}
+ QUALIFIED_RECIPE = %r{^recipe\[([^\]@]+)(@([0-9]+(\.[0-9]+){1,2}))?\]$}.freeze
+ QUALIFIED_ROLE = %r{^role\[([^\]]+)\]$}.freeze
+ VERSIONED_UNQUALIFIED_RECIPE = %r{^([^@]+)(@([0-9]+(\.[0-9]+){1,2}))$}.freeze
+ FALSE_FRIEND = %r{[\[\]]}.freeze
attr_reader :name, :type, :version
diff --git a/lib/chef/shell.rb b/lib/chef/shell.rb
index 6c5f70edcc..e717c3705e 100644
--- a/lib/chef/shell.rb
+++ b/lib/chef/shell.rb
@@ -215,7 +215,7 @@ module Shell
/etc/chef/client.rb if -z option is given.
/etc/chef/solo.rb if --solo-legacy-mode option is given.
.chef/knife.rb if -s option is given.
-FOOTER
+ FOOTER
option :config_file,
short: "-c CONFIG",
diff --git a/lib/chef/version_constraint.rb b/lib/chef/version_constraint.rb
index 6b57cfefe1..bce2a29887 100644
--- a/lib/chef/version_constraint.rb
+++ b/lib/chef/version_constraint.rb
@@ -21,7 +21,7 @@ class Chef
DEFAULT_CONSTRAINT = ">= 0.0.0".freeze
STANDARD_OPS = %w{< > <= >=}.freeze
OPS = %w{< > = <= >= ~>}.freeze
- PATTERN = /^(#{OPS.join('|')}) *([0-9].*)$/
+ PATTERN = /^(#{OPS.join('|')}) *([0-9].*)$/.freeze
VERSION_CLASS = Chef::Version
attr_reader :op, :version