summaryrefslogtreecommitdiff
path: root/lib/chef/provider
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2019-05-20 18:05:36 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2019-05-20 18:05:36 -0700
commit9dbdb769bfd963f82eb4bfea53c83501d0193766 (patch)
treedaba4babc4ba8eb73bd765783dc8a53a7abff6be /lib/chef/provider
parent248344cfe776b66a8da563c985e34d9c99967791 (diff)
downloadchef-9dbdb769bfd963f82eb4bfea53c83501d0193766.tar.gz
This hits the ones that are most frequently required.lcg/require-idempotency
Stops the kernel from scanning through all the activated gems every time in order to resolve names into pathnames. See rubygems/rubygems#2762 Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'lib/chef/provider')
-rw-r--r--lib/chef/provider/apt_repository.rb2
-rw-r--r--lib/chef/provider/directory.rb2
-rw-r--r--lib/chef/provider/execute.rb2
-rw-r--r--lib/chef/provider/file.rb4
-rw-r--r--lib/chef/provider/git.rb4
-rw-r--r--lib/chef/provider/group.rb2
-rw-r--r--lib/chef/provider/group/suse.rb2
-rw-r--r--lib/chef/provider/http_request.rb2
-rw-r--r--lib/chef/provider/launchd.rb2
-rw-r--r--lib/chef/provider/mount/solaris.rb2
-rw-r--r--lib/chef/provider/ohai.rb2
-rw-r--r--lib/chef/provider/package.rb2
-rw-r--r--lib/chef/provider/package/dnf/python_helper.rb2
-rw-r--r--lib/chef/provider/package/homebrew.rb2
-rw-r--r--lib/chef/provider/package/rubygems.rb4
-rw-r--r--lib/chef/provider/package/snap.rb2
-rw-r--r--lib/chef/provider/package/yum/python_helper.rb4
-rw-r--r--lib/chef/provider/package/yum/yum_cache.rb2
-rw-r--r--lib/chef/provider/registry_key.rb4
-rw-r--r--lib/chef/provider/remote_directory.rb2
-rw-r--r--lib/chef/provider/remote_file/cache_control_data.rb2
-rw-r--r--lib/chef/provider/remote_file/content.rb4
-rw-r--r--lib/chef/provider/remote_file/ftp.rb4
-rw-r--r--lib/chef/provider/remote_file/local_file.rb4
-rw-r--r--lib/chef/provider/remote_file/network_file.rb4
-rw-r--r--lib/chef/provider/remote_file/sftp.rb4
-rw-r--r--lib/chef/provider/script.rb4
-rw-r--r--lib/chef/provider/service/macosx.rb4
-rw-r--r--lib/chef/provider/service/systemd.rb2
-rw-r--r--lib/chef/provider/subversion.rb2
-rw-r--r--lib/chef/provider/systemd_unit.rb2
-rw-r--r--lib/chef/provider/user.rb2
-rw-r--r--lib/chef/provider/user/dscl.rb2
-rw-r--r--lib/chef/provider/windows_task.rb2
-rw-r--r--lib/chef/provider/zypper_repository.rb2
35 files changed, 47 insertions, 47 deletions
diff --git a/lib/chef/provider/apt_repository.rb b/lib/chef/provider/apt_repository.rb
index bba0b45038..9065a7d9dc 100644
--- a/lib/chef/provider/apt_repository.rb
+++ b/lib/chef/provider/apt_repository.rb
@@ -21,7 +21,7 @@ require_relative "../dsl/declare_resource"
require_relative "../mixin/shell_out"
require_relative "../http/simple"
require_relative "noop"
-require "tmpdir"
+require "tmpdir" unless defined?(Dir.mktmpdir)
class Chef
class Provider
diff --git a/lib/chef/provider/directory.rb b/lib/chef/provider/directory.rb
index 1a2a2d2b7c..ad627757f8 100644
--- a/lib/chef/provider/directory.rb
+++ b/lib/chef/provider/directory.rb
@@ -21,7 +21,7 @@ require_relative "../log"
require_relative "../resource/directory"
require_relative "../provider"
require_relative "file"
-require "fileutils"
+require "fileutils" unless defined?(FileUtils)
class Chef
class Provider
diff --git a/lib/chef/provider/execute.rb b/lib/chef/provider/execute.rb
index 9a70996a2e..793d620c88 100644
--- a/lib/chef/provider/execute.rb
+++ b/lib/chef/provider/execute.rb
@@ -18,7 +18,7 @@
require_relative "../log"
require_relative "../provider"
-require "forwardable"
+require "forwardable" unless defined?(Forwardable)
require_relative "../mixin/train_or_shell"
class Chef
diff --git a/lib/chef/provider/file.rb b/lib/chef/provider/file.rb
index 823a73c01b..2e48501e33 100644
--- a/lib/chef/provider/file.rb
+++ b/lib/chef/provider/file.rb
@@ -21,8 +21,8 @@ require_relative "../config"
require_relative "../log"
require_relative "../resource/file"
require_relative "../provider"
-require "etc"
-require "fileutils"
+require "etc" unless defined?(Etc)
+require "fileutils" unless defined?(FileUtils)
require_relative "../scan_access_control"
require_relative "../mixin/checksum"
require_relative "../mixin/file_class"
diff --git a/lib/chef/provider/git.rb b/lib/chef/provider/git.rb
index 1abffe62fa..2d8cfbc877 100644
--- a/lib/chef/provider/git.rb
+++ b/lib/chef/provider/git.rb
@@ -19,7 +19,7 @@
require_relative "../exceptions"
require_relative "../log"
require_relative "../provider"
-require "fileutils"
+require "fileutils" unless defined?(FileUtils)
class Chef
class Provider
@@ -314,7 +314,7 @@ class Chef
# user who is executing `git` not the user running Chef.
env["HOME"] =
begin
- require "etc"
+ require "etc" unless defined?(Etc)
case new_resource.user
when Integer
Etc.getpwuid(new_resource.user).dir
diff --git a/lib/chef/provider/group.rb b/lib/chef/provider/group.rb
index b3aa42ae58..ba84ea9468 100644
--- a/lib/chef/provider/group.rb
+++ b/lib/chef/provider/group.rb
@@ -18,7 +18,7 @@
require_relative "../provider"
require_relative "../mixin/shell_out"
-require "etc"
+require "etc" unless defined?(Etc)
class Chef
class Provider
diff --git a/lib/chef/provider/group/suse.rb b/lib/chef/provider/group/suse.rb
index 15360808c9..f17c1fc005 100644
--- a/lib/chef/provider/group/suse.rb
+++ b/lib/chef/provider/group/suse.rb
@@ -17,7 +17,7 @@
#
require_relative "groupadd"
-require "etc"
+require "etc" unless defined?(Etc)
class Chef
class Provider
diff --git a/lib/chef/provider/http_request.rb b/lib/chef/provider/http_request.rb
index 98f73e79c4..6859385f7b 100644
--- a/lib/chef/provider/http_request.rb
+++ b/lib/chef/provider/http_request.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "tempfile"
+require "tempfile" unless defined?(Tempfile)
require_relative "../http/simple"
class Chef
diff --git a/lib/chef/provider/launchd.rb b/lib/chef/provider/launchd.rb
index 6206f7fd7e..2530e6f779 100644
--- a/lib/chef/provider/launchd.rb
+++ b/lib/chef/provider/launchd.rb
@@ -21,7 +21,7 @@ require_relative "../resource/file"
require_relative "../resource/cookbook_file"
require_relative "../resource/macosx_service"
require "plist"
-require "forwardable"
+require "forwardable" unless defined?(Forwardable)
class Chef
class Provider
diff --git a/lib/chef/provider/mount/solaris.rb b/lib/chef/provider/mount/solaris.rb
index 18664246b8..69659d4918 100644
--- a/lib/chef/provider/mount/solaris.rb
+++ b/lib/chef/provider/mount/solaris.rb
@@ -20,7 +20,7 @@
require_relative "../mount"
require_relative "../../log"
-require "forwardable"
+require "forwardable" unless defined?(Forwardable)
class Chef
class Provider
diff --git a/lib/chef/provider/ohai.rb b/lib/chef/provider/ohai.rb
index 0b65a1d28a..9cd67b764c 100644
--- a/lib/chef/provider/ohai.rb
+++ b/lib/chef/provider/ohai.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "ohai"
+require "ohai" unless defined?(Ohai::System)
class Chef
class Provider
diff --git a/lib/chef/provider/package.rb b/lib/chef/provider/package.rb
index 29c3a55a42..2c984b780e 100644
--- a/lib/chef/provider/package.rb
+++ b/lib/chef/provider/package.rb
@@ -22,7 +22,7 @@ require_relative "../log"
require_relative "../file_cache"
require_relative "../platform"
require_relative "../decorator/lazy_array"
-require "shellwords"
+require "shellwords" unless defined?(Shellwords)
class Chef
class Provider
diff --git a/lib/chef/provider/package/dnf/python_helper.rb b/lib/chef/provider/package/dnf/python_helper.rb
index 9a5db7d0ef..881c852392 100644
--- a/lib/chef/provider/package/dnf/python_helper.rb
+++ b/lib/chef/provider/package/dnf/python_helper.rb
@@ -18,7 +18,7 @@
require_relative "../../../mixin/which"
require_relative "../../../mixin/shell_out"
require_relative "version"
-require "timeout"
+require "timeout" unless defined?(Timeout)
class Chef
class Provider
diff --git a/lib/chef/provider/package/homebrew.rb b/lib/chef/provider/package/homebrew.rb
index 7fa27b9bb8..f71aaf1882 100644
--- a/lib/chef/provider/package/homebrew.rb
+++ b/lib/chef/provider/package/homebrew.rb
@@ -18,7 +18,7 @@
# limitations under the License.
#
-require "etc"
+require "etc" unless defined?(Etc)
require_relative "../../mixin/homebrew_user"
class Chef
diff --git a/lib/chef/provider/package/rubygems.rb b/lib/chef/provider/package/rubygems.rb
index 6817ac1ec9..e8b88437fb 100644
--- a/lib/chef/provider/package/rubygems.rb
+++ b/lib/chef/provider/package/rubygems.rb
@@ -17,14 +17,14 @@
# limitations under the License.
#
-require "uri"
+require "uri" unless defined?(URI)
require_relative "../package"
require_relative "../../resource/package"
require_relative "../../mixin/get_source_from_package"
require_relative "../../mixin/which"
# Class methods on Gem are defined in rubygems
-require "rubygems"
+require "rubygems" unless defined?(Gem)
# Ruby 1.9's gem_prelude can interact poorly with loading the full rubygems
# explicitly like this. Make sure rubygems/specification is always last in this
# list
diff --git a/lib/chef/provider/package/snap.rb b/lib/chef/provider/package/snap.rb
index b91a3b87e3..8096f54659 100644
--- a/lib/chef/provider/package/snap.rb
+++ b/lib/chef/provider/package/snap.rb
@@ -19,7 +19,7 @@
require_relative "../package"
require_relative "../../resource/snap_package"
require_relative "../../mixin/shell_out"
-require "socket"
+require "socket" unless defined?(Socket)
require "json"
class Chef
diff --git a/lib/chef/provider/package/yum/python_helper.rb b/lib/chef/provider/package/yum/python_helper.rb
index 4641980be7..ee7f64d1ea 100644
--- a/lib/chef/provider/package/yum/python_helper.rb
+++ b/lib/chef/provider/package/yum/python_helper.rb
@@ -18,8 +18,8 @@
require_relative "../../../mixin/which"
require_relative "../../../mixin/shell_out"
require_relative "version"
-require "singleton"
-require "timeout"
+require "singleton" unless defined?(Singleton)
+require "timeout" unless defined?(Timeout)
class Chef
class Provider
diff --git a/lib/chef/provider/package/yum/yum_cache.rb b/lib/chef/provider/package/yum/yum_cache.rb
index 0615a9bf85..ce46a0fcfd 100644
--- a/lib/chef/provider/package/yum/yum_cache.rb
+++ b/lib/chef/provider/package/yum/yum_cache.rb
@@ -18,7 +18,7 @@
require_relative "python_helper"
require_relative "../../package"
-require "singleton"
+require "singleton" unless defined?(Singleton)
#
# These are largely historical APIs, the YumCache object no longer exists and this is a
diff --git a/lib/chef/provider/registry_key.rb b/lib/chef/provider/registry_key.rb
index 3e3faef40e..11d9f3f9b3 100644
--- a/lib/chef/provider/registry_key.rb
+++ b/lib/chef/provider/registry_key.rb
@@ -22,8 +22,8 @@ require_relative "../log"
require_relative "../resource/file"
require_relative "../mixin/checksum"
require_relative "../provider"
-require "etc"
-require "fileutils"
+require "etc" unless defined?(Etc)
+require "fileutils" unless defined?(FileUtils)
require_relative "../scan_access_control"
require_relative "../win32/registry"
diff --git a/lib/chef/provider/remote_directory.rb b/lib/chef/provider/remote_directory.rb
index 13088b3706..933ebe119d 100644
--- a/lib/chef/provider/remote_directory.rb
+++ b/lib/chef/provider/remote_directory.rb
@@ -24,7 +24,7 @@ require_relative "../mixin/file_class"
require_relative "../platform/query_helpers"
require_relative "../util/path_helper"
-require "forwardable"
+require "forwardable" unless defined?(Forwardable)
class Chef
class Provider
diff --git a/lib/chef/provider/remote_file/cache_control_data.rb b/lib/chef/provider/remote_file/cache_control_data.rb
index 974b229a45..5742ac8ce6 100644
--- a/lib/chef/provider/remote_file/cache_control_data.rb
+++ b/lib/chef/provider/remote_file/cache_control_data.rb
@@ -19,7 +19,7 @@
# limitations under the License.
#
-require "stringio"
+require "stringio" unless defined?(StringIO)
require_relative "../../file_cache"
require_relative "../../json_compat"
require_relative "../../digester"
diff --git a/lib/chef/provider/remote_file/content.rb b/lib/chef/provider/remote_file/content.rb
index 3e1af01f22..8fe52288c0 100644
--- a/lib/chef/provider/remote_file/content.rb
+++ b/lib/chef/provider/remote_file/content.rb
@@ -17,8 +17,8 @@
# limitations under the License.
#
-require "uri"
-require "tempfile"
+require "uri" unless defined?(URI)
+require "tempfile" unless defined?(Tempfile)
require_relative "../../file_content_management/content_base"
require_relative "../../mixin/uris"
diff --git a/lib/chef/provider/remote_file/ftp.rb b/lib/chef/provider/remote_file/ftp.rb
index b6399ee077..eafebc9693 100644
--- a/lib/chef/provider/remote_file/ftp.rb
+++ b/lib/chef/provider/remote_file/ftp.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require "uri"
-require "tempfile"
+require "uri" unless defined?(URI)
+require "tempfile" unless defined?(Tempfile)
require "net/ftp"
require_relative "../remote_file"
require_relative "../../file_content_management/tempfile"
diff --git a/lib/chef/provider/remote_file/local_file.rb b/lib/chef/provider/remote_file/local_file.rb
index eb1b88e1fa..14877806ce 100644
--- a/lib/chef/provider/remote_file/local_file.rb
+++ b/lib/chef/provider/remote_file/local_file.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require "uri"
-require "tempfile"
+require "uri" unless defined?(URI)
+require "tempfile" unless defined?(Tempfile)
require_relative "../remote_file"
class Chef
diff --git a/lib/chef/provider/remote_file/network_file.rb b/lib/chef/provider/remote_file/network_file.rb
index 11d8dd2ff5..b08aeb55cc 100644
--- a/lib/chef/provider/remote_file/network_file.rb
+++ b/lib/chef/provider/remote_file/network_file.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require "uri"
-require "tempfile"
+require "uri" unless defined?(URI)
+require "tempfile" unless defined?(Tempfile)
require_relative "../remote_file"
require_relative "../../mixin/user_context"
diff --git a/lib/chef/provider/remote_file/sftp.rb b/lib/chef/provider/remote_file/sftp.rb
index f112b3782c..3da49ebedd 100644
--- a/lib/chef/provider/remote_file/sftp.rb
+++ b/lib/chef/provider/remote_file/sftp.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require "uri"
-require "tempfile"
+require "uri" unless defined?(URI)
+require "tempfile" unless defined?(Tempfile)
require "net/sftp"
require_relative "../remote_file"
require_relative "../../file_content_management/tempfile"
diff --git a/lib/chef/provider/script.rb b/lib/chef/provider/script.rb
index 8d33c56da2..4282825650 100644
--- a/lib/chef/provider/script.rb
+++ b/lib/chef/provider/script.rb
@@ -16,10 +16,10 @@
# limitations under the License.
#
-require "tempfile"
+require "tempfile" unless defined?(Tempfile)
require_relative "execute"
require_relative "../win32/security" if Chef::Platform.windows?
-require "forwardable"
+require "forwardable" unless defined?(Forwardable)
class Chef
class Provider
diff --git a/lib/chef/provider/service/macosx.rb b/lib/chef/provider/service/macosx.rb
index 0e8a29ce32..746581df73 100644
--- a/lib/chef/provider/service/macosx.rb
+++ b/lib/chef/provider/service/macosx.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require "etc"
-require "rexml/document"
+require "etc" unless defined?(Etc)
+require "rexml/document" unless defined?(REXML::Document)
require_relative "../../resource/service"
require_relative "../../resource/macosx_service"
require_relative "simple"
diff --git a/lib/chef/provider/service/systemd.rb b/lib/chef/provider/service/systemd.rb
index e15eab23bd..4cb564e8c0 100644
--- a/lib/chef/provider/service/systemd.rb
+++ b/lib/chef/provider/service/systemd.rb
@@ -20,7 +20,7 @@
require_relative "../../resource/service"
require_relative "simple"
require_relative "../../mixin/which"
-require "shellwords"
+require "shellwords" unless defined?(Shellwords)
class Chef::Provider::Service::Systemd < Chef::Provider::Service::Simple
diff --git a/lib/chef/provider/subversion.rb b/lib/chef/provider/subversion.rb
index 10be5fd7c4..580c879c97 100644
--- a/lib/chef/provider/subversion.rb
+++ b/lib/chef/provider/subversion.rb
@@ -21,7 +21,7 @@
require_relative "../log"
require_relative "../provider"
require "chef-config/mixin/fuzzy_hostname_matcher"
-require "fileutils"
+require "fileutils" unless defined?(FileUtils)
class Chef
class Provider
diff --git a/lib/chef/provider/systemd_unit.rb b/lib/chef/provider/systemd_unit.rb
index c24c088935..81a56d959a 100644
--- a/lib/chef/provider/systemd_unit.rb
+++ b/lib/chef/provider/systemd_unit.rb
@@ -22,7 +22,7 @@ require_relative "../mixin/shell_out"
require_relative "../resource/file"
require_relative "../resource/file/verification/systemd_unit"
require "iniparse"
-require "shellwords"
+require "shellwords" unless defined?(Shellwords)
class Chef
class Provider
diff --git a/lib/chef/provider/user.rb b/lib/chef/provider/user.rb
index 0cd6b9a1c1..f4046a8bbf 100644
--- a/lib/chef/provider/user.rb
+++ b/lib/chef/provider/user.rb
@@ -17,7 +17,7 @@
#
require_relative "../provider"
-require "etc"
+require "etc" unless defined?(Etc)
class Chef
class Provider
diff --git a/lib/chef/provider/user/dscl.rb b/lib/chef/provider/user/dscl.rb
index 70379c177e..f5da8e695b 100644
--- a/lib/chef/provider/user/dscl.rb
+++ b/lib/chef/provider/user/dscl.rb
@@ -19,7 +19,7 @@
require_relative "../../mixin/shell_out"
require_relative "../user"
require_relative "../../resource/user/dscl_user"
-require "openssl"
+require "openssl" unless defined?(OpenSSL)
require "plist"
require_relative "../../util/path_helper"
diff --git a/lib/chef/provider/windows_task.rb b/lib/chef/provider/windows_task.rb
index dadfd45580..83347b764a 100644
--- a/lib/chef/provider/windows_task.rb
+++ b/lib/chef/provider/windows_task.rb
@@ -17,7 +17,7 @@
#
require_relative "../mixin/shell_out"
-require "rexml/document"
+require "rexml/document" unless defined?(REXML::Document)
require "iso8601" if Chef::Platform.windows?
require_relative "../mixin/powershell_out"
require_relative "../provider"
diff --git a/lib/chef/provider/zypper_repository.rb b/lib/chef/provider/zypper_repository.rb
index 49c880a8d0..8c1497b5f5 100644
--- a/lib/chef/provider/zypper_repository.rb
+++ b/lib/chef/provider/zypper_repository.rb
@@ -20,7 +20,7 @@ require_relative "../resource"
require_relative "../dsl/declare_resource"
require_relative "noop"
require_relative "../mixin/shell_out"
-require "shellwords"
+require "shellwords" unless defined?(Shellwords)
class Chef
class Provider