diff options
42 files changed, 125 insertions, 106 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b5327dfd1..0d36399f12 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,23 @@ <!-- usage documentation: http://expeditor-docs.es.chef.io/configuration/changelog/ --> This changelog lists individual merged pull requests to Chef Infra Client and geared towards developers. For a list of significant changes per release see the [Chef Infra Client Release Notes](https://docs.chef.io/release_notes_client/). -<!-- latest_release --> +<!-- latest_release 17.9.23 --> +## [v17.9.23](https://github.com/chef/chef/tree/v17.9.23) (2022-01-04) + +#### Merged Pull Requests +- Resolve Style/SelectByRegexp warnings [#12422](https://github.com/chef/chef/pull/12422) ([tas50](https://github.com/tas50)) <!-- latest_release --> -<!-- release_rollup --> +<!-- release_rollup since=17.9.18 --> +### Changes not yet released to stable + +#### Merged Pull Requests +- Resolve Style/SelectByRegexp warnings [#12422](https://github.com/chef/chef/pull/12422) ([tas50](https://github.com/tas50)) <!-- 17.9.23 --> +- Resolve Style/MapToHash chefstyle warning [#12421](https://github.com/chef/chef/pull/12421) ([tas50](https://github.com/tas50)) <!-- 17.9.22 --> +- Fix typo in subscribes method documentation [#12419](https://github.com/chef/chef/pull/12419) ([gravitystorm](https://github.com/gravitystorm)) <!-- 17.9.21 --> +- Bump omnibus-software from `4707275` to `b6dd27a` in /omnibus [#12425](https://github.com/chef/chef/pull/12425) ([dependabot[bot]](https://github.com/dependabot[bot])) <!-- 17.9.20 --> +- Bump chef/chefstyle to c72bbc6a79ab0859755981f99d76635cd5bc275a [#12420](https://github.com/chef/chef/pull/12420) ([chef-expeditor[bot]](https://github.com/chef-expeditor[bot])) <!-- 17.9.19 --> +- homebrew_tap: Fix failures due to missing `full` property [#12418](https://github.com/chef/chef/pull/12418) ([jweyer8](https://github.com/jweyer8)) <!-- 17.9.19 --> <!-- release_rollup --> <!-- latest_stable_release --> diff --git a/Gemfile.lock b/Gemfile.lock index 4b1a09470e..ef544a088a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,17 +1,17 @@ GIT remote: https://github.com/chef/chefstyle.git - revision: 8b945f7083df2459718f023304116b8404a83a7d + revision: d3050865f4c7b4be668397007d9964ce2d54e6ee branch: main specs: - chefstyle (2.1.3) - rubocop (= 1.23.0) + chefstyle (2.2.0) + rubocop (= 1.24.1) GIT remote: https://github.com/chef/ohai.git - revision: 795c6f0bac2c47dd94ea1e7bf55b1a906d2a14dd + revision: e86d186661a599703fe929497b33c5f7a3257d49 branch: main specs: - ohai (17.9.0) + ohai (17.9.1) chef-config (>= 14.12, < 18) chef-utils (>= 16.0, < 18) ffi (~> 1.9) @@ -35,12 +35,12 @@ GIT PATH remote: . specs: - chef (17.9.18) + chef (17.9.23) addressable aws-sdk-s3 (~> 1.91) aws-sdk-secretsmanager (~> 1.46) - chef-config (= 17.9.18) - chef-utils (= 17.9.18) + chef-config (= 17.9.23) + chef-utils (= 17.9.23) chef-vault chef-zero (>= 14.0.11) corefoundation (~> 0.3.4) @@ -66,12 +66,12 @@ PATH train-winrm (>= 0.2.5) uuidtools (>= 2.1.5, < 3.0) vault (~> 0.16) - chef (17.9.18-universal-mingw32) + chef (17.9.23-universal-mingw32) addressable aws-sdk-s3 (~> 1.91) aws-sdk-secretsmanager (~> 1.46) - chef-config (= 17.9.18) - chef-utils (= 17.9.18) + chef-config (= 17.9.23) + chef-utils (= 17.9.23) chef-vault chef-zero (>= 14.0.11) corefoundation (~> 0.3.4) @@ -112,15 +112,15 @@ PATH PATH remote: chef-bin specs: - chef-bin (17.9.18) - chef (= 17.9.18) + chef-bin (17.9.23) + chef (= 17.9.23) PATH remote: chef-config specs: - chef-config (17.9.18) + chef-config (17.9.23) addressable - chef-utils (= 17.9.18) + chef-utils (= 17.9.23) fuzzyurl mixlib-config (>= 2.2.12, < 4.0) mixlib-shellout (>= 2.0, < 4.0) @@ -129,7 +129,7 @@ PATH PATH remote: chef-utils specs: - chef-utils (17.9.18) + chef-utils (17.9.23) concurrent-ruby GEM @@ -142,7 +142,7 @@ GEM mixlib-shellout (>= 2.0, < 4.0) ast (2.4.2) aws-eventstream (1.2.0) - aws-partitions (1.543.0) + aws-partitions (1.544.0) aws-sdk-core (3.125.0) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.525.0) @@ -329,16 +329,16 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.10.0) rspec-support (3.10.3) - rubocop (1.23.0) + rubocop (1.24.1) parallel (~> 1.10) parser (>= 3.0.0.0) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml - rubocop-ast (>= 1.12.0, < 2.0) + rubocop-ast (>= 1.15.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.15.0) + rubocop-ast (1.15.1) parser (>= 3.0.1.1) ruby-progressbar (1.11.0) ruby2_keywords (0.0.5) @@ -1 +1 @@ -17.9.18
\ No newline at end of file +17.9.23
\ No newline at end of file diff --git a/chef-bin/lib/chef-bin/version.rb b/chef-bin/lib/chef-bin/version.rb index 954a419613..d28440a9eb 100644 --- a/chef-bin/lib/chef-bin/version.rb +++ b/chef-bin/lib/chef-bin/version.rb @@ -21,7 +21,7 @@ module ChefBin CHEFBIN_ROOT = File.expand_path("..", __dir__) - VERSION = "17.9.18".freeze + VERSION = "17.9.23".freeze end # diff --git a/chef-config/lib/chef-config/config.rb b/chef-config/lib/chef-config/config.rb index 3eb8c8475c..970ee840a9 100644 --- a/chef-config/lib/chef-config/config.rb +++ b/chef-config/lib/chef-config/config.rb @@ -1223,7 +1223,7 @@ module ChefConfig "en.UTF-8" else # Will match en_ZZ.UTF-8, en_ZZ.utf-8, en_ZZ.UTF8, en_ZZ.utf8 - guesses = locales.select { |l| l =~ /^en_.*UTF-?8$/i } + guesses = locales.grep(/^en_.*UTF-?8$/i) unless guesses.empty? guessed_locale = guesses.first # Transform into the form en_ZZ.UTF-8 @@ -1287,10 +1287,10 @@ module ChefConfig require "digest/md5" unless defined?(Digest::MD5) # Remove pre-existing constants if they do exist to reduce the # amount of log spam and warnings. - Digest.send(:remove_const, "SHA1") if Digest.const_defined?("SHA1") - Digest.const_set("SHA1", OpenSSL::Digest::SHA1) - OpenSSL::Digest.send(:remove_const, "MD5") if OpenSSL::Digest.const_defined?("MD5") - OpenSSL::Digest.const_set("MD5", Digest::MD5) + Digest.send(:remove_const, "SHA1") if Digest.const_defined?(:SHA1) + Digest.const_set(:SHA1, OpenSSL::Digest::SHA1) + OpenSSL::Digest.send(:remove_const, "MD5") if OpenSSL::Digest.const_defined?(:MD5) + OpenSSL::Digest.const_set(:MD5, Digest::MD5) ChefConfig.logger.debug "FIPS mode is enabled." end end diff --git a/chef-config/lib/chef-config/version.rb b/chef-config/lib/chef-config/version.rb index 7593d77449..d603d8aca4 100644 --- a/chef-config/lib/chef-config/version.rb +++ b/chef-config/lib/chef-config/version.rb @@ -15,5 +15,5 @@ module ChefConfig CHEFCONFIG_ROOT = File.expand_path("..", __dir__) - VERSION = "17.9.18".freeze + VERSION = "17.9.23".freeze end diff --git a/chef-utils/lib/chef-utils/version.rb b/chef-utils/lib/chef-utils/version.rb index b3979e81db..bd64e0b318 100644 --- a/chef-utils/lib/chef-utils/version.rb +++ b/chef-utils/lib/chef-utils/version.rb @@ -16,5 +16,5 @@ module ChefUtils CHEFUTILS_ROOT = File.expand_path("..", __dir__) - VERSION = "17.9.18" + VERSION = "17.9.23" end diff --git a/kitchen-tests/cookbooks/end_to_end/recipes/_homebrew_tap.rb b/kitchen-tests/cookbooks/end_to_end/recipes/_homebrew_tap.rb new file mode 100644 index 0000000000..16600a92a0 --- /dev/null +++ b/kitchen-tests/cookbooks/end_to_end/recipes/_homebrew_tap.rb @@ -0,0 +1,5 @@ +homebrew_tap "chef/chef" + +homebrew_tap "chef/chef" do + action :untap +end
\ No newline at end of file diff --git a/kitchen-tests/cookbooks/end_to_end/recipes/macos.rb b/kitchen-tests/cookbooks/end_to_end/recipes/macos.rb index b83eb74506..213ef2d516 100644 --- a/kitchen-tests/cookbooks/end_to_end/recipes/macos.rb +++ b/kitchen-tests/cookbooks/end_to_end/recipes/macos.rb @@ -109,3 +109,4 @@ include_recipe "::_macos_userdefaults" include_recipe "::_ohai_hint" include_recipe "::_openssl" include_recipe "::_chef_gem" +include_recipe "::_homebrew_tap" diff --git a/knife/lib/chef/knife/acl_bulk_add.rb b/knife/lib/chef/knife/acl_bulk_add.rb index 4992fe2afa..bdd2e0fdc4 100644 --- a/knife/lib/chef/knife/acl_bulk_add.rb +++ b/knife/lib/chef/knife/acl_bulk_add.rb @@ -56,7 +56,7 @@ class Chef objects_to_modify = [] all_objects = rest.get_rest(object_type) - objects_to_modify = all_objects.keys.select { |object_name| object_name =~ object_name_matcher } + objects_to_modify = all_objects.keys.grep(object_name_matcher) if objects_to_modify.empty? ui.info "No #{object_type} match the expression /#{regex}/" diff --git a/knife/lib/chef/knife/acl_bulk_remove.rb b/knife/lib/chef/knife/acl_bulk_remove.rb index 0f35f1e2fb..fce76f250d 100644 --- a/knife/lib/chef/knife/acl_bulk_remove.rb +++ b/knife/lib/chef/knife/acl_bulk_remove.rb @@ -61,7 +61,7 @@ class Chef objects_to_modify = [] all_objects = rest.get_rest(object_type) - objects_to_modify = all_objects.keys.select { |object_name| object_name =~ object_name_matcher } + objects_to_modify = all_objects.keys.grep(object_name_matcher) if objects_to_modify.empty? ui.info "No #{object_type} match the expression /#{regex}/" diff --git a/knife/lib/chef/knife/core/subcommand_loader.rb b/knife/lib/chef/knife/core/subcommand_loader.rb index ca7bfcd008..d70ba11a59 100644 --- a/knife/lib/chef/knife/core/subcommand_loader.rb +++ b/knife/lib/chef/knife/core/subcommand_loader.rb @@ -184,7 +184,7 @@ class Chef # @return [Array<String>] # def positional_arguments(args) - args.select { |arg| arg =~ /^(([[:alnum:]])[[:alnum:]\_\-]+)$/ } + args.grep(/^(([[:alnum:]])[[:alnum:]\_\-]+)$/) end # Returns an Array of paths to knife commands located in diff --git a/knife/lib/chef/knife/version.rb b/knife/lib/chef/knife/version.rb index 12504241cd..d72792251f 100644 --- a/knife/lib/chef/knife/version.rb +++ b/knife/lib/chef/knife/version.rb @@ -17,7 +17,7 @@ class Chef class Knife KNIFE_ROOT = File.expand_path("../..", __dir__) - VERSION = "17.9.18".freeze + VERSION = "17.9.23".freeze end end diff --git a/knife/spec/knife_spec_helper.rb b/knife/spec/knife_spec_helper.rb index 7395d2759b..5a3c0761d5 100644 --- a/knife/spec/knife_spec_helper.rb +++ b/knife/spec/knife_spec_helper.rb @@ -78,8 +78,8 @@ require "spec/support/shared/matchers/match_environment_variable" # Excludes support/platforms by default # Do not change the gsub. Dir["spec/support/**/*.rb"] - .reject { |f| f =~ %r{^spec/support/platforms} } - .reject { |f| f =~ %r{^spec/support/pedant} } + .grep_v(%r{^spec/support/platforms}) + .grep_v(%r{^spec/support/pedant}) .map { |f| f.gsub(/.rb$/, "") } .map { |f| f.gsub(%r{spec/}, "") } .each { |f| require f } diff --git a/knife/spec/support/platform_helpers.rb b/knife/spec/support/platform_helpers.rb index a3fb95e069..4d3acbcb33 100644 --- a/knife/spec/support/platform_helpers.rb +++ b/knife/spec/support/platform_helpers.rb @@ -168,7 +168,7 @@ def wpar? end def supports_cloexec? - Fcntl.const_defined?("F_SETFD") && Fcntl.const_defined?("FD_CLOEXEC") + Fcntl.const_defined?(:F_SETFD) && Fcntl.const_defined?(:FD_CLOEXEC) end def selinux_enabled? diff --git a/lib/chef/cookbook/syntax_check.rb b/lib/chef/cookbook/syntax_check.rb index 8b593eea81..555d2f6715 100644 --- a/lib/chef/cookbook/syntax_check.rb +++ b/lib/chef/cookbook/syntax_check.rb @@ -113,7 +113,7 @@ class Chef end def remove_uninteresting_ruby_files(file_list) - file_list.reject { |f| f =~ %r{#{Regexp.quote(cookbook_path)}/(files|templates)/} } + file_list.grep_v(%r{#{Regexp.quote(cookbook_path)}/(files|templates)/}) end def ruby_files diff --git a/lib/chef/provider/package.rb b/lib/chef/provider/package.rb index daf46c502e..a49a97ea7e 100644 --- a/lib/chef/provider/package.rb +++ b/lib/chef/provider/package.rb @@ -658,7 +658,7 @@ class Chef end def allow_downgrade - if new_resource.respond_to?("allow_downgrade") + if new_resource.respond_to?(:allow_downgrade) new_resource.allow_downgrade else true diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb index 746efb5fd4..03444ce38c 100644 --- a/lib/chef/resource.rb +++ b/lib/chef/resource.rb @@ -311,7 +311,7 @@ class Chef # file '/foo.txt' do # content 'hi' # action :nothing - # subscribes :create, '/bar.txt' + # subscribes :create, bar # end # @example Multiple resources by string # file '/foo.txt' do diff --git a/lib/chef/resource/homebrew_tap.rb b/lib/chef/resource/homebrew_tap.rb index b728d447c8..a150210951 100644 --- a/lib/chef/resource/homebrew_tap.rb +++ b/lib/chef/resource/homebrew_tap.rb @@ -53,7 +53,7 @@ class Chef action :tap, description: "Add a Homebrew tap." do unless tapped?(new_resource.tap_name) converge_by("tap #{new_resource.tap_name}") do - shell_out!("#{new_resource.homebrew_path} tap #{new_resource.full ? "--full" : ""} #{new_resource.tap_name} #{new_resource.url || ""}", + shell_out!("#{new_resource.homebrew_path} tap #{new_resource.tap_name} #{new_resource.url || ""}", user: new_resource.owner, env: { "HOME" => ::Dir.home(new_resource.owner), "USER" => new_resource.owner }, cwd: ::Dir.home(new_resource.owner)) diff --git a/lib/chef/resource_reporter.rb b/lib/chef/resource_reporter.rb index 242a6e9f0f..16d90baf4f 100644 --- a/lib/chef/resource_reporter.rb +++ b/lib/chef/resource_reporter.rb @@ -34,7 +34,7 @@ class Chef as_hash["after"] = new_resource.state_for_resource_reporter as_hash["before"] = current_resource ? current_resource.state_for_resource_reporter : {} as_hash["duration"] = ( action_record.elapsed_time * 1000 ).to_i.to_s - as_hash["delta"] = new_resource.diff if new_resource.respond_to?("diff") + as_hash["delta"] = new_resource.diff if new_resource.respond_to?(:diff) as_hash["delta"] = "" if as_hash["delta"].nil? # TODO: rename as "action" diff --git a/lib/chef/run_lock.rb b/lib/chef/run_lock.rb index 8382983ca0..b70a936aab 100644 --- a/lib/chef/run_lock.rb +++ b/lib/chef/run_lock.rb @@ -144,7 +144,7 @@ class Chef # If we support FD_CLOEXEC, then use it. # NB: ruby-2.0.0-p195 sets FD_CLOEXEC by default, but not # ruby-1.8.7/1.9.3 - if Fcntl.const_defined?("F_SETFD") && Fcntl.const_defined?("FD_CLOEXEC") + if Fcntl.const_defined?(:F_SETFD) && Fcntl.const_defined?(:FD_CLOEXEC) runlock.fcntl(Fcntl::F_SETFD, runlock.fcntl(Fcntl::F_GETFD, 0) | Fcntl::FD_CLOEXEC) end # Flock will return 0 if it can acquire the lock otherwise it diff --git a/lib/chef/version.rb b/lib/chef/version.rb index a3b3300291..d38abc2357 100644 --- a/lib/chef/version.rb +++ b/lib/chef/version.rb @@ -23,7 +23,7 @@ require_relative "version_string" class Chef CHEF_ROOT = File.expand_path("..", __dir__) - VERSION = Chef::VersionString.new("17.9.18") + VERSION = Chef::VersionString.new("17.9.23") end # diff --git a/omnibus/Gemfile.lock b/omnibus/Gemfile.lock index b3dca6cab1..bc892b1569 100644 --- a/omnibus/Gemfile.lock +++ b/omnibus/Gemfile.lock @@ -1,6 +1,6 @@ GIT remote: https://github.com/chef/omnibus-software.git - revision: 4707275bb5cac7643938972738e83723e8fd5621 + revision: b6dd27a6456aa6a19bb81e2dd65c8438067b46e9 branch: main specs: omnibus-software (4.0.0) @@ -33,7 +33,7 @@ GEM artifactory (3.0.15) awesome_print (1.9.2) aws-eventstream (1.2.0) - aws-partitions (1.543.0) + aws-partitions (1.544.0) aws-sdk-core (3.125.0) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.525.0) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 60b608e4ff..5cd04437be 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -78,9 +78,9 @@ require "spec/support/recipe_dsl_helper" # Excludes support/platforms by default # Do not change the gsub. Dir["spec/support/**/*.rb"] - .reject { |f| f =~ %r{^spec/support/platforms} } - .reject { |f| f =~ %r{^spec/support/pedant} } - .reject { |f| f =~ %r{^spec/support/shared/integration/knife_support} } + .grep_v(%r{^spec/support/platforms}) + .grep_v(%r{^spec/support/pedant}) + .grep_v(%r{^spec/support/shared/integration/knife_support}) .map { |f| f.gsub(/.rb$/, "") } .map { |f| f.gsub(%r{spec/}, "") } .each { |f| require f } diff --git a/spec/support/platform_helpers.rb b/spec/support/platform_helpers.rb index 1538a4eb34..430d9b055f 100644 --- a/spec/support/platform_helpers.rb +++ b/spec/support/platform_helpers.rb @@ -172,7 +172,7 @@ def wpar? end def supports_cloexec? - Fcntl.const_defined?("F_SETFD") && Fcntl.const_defined?("FD_CLOEXEC") + Fcntl.const_defined?(:F_SETFD) && Fcntl.const_defined?(:FD_CLOEXEC) end def selinux_enabled? diff --git a/spec/support/shared/functional/file_resource.rb b/spec/support/shared/functional/file_resource.rb index 1385d3dc30..70379263b6 100644 --- a/spec/support/shared/functional/file_resource.rb +++ b/spec/support/shared/functional/file_resource.rb @@ -157,7 +157,7 @@ shared_examples_for "a file with the wrong content" do context "when running :create action" do let(:provider) { resource.provider_for_action(:create) } - let(:reporter_messages) { provider.instance_variable_get("@converge_actions").actions[0][0] } + let(:reporter_messages) { provider.instance_variable_get(:@converge_actions).actions[0][0] } before do provider.run_action diff --git a/spec/support/shared/unit/provider/useradd_based_user_provider.rb b/spec/support/shared/unit/provider/useradd_based_user_provider.rb index 1f9f87866c..7e7a8ae857 100644 --- a/spec/support/shared/unit/provider/useradd_based_user_provider.rb +++ b/spec/support/shared/unit/provider/useradd_based_user_provider.rb @@ -169,7 +169,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option before do provider.new_resource.system true # there is no public API to set attribute's value to nil - provider.new_resource.instance_variable_set("@home", nil) + provider.new_resource.instance_variable_set(:@home, nil) end it "should not include -m or -d in the command options" do diff --git a/spec/unit/dsl/registry_helper_spec.rb b/spec/unit/dsl/registry_helper_spec.rb index 5ef8caa053..09dfe24226 100644 --- a/spec/unit/dsl/registry_helper_spec.rb +++ b/spec/unit/dsl/registry_helper_spec.rb @@ -31,22 +31,22 @@ describe Chef::Resource::RegistryKey do context "tests registry dsl" do it "resource can access registry_helper method registry_key_exists" do - expect(@resource.respond_to?("registry_key_exists?")).to eq(true) + expect(@resource.respond_to?(:registry_key_exists?)).to eq(true) end it "resource can access registry_helper method registry_get_values" do - expect(@resource.respond_to?("registry_get_values")).to eq(true) + expect(@resource.respond_to?(:registry_get_values)).to eq(true) end it "resource can access registry_helper method registry_has_subkey" do - expect(@resource.respond_to?("registry_has_subkeys?")).to eq(true) + expect(@resource.respond_to?(:registry_has_subkeys?)).to eq(true) end it "resource can access registry_helper method registry_get_subkeys" do - expect(@resource.respond_to?("registry_get_subkeys")).to eq(true) + expect(@resource.respond_to?(:registry_get_subkeys)).to eq(true) end it "resource can access registry_helper method registry_value_exists" do - expect(@resource.respond_to?("registry_value_exists?")).to eq(true) + expect(@resource.respond_to?(:registry_value_exists?)).to eq(true) end it "resource can access registry_helper method data_value_exists" do - expect(@resource.respond_to?("registry_data_exists?")).to eq(true) + expect(@resource.respond_to?(:registry_data_exists?)).to eq(true) end end end diff --git a/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb b/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb index 0760bcee1d..a5ec146fc1 100644 --- a/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb +++ b/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb @@ -94,7 +94,7 @@ describe Chef::GuardInterpreter::ResourceGuardInterpreter do describe "script command opts switch" do let(:guard_interpreter) { Chef::GuardInterpreter::ResourceGuardInterpreter.new(parent_resource, "exit 0", {}) } - let(:resource) { guard_interpreter.instance_variable_get("@resource") } + let(:resource) { guard_interpreter.instance_variable_get(:@resource) } context "resource is a Script" do context "and guard_interpreter is a :script" do diff --git a/spec/unit/lwrp_spec.rb b/spec/unit/lwrp_spec.rb index 5767e3987b..e93640ab86 100644 --- a/spec/unit/lwrp_spec.rb +++ b/spec/unit/lwrp_spec.rb @@ -54,7 +54,7 @@ describe "LWRP" do end it "should not skip loading a resource when there's a top level symbol of the same name" do - Object.const_set("LwrpFoo", Class.new) + Object.const_set(:LwrpFoo, Class.new) file = File.expand_path( "lwrp/resources/foo.rb", CHEF_SPEC_DATA) expect(Chef::Log).not_to receive(:info).with(/Skipping/) expect(Chef::Log).not_to receive(:trace).with(/anymore/) @@ -63,7 +63,7 @@ describe "LWRP" do end it "should not skip loading a provider when there's a top level symbol of the same name" do - Object.const_set("LwrpBuckPasser", Class.new) + Object.const_set(:LwrpBuckPasser, Class.new) file = File.expand_path( "lwrp/providers/buck_passer.rb", CHEF_SPEC_DATA) expect(Chef::Log).not_to receive(:info).with(/Skipping/) expect(Chef::Log).not_to receive(:trace).with(/anymore/) diff --git a/spec/unit/provider/dsc_script_spec.rb b/spec/unit/provider/dsc_script_spec.rb index d59b6f2480..41544a32a2 100644 --- a/spec/unit/provider/dsc_script_spec.rb +++ b/spec/unit/provider/dsc_script_spec.rb @@ -39,21 +39,21 @@ describe Chef::Provider::DscScript do it "describes the resource as converged if there were 0 DSC resources" do allow(provider).to receive(:run_configuration).with(:test).and_return([]) provider.load_current_resource - expect(provider.instance_variable_get("@resource_converged")).to be_truthy + expect(provider.instance_variable_get(:@resource_converged)).to be_truthy end it "describes the resource as not converged if there is 1 DSC resources that is converged" do dsc_resource_info = Chef::Util::DSC::ResourceInfo.new("resource", false, ["nothing will change something"]) allow(provider).to receive(:run_configuration).with(:test).and_return([dsc_resource_info]) provider.load_current_resource - expect(provider.instance_variable_get("@resource_converged")).to be_truthy + expect(provider.instance_variable_get(:@resource_converged)).to be_truthy end it "describes the resource as not converged if there is 1 DSC resources that is not converged" do dsc_resource_info = Chef::Util::DSC::ResourceInfo.new("resource", true, ["will change something"]) allow(provider).to receive(:run_configuration).with(:test).and_return([dsc_resource_info]) provider.load_current_resource - expect(provider.instance_variable_get("@resource_converged")).to be_falsey + expect(provider.instance_variable_get(:@resource_converged)).to be_falsey end it "describes the resource as not converged if there are any DSC resources that are not converged" do @@ -62,7 +62,7 @@ describe Chef::Provider::DscScript do allow(provider).to receive(:run_configuration).with(:test).and_return([dsc_resource_info1, dsc_resource_info2]) provider.load_current_resource - expect(provider.instance_variable_get("@resource_converged")).to be_falsey + expect(provider.instance_variable_get(:@resource_converged)).to be_falsey end it "describes the resource as converged if all DSC resources that are converged" do @@ -71,7 +71,7 @@ describe Chef::Provider::DscScript do allow(provider).to receive(:run_configuration).with(:test).and_return([dsc_resource_info1, dsc_resource_info2]) provider.load_current_resource - expect(provider.instance_variable_get("@resource_converged")).to be_truthy + expect(provider.instance_variable_get(:@resource_converged)).to be_truthy end end @@ -126,19 +126,19 @@ describe Chef::Provider::DscScript do describe "#generate_description" do it "removes the resource name from the beginning of any log line from the LCM" do dsc_resource_info = Chef::Util::DSC::ResourceInfo.new("resourcename", true, ["resourcename doing something", "lastline"]) - provider.instance_variable_set("@dsc_resources_info", [dsc_resource_info]) + provider.instance_variable_set(:@dsc_resources_info, [dsc_resource_info]) expect(provider.send(:generate_description)[1]).to match(/converge DSC resource resourcename by doing something/) end it "ignores the last line" do dsc_resource_info = Chef::Util::DSC::ResourceInfo.new("resourcename", true, ["resourcename doing something", "lastline"]) - provider.instance_variable_set("@dsc_resources_info", [dsc_resource_info]) + provider.instance_variable_set(:@dsc_resources_info, [dsc_resource_info]) expect(provider.send(:generate_description)[1]).not_to match(/lastline/) end it "reports a dsc resource has not been changed if the LCM reported no change was required" do dsc_resource_info = Chef::Util::DSC::ResourceInfo.new("resourcename", false, ["resourcename does nothing", "lastline"]) - provider.instance_variable_set("@dsc_resources_info", [dsc_resource_info]) + provider.instance_variable_set(:@dsc_resources_info, [dsc_resource_info]) expect(provider.send(:generate_description)[1]).to match(/converge DSC resource resourcename by doing nothing/) end end diff --git a/spec/unit/provider/group/usermod_spec.rb b/spec/unit/provider/group/usermod_spec.rb index caac1857cf..4071797720 100644 --- a/spec/unit/provider/group/usermod_spec.rb +++ b/spec/unit/provider/group/usermod_spec.rb @@ -61,7 +61,7 @@ describe Chef::Provider::Group::Usermod do @provider.action = :modify @provider.define_resource_requirements @provider.load_current_resource - @provider.instance_variable_set("@group_exists", true) + @provider.instance_variable_set(:@group_exists, true) expect { @provider.run_action(@provider.process_resource_requirements) }.to raise_error(Chef::Exceptions::Group, "setting group members directly is not supported by #{@provider}, must set append true in group") end @@ -69,7 +69,7 @@ describe Chef::Provider::Group::Usermod do @provider.action = :modify @provider.define_resource_requirements @provider.load_current_resource - @provider.instance_variable_set("@group_exists", true) + @provider.instance_variable_set(:@group_exists, true) @new_resource.append(true) @new_resource.excluded_members(["someone"]) expect { @provider.run_action(@provider.process_resource_requirements) }.to raise_error(Chef::Exceptions::Group, "excluded_members is not supported by #{@provider}") diff --git a/spec/unit/provider/ifconfig/aix_spec.rb b/spec/unit/provider/ifconfig/aix_spec.rb index 613291aabb..39edf25fcd 100644 --- a/spec/unit/provider/ifconfig/aix_spec.rb +++ b/spec/unit/provider/ifconfig/aix_spec.rb @@ -68,8 +68,8 @@ describe Chef::Provider::Ifconfig::Aix do it "should add an interface if it does not exist" do @new_resource.device "en10" allow(@provider).to receive(:load_current_resource) do - @provider.instance_variable_set("@status", double("Status", exitstatus: 0)) - @provider.instance_variable_set("@current_resource", Chef::Resource::Ifconfig.new("10.0.0.1", @run_context)) + @provider.instance_variable_set(:@status, double("Status", exitstatus: 0)) + @provider.instance_variable_set(:@current_resource, Chef::Resource::Ifconfig.new("10.0.0.1", @run_context)) end command = "chdev -l #{@new_resource.device} -a netaddr=#{@new_resource.name}" expect(@provider).to receive(:shell_out_compacted!).with(*command.split(" ")) @@ -82,8 +82,8 @@ describe Chef::Provider::Ifconfig::Aix do @new_resource.device "en0" @new_resource.metric "1" allow(@provider).to receive(:load_current_resource) do - @provider.instance_variable_set("@status", double("Status", exitstatus: 0)) - @provider.instance_variable_set("@current_resource", Chef::Resource::Ifconfig.new("10.0.0.1", @run_context)) + @provider.instance_variable_set(:@status, double("Status", exitstatus: 0)) + @provider.instance_variable_set(:@current_resource, Chef::Resource::Ifconfig.new("10.0.0.1", @run_context)) end expect { @provider.run_action(:add) }.to raise_error(Chef::Exceptions::Ifconfig, "interface metric property cannot be set for :add action") @@ -94,8 +94,8 @@ describe Chef::Provider::Ifconfig::Aix do it "should enable an interface if it does not exist" do @new_resource.device "en10" allow(@provider).to receive(:load_current_resource) do - @provider.instance_variable_set("@status", double("Status", exitstatus: 0)) - @provider.instance_variable_set("@current_resource", Chef::Resource::Ifconfig.new("10.0.0.1", @run_context)) + @provider.instance_variable_set(:@status, double("Status", exitstatus: 0)) + @provider.instance_variable_set(:@current_resource, Chef::Resource::Ifconfig.new("10.0.0.1", @run_context)) end command = "ifconfig #{@new_resource.device} #{@new_resource.name}" expect(@provider).to receive(:shell_out_compacted!).with(*command.split(" ")) @@ -110,8 +110,8 @@ describe Chef::Provider::Ifconfig::Aix do it "should not disable an interface if it does not exist" do @new_resource.device "en10" allow(@provider).to receive(:load_current_resource) do - @provider.instance_variable_set("@status", double("Status", exitstatus: 0)) - @provider.instance_variable_set("@current_resource", Chef::Resource::Ifconfig.new("10.0.0.1", @run_context)) + @provider.instance_variable_set(:@status, double("Status", exitstatus: 0)) + @provider.instance_variable_set(:@current_resource, Chef::Resource::Ifconfig.new("10.0.0.1", @run_context)) end expect(@provider).not_to receive(:shell_out_compacted!) @@ -124,10 +124,10 @@ describe Chef::Provider::Ifconfig::Aix do before do @new_resource.device "en10" allow(@provider).to receive(:load_current_resource) do - @provider.instance_variable_set("@status", double("Status", exitstatus: 0)) + @provider.instance_variable_set(:@status, double("Status", exitstatus: 0)) current_resource = Chef::Resource::Ifconfig.new("10.0.0.1", @run_context) current_resource.device @new_resource.device - @provider.instance_variable_set("@current_resource", current_resource) + @provider.instance_variable_set(:@current_resource, current_resource) end end @@ -147,8 +147,8 @@ describe Chef::Provider::Ifconfig::Aix do it "should not delete an interface if it does not exist" do @new_resource.device "en10" allow(@provider).to receive(:load_current_resource) do - @provider.instance_variable_set("@status", double("Status", exitstatus: 0)) - @provider.instance_variable_set("@current_resource", Chef::Resource::Ifconfig.new("10.0.0.1", @run_context)) + @provider.instance_variable_set(:@status, double("Status", exitstatus: 0)) + @provider.instance_variable_set(:@current_resource, Chef::Resource::Ifconfig.new("10.0.0.1", @run_context)) end expect(@provider).not_to receive(:shell_out_compacted!) @@ -161,10 +161,10 @@ describe Chef::Provider::Ifconfig::Aix do before do @new_resource.device "en10" allow(@provider).to receive(:load_current_resource) do - @provider.instance_variable_set("@status", double("Status", exitstatus: 0)) + @provider.instance_variable_set(:@status, double("Status", exitstatus: 0)) current_resource = Chef::Resource::Ifconfig.new("10.0.0.1", @run_context) current_resource.device @new_resource.device - @provider.instance_variable_set("@current_resource", current_resource) + @provider.instance_variable_set(:@current_resource, current_resource) end end diff --git a/spec/unit/provider/ifconfig/debian_spec.rb b/spec/unit/provider/ifconfig/debian_spec.rb index 308435dea2..7cf951498d 100644 --- a/spec/unit/provider/ifconfig/debian_spec.rb +++ b/spec/unit/provider/ifconfig/debian_spec.rb @@ -42,7 +42,7 @@ describe Chef::Provider::Ifconfig::Debian do let(:provider) do status = double("Status", exitstatus: 0) provider = Chef::Provider::Ifconfig::Debian.new(new_resource, run_context) - provider.instance_variable_set("@status", status) + provider.instance_variable_set(:@status, status) provider.current_resource = current_resource allow(provider).to receive(:load_current_resource) allow(provider).to receive(:shell_out!) diff --git a/spec/unit/provider/ifconfig/redhat_spec.rb b/spec/unit/provider/ifconfig/redhat_spec.rb index 75291d3bf9..361363451a 100644 --- a/spec/unit/provider/ifconfig/redhat_spec.rb +++ b/spec/unit/provider/ifconfig/redhat_spec.rb @@ -40,7 +40,7 @@ describe Chef::Provider::Ifconfig::Redhat do @current_resource = Chef::Resource::Ifconfig.new("10.0.0.1", @run_context) status = double("Status", exitstatus: 0) - @provider.instance_variable_set("@status", status) + @provider.instance_variable_set(:@status, status) @provider.current_resource = @current_resource config_filename = "/etc/sysconfig/network-scripts/ifcfg-#{@new_resource.device}" diff --git a/spec/unit/provider/ifconfig_spec.rb b/spec/unit/provider/ifconfig_spec.rb index 166fe24304..120e63c809 100644 --- a/spec/unit/provider/ifconfig_spec.rb +++ b/spec/unit/provider/ifconfig_spec.rb @@ -35,7 +35,7 @@ describe Chef::Provider::Ifconfig do @current_resource = Chef::Resource::Ifconfig.new("10.0.0.1", @run_context) status = double("Status", exitstatus: 0) - @provider.instance_variable_set("@status", status) + @provider.instance_variable_set(:@status, status) @provider.current_resource = @current_resource end @@ -58,7 +58,7 @@ describe Chef::Provider::Ifconfig do @provider.load_current_resource end it "should track state of ifconfig failure" do - expect(@provider.instance_variable_get("@status").exitstatus).not_to eq(0) + expect(@provider.instance_variable_get(:@status).exitstatus).not_to eq(0) end it "should thrown an exception when ifconfig fails" do @provider.action = :add @@ -79,7 +79,7 @@ describe Chef::Provider::Ifconfig do @provider.load_current_resource end it "should track state of ifconfig failure" do - expect(@provider.instance_variable_get("@status").exitstatus).not_to eq(0) + expect(@provider.instance_variable_get(:@status).exitstatus).not_to eq(0) end it "should thrown an exception when ifconfig fails" do @provider.action = :add diff --git a/spec/unit/provider/remote_file/cache_control_data_spec.rb b/spec/unit/provider/remote_file/cache_control_data_spec.rb index 19848e4456..3252a08e6c 100644 --- a/spec/unit/provider/remote_file/cache_control_data_spec.rb +++ b/spec/unit/provider/remote_file/cache_control_data_spec.rb @@ -219,11 +219,11 @@ describe Chef::Provider::RemoteFile::CacheControlData do let(:truncated_remote_uri) { URI.parse(long_remote_path[0...CACHE_FILE_TRUNCATED_FRIENDLY_FILE_NAME_LENGTH]) } let(:truncated_file_cache_path) do cache_control_data_truncated = Chef::Provider::RemoteFile::CacheControlData.load_and_validate(truncated_remote_uri, current_file_checksum) - cache_control_data_truncated.send("sanitized_cache_file_basename")[0...CACHE_FILE_TRUNCATED_FRIENDLY_FILE_NAME_LENGTH] + cache_control_data_truncated.send(:sanitized_cache_file_basename)[0...CACHE_FILE_TRUNCATED_FRIENDLY_FILE_NAME_LENGTH] end it "truncates the file cache path to 102 characters" do - normalized_cache_path = cache_control_data.send("sanitized_cache_file_basename") + normalized_cache_path = cache_control_data.send(:sanitized_cache_file_basename) expect(Chef::FileCache).to receive(:store).with("remote_file/" + normalized_cache_path, cache_control_data.json_data) @@ -233,7 +233,7 @@ describe Chef::Provider::RemoteFile::CacheControlData do end it "uses a file cache path that starts with the first #{CACHE_FILE_TRUNCATED_FRIENDLY_FILE_NAME_LENGTH} characters of the URI" do - normalized_cache_path = cache_control_data.send("sanitized_cache_file_basename") + normalized_cache_path = cache_control_data.send(:sanitized_cache_file_basename) expect(truncated_file_cache_path.length).to eq(CACHE_FILE_TRUNCATED_FRIENDLY_FILE_NAME_LENGTH) expect(normalized_cache_path.start_with?(truncated_file_cache_path)).to eq(true) diff --git a/spec/unit/provider/service/gentoo_service_spec.rb b/spec/unit/provider/service/gentoo_service_spec.rb index efab722ac8..25726684ae 100644 --- a/spec/unit/provider/service/gentoo_service_spec.rb +++ b/spec/unit/provider/service/gentoo_service_spec.rb @@ -49,13 +49,13 @@ describe Chef::Provider::Service::Gentoo do it "should track when service file is not found in /etc/runlevels" do @provider.load_current_resource - expect(@provider.instance_variable_get("@found_script")).to be_falsey + expect(@provider.instance_variable_get(:@found_script)).to be_falsey end it "should track when service file is found in /etc/runlevels/**/" do allow(Dir).to receive(:glob).with("/etc/runlevels/**/chef").and_return(["/etc/runlevels/default/chef"]) @provider.load_current_resource - expect(@provider.instance_variable_get("@found_script")).to be_truthy + expect(@provider.instance_variable_get(:@found_script)).to be_truthy end describe "when detecting the service enable state" do diff --git a/spec/unit/provider/service/upstart_service_spec.rb b/spec/unit/provider/service/upstart_service_spec.rb index 924ac58551..5f41319c89 100644 --- a/spec/unit/provider/service/upstart_service_spec.rb +++ b/spec/unit/provider/service/upstart_service_spec.rb @@ -160,7 +160,7 @@ describe Chef::Provider::Service::Upstart do it "should track state when the upstart configuration file fails to load" do expect(File).to receive(:exist?).and_return false @provider.load_current_resource - expect(@provider.instance_variable_get("@config_file_found")).to eq(false) + expect(@provider.instance_variable_get(:@config_file_found)).to eq(false) end describe "when a status command has been specified" do @@ -177,7 +177,7 @@ describe Chef::Provider::Service::Upstart do it "should track state when the user-provided status command fails" do allow(@provider).to receive(:shell_out!).and_raise(Errno::ENOENT) @provider.load_current_resource - expect(@provider.instance_variable_get("@command_success")).to eq(false) + expect(@provider.instance_variable_get(:@command_success)).to eq(false) end it "should set running to false if it catches a Chef::Exceptions::Exec when using a status command" do @@ -190,7 +190,7 @@ describe Chef::Provider::Service::Upstart do it "should track state when we fail to obtain service status via upstart_goal_state" do expect(@provider).to receive(:upstart_goal_state).and_raise Chef::Exceptions::Exec @provider.load_current_resource - expect(@provider.instance_variable_get("@command_success")).to eq(false) + expect(@provider.instance_variable_get(:@command_success)).to eq(false) end it "should return the current resource" do diff --git a/spec/unit/resource/conditional_spec.rb b/spec/unit/resource/conditional_spec.rb index 5f99238919..5374157336 100644 --- a/spec/unit/resource/conditional_spec.rb +++ b/spec/unit/resource/conditional_spec.rb @@ -59,7 +59,7 @@ describe Chef::Resource::Conditional do describe "after running a negative/false command given as a string" do before do - @status.send("success?=", false) + @status.send(:"success?=", false) @conditional = Chef::Resource::Conditional.only_if(@parent_resource, "false") end @@ -80,7 +80,7 @@ describe Chef::Resource::Conditional do describe "after running a negative/false command given as an array" do before do - @status.send("success?=", false) + @status.send(:"success?=", false) @conditional = Chef::Resource::Conditional.only_if(@parent_resource, ["false"]) end @@ -162,7 +162,7 @@ describe Chef::Resource::Conditional do describe "after running a failed/false command given as a string" do before do - @status.send("success?=", false) + @status.send(:"success?=", false) @conditional = Chef::Resource::Conditional.not_if(@parent_resource, "false") end @@ -183,7 +183,7 @@ describe Chef::Resource::Conditional do describe "after running a failed/false command given as an array" do before do - @status.send("success?=", false) + @status.send(:"success?=", false) @conditional = Chef::Resource::Conditional.not_if(@parent_resource, ["false"]) end diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb index faf87076fd..f20a6d3bc6 100644 --- a/spec/unit/resource_spec.rb +++ b/spec/unit/resource_spec.rb @@ -955,7 +955,7 @@ describe Chef::Resource do node.name("bumblebee") node.automatic[:platform] = "autobots" node.automatic[:platform_version] = "6.1" - Object.const_set("Soundwave", klz1) + Object.const_set(:Soundwave, klz1) klz1.provides :soundwave end @@ -978,7 +978,7 @@ describe Chef::Resource do node.automatic[:platform] = "autobots" node.automatic[:platform_version] = "6.1" klz2.provides :dinobot, platform: ["autobots"] - Object.const_set("Grimlock", klz2) + Object.const_set(:Grimlock, klz2) klz2.provides :grimlock end diff --git a/tasks/docs.rb b/tasks/docs.rb index 2fd92cc40e..a7743ff219 100755 --- a/tasks/docs.rb +++ b/tasks/docs.rb @@ -133,7 +133,7 @@ namespace :docs_site do # @return [Hash] # def action_list(actions, default_action) - actions = actions.map { |k, v| [k.to_sym, { "markdown" => k == default_action.first ? "#{v} (default)" : v } ] }.to_h + actions = actions.to_h { |k, v| [k.to_sym, { "markdown" => k == default_action.first ? "#{v} (default)" : v } ] } actions[:nothing] = { "shortcode" => "resources_common_actions_nothing.md" } actions end |