diff options
author | Thom May <thom@chef.io> | 2016-01-14 14:08:03 +0000 |
---|---|---|
committer | Thom May <thom@chef.io> | 2016-01-14 14:08:03 +0000 |
commit | 51cfbdc4d16739caac4d946fadbe678444aafe34 (patch) | |
tree | 56dfd8f1cd9fd933de27268b32402e955a43ac2b /lib/chef/knife | |
parent | 05064423057d4cf46f4713b81b08829cf6d20af6 (diff) | |
download | chef-51cfbdc4d16739caac4d946fadbe678444aafe34.tar.gz |
Use double quotes by default
This is an entirely mechanically generated (chefstyle -a) change, to go
along with chef/chefstyle#5 . We should pick something and use it
consistently, and my opinion is that double quotes are the appropriate
thing.
Diffstat (limited to 'lib/chef/knife')
136 files changed, 687 insertions, 687 deletions
diff --git a/lib/chef/knife/bootstrap.rb b/lib/chef/knife/bootstrap.rb index a429c7246b..23ec98e563 100644 --- a/lib/chef/knife/bootstrap.rb +++ b/lib/chef/knife/bootstrap.rb @@ -16,12 +16,12 @@ # limitations under the License. # -require 'chef/knife' -require 'chef/knife/data_bag_secret_options' -require 'erubis' -require 'chef/knife/bootstrap/chef_vault_handler' -require 'chef/knife/bootstrap/client_builder' -require 'chef/util/path_helper' +require "chef/knife" +require "chef/knife/data_bag_secret_options" +require "erubis" +require "chef/knife/bootstrap/chef_vault_handler" +require "chef/knife/bootstrap/client_builder" +require "chef/util/path_helper" class Chef class Knife @@ -32,13 +32,13 @@ class Chef attr_accessor :chef_vault_handler deps do - require 'chef/knife/core/bootstrap_context' - require 'chef/json_compat' - require 'tempfile' - require 'highline' - require 'net/ssh' - require 'net/ssh/multi' - require 'chef/knife/ssh' + require "chef/knife/core/bootstrap_context" + require "chef/json_compat" + require "tempfile" + require "highline" + require "net/ssh" + require "net/ssh/multi" + require "chef/knife/ssh" Chef::Knife::Ssh.load_deps end @@ -232,15 +232,15 @@ class Chef :boolean => true option :bootstrap_vault_file, - :long => '--bootstrap-vault-file VAULT_FILE', - :description => 'A JSON file with a list of vault(s) and item(s) to be updated' + :long => "--bootstrap-vault-file VAULT_FILE", + :description => "A JSON file with a list of vault(s) and item(s) to be updated" option :bootstrap_vault_json, - :long => '--bootstrap-vault-json VAULT_JSON', - :description => 'A JSON string with the vault(s) and item(s) to be updated' + :long => "--bootstrap-vault-json VAULT_JSON", + :description => "A JSON string with the vault(s) and item(s) to be updated" option :bootstrap_vault_item, - :long => '--bootstrap-vault-item VAULT_ITEM', + :long => "--bootstrap-vault-item VAULT_ITEM", :description => 'A single vault and item to update as "vault:item"', :proc => Proc.new { |i| (vault, item) = i.split(/:/) @@ -282,13 +282,13 @@ class Chef # @return [String] The DNS or IP that bootstrap will connect to def server_name if host_descriptor - @server_name ||= host_descriptor.split('@').reverse[0] + @server_name ||= host_descriptor.split("@").reverse[0] end end def user_name if host_descriptor - @user_name ||= host_descriptor.split('@').reverse[1] + @user_name ||= host_descriptor.split("@").reverse[1] end end @@ -310,9 +310,9 @@ class Chef # Otherwise search the template directories until we find the right one bootstrap_files = [] - bootstrap_files << File.join(File.dirname(__FILE__), 'bootstrap/templates', "#{template}.erb") + bootstrap_files << File.join(File.dirname(__FILE__), "bootstrap/templates", "#{template}.erb") bootstrap_files << File.join(Knife.chef_config_dir, "bootstrap", "#{template}.erb") if Chef::Knife.chef_config_dir - Chef::Util::PathHelper.home('.chef', 'bootstrap', "#{template}.erb") {|p| bootstrap_files << p} + Chef::Util::PathHelper.home(".chef", "bootstrap", "#{template}.erb") {|p| bootstrap_files << p} bootstrap_files << Gem.find_files(File.join("chef","knife","bootstrap","#{template}.erb")) bootstrap_files.flatten! diff --git a/lib/chef/knife/bootstrap/chef_vault_handler.rb b/lib/chef/knife/bootstrap/chef_vault_handler.rb index 9d0dfec621..6732c0f28d 100644 --- a/lib/chef/knife/bootstrap/chef_vault_handler.rb +++ b/lib/chef/knife/bootstrap/chef_vault_handler.rb @@ -15,7 +15,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # -require 'chef/knife/bootstrap' +require "chef/knife/bootstrap" class Chef class Knife @@ -143,8 +143,8 @@ class Chef @require_chef_vault ||= begin error_message = "Knife bootstrap needs version 2.6.0 or higher of the chef-vault gem to configure chef vault items" - require 'chef-vault' - if Gem::Version.new(ChefVault::VERSION) < Gem::Version.new('2.6.0') + require "chef-vault" + if Gem::Version.new(ChefVault::VERSION) < Gem::Version.new("2.6.0") raise error_message end true diff --git a/lib/chef/knife/bootstrap/client_builder.rb b/lib/chef/knife/bootstrap/client_builder.rb index f5a2ff2bb1..a955b759e2 100644 --- a/lib/chef/knife/bootstrap/client_builder.rb +++ b/lib/chef/knife/bootstrap/client_builder.rb @@ -16,12 +16,12 @@ # limitations under the License. # -require 'chef/node' -require 'chef/server_api' -require 'chef/api_client/registration' -require 'chef/api_client' -require 'chef/knife/bootstrap' -require 'tmpdir' +require "chef/node" +require "chef/server_api" +require "chef/api_client/registration" +require "chef/api_client" +require "chef/knife/bootstrap" +require "tmpdir" class Chef class Knife diff --git a/lib/chef/knife/client_bulk_delete.rb b/lib/chef/knife/client_bulk_delete.rb index b439e6f995..9ee9a303df 100644 --- a/lib/chef/knife/client_bulk_delete.rb +++ b/lib/chef/knife/client_bulk_delete.rb @@ -16,15 +16,15 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife class ClientBulkDelete < Knife deps do - require 'chef/api_client_v1' - require 'chef/json_compat' + require "chef/api_client_v1" + require "chef/json_compat" end option :delete_validators, diff --git a/lib/chef/knife/client_create.rb b/lib/chef/knife/client_create.rb index fa9a1a7e32..43f087e5d0 100644 --- a/lib/chef/knife/client_create.rb +++ b/lib/chef/knife/client_create.rb @@ -16,15 +16,15 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife class ClientCreate < Knife deps do - require 'chef/api_client_v1' - require 'chef/json_compat' + require "chef/api_client_v1" + require "chef/json_compat" end option :file, diff --git a/lib/chef/knife/client_delete.rb b/lib/chef/knife/client_delete.rb index a49c0867a8..f94010a4ce 100644 --- a/lib/chef/knife/client_delete.rb +++ b/lib/chef/knife/client_delete.rb @@ -16,15 +16,15 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife class ClientDelete < Knife deps do - require 'chef/api_client_v1' - require 'chef/json_compat' + require "chef/api_client_v1" + require "chef/json_compat" end option :delete_validators, @@ -43,7 +43,7 @@ class Chef exit 1 end - delete_object(Chef::ApiClientV1, @client_name, 'client') { + delete_object(Chef::ApiClientV1, @client_name, "client") { object = Chef::ApiClientV1.load(@client_name) if object.validator unless config[:delete_validators] diff --git a/lib/chef/knife/client_edit.rb b/lib/chef/knife/client_edit.rb index 5dcd8f212b..df3ede04c9 100644 --- a/lib/chef/knife/client_edit.rb +++ b/lib/chef/knife/client_edit.rb @@ -16,15 +16,15 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife class ClientEdit < Knife deps do - require 'chef/api_client_v1' - require 'chef/json_compat' + require "chef/api_client_v1" + require "chef/json_compat" end banner "knife client edit CLIENT (options)" diff --git a/lib/chef/knife/client_key_create.rb b/lib/chef/knife/client_key_create.rb index 3b7e97eb24..bf103678a8 100644 --- a/lib/chef/knife/client_key_create.rb +++ b/lib/chef/knife/client_key_create.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'chef/knife' -require 'chef/knife/key_create_base' +require "chef/knife" +require "chef/knife/key_create_base" class Chef class Knife @@ -43,7 +43,7 @@ class Chef end def actor_field_name - 'client' + "client" end def service_object @@ -51,7 +51,7 @@ class Chef end def actor_missing_error - 'You must specify a client name' + "You must specify a client name" end def apply_params!(params) diff --git a/lib/chef/knife/client_key_delete.rb b/lib/chef/knife/client_key_delete.rb index 8ecdfe1ec8..c76197a02d 100644 --- a/lib/chef/knife/client_key_delete.rb +++ b/lib/chef/knife/client_key_delete.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife @@ -42,15 +42,15 @@ class Chef end def actor_field_name - 'client' + "client" end def actor_missing_error - 'You must specify a client name' + "You must specify a client name" end def keyname_missing_error - 'You must specify a key name' + "You must specify a key name" end def service_object diff --git a/lib/chef/knife/client_key_edit.rb b/lib/chef/knife/client_key_edit.rb index 1de45f4ca2..5aa4dc4781 100644 --- a/lib/chef/knife/client_key_edit.rb +++ b/lib/chef/knife/client_key_edit.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'chef/knife' -require 'chef/knife/key_edit_base' +require "chef/knife" +require "chef/knife/key_edit_base" class Chef class Knife @@ -30,7 +30,7 @@ class Chef class ClientKeyEdit < Knife include Chef::Knife::KeyEditBase - banner 'knife client key edit CLIENT KEYNAME (options)' + banner "knife client key edit CLIENT KEYNAME (options)" attr_reader :actor @@ -45,7 +45,7 @@ class Chef end def actor_field_name - 'client' + "client" end def service_object @@ -53,11 +53,11 @@ class Chef end def actor_missing_error - 'You must specify a client name' + "You must specify a client name" end def keyname_missing_error - 'You must specify a key name' + "You must specify a key name" end def apply_params!(params) diff --git a/lib/chef/knife/client_key_list.rb b/lib/chef/knife/client_key_list.rb index f6f29ae03f..5679cc43e2 100644 --- a/lib/chef/knife/client_key_list.rb +++ b/lib/chef/knife/client_key_list.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'chef/knife' -require 'chef/knife/key_list_base' +require "chef/knife" +require "chef/knife/key_list_base" class Chef class Knife @@ -49,7 +49,7 @@ class Chef end def actor_missing_error - 'You must specify a client name' + "You must specify a client name" end def service_object diff --git a/lib/chef/knife/client_key_show.rb b/lib/chef/knife/client_key_show.rb index c39a279000..7ec32dd761 100644 --- a/lib/chef/knife/client_key_show.rb +++ b/lib/chef/knife/client_key_show.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife @@ -46,11 +46,11 @@ class Chef end def actor_missing_error - 'You must specify a client name' + "You must specify a client name" end def keyname_missing_error - 'You must specify a key name' + "You must specify a key name" end def service_object diff --git a/lib/chef/knife/client_list.rb b/lib/chef/knife/client_list.rb index d8a3698b6a..d5bfb4600a 100644 --- a/lib/chef/knife/client_list.rb +++ b/lib/chef/knife/client_list.rb @@ -16,15 +16,15 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife class ClientList < Knife deps do - require 'chef/api_client_v1' - require 'chef/json_compat' + require "chef/api_client_v1" + require "chef/json_compat" end banner "knife client list (options)" diff --git a/lib/chef/knife/client_reregister.rb b/lib/chef/knife/client_reregister.rb index b94761e718..ac52f41fae 100644 --- a/lib/chef/knife/client_reregister.rb +++ b/lib/chef/knife/client_reregister.rb @@ -16,15 +16,15 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife class ClientReregister < Knife deps do - require 'chef/api_client_v1' - require 'chef/json_compat' + require "chef/api_client_v1" + require "chef/json_compat" end banner "knife client reregister CLIENT (options)" diff --git a/lib/chef/knife/client_show.rb b/lib/chef/knife/client_show.rb index bdac3f9758..a41ea4d7ce 100644 --- a/lib/chef/knife/client_show.rb +++ b/lib/chef/knife/client_show.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife @@ -25,8 +25,8 @@ class Chef include Knife::Core::MultiAttributeReturnOption deps do - require 'chef/api_client_v1' - require 'chef/json_compat' + require "chef/api_client_v1" + require "chef/json_compat" end banner "knife client show CLIENT (options)" diff --git a/lib/chef/knife/configure.rb b/lib/chef/knife/configure.rb index 8bb8930aee..f4d539aa13 100644 --- a/lib/chef/knife/configure.rb +++ b/lib/chef/knife/configure.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife @@ -25,7 +25,7 @@ class Chef attr_reader :chef_repo, :new_client_key, :validation_client_name, :validation_key deps do - require 'ohai' + require "ohai" Chef::Knife::ClientCreate.load_deps Chef::Knife::UserCreate.load_deps end @@ -61,7 +61,7 @@ class Chef def configure_chef # We are just faking out the system so that you can do this without a key specified - Chef::Config[:node_name] = 'woot' + Chef::Config[:node_name] = "woot" super Chef::Config[:node_name] = nil end @@ -136,14 +136,14 @@ EOH @chef_server = config[:chef_server_url] || ask_question("Please enter the chef server URL: ", :default => "https://#{server_name}:443") if config[:initial] @new_client_name = config[:node_name] || ask_question("Please enter a name for the new user: ", :default => Etc.getlogin) - @admin_client_name = config[:admin_client_name] || ask_question("Please enter the existing admin name: ", :default => 'admin') - @admin_client_key = config[:admin_client_key] || ask_question("Please enter the location of the existing admin's private key: ", :default => '/etc/chef-server/admin.pem') + @admin_client_name = config[:admin_client_name] || ask_question("Please enter the existing admin name: ", :default => "admin") + @admin_client_key = config[:admin_client_key] || ask_question("Please enter the location of the existing admin's private key: ", :default => "/etc/chef-server/admin.pem") @admin_client_key = File.expand_path(@admin_client_key) else @new_client_name = config[:node_name] || ask_question("Please enter an existing username or clientname for the API: ", :default => Etc.getlogin) end - @validation_client_name = config[:validation_client_name] || ask_question("Please enter the validation clientname: ", :default => 'chef-validator') - @validation_key = config[:validation_key] || ask_question("Please enter the location of the validation key: ", :default => '/etc/chef-server/chef-validator.pem') + @validation_client_name = config[:validation_client_name] || ask_question("Please enter the validation clientname: ", :default => "chef-validator") + @validation_key = config[:validation_key] || ask_question("Please enter the location of the validation key: ", :default => "/etc/chef-server/chef-validator.pem") @validation_key = File.expand_path(@validation_key) @chef_repo = config[:repository] || ask_question("Please enter the path to a chef repository (or leave blank): ") @@ -154,9 +154,9 @@ EOH def guess_servername o = Ohai::System.new o.load_plugins - o.require_plugin 'os' - o.require_plugin 'hostname' - o[:fqdn] || o[:machinename] || o[:hostname] || 'localhost' + o.require_plugin "os" + o.require_plugin "hostname" + o[:fqdn] || o[:machinename] || o[:hostname] || "localhost" end def config_file diff --git a/lib/chef/knife/configure_client.rb b/lib/chef/knife/configure_client.rb index 838d9a1f58..d1d1b2f3de 100644 --- a/lib/chef/knife/configure_client.rb +++ b/lib/chef/knife/configure_client.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife @@ -34,13 +34,13 @@ class Chef FileUtils.mkdir_p(@config_dir) ui.info("Writing client.rb") File.open(File.join(@config_dir, "client.rb"), "w") do |file| - file.puts('log_level :info') - file.puts('log_location STDOUT') + file.puts("log_level :info") + file.puts("log_location STDOUT") file.puts("chef_server_url '#{Chef::Config[:chef_server_url]}'") file.puts("validation_client_name '#{Chef::Config[:validation_client_name]}'") end ui.info("Writing validation.pem") - File.open(File.join(@config_dir, 'validation.pem'), "w") do |validation| + File.open(File.join(@config_dir, "validation.pem"), "w") do |validation| validation.puts(IO.read(Chef::Config[:validation_key])) end end diff --git a/lib/chef/knife/cookbook_bulk_delete.rb b/lib/chef/knife/cookbook_bulk_delete.rb index ec0d06937f..0a08fd5d46 100644 --- a/lib/chef/knife/cookbook_bulk_delete.rb +++ b/lib/chef/knife/cookbook_bulk_delete.rb @@ -17,18 +17,18 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife class CookbookBulkDelete < Knife deps do - require 'chef/knife/cookbook_delete' - require 'chef/cookbook_version' + require "chef/knife/cookbook_delete" + require "chef/cookbook_version" end - option :purge, :short => '-p', :long => '--purge', :boolean => true, :description => 'Permanently remove files from backing data store' + option :purge, :short => "-p", :long => "--purge", :boolean => true, :description => "Permanently remove files from backing data store" banner "knife cookbook bulk delete REGEX (options)" diff --git a/lib/chef/knife/cookbook_create.rb b/lib/chef/knife/cookbook_create.rb index 97f6e65d3c..391a9aee85 100644 --- a/lib/chef/knife/cookbook_create.rb +++ b/lib/chef/knife/cookbook_create.rb @@ -16,16 +16,16 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife class CookbookCreate < Knife deps do - require 'chef/json_compat' - require 'uri' - require 'fileutils' + require "chef/json_compat" + require "uri" + require "fileutils" end banner "knife cookbook create COOKBOOK (options)" @@ -182,8 +182,8 @@ EOH def create_changelog(dir, cookbook_name) msg("** Creating CHANGELOG for cookbook: #{cookbook_name}") - unless File.exists?(File.join(dir,cookbook_name,'CHANGELOG.md')) - open(File.join(dir, cookbook_name, 'CHANGELOG.md'),'w') do |file| + unless File.exists?(File.join(dir,cookbook_name,"CHANGELOG.md")) + open(File.join(dir, cookbook_name, "CHANGELOG.md"),"w") do |file| file.puts <<-EOH #{cookbook_name} CHANGELOG #{'='*"#{cookbook_name} CHANGELOG".length} diff --git a/lib/chef/knife/cookbook_delete.rb b/lib/chef/knife/cookbook_delete.rb index 5fe0e9664d..8112ed11f9 100644 --- a/lib/chef/knife/cookbook_delete.rb +++ b/lib/chef/knife/cookbook_delete.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife @@ -25,12 +25,12 @@ class Chef attr_accessor :cookbook_name, :version deps do - require 'chef/cookbook_version' + require "chef/cookbook_version" end - option :all, :short => '-a', :long => '--all', :boolean => true, :description => 'delete all versions' + option :all, :short => "-a", :long => "--all", :boolean => true, :description => "delete all versions" - option :purge, :short => '-p', :long => '--purge', :boolean => true, :description => 'Permanently remove files from backing data store' + option :purge, :short => "-p", :long => "--purge", :boolean => true, :description => "Permanently remove files from backing data store" banner "knife cookbook delete COOKBOOK VERSION (options)" @@ -106,7 +106,7 @@ class Chef end valid_responses[(available_versions.size + 1).to_s] = :all question << "#{available_versions.size + 1}. All versions\n\n" - responses = ask_question(question).split(',').map { |response| response.strip } + responses = ask_question(question).split(",").map { |response| response.strip } if responses.empty? ui.error("No versions specified, exiting") diff --git a/lib/chef/knife/cookbook_download.rb b/lib/chef/knife/cookbook_download.rb index 6ba5fc7d6c..0af5e3b89a 100644 --- a/lib/chef/knife/cookbook_download.rb +++ b/lib/chef/knife/cookbook_download.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife @@ -27,7 +27,7 @@ class Chef attr_accessor :cookbook_name deps do - require 'chef/cookbook_version' + require "chef/cookbook_version" end banner "knife cookbook download COOKBOOK [VERSION] (options)" @@ -87,10 +87,10 @@ class Chef next unless manifest.has_key?(segment) ui.info("Downloading #{segment}") manifest[segment].each do |segment_file| - dest = File.join(basedir, segment_file['path'].gsub('/', File::SEPARATOR)) + dest = File.join(basedir, segment_file["path"].gsub("/", File::SEPARATOR)) Chef::Log.debug("Downloading #{segment_file['path']} to #{dest}") FileUtils.mkdir_p(File.dirname(dest)) - tempfile = rest.streaming_request(segment_file['url']) + tempfile = rest.streaming_request(segment_file["url"]) FileUtils.mv(tempfile.path, dest) end end diff --git a/lib/chef/knife/cookbook_list.rb b/lib/chef/knife/cookbook_list.rb index dd78e854da..8b8fb163f9 100644 --- a/lib/chef/knife/cookbook_list.rb +++ b/lib/chef/knife/cookbook_list.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife diff --git a/lib/chef/knife/cookbook_metadata.rb b/lib/chef/knife/cookbook_metadata.rb index dfa69ae39f..66cb452d39 100644 --- a/lib/chef/knife/cookbook_metadata.rb +++ b/lib/chef/knife/cookbook_metadata.rb @@ -17,15 +17,15 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife class CookbookMetadata < Knife deps do - require 'chef/cookbook_loader' - require 'chef/cookbook/metadata' + require "chef/cookbook_loader" + require "chef/cookbook/metadata" end banner "knife cookbook metadata COOKBOOK (options)" @@ -62,7 +62,7 @@ class Chef def generate_metadata(cookbook) Array(config[:cookbook_path]).reverse.each do |path| - file = File.expand_path(File.join(path, cookbook, 'metadata.rb')) + file = File.expand_path(File.join(path, cookbook, "metadata.rb")) if File.exists?(file) generate_metadata_from_file(cookbook, file) else @@ -76,7 +76,7 @@ class Chef md = Chef::Cookbook::Metadata.new md.name(cookbook) md.from_file(file) - json_file = File.join(File.dirname(file), 'metadata.json') + json_file = File.join(File.dirname(file), "metadata.json") File.open(json_file, "w") do |f| f.write(Chef::JSONCompat.to_json_pretty(md)) end @@ -91,7 +91,7 @@ class Chef end def validate_metadata_json(path, cookbook) - json_file = File.join(path, cookbook, 'metadata.json') + json_file = File.join(path, cookbook, "metadata.json") if File.exist?(json_file) Chef::Cookbook::Metadata.validate_json(IO.read(json_file)) end diff --git a/lib/chef/knife/cookbook_metadata_from_file.rb b/lib/chef/knife/cookbook_metadata_from_file.rb index 8e26251d6e..51f3bdbb84 100644 --- a/lib/chef/knife/cookbook_metadata_from_file.rb +++ b/lib/chef/knife/cookbook_metadata_from_file.rb @@ -19,14 +19,14 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife class CookbookMetadataFromFile < Knife deps do - require 'chef/cookbook/metadata' + require "chef/cookbook/metadata" end banner "knife cookbook metadata from FILE (options)" diff --git a/lib/chef/knife/cookbook_show.rb b/lib/chef/knife/cookbook_show.rb index 07f7684c27..2229bd9d0e 100644 --- a/lib/chef/knife/cookbook_show.rb +++ b/lib/chef/knife/cookbook_show.rb @@ -16,16 +16,16 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife class CookbookShow < Knife deps do - require 'chef/json_compat' - require 'uri' - require 'chef/cookbook_version' + require "chef/json_compat" + require "uri" + require "chef/cookbook_version" end banner "knife cookbook show COOKBOOK [VERSION] [PART] [FILENAME] (options)" @@ -65,7 +65,7 @@ class Chef end cookbook_name, segment, filename = @name_args[0], @name_args[2], @name_args[3] - cookbook_version = @name_args[1] == 'latest' ? '_latest' : @name_args[1] + cookbook_version = @name_args[1] == "latest" ? "_latest" : @name_args[1] cookbook = rest.get("cookbooks/#{cookbook_name}/#{cookbook_version}") manifest_entry = cookbook.preferred_manifest_record(node, segment, filename) @@ -76,11 +76,11 @@ class Chef pretty_print(temp_file.read) when 3 # We are showing a specific part of the cookbook - cookbook_version = @name_args[1] == 'latest' ? '_latest' : @name_args[1] + cookbook_version = @name_args[1] == "latest" ? "_latest" : @name_args[1] result = rest.get("cookbooks/#{@name_args[0]}/#{cookbook_version}") output(result.manifest[@name_args[2]]) when 2 # We are showing the whole cookbook data - cookbook_version = @name_args[1] == 'latest' ? '_latest' : @name_args[1] + cookbook_version = @name_args[1] == "latest" ? "_latest" : @name_args[1] output(rest.get("cookbooks/#{@name_args[0]}/#{cookbook_version}")) when 1 # We are showing the cookbook versions (all of them) cookbook_name = @name_args[0] diff --git a/lib/chef/knife/cookbook_site_download.rb b/lib/chef/knife/cookbook_site_download.rb index 3aedd21ffa..2e66495bb5 100644 --- a/lib/chef/knife/cookbook_site_download.rb +++ b/lib/chef/knife/cookbook_site_download.rb @@ -15,14 +15,14 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife class CookbookSiteDownload < Knife deps do - require 'fileutils' + require "fileutils" end banner "knife cookbook site download COOKBOOK [VERSION] (options)" @@ -39,12 +39,12 @@ class Chef def run if current_cookbook_deprecated? - message = 'DEPRECATION: This cookbook has been deprecated. ' + message = "DEPRECATION: This cookbook has been deprecated. " message << "It has been replaced by #{replacement_cookbook}." ui.warn message unless config[:force] - ui.warn 'Use --force to force download deprecated cookbook.' + ui.warn "Use --force to force download deprecated cookbook." return end end @@ -53,12 +53,12 @@ class Chef end def version - @version = desired_cookbook_data['version'] + @version = desired_cookbook_data["version"] end private def cookbooks_api_url - 'https://supermarket.chef.io/api/v1/cookbooks' + "https://supermarket.chef.io/api/v1/cookbooks" end def current_cookbook_data @@ -68,13 +68,13 @@ class Chef end def current_cookbook_deprecated? - current_cookbook_data['deprecated'] == true + current_cookbook_data["deprecated"] == true end def desired_cookbook_data @desired_cookbook_data ||= begin uri = if @name_args.length == 1 - current_cookbook_data['latest_version'] + current_cookbook_data["latest_version"] else specific_cookbook_version_url end @@ -98,7 +98,7 @@ class Chef end def replacement_cookbook - replacement = File.basename(current_cookbook_data['replacement']) + replacement = File.basename(current_cookbook_data["replacement"]) end def specific_cookbook_version_url diff --git a/lib/chef/knife/cookbook_site_install.rb b/lib/chef/knife/cookbook_site_install.rb index cc68fe7897..cb6eeffc68 100644 --- a/lib/chef/knife/cookbook_site_install.rb +++ b/lib/chef/knife/cookbook_site_install.rb @@ -16,18 +16,18 @@ # limitations under the License. # -require 'chef/knife' -require 'chef/exceptions' -require 'shellwords' +require "chef/knife" +require "chef/exceptions" +require "shellwords" class Chef class Knife class CookbookSiteInstall < Knife deps do - require 'chef/mixin/shell_out' - require 'chef/knife/core/cookbook_scm_repo' - require 'chef/cookbook/metadata' + require "chef/mixin/shell_out" + require "chef/knife/core/cookbook_scm_repo" + require "chef/cookbook/metadata" end banner "knife cookbook site install COOKBOOK [VERSION] (options)" @@ -156,7 +156,7 @@ class Chef def convert_path(upstream_file) # converts a Windows path (C:\foo) to a mingw path (/c/foo) - if ENV['MSYSTEM'] == 'MINGW32' + if ENV["MSYSTEM"] == "MINGW32" return upstream_file.sub(/^([[:alpha:]]):/, '/\1') else return Shellwords.escape upstream_file diff --git a/lib/chef/knife/cookbook_site_list.rb b/lib/chef/knife/cookbook_site_list.rb index b5354ed6e6..7d3100dcda 100644 --- a/lib/chef/knife/cookbook_site_list.rb +++ b/lib/chef/knife/cookbook_site_list.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife @@ -33,7 +33,7 @@ class Chef def run if config[:with_uri] cookbooks = Hash.new - get_cookbook_list.each{ |k,v| cookbooks[k] = v['cookbook'] } + get_cookbook_list.each{ |k,v| cookbooks[k] = v["cookbook"] } ui.output(format_for_display(cookbooks)) else ui.msg(ui.list(get_cookbook_list.keys.sort, :columns_down)) diff --git a/lib/chef/knife/cookbook_site_search.rb b/lib/chef/knife/cookbook_site_search.rb index decbf6c2c3..0cade56f7a 100644 --- a/lib/chef/knife/cookbook_site_search.rb +++ b/lib/chef/knife/cookbook_site_search.rb @@ -15,7 +15,7 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife diff --git a/lib/chef/knife/cookbook_site_share.rb b/lib/chef/knife/cookbook_site_share.rb index c125c4b939..f926a38722 100644 --- a/lib/chef/knife/cookbook_site_share.rb +++ b/lib/chef/knife/cookbook_site_share.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'chef/knife' -require 'chef/mixin/shell_out' +require "chef/knife" +require "chef/mixin/shell_out" class Chef class Knife @@ -26,10 +26,10 @@ class Chef include Chef::Mixin::ShellOut deps do - require 'chef/cookbook_loader' - require 'chef/cookbook_uploader' - require 'chef/cookbook_site_streaming_uploader' - require 'mixlib/shellout' + require "chef/cookbook_loader" + require "chef/cookbook_uploader" + require "chef/cookbook_site_streaming_uploader" + require "mixlib/shellout" end include Chef::Mixin::ShellOut @@ -44,8 +44,8 @@ class Chef :proc => lambda { |o| Chef::Config.cookbook_path = o.split(":") } option :dry_run, - :long => '--dry-run', - :short => '-n', + :long => "--dry-run", + :short => "-n", :boolean => true, :default => false, :description => "Don't take action, only print what files will be uploaded to Supermarket." @@ -113,7 +113,7 @@ class Chef ui.fatal("Received an error from Supermarket: #{data["error_code"]}. On the first time you upload it, you are required to specify the category you want to share this cookbook to.") exit(1) else - data['category'] + data["category"] end rescue => e ui.fatal("Unable to reach Supermarket: #{e.message}. Increase log verbosity (-VV) for more information.") @@ -125,7 +125,7 @@ class Chef def do_upload(cookbook_filename, cookbook_category, user_id, user_secret_filename) uri = "https://supermarket.chef.io/api/v1/cookbooks" - category_string = Chef::JSONCompat.to_json({ 'category'=>cookbook_category }) + category_string = Chef::JSONCompat.to_json({ "category"=>cookbook_category }) http_resp = Chef::CookbookSiteStreamingUploader.post(uri, user_id, user_secret_filename, { :tarball => File.open(cookbook_filename), @@ -134,8 +134,8 @@ class Chef res = Chef::JSONCompat.from_json(http_resp.body) if http_resp.code.to_i != 201 - if res['error_messages'] - if res['error_messages'][0] =~ /Version already exists/ + if res["error_messages"] + if res["error_messages"][0] =~ /Version already exists/ ui.error "The same version of this cookbook already exists on Supermarket." exit(1) else diff --git a/lib/chef/knife/cookbook_site_show.rb b/lib/chef/knife/cookbook_site_show.rb index 521a60eb36..01ed6c2346 100644 --- a/lib/chef/knife/cookbook_site_show.rb +++ b/lib/chef/knife/cookbook_site_show.rb @@ -15,7 +15,7 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife diff --git a/lib/chef/knife/cookbook_site_unshare.rb b/lib/chef/knife/cookbook_site_unshare.rb index 0c196c328a..bb857b7d1d 100644 --- a/lib/chef/knife/cookbook_site_unshare.rb +++ b/lib/chef/knife/cookbook_site_unshare.rb @@ -17,14 +17,14 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife class CookbookSiteUnshare < Knife deps do - require 'chef/json_compat' + require "chef/json_compat" end banner "knife cookbook site unshare COOKBOOK" diff --git a/lib/chef/knife/cookbook_site_vendor.rb b/lib/chef/knife/cookbook_site_vendor.rb index 82575958bd..9f4399f4cb 100644 --- a/lib/chef/knife/cookbook_site_vendor.rb +++ b/lib/chef/knife/cookbook_site_vendor.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'chef/knife' -require 'chef/knife/cookbook_site_install' +require "chef/knife" +require "chef/knife/cookbook_site_install" class Chef::Knife::CookbookSiteVendor < Chef::Knife::CookbookSiteInstall @@ -41,6 +41,6 @@ DEPRECATED: please use knife cookbook site install #{superclass.banner} B - category 'deprecated' + category "deprecated" end diff --git a/lib/chef/knife/cookbook_test.rb b/lib/chef/knife/cookbook_test.rb index 91e0b55c47..23bb7d8d78 100644 --- a/lib/chef/knife/cookbook_test.rb +++ b/lib/chef/knife/cookbook_test.rb @@ -18,15 +18,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife class CookbookTest < Knife deps do - require 'chef/cookbook_loader' - require 'chef/cookbook/syntax_check' + require "chef/cookbook_loader" + require "chef/cookbook/syntax_check" end banner "knife cookbook test [COOKBOOKS...] (options)" diff --git a/lib/chef/knife/cookbook_upload.rb b/lib/chef/knife/cookbook_upload.rb index b2acd74b4b..ba52d311ca 100644 --- a/lib/chef/knife/cookbook_upload.rb +++ b/lib/chef/knife/cookbook_upload.rb @@ -18,8 +18,8 @@ # limitations under the License. # -require 'chef/knife' -require 'chef/cookbook_uploader' +require "chef/knife" +require "chef/cookbook_uploader" class Chef class Knife @@ -29,9 +29,9 @@ class Chef MATCH_CHECKSUM = /[0-9a-f]{32,}/ deps do - require 'chef/exceptions' - require 'chef/cookbook_loader' - require 'chef/cookbook_uploader' + require "chef/exceptions" + require "chef/cookbook_loader" + require "chef/cookbook_uploader" end banner "knife cookbook upload [COOKBOOKS...] (options)" @@ -43,8 +43,8 @@ class Chef :proc => lambda { |o| o.split(":") } option :freeze, - :long => '--freeze', - :description => 'Freeze this version of the cookbook so that it cannot be overwritten', + :long => "--freeze", + :description => "Freeze this version of the cookbook so that it cannot be overwritten", :boolean => true option :all, @@ -53,19 +53,19 @@ class Chef :description => "Upload all cookbooks, rather than just a single cookbook" option :force, - :long => '--force', + :long => "--force", :boolean => true, :description => "Update cookbook versions even if they have been frozen" option :concurrency, - :long => '--concurrency NUMBER_OF_THREADS', + :long => "--concurrency NUMBER_OF_THREADS", :description => "How many concurrent threads will be used", :default => 10, :proc => lambda { |o| o.to_i } option :environment, - :short => '-E', - :long => '--environment ENVIRONMENT', + :short => "-E", + :long => "--environment ENVIRONMENT", :description => "Set ENVIRONMENT's version dependency match the version you're uploading.", :default => nil @@ -118,7 +118,7 @@ class Chef end ui.info("Uploaded all cookbooks.") else - cookbook_path = config[:cookbook_path].respond_to?(:join) ? config[:cookbook_path].join(', ') : config[:cookbook_path] + cookbook_path = config[:cookbook_path].respond_to?(:join) ? config[:cookbook_path].join(", ") : config[:cookbook_path] ui.warn("Could not find any cookbooks in your cookbook path: #{cookbook_path}. Use --cookbook-path to specify the desired path.") end else @@ -287,7 +287,7 @@ WARNING if @server_side_cookbooks[cookbook_name].nil? false else - versions = @server_side_cookbooks[cookbook_name]['versions'].collect {|versions| versions["version"]} + versions = @server_side_cookbooks[cookbook_name]["versions"].collect {|versions| versions["version"]} Log.debug "Versions of cookbook '#{cookbook_name}' returned by the server: #{versions.join(", ")}" @server_side_cookbooks[cookbook_name]["versions"].each do |versions_hash| if Chef::VersionConstraint.new(version).include?(versions_hash["version"]) diff --git a/lib/chef/knife/core/bootstrap_context.rb b/lib/chef/knife/core/bootstrap_context.rb index c39ae6837d..b0a759dd05 100644 --- a/lib/chef/knife/core/bootstrap_context.rb +++ b/lib/chef/knife/core/bootstrap_context.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'chef/run_list' -require 'chef/util/path_helper' +require "chef/run_list" +require "chef/util/path_helper" class Chef class Knife @@ -125,9 +125,9 @@ validation_client_name "#{@chef_config[:validation_client_name]}" def start_chef # If the user doesn't have a client path configure, let bash use the PATH for what it was designed for - client_path = @chef_config[:chef_client_path] || 'chef-client' + client_path = @chef_config[:chef_client_path] || "chef-client" s = "#{client_path} -j /etc/chef/first-boot.json" - s << ' -l debug' if @config[:verbosity] and @config[:verbosity] >= 2 + s << " -l debug" if @config[:verbosity] and @config[:verbosity] >= 2 s << " -E #{bootstrap_environment}" unless bootstrap_environment.nil? s << " --no-color" unless @config[:color] s diff --git a/lib/chef/knife/core/cookbook_scm_repo.rb b/lib/chef/knife/core/cookbook_scm_repo.rb index 727cff3153..f10bc969eb 100644 --- a/lib/chef/knife/core/cookbook_scm_repo.rb +++ b/lib/chef/knife/core/cookbook_scm_repo.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'chef/mixin/shell_out' +require "chef/mixin/shell_out" class Chef class Knife @@ -34,7 +34,7 @@ class Chef def initialize(repo_path, ui, opts={}) @repo_path = repo_path @ui = ui - @default_branch = 'master' + @default_branch = "master" @use_current_branch = false apply_opts(opts) end @@ -57,7 +57,7 @@ class Chef ui.info "If this is a new git repo, make sure you have at least one commit before installing cookbooks" exit 1 end - cmd = git('status --porcelain') + cmd = git("status --porcelain") if cmd.stdout =~ DIRTY_REPO ui.error "You have uncommitted changes to your cookbook repo (#{repo_path}):" ui.msg cmd.stdout @@ -124,13 +124,13 @@ class Chef def get_current_branch() ref = git("symbolic-ref HEAD").stdout - ref.chomp.split('/')[2] + ref.chomp.split("/")[2] end private def git_repo?(directory) - if File.directory?(File.join(directory, '.git')) + if File.directory?(File.join(directory, ".git")) return true elsif File.dirname(directory) == directory return false @@ -142,9 +142,9 @@ class Chef def apply_opts(opts) opts.each do |option, value| case option.to_s - when 'default_branch' + when "default_branch" @default_branch = value - when 'use_current_branch' + when "use_current_branch" @use_current_branch = value end end diff --git a/lib/chef/knife/core/custom_manifest_loader.rb b/lib/chef/knife/core/custom_manifest_loader.rb index c19e749f32..da3eee4d90 100644 --- a/lib/chef/knife/core/custom_manifest_loader.rb +++ b/lib/chef/knife/core/custom_manifest_loader.rb @@ -14,7 +14,7 @@ # limitations under the License. # -require 'chef/version' +require "chef/version" class Chef class Knife class SubcommandLoader diff --git a/lib/chef/knife/core/gem_glob_loader.rb b/lib/chef/knife/core/gem_glob_loader.rb index d09131aacb..bc987c907b 100644 --- a/lib/chef/knife/core/gem_glob_loader.rb +++ b/lib/chef/knife/core/gem_glob_loader.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'chef/version' -require 'chef/util/path_helper' +require "chef/version" +require "chef/util/path_helper" class Chef class Knife class SubcommandLoader @@ -39,7 +39,7 @@ class Chef # subcommand loader has been modified to load the plugins by using Kernel.load # with the absolute path. def gem_and_builtin_subcommands - require 'rubygems' + require "rubygems" find_subcommands_via_rubygems rescue LoadError find_subcommands_via_dirglob @@ -47,7 +47,7 @@ class Chef def find_subcommands_via_dirglob # The "require paths" of the core knife subcommands bundled with chef - files = Dir[File.join(Chef::Util::PathHelper.escape_glob(File.expand_path('../../../knife', __FILE__)), '*.rb')] + files = Dir[File.join(Chef::Util::PathHelper.escape_glob(File.expand_path("../../../knife", __FILE__)), "*.rb")] subcommand_files = {} files.each do |knife_file| rel_path = knife_file[/#{CHEF_ROOT}#{Regexp.escape(File::SEPARATOR)}(.*)\.rb/,1] @@ -57,7 +57,7 @@ class Chef end def find_subcommands_via_rubygems - files = find_files_latest_gems 'chef/knife/*.rb' + files = find_files_latest_gems "chef/knife/*.rb" subcommand_files = {} files.each do |file| rel_path = file[/(#{Regexp.escape File.join('chef', 'knife', '')}.*)\.rb/, 1] diff --git a/lib/chef/knife/core/generic_presenter.rb b/lib/chef/knife/core/generic_presenter.rb index 1b26becfa1..e0c5b5567c 100644 --- a/lib/chef/knife/core/generic_presenter.rb +++ b/lib/chef/knife/core/generic_presenter.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'chef/knife/core/text_formatter' +require "chef/knife/core/text_formatter" class Chef class Knife @@ -80,10 +80,10 @@ class Chef when :json Chef::JSONCompat.to_json_pretty(data) when :yaml - require 'yaml' + require "yaml" YAML::dump(data) when :pp - require 'stringio' + require "stringio" # If you were looking for some attribute and there is only one match # just dump the attribute value if config[:attribute] and data.length == 1 @@ -200,14 +200,14 @@ class Chef if config[:with_uri] item.inject({}) do |collected, (cookbook, versions)| collected[cookbook] = Hash.new - versions['versions'].each do |ver| - collected[cookbook][ver['version']] = ver['url'] + versions["versions"].each do |ver| + collected[cookbook][ver["version"]] = ver["url"] end collected end else versions_by_cookbook = item.inject({}) do |collected, ( cookbook, versions )| - collected[cookbook] = versions["versions"].map {|v| v['version']} + collected[cookbook] = versions["versions"].map {|v| v["version"]} collected end key_length = versions_by_cookbook.empty? ? 0 : versions_by_cookbook.keys.map {|name| name.size }.max + 2 diff --git a/lib/chef/knife/core/hashed_command_loader.rb b/lib/chef/knife/core/hashed_command_loader.rb index 6eb3635726..fe351e0ea9 100644 --- a/lib/chef/knife/core/hashed_command_loader.rb +++ b/lib/chef/knife/core/hashed_command_loader.rb @@ -15,7 +15,7 @@ # limitations under the License. # -require 'chef/version' +require "chef/version" class Chef class Knife class SubcommandLoader @@ -24,7 +24,7 @@ class Chef # for the given command. # class HashedCommandLoader < Chef::Knife::SubcommandLoader - KEY = '_autogenerated_command_paths' + KEY = "_autogenerated_command_paths" attr_accessor :manifest def initialize(chef_config_dir, plugin_manifest) @@ -34,8 +34,8 @@ class Chef def guess_category(args) category_words = positional_arguments(args) - category_words.map! { |w| w.split('-') }.flatten! - find_longest_key(manifest[KEY]["plugins_by_category"], category_words, ' ') + category_words.map! { |w| w.split("-") }.flatten! + find_longest_key(manifest[KEY]["plugins_by_category"], category_words, " ") end def list_commands(pref_category=nil) diff --git a/lib/chef/knife/core/node_editor.rb b/lib/chef/knife/core/node_editor.rb index 7b7cb72df9..9896195a97 100644 --- a/lib/chef/knife/core/node_editor.rb +++ b/lib/chef/knife/core/node_editor.rb @@ -17,8 +17,8 @@ # limitations under the License. # -require 'chef/json_compat' -require 'chef/node' +require "chef/json_compat" +require "chef/node" class Chef class Knife @@ -104,9 +104,9 @@ class Chef data = updated_data.dup unless config[:all_attributes] - data['automatic'] = node.automatic_attrs - data['default'] = node.default_attrs - data['override'] = node.override_attrs + data["automatic"] = node.automatic_attrs + data["default"] = node.default_attrs + data["override"] = node.override_attrs end @updated_node = Node.from_hash(data) diff --git a/lib/chef/knife/core/node_presenter.rb b/lib/chef/knife/core/node_presenter.rb index 5192c53f51..ffd31ed953 100644 --- a/lib/chef/knife/core/node_presenter.rb +++ b/lib/chef/knife/core/node_presenter.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'chef/knife/core/text_formatter' -require 'chef/knife/core/generic_presenter' +require "chef/knife/core/text_formatter" +require "chef/knife/core/generic_presenter" class Chef class Knife @@ -32,18 +32,18 @@ class Chef def self.included(includer) includer.class_eval do option :medium_output, - :short => '-m', - :long => '--medium', + :short => "-m", + :long => "--medium", :boolean => true, :default => false, - :description => 'Include normal attributes in the output' + :description => "Include normal attributes in the output" option :long_output, - :short => '-l', - :long => '--long', + :short => "-l", + :long => "--long", :boolean => true, :default => false, - :description => 'Include all attributes in the output' + :description => "Include all attributes in the output" end end end diff --git a/lib/chef/knife/core/object_loader.rb b/lib/chef/knife/core/object_loader.rb index 97ca381471..69c2428bd4 100644 --- a/lib/chef/knife/core/object_loader.rb +++ b/lib/chef/knife/core/object_loader.rb @@ -16,9 +16,9 @@ # limitations under the License. # -require 'ffi_yajl' -require 'chef/util/path_helper' -require 'chef/data_bag_item' +require "ffi_yajl" +require "chef/util/path_helper" +require "chef/data_bag_item" class Chef class Knife @@ -71,14 +71,14 @@ class Chef # # @api public def find_all_objects(path) - path = File.join(Chef::Util::PathHelper.escape_glob(File.expand_path(path)), '*') - path << '.{json,rb}' + path = File.join(Chef::Util::PathHelper.escape_glob(File.expand_path(path)), "*") + path << ".{json,rb}" objects = Dir.glob(path) objects.map { |o| File.basename(o) } end def find_all_object_dirs(path) - path = File.join(Chef::Util::PathHelper.escape_glob(File.expand_path(path)), '*') + path = File.join(Chef::Util::PathHelper.escape_glob(File.expand_path(path)), "*") objects = Dir.glob(path) objects.delete_if { |o| !File.directory?(o) } objects.map { |o| File.basename(o) } diff --git a/lib/chef/knife/core/status_presenter.rb b/lib/chef/knife/core/status_presenter.rb index 9cf839d3a6..4451835962 100644 --- a/lib/chef/knife/core/status_presenter.rb +++ b/lib/chef/knife/core/status_presenter.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'chef/knife/core/text_formatter' -require 'chef/knife/core/generic_presenter' +require "chef/knife/core/text_formatter" +require "chef/knife/core/generic_presenter" class Chef class Knife @@ -32,18 +32,18 @@ class Chef def self.included(includer) includer.class_eval do option :medium_output, - :short => '-m', - :long => '--medium', + :short => "-m", + :long => "--medium", :boolean => true, :default => false, - :description => 'Include normal attributes in the output' + :description => "Include normal attributes in the output" option :long_output, - :short => '-l', - :long => '--long', + :short => "-l", + :long => "--long", :boolean => true, :default => false, - :description => 'Include all attributes in the output' + :description => "Include all attributes in the output" end end end @@ -93,13 +93,13 @@ class Chef # the volume of output is adjusted accordingly. Uses colors if enabled # in the ui object. def summarize(list) - summarized='' + summarized="" list.each do |data| node = data # special case ec2 with their split horizon whatsis. ip = (node[:ec2] && node[:ec2][:public_ipv4]) || node[:ipaddress] fqdn = (node[:ec2] && node[:ec2][:public_hostname]) || node[:fqdn] - name = node['name'] || node.name + name = node["name"] || node.name hours, minutes, _ = time_difference_in_hms(node["ohai_time"]) hours_text = "#{hours} hour#{hours == 1 ? ' ' : 's'}" @@ -117,20 +117,20 @@ class Chef end line_parts = Array.new - line_parts << @ui.color(text, color) + ' ago' << name + line_parts << @ui.color(text, color) + " ago" << name line_parts << fqdn if fqdn line_parts << ip if ip line_parts << run_list if run_list - if node['platform'] - platform = node['platform'] - if node['platform_version'] + if node["platform"] + platform = node["platform"] + if node["platform_version"] platform << " #{node['platform_version']}" end line_parts << platform end - summarized=summarized + line_parts.join(', ') + ".\n" + summarized=summarized + line_parts.join(", ") + ".\n" end summarized end diff --git a/lib/chef/knife/core/subcommand_loader.rb b/lib/chef/knife/core/subcommand_loader.rb index 808e053c40..4a1ed2481a 100644 --- a/lib/chef/knife/core/subcommand_loader.rb +++ b/lib/chef/knife/core/subcommand_loader.rb @@ -16,11 +16,11 @@ # limitations under the License. # -require 'chef/version' -require 'chef/util/path_helper' -require 'chef/knife/core/gem_glob_loader' -require 'chef/knife/core/hashed_command_loader' -require 'chef/knife/core/custom_manifest_loader' +require "chef/version" +require "chef/util/path_helper" +require "chef/knife/core/gem_glob_loader" +require "chef/knife/core/hashed_command_loader" +require "chef/knife/core/custom_manifest_loader" class Chef class Knife @@ -75,7 +75,7 @@ class Chef end def self.plugin_manifest_path - Chef::Util::PathHelper.home('.chef', 'plugin_manifest.json') + Chef::Util::PathHelper.home(".chef", "plugin_manifest.json") end def initialize(chef_config_dir, env = nil) @@ -117,15 +117,15 @@ class Chef cmd_words = positional_arguments(args) load_command(cmd_words) result = Chef::Knife.subcommands[find_longest_key(Chef::Knife.subcommands, - cmd_words, '_')] - result || Chef::Knife.subcommands[args.first.gsub('-', '_')] + cmd_words, "_")] + result || Chef::Knife.subcommands[args.first.gsub("-", "_")] end def guess_category(args) category_words = positional_arguments(args) - category_words.map! { |w| w.split('-') }.flatten! + category_words.map! { |w| w.split("-") }.flatten! find_longest_key(Chef::Knife.subcommands_by_category, - category_words, ' ') + category_words, " ") end @@ -134,7 +134,7 @@ class Chef # def find_subcommands_via_dirglob # The "require paths" of the core knife subcommands bundled with chef - files = Dir[File.join(Chef::Util::PathHelper.escape_glob(File.expand_path('../../../knife', __FILE__)), '*.rb')] + files = Dir[File.join(Chef::Util::PathHelper.escape_glob(File.expand_path("../../../knife", __FILE__)), "*.rb")] subcommand_files = {} files.each do |knife_file| rel_path = knife_file[/#{CHEF_ROOT}#{Regexp.escape(File::SEPARATOR)}(.*)\.rb/,1] @@ -163,7 +163,7 @@ Please use Chef::Knife::SubcommandLoader.for_config(chef_config_dir, env)" # of words and a separator. We find the the longest key in the # hash composed of the given words joined by the separator. # - def find_longest_key(hash, words, sep = '_') + def find_longest_key(hash, words, sep = "_") match = nil until match || words.empty? candidate = words.join(sep) @@ -196,8 +196,8 @@ Please use Chef::Knife::SubcommandLoader.for_config(chef_config_dir, env)" end # finally search ~/.chef/plugins/knife/*.rb - Chef::Util::PathHelper.home('.chef', 'plugins', 'knife') do |p| - user_specific_files.concat Dir.glob(File.join(Chef::Util::PathHelper.escape_glob(p), '*.rb')) + Chef::Util::PathHelper.home(".chef", "plugins", "knife") do |p| + user_specific_files.concat Dir.glob(File.join(Chef::Util::PathHelper.escape_glob(p), "*.rb")) end user_specific_files diff --git a/lib/chef/knife/core/text_formatter.rb b/lib/chef/knife/core/text_formatter.rb index 5afdb6aaa9..6295d42ec2 100644 --- a/lib/chef/knife/core/text_formatter.rb +++ b/lib/chef/knife/core/text_formatter.rb @@ -42,7 +42,7 @@ class Chef end def text_format(data) - buffer = '' + buffer = "" if data.respond_to?(:keys) justify_width = data.keys.map {|k| k.to_s.size }.max.to_i + 1 diff --git a/lib/chef/knife/core/ui.rb b/lib/chef/knife/core/ui.rb index a54f14afc1..edc51088ec 100644 --- a/lib/chef/knife/core/ui.rb +++ b/lib/chef/knife/core/ui.rb @@ -18,10 +18,10 @@ # limitations under the License. # -require 'forwardable' -require 'chef/platform/query_helpers' -require 'chef/knife/core/generic_presenter' -require 'tempfile' +require "forwardable" +require "chef/platform/query_helpers" +require "chef/knife/core/generic_presenter" +require "tempfile" class Chef class Knife @@ -57,7 +57,7 @@ class Chef def highline @highline ||= begin - require 'highline' + require "highline" HighLine.new end end @@ -175,7 +175,7 @@ class Chef def edit_data(data, parse_output=true) output = Chef::JSONCompat.to_json_pretty(data) if (!config[:disable_editing]) - Tempfile.open([ 'knife-edit-', '.json' ]) do |tf| + Tempfile.open([ "knife-edit-", ".json" ]) do |tf| tf.sync = true tf.puts output tf.close @@ -217,11 +217,11 @@ class Chef def confirmation_instructions(default_choice) case default_choice when true - '? (Y/n) ' + "? (Y/n) " when false - '? (y/N) ' + "? (y/N) " else - '? (Y/N) ' + "? (Y/N) " end end diff --git a/lib/chef/knife/data_bag_create.rb b/lib/chef/knife/data_bag_create.rb index 0aa3002b23..afd7a90b7f 100644 --- a/lib/chef/knife/data_bag_create.rb +++ b/lib/chef/knife/data_bag_create.rb @@ -17,8 +17,8 @@ # limitations under the License. # -require 'chef/knife' -require 'chef/knife/data_bag_secret_options' +require "chef/knife" +require "chef/knife/data_bag_secret_options" class Chef class Knife @@ -26,8 +26,8 @@ class Chef include DataBagSecretOptions deps do - require 'chef/data_bag' - require 'chef/encrypted_data_bag_item' + require "chef/data_bag" + require "chef/encrypted_data_bag_item" end banner "knife data bag create BAG [ITEM] (options)" diff --git a/lib/chef/knife/data_bag_delete.rb b/lib/chef/knife/data_bag_delete.rb index a3215d4c54..4f5efd6ed6 100644 --- a/lib/chef/knife/data_bag_delete.rb +++ b/lib/chef/knife/data_bag_delete.rb @@ -16,14 +16,14 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife class DataBagDelete < Knife deps do - require 'chef/data_bag' + require "chef/data_bag" end banner "knife data bag delete BAG [ITEM] (options)" diff --git a/lib/chef/knife/data_bag_edit.rb b/lib/chef/knife/data_bag_edit.rb index 88c5669508..5a722dc278 100644 --- a/lib/chef/knife/data_bag_edit.rb +++ b/lib/chef/knife/data_bag_edit.rb @@ -17,8 +17,8 @@ # limitations under the License. # -require 'chef/knife' -require 'chef/knife/data_bag_secret_options' +require "chef/knife" +require "chef/knife/data_bag_secret_options" class Chef class Knife @@ -26,8 +26,8 @@ class Chef include DataBagSecretOptions deps do - require 'chef/data_bag_item' - require 'chef/encrypted_data_bag_item' + require "chef/data_bag_item" + require "chef/encrypted_data_bag_item" end banner "knife data bag edit BAG ITEM (options)" diff --git a/lib/chef/knife/data_bag_from_file.rb b/lib/chef/knife/data_bag_from_file.rb index d1b7daa4a2..617a187b52 100644 --- a/lib/chef/knife/data_bag_from_file.rb +++ b/lib/chef/knife/data_bag_from_file.rb @@ -17,9 +17,9 @@ # limitations under the License. # -require 'chef/knife' -require 'chef/util/path_helper' -require 'chef/knife/data_bag_secret_options' +require "chef/knife" +require "chef/util/path_helper" +require "chef/knife/data_bag_secret_options" class Chef class Knife @@ -27,11 +27,11 @@ class Chef include DataBagSecretOptions deps do - require 'chef/data_bag' - require 'chef/data_bag_item' - require 'chef/knife/core/object_loader' - require 'chef/json_compat' - require 'chef/encrypted_data_bag_item' + require "chef/data_bag" + require "chef/data_bag_item" + require "chef/knife/core/object_loader" + require "chef/json_compat" + require "chef/encrypted_data_bag_item" end banner "knife data bag from file BAG FILE|FOLDER [FILE|FOLDER..] (options)" diff --git a/lib/chef/knife/data_bag_list.rb b/lib/chef/knife/data_bag_list.rb index 5e556b60bc..93a28a9b4c 100644 --- a/lib/chef/knife/data_bag_list.rb +++ b/lib/chef/knife/data_bag_list.rb @@ -16,14 +16,14 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife class DataBagList < Knife deps do - require 'chef/data_bag' + require "chef/data_bag" end banner "knife data bag list (options)" diff --git a/lib/chef/knife/data_bag_secret_options.rb b/lib/chef/knife/data_bag_secret_options.rb index 766006089e..2a585bda57 100644 --- a/lib/chef/knife/data_bag_secret_options.rb +++ b/lib/chef/knife/data_bag_secret_options.rb @@ -16,9 +16,9 @@ # limitations under the License. # -require 'mixlib/cli' -require 'chef/config' -require 'chef/encrypted_data_bag_item/check_encrypted' +require "mixlib/cli" +require "chef/config" +require "chef/encrypted_data_bag_item/check_encrypted" class Chef class Knife @@ -65,7 +65,7 @@ class Chef def read_secret # Moving the non 'compile-time' requires into here to speed up knife command loading # IE, if we are not running 'knife data bag *' we don't need to load 'chef/encrypted_data_bag_item' - require 'chef/encrypted_data_bag_item' + require "chef/encrypted_data_bag_item" if has_cl_secret? config[:secret] diff --git a/lib/chef/knife/data_bag_show.rb b/lib/chef/knife/data_bag_show.rb index 2adafbde79..1b580ed50b 100644 --- a/lib/chef/knife/data_bag_show.rb +++ b/lib/chef/knife/data_bag_show.rb @@ -17,8 +17,8 @@ # limitations under the License. # -require 'chef/knife' -require 'chef/knife/data_bag_secret_options' +require "chef/knife" +require "chef/knife/data_bag_secret_options" class Chef class Knife @@ -26,8 +26,8 @@ class Chef include DataBagSecretOptions deps do - require 'chef/data_bag' - require 'chef/encrypted_data_bag_item' + require "chef/data_bag" + require "chef/encrypted_data_bag_item" end banner "knife data bag show BAG [ITEM] (options)" diff --git a/lib/chef/knife/delete.rb b/lib/chef/knife/delete.rb index 0030c45026..aeb4744873 100644 --- a/lib/chef/knife/delete.rb +++ b/lib/chef/knife/delete.rb @@ -1,4 +1,4 @@ -require 'chef/chef_fs/knife' +require "chef/chef_fs/knife" class Chef class Knife @@ -8,22 +8,22 @@ class Chef category "path-based" deps do - require 'chef/chef_fs/file_system' + require "chef/chef_fs/file_system" end option :recurse, - :short => '-r', - :long => '--[no-]recurse', + :short => "-r", + :long => "--[no-]recurse", :boolean => true, :default => false, :description => "Delete directories recursively." option :both, - :long => '--both', + :long => "--both", :boolean => true, :default => false, :description => "Delete both the local and remote copies." option :local, - :long => '--local', + :long => "--local", :boolean => true, :default => false, :description => "Delete the local copy (leave the remote copy)." diff --git a/lib/chef/knife/deps.rb b/lib/chef/knife/deps.rb index 4b23468962..0be83a8bf1 100644 --- a/lib/chef/knife/deps.rb +++ b/lib/chef/knife/deps.rb @@ -1,4 +1,4 @@ -require 'chef/chef_fs/knife' +require "chef/chef_fs/knife" class Chef class Knife @@ -8,20 +8,20 @@ class Chef category "path-based" deps do - require 'chef/chef_fs/file_system' - require 'chef/run_list' + require "chef/chef_fs/file_system" + require "chef/run_list" end option :recurse, - :long => '--[no-]recurse', + :long => "--[no-]recurse", :boolean => true, :description => "List dependencies recursively (default: true). Only works with --tree." option :tree, - :long => '--tree', + :long => "--tree", :boolean => true, :description => "Show dependencies in a visual tree. May show duplicates." option :remote, - :long => '--remote', + :long => "--remote", :boolean => true, :description => "List dependencies on the server instead of the local filesystem" @@ -73,30 +73,30 @@ class Chef def get_dependencies(entry) begin - if entry.parent && entry.parent.path == '/cookbooks' + if entry.parent && entry.parent.path == "/cookbooks" return entry.chef_object.metadata.dependencies.keys.map { |cookbook| "/cookbooks/#{cookbook}" } - elsif entry.parent && entry.parent.path == '/nodes' + elsif entry.parent && entry.parent.path == "/nodes" node = Chef::JSONCompat.parse(entry.read) result = [] - if node['chef_environment'] && node['chef_environment'] != '_default' + if node["chef_environment"] && node["chef_environment"] != "_default" result << "/environments/#{node['chef_environment']}.json" end - if node['run_list'] - result += dependencies_from_runlist(node['run_list']) + if node["run_list"] + result += dependencies_from_runlist(node["run_list"]) end result - elsif entry.parent && entry.parent.path == '/roles' + elsif entry.parent && entry.parent.path == "/roles" role = Chef::JSONCompat.parse(entry.read) result = [] - if role['run_list'] - dependencies_from_runlist(role['run_list']).each do |dependency| + if role["run_list"] + dependencies_from_runlist(role["run_list"]).each do |dependency| result << dependency if !result.include?(dependency) end end - if role['env_run_lists'] - role['env_run_lists'].each_pair do |env,run_list| + if role["env_run_lists"] + role["env_run_lists"].each_pair do |env,run_list| dependencies_from_runlist(run_list).each do |dependency| result << dependency if !result.include?(dependency) end diff --git a/lib/chef/knife/diff.rb b/lib/chef/knife/diff.rb index e5eda5228c..580e9e513f 100644 --- a/lib/chef/knife/diff.rb +++ b/lib/chef/knife/diff.rb @@ -1,4 +1,4 @@ -require 'chef/chef_fs/knife' +require "chef/chef_fs/knife" class Chef class Knife @@ -8,33 +8,33 @@ class Chef category "path-based" deps do - require 'chef/chef_fs/command_line' + require "chef/chef_fs/command_line" end option :recurse, - :long => '--[no-]recurse', + :long => "--[no-]recurse", :boolean => true, :default => true, :description => "List directories recursively." option :name_only, - :long => '--name-only', + :long => "--name-only", :boolean => true, :description => "Only show names of modified files." option :name_status, - :long => '--name-status', + :long => "--name-status", :boolean => true, :description => "Only show names and statuses of modified files: Added, Deleted, Modified, and Type Changed." option :diff_filter, - :long => '--diff-filter=[(A|D|M|T)...[*]]', + :long => "--diff-filter=[(A|D|M|T)...[*]]", :description => "Select only files that are Added (A), Deleted (D), Modified (M), or have their type (i.e. regular file, directory) changed (T). Any combination of the filter characters (including none) can be used. When * (All-or-none) is added to the combination, all paths are selected if there is any file that matches other criteria in the comparison; if there is no file that matches other criteria, nothing is selected." option :cookbook_version, - :long => '--cookbook-version VERSION', - :description => 'Version of cookbook to download (if there are multiple versions and cookbook_versions is false)' + :long => "--cookbook-version VERSION", + :description => "Version of cookbook to download (if there are multiple versions and cookbook_versions is false)" def run if config[:name_only] diff --git a/lib/chef/knife/download.rb b/lib/chef/knife/download.rb index 5a432afd47..f2af0e0152 100644 --- a/lib/chef/knife/download.rb +++ b/lib/chef/knife/download.rb @@ -1,4 +1,4 @@ -require 'chef/chef_fs/knife' +require "chef/chef_fs/knife" class Chef class Knife @@ -8,43 +8,43 @@ class Chef category "path-based" deps do - require 'chef/chef_fs/command_line' + require "chef/chef_fs/command_line" end option :recurse, - :long => '--[no-]recurse', + :long => "--[no-]recurse", :boolean => true, :default => true, :description => "List directories recursively." option :purge, - :long => '--[no-]purge', + :long => "--[no-]purge", :boolean => true, :default => false, :description => "Delete matching local files and directories that do not exist remotely." option :force, - :long => '--[no-]force', + :long => "--[no-]force", :boolean => true, :default => false, :description => "Force upload of files even if they match (quicker and harmless, but doesn't print out what it changed)" option :dry_run, - :long => '--dry-run', - :short => '-n', + :long => "--dry-run", + :short => "-n", :boolean => true, :default => false, :description => "Don't take action, only print what would happen" option :diff, - :long => '--[no-]diff', + :long => "--[no-]diff", :boolean => true, :default => true, - :description => 'Turn off to avoid uploading existing files; only new (and possibly deleted) files with --no-diff' + :description => "Turn off to avoid uploading existing files; only new (and possibly deleted) files with --no-diff" option :cookbook_version, - :long => '--cookbook-version VERSION', - :description => 'Version of cookbook to download (if there are multiple versions and cookbook_versions is false)' + :long => "--cookbook-version VERSION", + :description => "Version of cookbook to download (if there are multiple versions and cookbook_versions is false)" def run if name_args.length == 0 diff --git a/lib/chef/knife/edit.rb b/lib/chef/knife/edit.rb index 7408179ed0..608ce82a8f 100644 --- a/lib/chef/knife/edit.rb +++ b/lib/chef/knife/edit.rb @@ -1,4 +1,4 @@ -require 'chef/chef_fs/knife' +require "chef/chef_fs/knife" class Chef class Knife @@ -8,12 +8,12 @@ class Chef category "path-based" deps do - require 'chef/chef_fs/file_system' - require 'chef/chef_fs/file_system/not_found_error' + require "chef/chef_fs/file_system" + require "chef/chef_fs/file_system/not_found_error" end option :local, - :long => '--local', + :long => "--local", :boolean => true, :description => "Show local files instead of remote" @@ -51,7 +51,7 @@ class Chef def edit_text(text, extension) if (!config[:disable_editing]) - Tempfile.open([ 'knife-edit-', extension ]) do |file| + Tempfile.open([ "knife-edit-", extension ]) do |file| # Write the text to a temporary file file.write(text) file.close diff --git a/lib/chef/knife/environment_compare.rb b/lib/chef/knife/environment_compare.rb index 54f011f323..a4f99da255 100644 --- a/lib/chef/knife/environment_compare.rb +++ b/lib/chef/knife/environment_compare.rb @@ -16,14 +16,14 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife class EnvironmentCompare < Knife deps do - require 'chef/environment' + require "chef/environment" end banner "knife environment compare [ENVIRONMENT..] (options)" @@ -60,7 +60,7 @@ class Chef cookbooks = rest.get("/cookbooks?num_versions=1") if config[:all] # display matrix view of in the requested format. - if config[:format] == 'summary' + if config[:format] == "summary" matrix = matrix_output(cookbooks, constraints) ui.output(matrix) else @@ -99,7 +99,7 @@ class Chef end def matrix_output(cookbooks, constraints) - rows = [ '' ] + rows = [ "" ] environments = [] constraints.each { |e,v| environments << e.to_s } columns = environments.count + 1 diff --git a/lib/chef/knife/environment_create.rb b/lib/chef/knife/environment_create.rb index 6bc00d52b9..ea69b9b874 100644 --- a/lib/chef/knife/environment_create.rb +++ b/lib/chef/knife/environment_create.rb @@ -16,15 +16,15 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife class EnvironmentCreate < Knife deps do - require 'chef/environment' - require 'chef/json_compat' + require "chef/environment" + require "chef/json_compat" end banner "knife environment create ENVIRONMENT (options)" diff --git a/lib/chef/knife/environment_delete.rb b/lib/chef/knife/environment_delete.rb index e17841f805..3cd0d46cd1 100644 --- a/lib/chef/knife/environment_delete.rb +++ b/lib/chef/knife/environment_delete.rb @@ -16,15 +16,15 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife class EnvironmentDelete < Knife deps do - require 'chef/environment' - require 'chef/json_compat' + require "chef/environment" + require "chef/json_compat" end banner "knife environment delete ENVIRONMENT (options)" diff --git a/lib/chef/knife/environment_edit.rb b/lib/chef/knife/environment_edit.rb index 54962ac20d..72d774aee4 100644 --- a/lib/chef/knife/environment_edit.rb +++ b/lib/chef/knife/environment_edit.rb @@ -16,15 +16,15 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife class EnvironmentEdit < Knife deps do - require 'chef/environment' - require 'chef/json_compat' + require "chef/environment" + require "chef/json_compat" end banner "knife environment edit ENVIRONMENT (options)" diff --git a/lib/chef/knife/environment_from_file.rb b/lib/chef/knife/environment_from_file.rb index 3812024c9c..9b38fc53e0 100644 --- a/lib/chef/knife/environment_from_file.rb +++ b/lib/chef/knife/environment_from_file.rb @@ -21,8 +21,8 @@ class Chef class EnvironmentFromFile < Knife deps do - require 'chef/environment' - require 'chef/knife/core/object_loader' + require "chef/environment" + require "chef/knife/core/object_loader" end banner "knife environment from file FILE [FILE..] (options)" diff --git a/lib/chef/knife/environment_list.rb b/lib/chef/knife/environment_list.rb index 4e70818093..801d14b6c2 100644 --- a/lib/chef/knife/environment_list.rb +++ b/lib/chef/knife/environment_list.rb @@ -16,15 +16,15 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife class EnvironmentList < Knife deps do - require 'chef/environment' - require 'chef/json_compat' + require "chef/environment" + require "chef/json_compat" end banner "knife environment list (options)" diff --git a/lib/chef/knife/environment_show.rb b/lib/chef/knife/environment_show.rb index 2dd07fe6e9..fe79c3f08d 100644 --- a/lib/chef/knife/environment_show.rb +++ b/lib/chef/knife/environment_show.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife @@ -25,8 +25,8 @@ class Chef include Knife::Core::MultiAttributeReturnOption deps do - require 'chef/environment' - require 'chef/json_compat' + require "chef/environment" + require "chef/json_compat" end banner "knife environment show ENVIRONMENT (options)" diff --git a/lib/chef/knife/exec.rb b/lib/chef/knife/exec.rb index ace4ee2300..7788ae8d85 100644 --- a/lib/chef/knife/exec.rb +++ b/lib/chef/knife/exec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'chef/knife' -require 'chef/util/path_helper' +require "chef/knife" +require "chef/util/path_helper" class Chef::Knife::Exec < Chef::Knife @@ -35,15 +35,15 @@ class Chef::Knife::Exec < Chef::Knife :proc => lambda { |o| o.split(":") } deps do - require 'chef/shell/ext' + require "chef/shell/ext" end def run config[:script_path] ||= Array(Chef::Config[:script_path]) # Default script paths are chef-repo/.chef/scripts and ~/.chef/scripts - config[:script_path] << File.join(Chef::Knife.chef_config_dir, 'scripts') if Chef::Knife.chef_config_dir - Chef::Util::PathHelper.home('.chef', 'scripts') { |p| config[:script_path] << p } + config[:script_path] << File.join(Chef::Knife.chef_config_dir, "scripts") if Chef::Knife.chef_config_dir + Chef::Util::PathHelper.home(".chef", "scripts") { |p| config[:script_path] << p } scripts = Array(name_args) context = Object.new diff --git a/lib/chef/knife/help.rb b/lib/chef/knife/help.rb index 13fe674704..b8cfab142c 100644 --- a/lib/chef/knife/help.rb +++ b/lib/chef/knife/help.rb @@ -40,17 +40,17 @@ class Chef MOAR_HELP exit 1 else - @query = name_args.join('-') + @query = name_args.join("-") end case @query - when 'topics', 'list' + when "topics", "list" print_help_topics exit 1 - when 'intro', 'knife' - @topic = 'knife' + when "intro", "knife" + @topic = "knife" else @topic = find_manpages_for_query(@query) end @@ -67,7 +67,7 @@ MOAR_HELP def print_help_topics ui.info "Available help topics are: " - help_topics.collect {|t| t.gsub(/knife-/, '') }.sort.each do |topic| + help_topics.collect {|t| t.gsub(/knife-/, "") }.sort.each do |topic| ui.msg " #{topic}" end end diff --git a/lib/chef/knife/index_rebuild.rb b/lib/chef/knife/index_rebuild.rb index 95b0dcaffb..22962c6bec 100644 --- a/lib/chef/knife/index_rebuild.rb +++ b/lib/chef/knife/index_rebuild.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife diff --git a/lib/chef/knife/key_create.rb b/lib/chef/knife/key_create.rb index 5ee36e9793..e0946fe88d 100644 --- a/lib/chef/knife/key_create.rb +++ b/lib/chef/knife/key_create.rb @@ -16,9 +16,9 @@ # limitations under the License. # -require 'chef/key' -require 'chef/json_compat' -require 'chef/exceptions' +require "chef/key" +require "chef/json_compat" +require "chef/exceptions" class Chef class Knife diff --git a/lib/chef/knife/key_delete.rb b/lib/chef/knife/key_delete.rb index fb996cff17..725296b22b 100644 --- a/lib/chef/knife/key_delete.rb +++ b/lib/chef/knife/key_delete.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'chef/key' +require "chef/key" class Chef class Knife diff --git a/lib/chef/knife/key_edit.rb b/lib/chef/knife/key_edit.rb index 48ae344e6e..e08dd9eb65 100644 --- a/lib/chef/knife/key_edit.rb +++ b/lib/chef/knife/key_edit.rb @@ -16,9 +16,9 @@ # limitations under the License. # -require 'chef/key' -require 'chef/json_compat' -require 'chef/exceptions' +require "chef/key" +require "chef/json_compat" +require "chef/exceptions" class Chef class Knife diff --git a/lib/chef/knife/key_list.rb b/lib/chef/knife/key_list.rb index e96a27161f..7a968e85bd 100644 --- a/lib/chef/knife/key_list.rb +++ b/lib/chef/knife/key_list.rb @@ -16,9 +16,9 @@ # limitations under the License. # -require 'chef/key' -require 'chef/json_compat' -require 'chef/exceptions' +require "chef/key" +require "chef/json_compat" +require "chef/exceptions" class Chef class Knife @@ -64,21 +64,21 @@ EOS if @config[:with_details] max_length = 0 keys.each do |key| - key['name'] = key['name'] + ":" - max_length = key['name'].length if key['name'].length > max_length + key["name"] = key["name"] + ":" + max_length = key["name"].length if key["name"].length > max_length end keys.each do |key| - next if !key['expired'] && @config[:only_expired] - next if key['expired'] && @config[:only_non_expired] + next if !key["expired"] && @config[:only_expired] + next if key["expired"] && @config[:only_non_expired] display = "#{colorize(key['name'].ljust(max_length))} #{key['uri']}" display = "#{display} (expired)" if key["expired"] display_info(display) end else keys.each do |key| - next if !key['expired'] && @config[:only_expired] - next if key['expired'] && @config[:only_non_expired] - display_info(key['name']) + next if !key["expired"] && @config[:only_expired] + next if key["expired"] && @config[:only_non_expired] + display_info(key["name"]) end end end diff --git a/lib/chef/knife/key_show.rb b/lib/chef/knife/key_show.rb index 522f7a1a77..4b9ff617ef 100644 --- a/lib/chef/knife/key_show.rb +++ b/lib/chef/knife/key_show.rb @@ -16,9 +16,9 @@ # limitations under the License. # -require 'chef/key' -require 'chef/json_compat' -require 'chef/exceptions' +require "chef/key" +require "chef/json_compat" +require "chef/exceptions" class Chef class Knife diff --git a/lib/chef/knife/list.rb b/lib/chef/knife/list.rb index 263b0e7431..3d1583b270 100644 --- a/lib/chef/knife/list.rb +++ b/lib/chef/knife/list.rb @@ -1,4 +1,4 @@ -require 'chef/chef_fs/knife' +require "chef/chef_fs/knife" class Chef class Knife @@ -8,33 +8,33 @@ class Chef category "path-based" deps do - require 'chef/chef_fs/file_system' - require 'highline' + require "chef/chef_fs/file_system" + require "highline" end option :recursive, - :short => '-R', + :short => "-R", :boolean => true, :description => "List directories recursively" option :bare_directories, - :short => '-d', + :short => "-d", :boolean => true, :description => "When directories match the pattern, do not show the directories' children" option :local, - :long => '--local', + :long => "--local", :boolean => true, :description => "List local directory instead of remote" option :flat, - :short => '-f', - :long => '--flat', + :short => "-f", + :long => "--flat", :boolean => true, :description => "Show a list of filenames rather than the prettified ls-like output normally produced" option :one_column, - :short => '-1', + :short => "-1", :boolean => true, :description => "Show only one column of results" option :trailing_slashes, - :short => '-p', + :short => "-p", :boolean => true, :description => "Show trailing slashes after directories" @@ -130,17 +130,17 @@ class Chef else columns = HighLine::SystemExtensions.terminal_size[0] end - current_line = '' + current_line = "" results.each do |result| if current_line.length > 0 && current_line.length + print_space > columns output current_line.rstrip - current_line = '' + current_line = "" end if current_line.length == 0 current_line << indent end current_line << result - current_line << (' ' * (print_space - result.length)) + current_line << (" " * (print_space - result.length)) end output current_line.rstrip if current_line.length > 0 end diff --git a/lib/chef/knife/node_bulk_delete.rb b/lib/chef/knife/node_bulk_delete.rb index 89b2abe6ae..45291bf033 100644 --- a/lib/chef/knife/node_bulk_delete.rb +++ b/lib/chef/knife/node_bulk_delete.rb @@ -16,15 +16,15 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife class NodeBulkDelete < Knife deps do - require 'chef/node' - require 'chef/json_compat' + require "chef/node" + require "chef/json_compat" end banner "knife node bulk delete REGEX (options)" diff --git a/lib/chef/knife/node_create.rb b/lib/chef/knife/node_create.rb index 7f50a30c80..351f407b25 100644 --- a/lib/chef/knife/node_create.rb +++ b/lib/chef/knife/node_create.rb @@ -16,15 +16,15 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife class NodeCreate < Knife deps do - require 'chef/node' - require 'chef/json_compat' + require "chef/node" + require "chef/json_compat" end banner "knife node create NODE (options)" diff --git a/lib/chef/knife/node_delete.rb b/lib/chef/knife/node_delete.rb index a645d32035..d9e48f96c4 100644 --- a/lib/chef/knife/node_delete.rb +++ b/lib/chef/knife/node_delete.rb @@ -16,15 +16,15 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife class NodeDelete < Knife deps do - require 'chef/node' - require 'chef/json_compat' + require "chef/node" + require "chef/json_compat" end banner "knife node delete NODE (options)" diff --git a/lib/chef/knife/node_edit.rb b/lib/chef/knife/node_edit.rb index 0d6b8fcf6c..fd7637b529 100644 --- a/lib/chef/knife/node_edit.rb +++ b/lib/chef/knife/node_edit.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife @@ -24,9 +24,9 @@ class Chef class NodeEdit < Knife deps do - require 'chef/node' - require 'chef/json_compat' - require 'chef/knife/core/node_editor' + require "chef/node" + require "chef/json_compat" + require "chef/knife/core/node_editor" end banner "knife node edit NODE (options)" diff --git a/lib/chef/knife/node_environment_set.rb b/lib/chef/knife/node_environment_set.rb index da72aeaab8..b91ede56a5 100644 --- a/lib/chef/knife/node_environment_set.rb +++ b/lib/chef/knife/node_environment_set.rb @@ -16,14 +16,14 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife class NodeEnvironmentSet < Knife deps do - require 'chef/node' + require "chef/node" end banner "knife node environment set NODE ENVIRONMENT" diff --git a/lib/chef/knife/node_from_file.rb b/lib/chef/knife/node_from_file.rb index 66f2a466fd..3c43c69bbf 100644 --- a/lib/chef/knife/node_from_file.rb +++ b/lib/chef/knife/node_from_file.rb @@ -16,16 +16,16 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife class NodeFromFile < Knife deps do - require 'chef/node' - require 'chef/json_compat' - require 'chef/knife/core/object_loader' + require "chef/node" + require "chef/json_compat" + require "chef/knife/core/object_loader" end banner "knife node from file FILE (options)" @@ -36,7 +36,7 @@ class Chef def run @name_args.each do |arg| - updated = loader.load_from('nodes', arg) + updated = loader.load_from("nodes", arg) updated.save diff --git a/lib/chef/knife/node_list.rb b/lib/chef/knife/node_list.rb index 3926d101cf..9348341a21 100644 --- a/lib/chef/knife/node_list.rb +++ b/lib/chef/knife/node_list.rb @@ -16,15 +16,15 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife class NodeList < Knife deps do - require 'chef/node' - require 'chef/json_compat' + require "chef/node" + require "chef/json_compat" end banner "knife node list (options)" diff --git a/lib/chef/knife/node_run_list_add.rb b/lib/chef/knife/node_run_list_add.rb index 519c280400..ca7e8c9191 100644 --- a/lib/chef/knife/node_run_list_add.rb +++ b/lib/chef/knife/node_run_list_add.rb @@ -16,15 +16,15 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife class NodeRunListAdd < Knife deps do - require 'chef/node' - require 'chef/json_compat' + require "chef/node" + require "chef/json_compat" end banner "knife node run_list add [NODE] [ENTRY[,ENTRY]] (options)" @@ -44,11 +44,11 @@ class Chef if @name_args.size > 2 # Check for nested lists and create a single plain one entries = @name_args[1..-1].map do |entry| - entry.split(',').map { |e| e.strip } + entry.split(",").map { |e| e.strip } end.flatten else # Convert to array and remove the extra spaces - entries = @name_args[1].split(',').map { |e| e.strip } + entries = @name_args[1].split(",").map { |e| e.strip } end if config[:after] && config[:before] diff --git a/lib/chef/knife/node_run_list_remove.rb b/lib/chef/knife/node_run_list_remove.rb index ef03c176b8..d2bfcf6c9f 100644 --- a/lib/chef/knife/node_run_list_remove.rb +++ b/lib/chef/knife/node_run_list_remove.rb @@ -16,15 +16,15 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife class NodeRunListRemove < Knife deps do - require 'chef/node' - require 'chef/json_compat' + require "chef/node" + require "chef/json_compat" end banner "knife node run_list remove [NODE] [ENTRY[,ENTRY]] (options)" @@ -35,11 +35,11 @@ class Chef if @name_args.size > 2 # Check for nested lists and create a single plain one entries = @name_args[1..-1].map do |entry| - entry.split(',').map { |e| e.strip } + entry.split(",").map { |e| e.strip } end.flatten else # Convert to array and remove the extra spaces - entries = @name_args[1].split(',').map { |e| e.strip } + entries = @name_args[1].split(",").map { |e| e.strip } end # iterate over the list of things to remove, @@ -50,7 +50,7 @@ class Chef else ui.warn "#{e} is not in the run list" unless e =~ /^(recipe|role)\[/ - ui.warn '(did you forget recipe[] or role[] around it?)' + ui.warn "(did you forget recipe[] or role[] around it?)" end end end diff --git a/lib/chef/knife/node_run_list_set.rb b/lib/chef/knife/node_run_list_set.rb index e327d2acee..8d12c1f5bf 100644 --- a/lib/chef/knife/node_run_list_set.rb +++ b/lib/chef/knife/node_run_list_set.rb @@ -16,15 +16,15 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife class NodeRunListSet < Knife deps do - require 'chef/node' - require 'chef/json_compat' + require "chef/node" + require "chef/json_compat" end banner "knife node run_list set NODE ENTRIES (options)" @@ -37,11 +37,11 @@ class Chef elsif @name_args.size > 2 # Check for nested lists and create a single plain one entries = @name_args[1..-1].map do |entry| - entry.split(',').map { |e| e.strip } + entry.split(",").map { |e| e.strip } end.flatten else # Convert to array and remove the extra spaces - entries = @name_args[1].split(',').map { |e| e.strip } + entries = @name_args[1].split(",").map { |e| e.strip } end node = Chef::Node.load(@name_args[0]) diff --git a/lib/chef/knife/node_show.rb b/lib/chef/knife/node_show.rb index dc47da1e8f..115158e52e 100644 --- a/lib/chef/knife/node_show.rb +++ b/lib/chef/knife/node_show.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'chef/knife' -require 'chef/knife/core/node_presenter' +require "chef/knife" +require "chef/knife/core/node_presenter" class Chef class Knife @@ -27,8 +27,8 @@ class Chef include Knife::Core::MultiAttributeReturnOption deps do - require 'chef/node' - require 'chef/json_compat' + require "chef/node" + require "chef/json_compat" end banner "knife node show NODE (options)" diff --git a/lib/chef/knife/osc_user_create.rb b/lib/chef/knife/osc_user_create.rb index 6c3415473f..c5ccbaa13a 100644 --- a/lib/chef/knife/osc_user_create.rb +++ b/lib/chef/knife/osc_user_create.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" # DEPRECATION NOTE # This code only remains to support users still operating with @@ -27,8 +27,8 @@ class Chef class OscUserCreate < Knife deps do - require 'chef/user' - require 'chef/json_compat' + require "chef/user" + require "chef/json_compat" end option :file, diff --git a/lib/chef/knife/osc_user_delete.rb b/lib/chef/knife/osc_user_delete.rb index 5cd4f10413..4c79f5b69d 100644 --- a/lib/chef/knife/osc_user_delete.rb +++ b/lib/chef/knife/osc_user_delete.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" # DEPRECATION NOTE # This code only remains to support users still operating with @@ -28,8 +28,8 @@ class Chef class OscUserDelete < Knife deps do - require 'chef/user' - require 'chef/json_compat' + require "chef/user" + require "chef/json_compat" end banner "knife osc_user delete USER (options)" diff --git a/lib/chef/knife/osc_user_edit.rb b/lib/chef/knife/osc_user_edit.rb index 526475db05..db958a8852 100644 --- a/lib/chef/knife/osc_user_edit.rb +++ b/lib/chef/knife/osc_user_edit.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" # DEPRECATION NOTE # This code only remains to support users still operating with @@ -28,8 +28,8 @@ class Chef class OscUserEdit < Knife deps do - require 'chef/user' - require 'chef/json_compat' + require "chef/user" + require "chef/json_compat" end banner "knife osc_user edit USER (options)" diff --git a/lib/chef/knife/osc_user_list.rb b/lib/chef/knife/osc_user_list.rb index 84fca31899..9c0e3a7c00 100644 --- a/lib/chef/knife/osc_user_list.rb +++ b/lib/chef/knife/osc_user_list.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" # DEPRECATION NOTE # This code only remains to support users still operating with @@ -28,8 +28,8 @@ class Chef class OscUserList < Knife deps do - require 'chef/user' - require 'chef/json_compat' + require "chef/user" + require "chef/json_compat" end banner "knife osc_user list (options)" diff --git a/lib/chef/knife/osc_user_reregister.rb b/lib/chef/knife/osc_user_reregister.rb index 163b286fe0..bd983321f5 100644 --- a/lib/chef/knife/osc_user_reregister.rb +++ b/lib/chef/knife/osc_user_reregister.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" # DEPRECATION NOTE # This code only remains to support users still operating with @@ -28,8 +28,8 @@ class Chef class OscUserReregister < Knife deps do - require 'chef/user' - require 'chef/json_compat' + require "chef/user" + require "chef/json_compat" end banner "knife osc_user reregister USER (options)" diff --git a/lib/chef/knife/osc_user_show.rb b/lib/chef/knife/osc_user_show.rb index cb3a77585a..223fefa5e1 100644 --- a/lib/chef/knife/osc_user_show.rb +++ b/lib/chef/knife/osc_user_show.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" # DEPRECATION NOTE # This code only remains to support users still operating with @@ -30,8 +30,8 @@ class Chef include Knife::Core::MultiAttributeReturnOption deps do - require 'chef/user' - require 'chef/json_compat' + require "chef/user" + require "chef/json_compat" end banner "knife osc_user show USER (options)" diff --git a/lib/chef/knife/raw.rb b/lib/chef/knife/raw.rb index de8742deb9..80fbf97dcc 100644 --- a/lib/chef/knife/raw.rb +++ b/lib/chef/knife/raw.rb @@ -1,5 +1,5 @@ -require 'chef/knife' -require 'chef/http' +require "chef/knife" +require "chef/http" class Chef class Knife @@ -7,34 +7,34 @@ class Chef banner "knife raw REQUEST_PATH" deps do - require 'chef/json_compat' - require 'chef/config' - require 'chef/http' - require 'chef/http/authenticator' - require 'chef/http/cookie_manager' - require 'chef/http/decompressor' - require 'chef/http/json_output' + require "chef/json_compat" + require "chef/config" + require "chef/http" + require "chef/http/authenticator" + require "chef/http/cookie_manager" + require "chef/http/decompressor" + require "chef/http/json_output" end option :method, - :long => '--method METHOD', - :short => '-m METHOD', + :long => "--method METHOD", + :short => "-m METHOD", :default => "GET", :description => "Request method (GET, POST, PUT or DELETE). Default: GET" option :pretty, - :long => '--[no-]pretty', + :long => "--[no-]pretty", :boolean => true, :default => true, :description => "Pretty-print JSON output. Default: true" option :input, - :long => '--input FILE', - :short => '-i FILE', + :long => "--input FILE", + :short => "-i FILE", :description => "Name of file to use for PUT or POST" option :proxy_auth, - :long => '--proxy-auth', + :long => "--proxy-auth", :boolean => true, :default => false, :description => "Use webui proxy authentication. Client key must be the webui key." @@ -71,10 +71,10 @@ class Chef begin method = config[:method].to_sym - headers = {'Content-Type' => 'application/json'} + headers = {"Content-Type" => "application/json"} if config[:proxy_auth] - headers['x-ops-request-source'] = 'web' + headers["x-ops-request-source"] = "web" end if config[:pretty] @@ -93,7 +93,7 @@ class Chef exit 1 rescue Net::HTTPServerException => e ui.error "Server responded with error #{e.response.code} \"#{e.response.message}\"" - ui.error "Error Body: #{e.response.body}" if e.response.body && e.response.body != '' + ui.error "Error Body: #{e.response.body}" if e.response.body && e.response.body != "" exit 1 end end diff --git a/lib/chef/knife/recipe_list.rb b/lib/chef/knife/recipe_list.rb index 46ad619f1d..756069aebe 100644 --- a/lib/chef/knife/recipe_list.rb +++ b/lib/chef/knife/recipe_list.rb @@ -16,13 +16,13 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef::Knife::RecipeList < Chef::Knife banner "knife recipe list [PATTERN]" def run - recipes = rest.get('cookbooks/_recipes') + recipes = rest.get("cookbooks/_recipes") if pattern = @name_args.first recipes = recipes.grep(Regexp.new(pattern)) end diff --git a/lib/chef/knife/rehash.rb b/lib/chef/knife/rehash.rb index 6f1fd91911..dccf43b4e9 100644 --- a/lib/chef/knife/rehash.rb +++ b/lib/chef/knife/rehash.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'chef/knife' -require 'chef/knife/core/subcommand_loader' +require "chef/knife" +require "chef/knife/core/subcommand_loader" class Chef class Knife @@ -44,15 +44,15 @@ class Chef else { Chef::Knife::SubcommandLoader::HashedCommandLoader::KEY => {}} end - output[Chef::Knife::SubcommandLoader::HashedCommandLoader::KEY]['plugins_paths'] = Chef::Knife.subcommand_files - output[Chef::Knife::SubcommandLoader::HashedCommandLoader::KEY]['plugins_by_category'] = Chef::Knife.subcommands_by_category + output[Chef::Knife::SubcommandLoader::HashedCommandLoader::KEY]["plugins_paths"] = Chef::Knife.subcommand_files + output[Chef::Knife::SubcommandLoader::HashedCommandLoader::KEY]["plugins_by_category"] = Chef::Knife.subcommands_by_category output end def write_hash(data) - plugin_manifest_dir = File.expand_path('..', Chef::Knife::SubcommandLoader.plugin_manifest_path) + plugin_manifest_dir = File.expand_path("..", Chef::Knife::SubcommandLoader.plugin_manifest_path) FileUtils.mkdir_p(plugin_manifest_dir) unless File.directory?(plugin_manifest_dir) - File.open(Chef::Knife::SubcommandLoader.plugin_manifest_path, 'w') do |f| + File.open(Chef::Knife::SubcommandLoader.plugin_manifest_path, "w") do |f| f.write(Chef::JSONCompat.to_json_pretty(data)) ui.msg "Knife subcommands are cached in #{Chef::Knife::SubcommandLoader.plugin_manifest_path}. Delete this file to disable the caching." end diff --git a/lib/chef/knife/role_bulk_delete.rb b/lib/chef/knife/role_bulk_delete.rb index 8b24f55846..855881c298 100644 --- a/lib/chef/knife/role_bulk_delete.rb +++ b/lib/chef/knife/role_bulk_delete.rb @@ -16,15 +16,15 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife class RoleBulkDelete < Knife deps do - require 'chef/role' - require 'chef/json_compat' + require "chef/role" + require "chef/json_compat" end banner "knife role bulk delete REGEX (options)" diff --git a/lib/chef/knife/role_create.rb b/lib/chef/knife/role_create.rb index e9e363e870..8fef2c43cd 100644 --- a/lib/chef/knife/role_create.rb +++ b/lib/chef/knife/role_create.rb @@ -16,15 +16,15 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife class RoleCreate < Knife deps do - require 'chef/role' - require 'chef/json_compat' + require "chef/role" + require "chef/json_compat" end banner "knife role create ROLE (options)" diff --git a/lib/chef/knife/role_delete.rb b/lib/chef/knife/role_delete.rb index b823f37359..b3ff69860e 100644 --- a/lib/chef/knife/role_delete.rb +++ b/lib/chef/knife/role_delete.rb @@ -16,15 +16,15 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife class RoleDelete < Knife deps do - require 'chef/role' - require 'chef/json_compat' + require "chef/role" + require "chef/json_compat" end banner "knife role delete ROLE (options)" diff --git a/lib/chef/knife/role_edit.rb b/lib/chef/knife/role_edit.rb index b0580988a0..65086d8c6c 100644 --- a/lib/chef/knife/role_edit.rb +++ b/lib/chef/knife/role_edit.rb @@ -16,15 +16,15 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife class RoleEdit < Knife deps do - require 'chef/role' - require 'chef/json_compat' + require "chef/role" + require "chef/json_compat" end banner "knife role edit ROLE (options)" diff --git a/lib/chef/knife/role_env_run_list_add.rb b/lib/chef/knife/role_env_run_list_add.rb index faf84ccfdb..7dccd0d0a2 100644 --- a/lib/chef/knife/role_env_run_list_add.rb +++ b/lib/chef/knife/role_env_run_list_add.rb @@ -16,15 +16,15 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife class RoleEnvRunListAdd < Knife deps do - require 'chef/role' - require 'chef/json_compat' + require "chef/role" + require "chef/json_compat" end banner "knife role env_run_list add [ROLE] [ENVIRONMENT] [ENTRY[,ENTRY]] (options)" @@ -68,11 +68,11 @@ class Chef if @name_args.size > 2 # Check for nested lists and create a single plain one entries = @name_args[2..-1].map do |entry| - entry.split(',').map { |e| e.strip } + entry.split(",").map { |e| e.strip } end.flatten else # Convert to array and remove the extra spaces - entries = @name_args[2].split(',').map { |e| e.strip } + entries = @name_args[2].split(",").map { |e| e.strip } end add_to_env_run_list(role, environment, entries, config[:after]) diff --git a/lib/chef/knife/role_env_run_list_clear.rb b/lib/chef/knife/role_env_run_list_clear.rb index 4304f29a38..9994b45471 100644 --- a/lib/chef/knife/role_env_run_list_clear.rb +++ b/lib/chef/knife/role_env_run_list_clear.rb @@ -17,15 +17,15 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife class RoleEnvRunListClear < Knife deps do - require 'chef/role' - require 'chef/json_compat' + require "chef/role" + require "chef/json_compat" end banner "knife role env_run_list clear [ROLE] [ENVIRONMENT]" diff --git a/lib/chef/knife/role_env_run_list_remove.rb b/lib/chef/knife/role_env_run_list_remove.rb index 9ffc3f520e..07dd61de28 100644 --- a/lib/chef/knife/role_env_run_list_remove.rb +++ b/lib/chef/knife/role_env_run_list_remove.rb @@ -16,15 +16,15 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife class RoleEnvRunListRemove < Knife deps do - require 'chef/role' - require 'chef/json_compat' + require "chef/role" + require "chef/json_compat" end banner "knife role env_run_list remove [ROLE] [ENVIRONMENT] [ENTRIES]" diff --git a/lib/chef/knife/role_env_run_list_replace.rb b/lib/chef/knife/role_env_run_list_replace.rb index 146d0c4905..9929820594 100644 --- a/lib/chef/knife/role_env_run_list_replace.rb +++ b/lib/chef/knife/role_env_run_list_replace.rb @@ -16,15 +16,15 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife class RoleEnvRunListReplace < Knife deps do - require 'chef/role' - require 'chef/json_compat' + require "chef/role" + require "chef/json_compat" end banner "knife role env_run_list replace [ROLE] [ENVIRONMENT] [OLD_ENTRY] [NEW_ENTRY] " diff --git a/lib/chef/knife/role_env_run_list_set.rb b/lib/chef/knife/role_env_run_list_set.rb index a1618516c0..f414ced51c 100644 --- a/lib/chef/knife/role_env_run_list_set.rb +++ b/lib/chef/knife/role_env_run_list_set.rb @@ -17,15 +17,15 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife class RoleEnvRunListSet < Knife deps do - require 'chef/role' - require 'chef/json_compat' + require "chef/role" + require "chef/json_compat" end banner "knife role env_run_list set [ROLE] [ENVIRONMENT] [ENTRIES]" @@ -52,11 +52,11 @@ class Chef elsif @name_args.size > 2 # Check for nested lists and create a single plain one entries = @name_args[2..-1].map do |entry| - entry.split(',').map { |e| e.strip } + entry.split(",").map { |e| e.strip } end.flatten else # Convert to array and remove the extra spaces - entries = @name_args[2].split(',').map { |e| e.strip } + entries = @name_args[2].split(",").map { |e| e.strip } end set_env_run_list(role, environment, entries ) diff --git a/lib/chef/knife/role_from_file.rb b/lib/chef/knife/role_from_file.rb index c80218b753..aacf1211bf 100644 --- a/lib/chef/knife/role_from_file.rb +++ b/lib/chef/knife/role_from_file.rb @@ -16,16 +16,16 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife class RoleFromFile < Knife deps do - require 'chef/role' - require 'chef/knife/core/object_loader' - require 'chef/json_compat' + require "chef/role" + require "chef/knife/core/object_loader" + require "chef/json_compat" end banner "knife role from file FILE [FILE..] (options)" diff --git a/lib/chef/knife/role_list.rb b/lib/chef/knife/role_list.rb index 0f105b2188..8fa5707eb3 100644 --- a/lib/chef/knife/role_list.rb +++ b/lib/chef/knife/role_list.rb @@ -16,15 +16,15 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife class RoleList < Knife deps do - require 'chef/node' - require 'chef/json_compat' + require "chef/node" + require "chef/json_compat" end banner "knife role list (options)" diff --git a/lib/chef/knife/role_run_list_add.rb b/lib/chef/knife/role_run_list_add.rb index c9d7785bb7..c7f6b0afdf 100644 --- a/lib/chef/knife/role_run_list_add.rb +++ b/lib/chef/knife/role_run_list_add.rb @@ -16,15 +16,15 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife class RoleRunListAdd < Knife deps do - require 'chef/role' - require 'chef/json_compat' + require "chef/role" + require "chef/json_compat" end banner "knife role run_list add [ROLE] [ENTRY[,ENTRY]] (options)" @@ -68,11 +68,11 @@ class Chef if @name_args.size > 1 # Check for nested lists and create a single plain one entries = @name_args[1..-1].map do |entry| - entry.split(',').map { |e| e.strip } + entry.split(",").map { |e| e.strip } end.flatten else # Convert to array and remove the extra spaces - entries = @name_args[1].split(',').map { |e| e.strip } + entries = @name_args[1].split(",").map { |e| e.strip } end add_to_env_run_list(role, environment, entries, config[:after]) diff --git a/lib/chef/knife/role_run_list_clear.rb b/lib/chef/knife/role_run_list_clear.rb index ed6225d83d..2041c979b7 100644 --- a/lib/chef/knife/role_run_list_clear.rb +++ b/lib/chef/knife/role_run_list_clear.rb @@ -17,15 +17,15 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife class RoleRunListClear < Knife deps do - require 'chef/role' - require 'chef/json_compat' + require "chef/role" + require "chef/json_compat" end banner "knife role run_list clear [ROLE]" diff --git a/lib/chef/knife/role_run_list_remove.rb b/lib/chef/knife/role_run_list_remove.rb index d783b34ab4..655a6aa15f 100644 --- a/lib/chef/knife/role_run_list_remove.rb +++ b/lib/chef/knife/role_run_list_remove.rb @@ -16,15 +16,15 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife class RoleRunListRemove < Knife deps do - require 'chef/role' - require 'chef/json_compat' + require "chef/role" + require "chef/json_compat" end banner "knife role run_list remove [ROLE] [ENTRY]" diff --git a/lib/chef/knife/role_run_list_replace.rb b/lib/chef/knife/role_run_list_replace.rb index 1ab94df111..f28b69db25 100644 --- a/lib/chef/knife/role_run_list_replace.rb +++ b/lib/chef/knife/role_run_list_replace.rb @@ -16,15 +16,15 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife class RoleRunListReplace < Knife deps do - require 'chef/role' - require 'chef/json_compat' + require "chef/role" + require "chef/json_compat" end banner "knife role run_list replace [ROLE] [OLD_ENTRY] [NEW_ENTRY] " diff --git a/lib/chef/knife/role_run_list_set.rb b/lib/chef/knife/role_run_list_set.rb index b9675c70dd..30702458bc 100644 --- a/lib/chef/knife/role_run_list_set.rb +++ b/lib/chef/knife/role_run_list_set.rb @@ -17,15 +17,15 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife class RoleRunListSet < Knife deps do - require 'chef/role' - require 'chef/json_compat' + require "chef/role" + require "chef/json_compat" end banner "knife role run_list set [ROLE] [ENTRIES]" @@ -52,11 +52,11 @@ class Chef elsif @name_args.size > 1 # Check for nested lists and create a single plain one entries = @name_args[1..-1].map do |entry| - entry.split(',').map { |e| e.strip } + entry.split(",").map { |e| e.strip } end.flatten else # Convert to array and remove the extra spaces - entries = @name_args[1].split(',').map { |e| e.strip } + entries = @name_args[1].split(",").map { |e| e.strip } end set_env_run_list(role, environment, entries ) diff --git a/lib/chef/knife/role_show.rb b/lib/chef/knife/role_show.rb index 159571f281..1f8cba7b08 100644 --- a/lib/chef/knife/role_show.rb +++ b/lib/chef/knife/role_show.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife @@ -25,8 +25,8 @@ class Chef include Knife::Core::MultiAttributeReturnOption deps do - require 'chef/node' - require 'chef/json_compat' + require "chef/node" + require "chef/json_compat" end banner "knife role show ROLE (options)" diff --git a/lib/chef/knife/search.rb b/lib/chef/knife/search.rb index 014fc8dd87..642aaf8eef 100644 --- a/lib/chef/knife/search.rb +++ b/lib/chef/knife/search.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'chef/knife' -require 'chef/knife/core/node_presenter' +require "chef/knife" +require "chef/knife/core/node_presenter" class Chef class Knife @@ -26,10 +26,10 @@ class Chef include Knife::Core::MultiAttributeReturnOption deps do - require 'chef/node' - require 'chef/environment' - require 'chef/api_client' - require 'chef/search/query' + require "chef/node" + require "chef/environment" + require "chef/api_client" + require "chef/search/query" end include Knife::Core::NodeFormattingOptions @@ -80,7 +80,7 @@ class Chef read_cli_args fuzzify_query - if @type == 'node' + if @type == "node" ui.use_presenter Knife::Core::NodePresenter end diff --git a/lib/chef/knife/serve.rb b/lib/chef/knife/serve.rb index 84918e2ef2..4cb698c968 100644 --- a/lib/chef/knife/serve.rb +++ b/lib/chef/knife/serve.rb @@ -1,23 +1,23 @@ -require 'chef/knife' -require 'chef/local_mode' +require "chef/knife" +require "chef/local_mode" class Chef class Knife class Serve < Knife - banner 'knife serve (options)' + banner "knife serve (options)" option :repo_mode, - :long => '--repo-mode MODE', + :long => "--repo-mode MODE", :description => "Specifies the local repository layout. Values: static (only environments/roles/data_bags/cookbooks), everything (includes nodes/clients/users), hosted_everything (includes acls/groups/etc. for Enterprise/Hosted Chef). Default: everything/hosted_everything" option :chef_repo_path, - :long => '--chef-repo-path PATH', - :description => 'Overrides the location of chef repo. Default is specified by chef_repo_path in the config' + :long => "--chef-repo-path PATH", + :description => "Overrides the location of chef repo. Default is specified by chef_repo_path in the config" option :chef_zero_host, - :long => '--chef-zero-host IP', - :description => 'Overrides the host upon which chef-zero listens. Default is 127.0.0.1.' + :long => "--chef-zero-host IP", + :description => "Overrides the host upon which chef-zero listens. Default is 127.0.0.1." def configure_chef super diff --git a/lib/chef/knife/show.rb b/lib/chef/knife/show.rb index 4684a6ac7e..88a192994e 100644 --- a/lib/chef/knife/show.rb +++ b/lib/chef/knife/show.rb @@ -1,4 +1,4 @@ -require 'chef/chef_fs/knife' +require "chef/chef_fs/knife" class Chef class Knife @@ -8,12 +8,12 @@ class Chef category "path-based" deps do - require 'chef/chef_fs/file_system' - require 'chef/chef_fs/file_system/not_found_error' + require "chef/chef_fs/file_system" + require "chef/chef_fs/file_system/not_found_error" end option :local, - :long => '--local', + :long => "--local", :boolean => true, :description => "Show local files instead of remote" diff --git a/lib/chef/knife/ssh.rb b/lib/chef/knife/ssh.rb index 99ae2f426a..bf2f0d4bf0 100644 --- a/lib/chef/knife/ssh.rb +++ b/lib/chef/knife/ssh.rb @@ -16,23 +16,23 @@ # limitations under the License. # -require 'chef/mixin/shell_out' -require 'chef/knife' +require "chef/mixin/shell_out" +require "chef/knife" class Chef class Knife class Ssh < Knife deps do - require 'net/ssh' - require 'net/ssh/multi' - require 'chef/monkey_patches/net-ssh-multi' - require 'readline' - require 'chef/exceptions' - require 'chef/search/query' - require 'chef/mixin/command' - require 'chef/util/path_helper' - require 'mixlib/shellout' + require "net/ssh" + require "net/ssh/multi" + require "chef/monkey_patches/net-ssh-multi" + require "readline" + require "chef/exceptions" + require "chef/search/query" + require "chef/mixin/command" + require "chef/util/path_helper" + require "mixlib/shellout" end include Chef::Mixin::ShellOut @@ -109,8 +109,8 @@ class Chef :default => true option :on_error, - :short => '-e', - :long => '--exit-on-error', + :short => "-e", + :long => "--exit-on-error", :description => "Immediately exit if an error is encountered", :boolean => true, :proc => Proc.new { :raise } @@ -140,8 +140,8 @@ class Chef def configure_gateway config[:ssh_gateway] ||= Chef::Config[:knife][:ssh_gateway] if config[:ssh_gateway] - gw_host, gw_user = config[:ssh_gateway].split('@').reverse - gw_host, gw_port = gw_host.split(':') + gw_host, gw_user = config[:ssh_gateway].split("@").reverse + gw_host, gw_port = gw_host.split(":") gw_opts = session_options(gw_host, gw_port, gw_user) user = gw_opts.delete(:user) @@ -190,7 +190,7 @@ class Chef node[:cloud][:public_hostname] && !node[:cloud][:public_hostname].empty? Chef::Log.debug("Using node attribute 'cloud[:public_hostname]' automatically as the ssh target") - attribute = 'cloud.public_hostname' + attribute = "cloud.public_hostname" else # falling back to default of fqdn Chef::Log.debug("Using node attribute 'fqdn' as the ssh target") @@ -246,7 +246,7 @@ class Chef opts[:logger] = Chef::Log.logger if Chef::Log.level == :debug if !config[:host_key_verify] opts[:paranoid] = false - opts[:user_known_hosts_file] = '/dev/null' + opts[:user_known_hosts_file] = "/dev/null" end end end @@ -301,7 +301,7 @@ class Chef exit_status = 0 subsession ||= session command = fixup_sudo(command) - command.force_encoding('binary') if command.respond_to?(:force_encoding) + command.force_encoding("binary") if command.respond_to?(:force_encoding) subsession.open_channel do |ch| ch.request_pty ch.exec command do |ch, success| @@ -367,8 +367,8 @@ class Chef loop do command = read_line case command - when 'quit!' - puts 'Bye!' + when "quit!" + puts "Bye!" break when /^on (.+?); (.+)$/ raw_list = $1.split(" ") @@ -386,7 +386,7 @@ class Chef def screen tf = Tempfile.new("knife-ssh-screen") - Chef::Util::PathHelper.home('.screenrc') do |screenrc_path| + Chef::Util::PathHelper.home(".screenrc") do |screenrc_path| if File.exist? screenrc_path tf.puts("source #{screenrc_path}") end @@ -439,7 +439,7 @@ class Chef def macterm begin - require 'appscript' + require "appscript" rescue LoadError STDERR.puts "You need the rb-appscript gem to use knife ssh macterm. `(sudo) gem install rb-appscript` to install" raise @@ -447,7 +447,7 @@ class Chef Appscript.app("/Applications/Utilities/Terminal.app").windows.first.activate Appscript.app("System Events").application_processes["Terminal.app"].keystroke("n", :using=>:command_down) - term = Appscript.app('Terminal') + term = Appscript.app("Terminal") window = term.windows.first.get (session.servers_for.size - 1).times do |i| @@ -457,7 +457,7 @@ class Chef session.servers_for.each_with_index do |server, tab_number| cmd = "unset PROMPT_COMMAND; echo -e \"\\033]0;#{server.host}\\007\"; ssh #{server.user ? "#{server.user}@#{server.host}" : server.host}" - Appscript.app('Terminal').do_script(cmd, :in => window.tabs[tab_number + 1].get) + Appscript.app("Terminal").do_script(cmd, :in => window.tabs[tab_number + 1].get) end end diff --git a/lib/chef/knife/ssl_check.rb b/lib/chef/knife/ssl_check.rb index 38b4d81bb3..8ed18b8a5b 100644 --- a/lib/chef/knife/ssl_check.rb +++ b/lib/chef/knife/ssl_check.rb @@ -16,20 +16,20 @@ # limitations under the License. # -require 'chef/knife' -require 'chef/config' +require "chef/knife" +require "chef/config" class Chef class Knife class SslCheck < Chef::Knife deps do - require 'pp' - require 'socket' - require 'uri' - require 'chef/http/ssl_policies' - require 'openssl' - require 'chef/mixin/proxified_socket' + require "pp" + require "socket" + require "uri" + require "chef/http/ssl_policies" + require "openssl" + require "chef/mixin/proxified_socket" include Chef::Mixin::ProxifiedSocket end diff --git a/lib/chef/knife/ssl_fetch.rb b/lib/chef/knife/ssl_fetch.rb index 0c1ab7ea7b..f20576b917 100644 --- a/lib/chef/knife/ssl_fetch.rb +++ b/lib/chef/knife/ssl_fetch.rb @@ -16,19 +16,19 @@ # limitations under the License. # -require 'chef/knife' -require 'chef/config' +require "chef/knife" +require "chef/config" class Chef class Knife class SslFetch < Chef::Knife deps do - require 'pp' - require 'socket' - require 'uri' - require 'openssl' - require 'chef/mixin/proxified_socket' + require "pp" + require "socket" + require "uri" + require "openssl" + require "chef/mixin/proxified_socket" include Chef::Mixin::ProxifiedSocket end @@ -104,7 +104,7 @@ class Chef # practice. # https://tools.ietf.org/html/rfc6125#section-6.4.2 def normalize_cn(cn) - cn.gsub("*", "wildcard").gsub(/[^[:alnum:]\-]/, '_') + cn.gsub("*", "wildcard").gsub(/[^[:alnum:]\-]/, "_") end def configuration @@ -147,7 +147,7 @@ TRUST_TRUST ui.error("The service at the given URI (#{uri}) does not accept SSL connections") if uri.scheme == "http" - https_uri = uri.to_s.sub(/^http/, 'https') + https_uri = uri.to_s.sub(/^http/, "https") ui.error("Perhaps you meant to connect to '#{https_uri}'?") end exit 1 diff --git a/lib/chef/knife/status.rb b/lib/chef/knife/status.rb index e649c01ef4..29e7aa4c48 100644 --- a/lib/chef/knife/status.rb +++ b/lib/chef/knife/status.rb @@ -16,9 +16,9 @@ # limitations under the License. # -require 'chef/knife' -require 'chef/knife/core/status_presenter' -require 'chef/knife/core/node_presenter' +require "chef/knife" +require "chef/knife/core/status_presenter" +require "chef/knife/core/node_presenter" class Chef class Knife @@ -26,7 +26,7 @@ class Chef include Knife::Core::NodeFormattingOptions deps do - require 'chef/search/query' + require "chef/search/query" end banner "knife status QUERY (options)" diff --git a/lib/chef/knife/tag_create.rb b/lib/chef/knife/tag_create.rb index d3ca95242d..f568134727 100644 --- a/lib/chef/knife/tag_create.rb +++ b/lib/chef/knife/tag_create.rb @@ -18,14 +18,14 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife class TagCreate < Knife deps do - require 'chef/node' + require "chef/node" end banner "knife tag create NODE TAG ..." diff --git a/lib/chef/knife/tag_delete.rb b/lib/chef/knife/tag_delete.rb index 10751db216..4f7e059586 100644 --- a/lib/chef/knife/tag_delete.rb +++ b/lib/chef/knife/tag_delete.rb @@ -18,14 +18,14 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife class TagDelete < Knife deps do - require 'chef/node' + require "chef/node" end banner "knife tag delete NODE TAG ..." diff --git a/lib/chef/knife/tag_list.rb b/lib/chef/knife/tag_list.rb index 499eb8578c..659a6ac77f 100644 --- a/lib/chef/knife/tag_list.rb +++ b/lib/chef/knife/tag_list.rb @@ -18,14 +18,14 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife class TagList < Knife deps do - require 'chef/node' + require "chef/node" end banner "knife tag list NODE" diff --git a/lib/chef/knife/upload.rb b/lib/chef/knife/upload.rb index 8abd22b4dd..90b9a1562b 100644 --- a/lib/chef/knife/upload.rb +++ b/lib/chef/knife/upload.rb @@ -1,4 +1,4 @@ -require 'chef/chef_fs/knife' +require "chef/chef_fs/knife" class Chef class Knife @@ -8,45 +8,45 @@ class Chef category "path-based" deps do - require 'chef/chef_fs/command_line' + require "chef/chef_fs/command_line" end option :recurse, - :long => '--[no-]recurse', + :long => "--[no-]recurse", :boolean => true, :default => true, :description => "List directories recursively." option :purge, - :long => '--[no-]purge', + :long => "--[no-]purge", :boolean => true, :default => false, :description => "Delete matching local files and directories that do not exist remotely." option :force, - :long => '--[no-]force', + :long => "--[no-]force", :boolean => true, :default => false, :description => "Force upload of files even if they match (quicker for many files). Will overwrite frozen cookbooks." option :freeze, - :long => '--[no-]freeze', + :long => "--[no-]freeze", :boolean => true, :default => false, :description => "Freeze cookbooks that get uploaded." option :dry_run, - :long => '--dry-run', - :short => '-n', + :long => "--dry-run", + :short => "-n", :boolean => true, :default => false, :description => "Don't take action, only print what would happen" option :diff, - :long => '--[no-]diff', + :long => "--[no-]diff", :boolean => true, :default => true, - :description => 'Turn off to avoid uploading existing files; only new (and possibly deleted) files with --no-diff' + :description => "Turn off to avoid uploading existing files; only new (and possibly deleted) files with --no-diff" def run if name_args.length == 0 diff --git a/lib/chef/knife/user_create.rb b/lib/chef/knife/user_create.rb index 995573cd03..1fa698634f 100644 --- a/lib/chef/knife/user_create.rb +++ b/lib/chef/knife/user_create.rb @@ -17,8 +17,8 @@ # limitations under the License. # -require 'chef/knife' -require 'chef/knife/osc_user_create' +require "chef/knife" +require "chef/knife/osc_user_create" class Chef class Knife @@ -27,8 +27,8 @@ class Chef attr_accessor :user_field deps do - require 'chef/user_v1' - require 'chef/json_compat' + require "chef/user_v1" + require "chef/json_compat" end option :file, diff --git a/lib/chef/knife/user_delete.rb b/lib/chef/knife/user_delete.rb index 828cd51588..b6ea75c5cd 100644 --- a/lib/chef/knife/user_delete.rb +++ b/lib/chef/knife/user_delete.rb @@ -16,15 +16,15 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife class UserDelete < Knife deps do - require 'chef/user_v1' - require 'chef/json_compat' + require "chef/user_v1" + require "chef/json_compat" end banner "knife user delete USER (options)" diff --git a/lib/chef/knife/user_edit.rb b/lib/chef/knife/user_edit.rb index c3a4326ee8..991b5be272 100644 --- a/lib/chef/knife/user_edit.rb +++ b/lib/chef/knife/user_edit.rb @@ -16,15 +16,15 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife class UserEdit < Knife deps do - require 'chef/user_v1' - require 'chef/json_compat' + require "chef/user_v1" + require "chef/json_compat" end banner "knife user edit USER (options)" diff --git a/lib/chef/knife/user_key_create.rb b/lib/chef/knife/user_key_create.rb index 5ed699ff5b..e882e34e4d 100644 --- a/lib/chef/knife/user_key_create.rb +++ b/lib/chef/knife/user_key_create.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'chef/knife' -require 'chef/knife/key_create_base' +require "chef/knife" +require "chef/knife/key_create_base" class Chef class Knife @@ -30,7 +30,7 @@ class Chef class UserKeyCreate < Knife include Chef::Knife::KeyCreateBase - banner 'knife user key create USER (options)' + banner "knife user key create USER (options)" attr_reader :actor @@ -45,7 +45,7 @@ class Chef end def actor_field_name - 'user' + "user" end def service_object @@ -53,7 +53,7 @@ class Chef end def actor_missing_error - 'You must specify a user name' + "You must specify a user name" end def apply_params!(params) diff --git a/lib/chef/knife/user_key_delete.rb b/lib/chef/knife/user_key_delete.rb index 6db1c9f552..d5063c72ef 100644 --- a/lib/chef/knife/user_key_delete.rb +++ b/lib/chef/knife/user_key_delete.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife @@ -42,15 +42,15 @@ class Chef end def actor_field_name - 'user' + "user" end def actor_missing_error - 'You must specify a user name' + "You must specify a user name" end def keyname_missing_error - 'You must specify a key name' + "You must specify a key name" end def service_object diff --git a/lib/chef/knife/user_key_edit.rb b/lib/chef/knife/user_key_edit.rb index 0c35332523..9c766c8bea 100644 --- a/lib/chef/knife/user_key_edit.rb +++ b/lib/chef/knife/user_key_edit.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'chef/knife' -require 'chef/knife/key_edit_base' +require "chef/knife" +require "chef/knife/key_edit_base" class Chef class Knife @@ -30,7 +30,7 @@ class Chef class UserKeyEdit < Knife include Chef::Knife::KeyEditBase - banner 'knife user key edit USER KEYNAME (options)' + banner "knife user key edit USER KEYNAME (options)" attr_reader :actor @@ -45,7 +45,7 @@ class Chef end def actor_field_name - 'user' + "user" end def service_object @@ -53,11 +53,11 @@ class Chef end def actor_missing_error - 'You must specify a user name' + "You must specify a user name" end def keyname_missing_error - 'You must specify a key name' + "You must specify a key name" end def apply_params!(params) diff --git a/lib/chef/knife/user_key_list.rb b/lib/chef/knife/user_key_list.rb index a73f59c86f..9c308c47f8 100644 --- a/lib/chef/knife/user_key_list.rb +++ b/lib/chef/knife/user_key_list.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'chef/knife' -require 'chef/knife/key_list_base' +require "chef/knife" +require "chef/knife/key_list_base" class Chef class Knife @@ -49,7 +49,7 @@ class Chef end def actor_missing_error - 'You must specify a user name' + "You must specify a user name" end def service_object diff --git a/lib/chef/knife/user_key_show.rb b/lib/chef/knife/user_key_show.rb index b8453dd28e..b7e3bcb4d7 100644 --- a/lib/chef/knife/user_key_show.rb +++ b/lib/chef/knife/user_key_show.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife @@ -46,11 +46,11 @@ class Chef end def actor_missing_error - 'You must specify a user name' + "You must specify a user name" end def keyname_missing_error - 'You must specify a key name' + "You must specify a key name" end def service_object diff --git a/lib/chef/knife/user_list.rb b/lib/chef/knife/user_list.rb index 6a130392b9..44c581dd4a 100644 --- a/lib/chef/knife/user_list.rb +++ b/lib/chef/knife/user_list.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" # NOTE: only knife user command that is backwards compatible with OSC 11, # so no deprecation warnings are necessary. @@ -25,8 +25,8 @@ class Chef class UserList < Knife deps do - require 'chef/user_v1' - require 'chef/json_compat' + require "chef/user_v1" + require "chef/json_compat" end banner "knife user list (options)" diff --git a/lib/chef/knife/user_reregister.rb b/lib/chef/knife/user_reregister.rb index 09fd1cd2d6..8e99ac0906 100644 --- a/lib/chef/knife/user_reregister.rb +++ b/lib/chef/knife/user_reregister.rb @@ -16,15 +16,15 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife class UserReregister < Knife deps do - require 'chef/user_v1' - require 'chef/json_compat' + require "chef/user_v1" + require "chef/json_compat" end banner "knife user reregister USER (options)" diff --git a/lib/chef/knife/user_show.rb b/lib/chef/knife/user_show.rb index 3a2443471a..8ca181644e 100644 --- a/lib/chef/knife/user_show.rb +++ b/lib/chef/knife/user_show.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'chef/knife' +require "chef/knife" class Chef class Knife @@ -25,8 +25,8 @@ class Chef include Knife::Core::MultiAttributeReturnOption deps do - require 'chef/user_v1' - require 'chef/json_compat' + require "chef/user_v1" + require "chef/json_compat" end banner "knife user show USER (options)" diff --git a/lib/chef/knife/xargs.rb b/lib/chef/knife/xargs.rb index dd8e848058..f16890cba5 100644 --- a/lib/chef/knife/xargs.rb +++ b/lib/chef/knife/xargs.rb @@ -1,4 +1,4 @@ -require 'chef/chef_fs/knife' +require "chef/chef_fs/knife" class Chef class Knife @@ -8,65 +8,65 @@ class Chef category "path-based" deps do - require 'chef/chef_fs/file_system' - require 'chef/chef_fs/file_system/not_found_error' + require "chef/chef_fs/file_system" + require "chef/chef_fs/file_system/not_found_error" end # TODO modify to remote-only / local-only pattern (more like delete) option :local, - :long => '--local', + :long => "--local", :boolean => true, :description => "Xargs local files instead of remote" option :patterns, - :long => '--pattern [PATTERN]', - :short => '-p [PATTERN]', + :long => "--pattern [PATTERN]", + :short => "-p [PATTERN]", :description => "Pattern on command line (if these are not specified, a list of patterns is expected on standard input). Multiple patterns may be passed in this way.", :arg_arity => [1,-1] option :diff, - :long => '--[no-]diff', + :long => "--[no-]diff", :default => true, :boolean => true, :description => "Whether to show a diff when files change (default: true)" option :dry_run, - :long => '--dry-run', + :long => "--dry-run", :boolean => true, :description => "Prevents changes from actually being uploaded to the server." option :force, - :long => '--[no-]force', + :long => "--[no-]force", :boolean => true, :default => false, :description => "Force upload of files even if they are not changed (quicker and harmless, but doesn't print out what it changed)" option :replace_first, - :long => '--replace-first REPLACESTR', - :short => '-J REPLACESTR', + :long => "--replace-first REPLACESTR", + :short => "-J REPLACESTR", :description => "String to replace with filenames. -J will only replace the FIRST occurrence of the replacement string." option :replace_all, - :long => '--replace REPLACESTR', - :short => '-I REPLACESTR', + :long => "--replace REPLACESTR", + :short => "-I REPLACESTR", :description => "String to replace with filenames. -I will replace ALL occurrence of the replacement string." option :max_arguments_per_command, - :long => '--max-args MAXARGS', - :short => '-n MAXARGS', + :long => "--max-args MAXARGS", + :short => "-n MAXARGS", :description => "Maximum number of arguments per command line." option :max_command_line, - :long => '--max-chars LENGTH', - :short => '-s LENGTH', + :long => "--max-chars LENGTH", + :short => "-s LENGTH", :description => "Maximum size of command line, in characters" option :verbose_commands, - :short => '-t', + :short => "-t", :description => "Print command to be run on the command line" option :null_separator, - :short => '-0', + :short => "-0", :boolean => true, :description => "Use the NULL character (\0) as a separator, instead of whitespace" @@ -151,7 +151,7 @@ class Chef end def create_command(files) - command = name_args.join(' ') + command = name_args.join(" ") # Create the (empty) tempfiles tempfiles = {} @@ -167,7 +167,7 @@ class Chef end # Create the command - paths = tempfiles.keys.map { |tempfile| tempfile.path }.join(' ') + paths = tempfiles.keys.map { |tempfile| tempfile.path }.join(" ") if config[:replace_all] final_command = command.gsub(config[:replace_all], paths) elsif config[:replace_first] |