summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2020-09-23 20:45:22 -0700
committerGitHub <noreply@github.com>2020-09-23 20:45:22 -0700
commitf5f774bb6501b57e6bc0d44bb50bd92af9901545 (patch)
treedc755174a7b013d5d93d9202ec6bd179e369206b
parent06c0b973419effa3513840a9d59c7bf345c4a955 (diff)
parent0090ba66ebb5b6ad242f0b5d67be7c59ddcd3d0a (diff)
downloadchef-f5f774bb6501b57e6bc0d44bb50bd92af9901545.tar.gz
Merge pull request #10451 from chef/requires
Update require gating to include chef-utils/chef-config & gate more
-rw-r--r--.rubocop.yml8
-rw-r--r--Gemfile.lock4
-rw-r--r--chef-config/lib/chef-config/config.rb6
-rw-r--r--chef-config/spec/unit/fips_spec.rb2
-rw-r--r--chef-config/spec/unit/workstation_config_loader_spec.rb2
-rw-r--r--lib/chef/application.rb2
-rw-r--r--lib/chef/application/client.rb2
-rw-r--r--lib/chef/application/solo.rb2
-rw-r--r--lib/chef/event_loggers/windows_eventlog.rb2
-rw-r--r--lib/chef/formatters/error_inspectors/resource_failure_inspector.rb2
-rw-r--r--lib/chef/formatters/indentable_output_stream.rb2
-rw-r--r--lib/chef/knife/core/ui.rb2
-rw-r--r--lib/chef/local_mode.rb2
-rw-r--r--lib/chef/provider/file.rb2
-rw-r--r--lib/chef/resource/file.rb2
-rw-r--r--lib/chef/run_lock.rb2
16 files changed, 26 insertions, 18 deletions
diff --git a/.rubocop.yml b/.rubocop.yml
index b587000ad4..0c874566be 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -30,3 +30,11 @@ Lint/IneffectiveAccessModifier:
Enabled: false
Lint/ShadowedException:
Enabled: false
+
+# set additional paths
+ChefRuby/UnlessDefinedRequire:
+ Include:
+ - 'lib/**/*'
+ - 'chef-bin/**/*'
+ - 'chef-config/lib/**/*'
+ - 'chef-utils/lib/**/*'
diff --git a/Gemfile.lock b/Gemfile.lock
index 27d2186bab..4faeea1202 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,9 +1,9 @@
GIT
remote: https://github.com/chef/chefstyle.git
- revision: 1155f0044aca2fb7776d28f5adbe523a4705527f
+ revision: a40b62de5f41e98ba240eb502d778470e1ec5186
branch: master
specs:
- chefstyle (1.4.0)
+ chefstyle (1.4.1)
rubocop (= 0.91.0)
GIT
diff --git a/chef-config/lib/chef-config/config.rb b/chef-config/lib/chef-config/config.rb
index 58b60e5295..7451f744a7 100644
--- a/chef-config/lib/chef-config/config.rb
+++ b/chef-config/lib/chef-config/config.rb
@@ -1258,9 +1258,9 @@ module ChefConfig
# @api private
def self.enable_fips_mode
OpenSSL.fips_mode = true
- require "digest"
- require "digest/sha1"
- require "digest/md5"
+ require "digest" unless defined?(Digest)
+ require "digest/sha1" unless defined?(Digest::SHA1)
+ 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")
diff --git a/chef-config/spec/unit/fips_spec.rb b/chef-config/spec/unit/fips_spec.rb
index 5ee62b6c79..4be6f64a2d 100644
--- a/chef-config/spec/unit/fips_spec.rb
+++ b/chef-config/spec/unit/fips_spec.rb
@@ -20,7 +20,7 @@ require "chef-config/fips"
require "spec_helper"
begin
- require "win32/registry"
+ require "win32/registry" unless defined?(Win32::Registry)
rescue LoadError
# not on unix
end
diff --git a/chef-config/spec/unit/workstation_config_loader_spec.rb b/chef-config/spec/unit/workstation_config_loader_spec.rb
index c589b298ae..70b42ad961 100644
--- a/chef-config/spec/unit/workstation_config_loader_spec.rb
+++ b/chef-config/spec/unit/workstation_config_loader_spec.rb
@@ -17,7 +17,7 @@
#
require "spec_helper"
-require "tempfile"
+require "tempfile" unless defined?(Tempfile)
require "chef-config/exceptions"
require "chef-utils"
diff --git a/lib/chef/application.rb b/lib/chef/application.rb
index 002ab207b9..4ffbcde1c0 100644
--- a/lib/chef/application.rb
+++ b/lib/chef/application.rb
@@ -27,7 +27,7 @@ require "mixlib/cli" unless defined?(Mixlib::CLI)
require "tmpdir" unless defined?(Dir.mktmpdir)
require "rbconfig" unless defined?(RbConfig)
require_relative "application/exit_code"
-require "chef-utils" unless defined?(ChefUtils)
+require "chef-utils" unless defined?(ChefUtils::CANARY)
module LicenseAcceptance
autoload :Acceptor, "license_acceptance/acceptor"
end
diff --git a/lib/chef/application/client.rb b/lib/chef/application/client.rb
index 36ff1640d7..4a749a7c39 100644
--- a/lib/chef/application/client.rb
+++ b/lib/chef/application/client.rb
@@ -21,7 +21,7 @@ require_relative "base"
require_relative "../handler/error_report"
require_relative "../workstation_config_loader"
autoload :URI, "uri"
-require "chef-utils" unless defined?(ChefUtils)
+require "chef-utils" unless defined?(ChefUtils::CANARY)
module Mixlib
module Authentication
autoload :Log, "mixlib/authentication"
diff --git a/lib/chef/application/solo.rb b/lib/chef/application/solo.rb
index cda0852e13..8264393bb9 100644
--- a/lib/chef/application/solo.rb
+++ b/lib/chef/application/solo.rb
@@ -21,7 +21,7 @@ require_relative "../../chef"
require_relative "client"
require "fileutils" unless defined?(FileUtils)
require "pathname" unless defined?(Pathname)
-require "chef-utils" unless defined?(ChefUtils)
+require "chef-utils" unless defined?(ChefUtils::CANARY)
# DO NOT MAKE EDITS, see Chef::Application::Base
#
diff --git a/lib/chef/event_loggers/windows_eventlog.rb b/lib/chef/event_loggers/windows_eventlog.rb
index c1958321a8..6b290eb8a7 100644
--- a/lib/chef/event_loggers/windows_eventlog.rb
+++ b/lib/chef/event_loggers/windows_eventlog.rb
@@ -19,7 +19,7 @@
require_relative "base"
require_relative "../platform/query_helpers"
require_relative "../win32/eventlog"
-require "chef-utils" unless defined?(ChefUtils)
+require "chef-utils" unless defined?(ChefUtils::CANARY)
class Chef
module EventLoggers
diff --git a/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb b/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb
index 9c16072de7..d858c756a4 100644
--- a/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb
+++ b/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb
@@ -16,7 +16,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-require "chef-utils" unless defined?(ChefUtils)
+require "chef-utils" unless defined?(ChefUtils::CANARY)
class Chef
module Formatters
diff --git a/lib/chef/formatters/indentable_output_stream.rb b/lib/chef/formatters/indentable_output_stream.rb
index d508a32eb0..c2d835d951 100644
--- a/lib/chef/formatters/indentable_output_stream.rb
+++ b/lib/chef/formatters/indentable_output_stream.rb
@@ -20,7 +20,7 @@ class Chef
# pastel.decorate is a lightweight replacement for highline.color
def pastel
@pastel ||= begin
- require "pastel"
+ require "pastel" unless defined?(Pastel)
Pastel.new
end
end
diff --git a/lib/chef/knife/core/ui.rb b/lib/chef/knife/core/ui.rb
index 0d467b69c8..0a7bb2f69d 100644
--- a/lib/chef/knife/core/ui.rb
+++ b/lib/chef/knife/core/ui.rb
@@ -70,7 +70,7 @@ class Chef
# pastel.decorate is a lightweight replacement for highline.color
def pastel
@pastel ||= begin
- require "pastel"
+ require "pastel" unless defined?(Pastel)
Pastel.new
end
end
diff --git a/lib/chef/local_mode.rb b/lib/chef/local_mode.rb
index 5be97d9783..e7346322d2 100644
--- a/lib/chef/local_mode.rb
+++ b/lib/chef/local_mode.rb
@@ -15,7 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "chef-utils" unless defined?(ChefUtils)
+require "chef-utils" unless defined?(ChefUtils::CANARY)
require_relative "config"
require_relative "monkey_patches/webrick-utils" if ChefUtils.windows?
diff --git a/lib/chef/provider/file.rb b/lib/chef/provider/file.rb
index 0d75d76497..e2c07ad9f7 100644
--- a/lib/chef/provider/file.rb
+++ b/lib/chef/provider/file.rb
@@ -31,7 +31,7 @@ require_relative "../util/backup"
require_relative "../util/diff"
require_relative "../util/selinux"
require_relative "../file_content_management/deploy"
-require "chef-utils" unless defined?(ChefUtils)
+require "chef-utils" unless defined?(ChefUtils::CANARY)
# The Tao of File Providers:
# - the content provider must always return a tempfile that we can delete/mv
diff --git a/lib/chef/resource/file.rb b/lib/chef/resource/file.rb
index f9f7823f0a..7bebc4ae4c 100644
--- a/lib/chef/resource/file.rb
+++ b/lib/chef/resource/file.rb
@@ -22,7 +22,7 @@ require_relative "../platform/query_helpers"
require_relative "../mixin/securable"
require_relative "file/verification"
require "pathname" unless defined?(Pathname)
-require "chef-utils" unless defined?(ChefUtils)
+require "chef-utils" unless defined?(ChefUtils::CANARY)
class Chef
class Resource
diff --git a/lib/chef/run_lock.rb b/lib/chef/run_lock.rb
index 0f1eaf0742..75d1432773 100644
--- a/lib/chef/run_lock.rb
+++ b/lib/chef/run_lock.rb
@@ -23,7 +23,7 @@ end
require_relative "config"
require_relative "exceptions"
require "timeout" unless defined?(Timeout)
-require "chef-utils" unless defined?(ChefUtils)
+require "chef-utils" unless defined?(ChefUtils::CANARY)
class Chef