diff options
author | Tim Smith <tsmith@chef.io> | 2020-02-06 17:21:55 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-06 17:21:55 -0800 |
commit | 37b22e0524d4aac76e4dcead98bf6778079b58ca (patch) | |
tree | 6166033be83f399ef4289ac574f84748e09789aa /lib/chef/knife | |
parent | d923776da3a886c61ac6360bd968a3bc82dbb68f (diff) | |
parent | 8ab22a0878761e51a7d2c74d2cd0eb289e9affb6 (diff) | |
download | chef-37b22e0524d4aac76e4dcead98bf6778079b58ca.tar.gz |
Merge pull request #9351 from chef/knife_15
Lazy load as many knife deps as possible
Diffstat (limited to 'lib/chef/knife')
-rw-r--r-- | lib/chef/knife/client_key_create.rb | 5 | ||||
-rw-r--r-- | lib/chef/knife/client_key_delete.rb | 5 | ||||
-rw-r--r-- | lib/chef/knife/client_key_edit.rb | 5 | ||||
-rw-r--r-- | lib/chef/knife/client_key_list.rb | 5 | ||||
-rw-r--r-- | lib/chef/knife/client_key_show.rb | 5 | ||||
-rw-r--r-- | lib/chef/knife/config_list_profiles.rb | 5 | ||||
-rw-r--r-- | lib/chef/knife/config_use_profile.rb | 6 | ||||
-rw-r--r-- | lib/chef/knife/configure.rb | 2 | ||||
-rw-r--r-- | lib/chef/knife/cookbook_upload.rb | 7 | ||||
-rw-r--r-- | lib/chef/knife/data_bag_from_file.rb | 2 | ||||
-rw-r--r-- | lib/chef/knife/exec.rb | 5 | ||||
-rw-r--r-- | lib/chef/knife/raw.rb | 1 | ||||
-rw-r--r-- | lib/chef/knife/rehash.rb | 5 | ||||
-rw-r--r-- | lib/chef/knife/search.rb | 2 | ||||
-rw-r--r-- | lib/chef/knife/ssh.rb | 6 | ||||
-rw-r--r-- | lib/chef/knife/ssl_check.rb | 2 | ||||
-rw-r--r-- | lib/chef/knife/ssl_fetch.rb | 2 | ||||
-rw-r--r-- | lib/chef/knife/supermarket_install.rb | 2 | ||||
-rw-r--r-- | lib/chef/knife/user_key_create.rb | 5 | ||||
-rw-r--r-- | lib/chef/knife/user_key_delete.rb | 5 | ||||
-rw-r--r-- | lib/chef/knife/user_key_edit.rb | 5 | ||||
-rw-r--r-- | lib/chef/knife/user_key_list.rb | 5 | ||||
-rw-r--r-- | lib/chef/knife/user_key_show.rb | 5 |
23 files changed, 67 insertions, 30 deletions
diff --git a/lib/chef/knife/client_key_create.rb b/lib/chef/knife/client_key_create.rb index 564bbf1caa..9d71e2d344 100644 --- a/lib/chef/knife/client_key_create.rb +++ b/lib/chef/knife/client_key_create.rb @@ -17,7 +17,6 @@ # require_relative "../knife" -require_relative "key_create" require_relative "key_create_base" class Chef @@ -33,6 +32,10 @@ class Chef banner "knife client key create CLIENT (options)" + deps do + require_relative "key_create" + end + attr_reader :actor def initialize(argv = []) diff --git a/lib/chef/knife/client_key_delete.rb b/lib/chef/knife/client_key_delete.rb index 63351e2a6b..9518af37af 100644 --- a/lib/chef/knife/client_key_delete.rb +++ b/lib/chef/knife/client_key_delete.rb @@ -17,7 +17,6 @@ # require_relative "../knife" -require_relative "key_delete" class Chef class Knife @@ -30,6 +29,10 @@ class Chef class ClientKeyDelete < Knife banner "knife client key delete CLIENT KEYNAME (options)" + deps do + require_relative "key_delete" + end + attr_reader :actor def initialize(argv = []) diff --git a/lib/chef/knife/client_key_edit.rb b/lib/chef/knife/client_key_edit.rb index db7784a423..d0f22be780 100644 --- a/lib/chef/knife/client_key_edit.rb +++ b/lib/chef/knife/client_key_edit.rb @@ -17,7 +17,6 @@ # require_relative "../knife" -require_relative "key_edit" require_relative "key_edit_base" class Chef @@ -33,6 +32,10 @@ class Chef banner "knife client key edit CLIENT KEYNAME (options)" + deps do + require_relative "key_edit" + end + attr_reader :actor def initialize(argv = []) diff --git a/lib/chef/knife/client_key_list.rb b/lib/chef/knife/client_key_list.rb index 0eae1c9505..0150e9d67d 100644 --- a/lib/chef/knife/client_key_list.rb +++ b/lib/chef/knife/client_key_list.rb @@ -17,7 +17,6 @@ # require_relative "../knife" -require_relative "key_list" require_relative "key_list_base" class Chef @@ -33,6 +32,10 @@ class Chef banner "knife client key list CLIENT (options)" + deps do + require_relative "key_list" + end + attr_reader :actor def initialize(argv = []) diff --git a/lib/chef/knife/client_key_show.rb b/lib/chef/knife/client_key_show.rb index 3ef0028413..6bc614f2f4 100644 --- a/lib/chef/knife/client_key_show.rb +++ b/lib/chef/knife/client_key_show.rb @@ -17,7 +17,6 @@ # require_relative "../knife" -require_relative "key_show" class Chef class Knife @@ -30,6 +29,10 @@ class Chef class ClientKeyShow < Knife banner "knife client key show CLIENT KEYNAME (options)" + deps do + require_relative "key_show" + end + attr_reader :actor def initialize(argv = []) diff --git a/lib/chef/knife/config_list_profiles.rb b/lib/chef/knife/config_list_profiles.rb index fb40b30b0a..b69ebf4e69 100644 --- a/lib/chef/knife/config_list_profiles.rb +++ b/lib/chef/knife/config_list_profiles.rb @@ -16,13 +16,16 @@ # require_relative "../knife" -require_relative "../workstation_config_loader" class Chef class Knife class ConfigListProfiles < Knife banner "knife config list-profiles (options)" + deps do + require_relative "../workstation_config_loader" + end + option :ignore_knife_rb, short: "-i", long: "--ignore-knife-rb", diff --git a/lib/chef/knife/config_use_profile.rb b/lib/chef/knife/config_use_profile.rb index 89d75b3369..134ae5e8b6 100644 --- a/lib/chef/knife/config_use_profile.rb +++ b/lib/chef/knife/config_use_profile.rb @@ -15,8 +15,6 @@ # limitations under the License. # -require "fileutils" unless defined?(FileUtils) - require_relative "../knife" class Chef @@ -24,6 +22,10 @@ class Chef class ConfigUseProfile < Knife banner "knife config use-profile PROFILE" + deps do + require "fileutils" unless defined?(FileUtils) + end + # Disable normal config loading since this shouldn't fail if the profile # doesn't exist of the config is otherwise corrupted. def configure_chef diff --git a/lib/chef/knife/configure.rb b/lib/chef/knife/configure.rb index 888b4290dd..1efbea3d67 100644 --- a/lib/chef/knife/configure.rb +++ b/lib/chef/knife/configure.rb @@ -17,7 +17,6 @@ # require_relative "../knife" -require_relative "../util/path_helper" require_relative "../dist" class Chef @@ -27,6 +26,7 @@ class Chef attr_reader :chef_repo, :new_client_key, :validation_client_name, :validation_key deps do + require_relative "../util/path_helper" require "ohai" unless defined?(Ohai::System) Chef::Knife::ClientCreate.load_deps Chef::Knife::UserCreate.load_deps diff --git a/lib/chef/knife/cookbook_upload.rb b/lib/chef/knife/cookbook_upload.rb index 21b68f5a9b..aa226a1fc1 100644 --- a/lib/chef/knife/cookbook_upload.rb +++ b/lib/chef/knife/cookbook_upload.rb @@ -19,19 +19,16 @@ # require_relative "../knife" -require_relative "../cookbook_uploader" -require_relative "../mixin/file_class" class Chef class Knife class CookbookUpload < Knife - - include Chef::Mixin::FileClass - CHECKSUM = "checksum".freeze MATCH_CHECKSUM = /[0-9a-f]{32,}/.freeze deps do + require_relative "../mixin/file_class" + include Chef::Mixin::FileClass require_relative "../exceptions" require_relative "../cookbook_loader" require_relative "../cookbook_uploader" diff --git a/lib/chef/knife/data_bag_from_file.rb b/lib/chef/knife/data_bag_from_file.rb index 78cf2df3a5..9a666a6fe1 100644 --- a/lib/chef/knife/data_bag_from_file.rb +++ b/lib/chef/knife/data_bag_from_file.rb @@ -18,7 +18,6 @@ # require_relative "../knife" -require_relative "../util/path_helper" require_relative "data_bag_secret_options" class Chef @@ -27,6 +26,7 @@ class Chef include DataBagSecretOptions deps do + require_relative "../util/path_helper" require_relative "../data_bag" require_relative "../data_bag_item" require_relative "core/object_loader" diff --git a/lib/chef/knife/exec.rb b/lib/chef/knife/exec.rb index 6fb1d00c45..49b5f4c59e 100644 --- a/lib/chef/knife/exec.rb +++ b/lib/chef/knife/exec.rb @@ -17,13 +17,16 @@ # require_relative "../knife" -require_relative "../util/path_helper" require_relative "../dist" class Chef::Knife::Exec < Chef::Knife banner "knife exec [SCRIPT] (options)" + deps do + require_relative "../util/path_helper" + end + option :exec, short: "-E CODE", long: "--exec CODE", diff --git a/lib/chef/knife/raw.rb b/lib/chef/knife/raw.rb index 5f81c13175..5adb36ea70 100644 --- a/lib/chef/knife/raw.rb +++ b/lib/chef/knife/raw.rb @@ -15,7 +15,6 @@ # require_relative "../knife" -require_relative "../http" class Chef class Knife diff --git a/lib/chef/knife/rehash.rb b/lib/chef/knife/rehash.rb index f4294e8e3b..ed70aa9f24 100644 --- a/lib/chef/knife/rehash.rb +++ b/lib/chef/knife/rehash.rb @@ -17,13 +17,16 @@ # require_relative "../knife" -require_relative "core/subcommand_loader" class Chef class Knife class Rehash < Chef::Knife banner "knife rehash" + deps do + require_relative "core/subcommand_loader" + end + def run if ! Chef::Knife::SubcommandLoader.autogenerated_manifest? ui.msg "Using knife-rehash will speed up knife's load time by caching the location of subcommands on disk." diff --git a/lib/chef/knife/search.rb b/lib/chef/knife/search.rb index a089ee8f1b..5b5d26cb5f 100644 --- a/lib/chef/knife/search.rb +++ b/lib/chef/knife/search.rb @@ -18,7 +18,6 @@ require_relative "../knife" require_relative "core/node_presenter" -require "addressable/uri" unless defined?(Addressable::URI) class Chef class Knife @@ -27,6 +26,7 @@ class Chef include Knife::Core::MultiAttributeReturnOption deps do + require "addressable/uri" unless defined?(Addressable::URI) require_relative "../node" require_relative "../environment" require_relative "../api_client" diff --git a/lib/chef/knife/ssh.rb b/lib/chef/knife/ssh.rb index c270de6514..ae7b44d934 100644 --- a/lib/chef/knife/ssh.rb +++ b/lib/chef/knife/ssh.rb @@ -16,7 +16,6 @@ # limitations under the License. # -require_relative "../mixin/shell_out" require_relative "../knife" class Chef @@ -24,15 +23,16 @@ class Chef class Ssh < Knife deps do + require_relative "../mixin/shell_out" require "net/ssh" unless defined?(Net::SSH) require "net/ssh/multi" require "readline" require_relative "../exceptions" require_relative "../search/query" require_relative "../util/path_helper" - end - include Chef::Mixin::ShellOut + include Chef::Mixin::ShellOut + end attr_writer :password diff --git a/lib/chef/knife/ssl_check.rb b/lib/chef/knife/ssl_check.rb index f6e68ebe45..c4c26b9ef4 100644 --- a/lib/chef/knife/ssl_check.rb +++ b/lib/chef/knife/ssl_check.rb @@ -17,7 +17,6 @@ # require_relative "../knife" -require_relative "../config" require_relative "../dist" class Chef @@ -25,6 +24,7 @@ class Chef class SslCheck < Chef::Knife deps do + require_relative "../config" require "pp" unless defined?(PP) require "socket" unless defined?(Socket) require "uri" unless defined?(URI) diff --git a/lib/chef/knife/ssl_fetch.rb b/lib/chef/knife/ssl_fetch.rb index 3f6a466881..8c00aab7f7 100644 --- a/lib/chef/knife/ssl_fetch.rb +++ b/lib/chef/knife/ssl_fetch.rb @@ -17,13 +17,13 @@ # require_relative "../knife" -require_relative "../config" class Chef class Knife class SslFetch < Chef::Knife deps do + require_relative "../config" require "pp" unless defined?(PP) require "socket" unless defined?(Socket) require "uri" unless defined?(URI) diff --git a/lib/chef/knife/supermarket_install.rb b/lib/chef/knife/supermarket_install.rb index 204454eaba..5330db655b 100644 --- a/lib/chef/knife/supermarket_install.rb +++ b/lib/chef/knife/supermarket_install.rb @@ -17,13 +17,13 @@ # require_relative "../knife" -require_relative "../exceptions" class Chef class Knife class SupermarketInstall < Knife deps do + require_relative "../exceptions" require "shellwords" unless defined?(Shellwords) require "mixlib/archive" unless defined?(Mixlib::Archive) require_relative "core/cookbook_scm_repo" diff --git a/lib/chef/knife/user_key_create.rb b/lib/chef/knife/user_key_create.rb index feacc46d48..cfcd8255ed 100644 --- a/lib/chef/knife/user_key_create.rb +++ b/lib/chef/knife/user_key_create.rb @@ -17,7 +17,6 @@ # require_relative "../knife" -require_relative "key_create" require_relative "key_create_base" class Chef @@ -33,6 +32,10 @@ class Chef banner "knife user key create USER (options)" + deps do + require_relative "key_create" + end + attr_reader :actor def initialize(argv = []) diff --git a/lib/chef/knife/user_key_delete.rb b/lib/chef/knife/user_key_delete.rb index 4de225cbd5..5cd31a953b 100644 --- a/lib/chef/knife/user_key_delete.rb +++ b/lib/chef/knife/user_key_delete.rb @@ -17,7 +17,6 @@ # require_relative "../knife" -require_relative "key_delete" class Chef class Knife @@ -30,6 +29,10 @@ class Chef class UserKeyDelete < Knife banner "knife user key delete USER KEYNAME (options)" + deps do + require_relative "key_delete" + end + attr_reader :actor def initialize(argv = []) diff --git a/lib/chef/knife/user_key_edit.rb b/lib/chef/knife/user_key_edit.rb index 27f45f5f80..253d378b2d 100644 --- a/lib/chef/knife/user_key_edit.rb +++ b/lib/chef/knife/user_key_edit.rb @@ -17,7 +17,6 @@ # require_relative "../knife" -require_relative "key_edit" require_relative "key_edit_base" class Chef @@ -33,6 +32,10 @@ class Chef banner "knife user key edit USER KEYNAME (options)" + deps do + require_relative "key_edit" + end + attr_reader :actor def initialize(argv = []) diff --git a/lib/chef/knife/user_key_list.rb b/lib/chef/knife/user_key_list.rb index de03182a09..2051a4440f 100644 --- a/lib/chef/knife/user_key_list.rb +++ b/lib/chef/knife/user_key_list.rb @@ -17,7 +17,6 @@ # require_relative "../knife" -require_relative "key_list" require_relative "key_list_base" class Chef @@ -33,6 +32,10 @@ class Chef banner "knife user key list USER (options)" + deps do + require_relative "key_list" + end + attr_reader :actor def initialize(argv = []) diff --git a/lib/chef/knife/user_key_show.rb b/lib/chef/knife/user_key_show.rb index 3f09d8b047..8a47950f0c 100644 --- a/lib/chef/knife/user_key_show.rb +++ b/lib/chef/knife/user_key_show.rb @@ -17,7 +17,6 @@ # require_relative "../knife" -require_relative "key_show" class Chef class Knife @@ -30,6 +29,10 @@ class Chef class UserKeyShow < Knife banner "knife user key show USER KEYNAME (options)" + deps do + require_relative "key_show" + end + attr_reader :actor def initialize(argv = []) |