diff options
Diffstat (limited to 'lib')
163 files changed, 1700 insertions, 1701 deletions
diff --git a/lib/chef/api_client.rb b/lib/chef/api_client.rb index 656a0e364f..3120b58cc0 100644 --- a/lib/chef/api_client.rb +++ b/lib/chef/api_client.rb @@ -53,7 +53,7 @@ class Chef set_or_return( :name, arg, - :regex => /^[\-[:alnum:]_\.]+$/ + regex: /^[\-[:alnum:]_\.]+$/ ) end @@ -65,7 +65,7 @@ class Chef set_or_return( :admin, arg, - :kind_of => [ TrueClass, FalseClass ] + kind_of: [ TrueClass, FalseClass ] ) end @@ -77,7 +77,7 @@ class Chef set_or_return( :public_key, arg, - :kind_of => String + kind_of: String ) end @@ -90,7 +90,7 @@ class Chef set_or_return( :validator, arg, - :kind_of => [TrueClass, FalseClass] + kind_of: [TrueClass, FalseClass] ) end @@ -102,7 +102,7 @@ class Chef set_or_return( :private_key, arg, - :kind_of => [String, FalseClass] + kind_of: [String, FalseClass] ) end @@ -145,7 +145,7 @@ class Chef end def self.http_api - Chef::ServerAPI.new(Chef::Config[:chef_server_url], { :api_version => "0" }) + Chef::ServerAPI.new(Chef::Config[:chef_server_url], { api_version: "0" }) end def self.reregister(name) @@ -183,18 +183,18 @@ class Chef # Save this client via the REST API, returns a hash including the private key def save - http_api.put("clients/#{name}", { :name => name, :admin => admin, :validator => validator }) + http_api.put("clients/#{name}", { name: name, admin: admin, validator: validator }) rescue Net::HTTPServerException => e # If that fails, go ahead and try and update it if e.response.code == "404" - http_api.post("clients", { :name => name, :admin => admin, :validator => validator }) + http_api.post("clients", { name: name, admin: admin, validator: validator }) else raise e end end def reregister - reregistered_self = http_api.put("clients/#{name}", { :name => name, :admin => admin, :validator => validator, :private_key => true }) + reregistered_self = http_api.put("clients/#{name}", { name: name, admin: admin, validator: validator, private_key: true }) if reregistered_self.respond_to?(:[]) private_key(reregistered_self["private_key"]) else @@ -219,7 +219,7 @@ class Chef end def http_api - @http_api ||= Chef::ServerAPI.new(Chef::Config[:chef_server_url], { :api_version => "0" }) + @http_api ||= Chef::ServerAPI.new(Chef::Config[:chef_server_url], { api_version: "0" }) end end diff --git a/lib/chef/api_client/registration.rb b/lib/chef/api_client/registration.rb index 27e1f18c17..6cbb071020 100644 --- a/lib/chef/api_client/registration.rb +++ b/lib/chef/api_client/registration.rb @@ -139,7 +139,7 @@ class Chef end def put_data - base_put_data = { :name => name, :admin => false } + base_put_data = { name: name, admin: false } if self_generate_keys? base_put_data[:public_key] = generated_public_key else @@ -149,7 +149,7 @@ class Chef end def post_data - post_data = { :name => name, :admin => false } + post_data = { name: name, admin: false } post_data[:public_key] = generated_public_key if self_generate_keys? post_data end @@ -157,9 +157,9 @@ class Chef def http_api @http_api ||= Chef::ServerAPI.new(Chef::Config[:chef_server_url], { - :api_version => "0", - :client_name => Chef::Config[:validation_client_name], - :signing_key_filename => Chef::Config[:validation_key], + api_version: "0", + client_name: Chef::Config[:validation_client_name], + signing_key_filename: Chef::Config[:validation_key], } ) end diff --git a/lib/chef/api_client_v1.rb b/lib/chef/api_client_v1.rb index 7fbff6d6ba..645016c5b9 100644 --- a/lib/chef/api_client_v1.rb +++ b/lib/chef/api_client_v1.rb @@ -57,15 +57,15 @@ class Chef end def chef_rest_v0 - @chef_rest_v0 ||= Chef::ServerAPI.new(Chef::Config[:chef_server_url], { :api_version => "0", :inflate_json_class => false }) + @chef_rest_v0 ||= Chef::ServerAPI.new(Chef::Config[:chef_server_url], { api_version: "0", inflate_json_class: false }) end def chef_rest_v1 - @chef_rest_v1 ||= Chef::ServerAPI.new(Chef::Config[:chef_server_url], { :api_version => "1", :inflate_json_class => false }) + @chef_rest_v1 ||= Chef::ServerAPI.new(Chef::Config[:chef_server_url], { api_version: "1", inflate_json_class: false }) end def self.http_api - Chef::ServerAPI.new(Chef::Config[:chef_server_url], { :api_version => "1", :inflate_json_class => false }) + Chef::ServerAPI.new(Chef::Config[:chef_server_url], { api_version: "1", inflate_json_class: false }) end # Gets or sets the client name. @@ -76,7 +76,7 @@ class Chef set_or_return( :name, arg, - :regex => /^[\-[:alnum:]_\.]+$/ + regex: /^[\-[:alnum:]_\.]+$/ ) end @@ -88,7 +88,7 @@ class Chef set_or_return( :admin, arg, - :kind_of => [ TrueClass, FalseClass ] + kind_of: [ TrueClass, FalseClass ] ) end @@ -100,7 +100,7 @@ class Chef set_or_return( :public_key, arg, - :kind_of => String + kind_of: String ) end @@ -113,7 +113,7 @@ class Chef set_or_return( :validator, arg, - :kind_of => [TrueClass, FalseClass] + kind_of: [TrueClass, FalseClass] ) end @@ -126,7 +126,7 @@ class Chef set_or_return( :private_key, arg, - :kind_of => [String, TrueClass, FalseClass] + kind_of: [String, TrueClass, FalseClass] ) end @@ -138,7 +138,7 @@ class Chef set_or_return( :create_key, arg, - :kind_of => [ TrueClass, FalseClass ] + kind_of: [ TrueClass, FalseClass ] ) end @@ -226,7 +226,7 @@ class Chef def reregister # Try API V0 and if it fails due to V0 not being supported, raise the proper error message. # reregister only supported in API V0 or lesser. - reregistered_self = chef_rest_v0.put("clients/#{name}", { :name => name, :admin => admin, :validator => validator, :private_key => true }) + reregistered_self = chef_rest_v0.put("clients/#{name}", { name: name, admin: admin, validator: validator, private_key: true }) if reregistered_self.respond_to?(:[]) private_key(reregistered_self["private_key"]) else @@ -254,7 +254,7 @@ class Chef # it was never implemented, we will simply ignore that functionality # as it is being deprecated. # Delete this comment after V0 support is dropped. - payload = { :name => name } + payload = { name: name } payload[:validator] = validator unless validator.nil? # DEPRECATION @@ -277,11 +277,11 @@ class Chef # Create the client via the REST API def create payload = { - :name => name, - :validator => validator, + name: name, + validator: validator, # this field is ignored in API V1, but left for backwards-compat, # can remove after OSC 11 support is finished? - :admin => admin, + admin: admin, } begin # try API V1 diff --git a/lib/chef/application/apply.rb b/lib/chef/application/apply.rb index ec627ada2e..7325d89e1e 100644 --- a/lib/chef/application/apply.rb +++ b/lib/chef/application/apply.rb @@ -32,86 +32,86 @@ class Chef::Application::Apply < Chef::Application banner "Usage: chef-apply [RECIPE_FILE | -e RECIPE_TEXT | -s] [OPTIONS]" option :execute, - :short => "-e RECIPE_TEXT", - :long => "--execute RECIPE_TEXT", - :description => "Execute resources supplied in a string", - :proc => nil + short: "-e RECIPE_TEXT", + long: "--execute RECIPE_TEXT", + description: "Execute resources supplied in a string", + proc: nil option :stdin, - :short => "-s", - :long => "--stdin", - :description => "Execute resources read from STDIN", - :boolean => true + short: "-s", + long: "--stdin", + description: "Execute resources read from STDIN", + boolean: true option :json_attribs, - :short => "-j JSON_ATTRIBS", - :long => "--json-attributes JSON_ATTRIBS", - :description => "Load attributes from a JSON file or URL", - :proc => nil + short: "-j JSON_ATTRIBS", + long: "--json-attributes JSON_ATTRIBS", + description: "Load attributes from a JSON file or URL", + proc: nil option :force_logger, - :long => "--force-logger", - :description => "Use logger output instead of formatter output", - :boolean => true, - :default => false + long: "--force-logger", + description: "Use logger output instead of formatter output", + boolean: true, + default: false option :force_formatter, - :long => "--force-formatter", - :description => "Use formatter output instead of logger output", - :boolean => true, - :default => false + long: "--force-formatter", + description: "Use formatter output instead of logger output", + boolean: true, + default: false option :formatter, - :short => "-F FORMATTER", - :long => "--format FORMATTER", - :description => "output format to use", - :proc => lambda { |format| Chef::Config.add_formatter(format) } + short: "-F FORMATTER", + long: "--format FORMATTER", + description: "output format to use", + proc: lambda { |format| Chef::Config.add_formatter(format) } option :log_level, - :short => "-l LEVEL", - :long => "--log_level LEVEL", - :description => "Set the log level (trace, debug, info, warn, error, fatal)", - :proc => lambda { |l| l.to_sym } + short: "-l LEVEL", + long: "--log_level LEVEL", + description: "Set the log level (trace, debug, info, warn, error, fatal)", + proc: lambda { |l| l.to_sym } option :help, - :short => "-h", - :long => "--help", - :description => "Show this message", - :on => :tail, - :boolean => true, - :show_options => true, - :exit => 0 + short: "-h", + long: "--help", + description: "Show this message", + on: :tail, + boolean: true, + show_options: true, + exit: 0 option :version, - :short => "-v", - :long => "--version", - :description => "Show chef version", - :boolean => true, - :proc => lambda { |v| puts "Chef: #{::Chef::VERSION}" }, - :exit => 0 + short: "-v", + long: "--version", + description: "Show chef version", + boolean: true, + proc: lambda { |v| puts "Chef: #{::Chef::VERSION}" }, + exit: 0 option :why_run, - :short => "-W", - :long => "--why-run", - :description => "Enable whyrun mode", - :boolean => true + short: "-W", + long: "--why-run", + description: "Enable whyrun mode", + boolean: true option :profile_ruby, - :long => "--[no-]profile-ruby", - :description => "Dump complete Ruby call graph stack of entire Chef run (expert only)", - :boolean => true, - :default => false + long: "--[no-]profile-ruby", + description: "Dump complete Ruby call graph stack of entire Chef run (expert only)", + boolean: true, + default: false option :color, - :long => "--[no-]color", - :boolean => true, - :default => true, - :description => "Use colored output, defaults to enabled" + long: "--[no-]color", + boolean: true, + default: true, + description: "Use colored output, defaults to enabled" option :minimal_ohai, - :long => "--minimal-ohai", - :description => "Only run the bare minimum ohai plugins chef needs to function", - :boolean => true + long: "--minimal-ohai", + description: "Only run the bare minimum ohai plugins chef needs to function", + boolean: true attr_reader :json_attribs diff --git a/lib/chef/application/client.rb b/lib/chef/application/client.rb index ffb997f187..7e376fdd9f 100644 --- a/lib/chef/application/client.rb +++ b/lib/chef/application/client.rb @@ -38,172 +38,171 @@ class Chef::Application::Client < Chef::Application SELF_PIPE = [] option :config_file, - :short => "-c CONFIG", - :long => "--config CONFIG", - :description => "The configuration file to use" + short: "-c CONFIG", + long: "--config CONFIG", + description: "The configuration file to use" option :config_option, - :long => "--config-option OPTION=VALUE", - :description => "Override a single configuration option", - :proc => lambda { |option, existing| + long: "--config-option OPTION=VALUE", + description: "Override a single configuration option", + proc: lambda { |option, existing| (existing ||= []) << option existing } option :formatter, - :short => "-F FORMATTER", - :long => "--format FORMATTER", - :description => "output format to use", - :proc => lambda { |format| Chef::Config.add_formatter(format) } + short: "-F FORMATTER", + long: "--format FORMATTER", + description: "output format to use", + proc: lambda { |format| Chef::Config.add_formatter(format) } option :force_logger, - :long => "--force-logger", - :description => "Use logger output instead of formatter output", - :boolean => true, - :default => false + long: "--force-logger", + description: "Use logger output instead of formatter output", + boolean: true, + default: false option :force_formatter, - :long => "--force-formatter", - :description => "Use formatter output instead of logger output", - :boolean => true, - :default => false + long: "--force-formatter", + description: "Use formatter output instead of logger output", + boolean: true, + default: false option :profile_ruby, - :long => "--[no-]profile-ruby", - :description => "Dump complete Ruby call graph stack of entire Chef run (expert only)", - :boolean => true, - :default => false + long: "--[no-]profile-ruby", + description: "Dump complete Ruby call graph stack of entire Chef run (expert only)", + boolean: true, + default: false option :color, - :long => "--[no-]color", - :boolean => true, - :default => true, - :description => "Use colored output, defaults to enabled" + long: "--[no-]color", + boolean: true, + default: true, + description: "Use colored output, defaults to enabled" option :log_level, - :short => "-l LEVEL", - :long => "--log_level LEVEL", - :description => "Set the log level (auto, trace, debug, info, warn, error, fatal)", - :proc => lambda { |l| l.to_sym } + short: "-l LEVEL", + long: "--log_level LEVEL", + description: "Set the log level (auto, trace, debug, info, warn, error, fatal)", + proc: lambda { |l| l.to_sym } option :log_location, - :short => "-L LOGLOCATION", - :long => "--logfile LOGLOCATION", - :description => "Set the log file location, defaults to STDOUT - recommended for daemonizing", - :proc => nil + short: "-L LOGLOCATION", + long: "--logfile LOGLOCATION", + description: "Set the log file location, defaults to STDOUT - recommended for daemonizing", + proc: nil option :help, - :short => "-h", - :long => "--help", - :description => "Show this message", - :on => :tail, - :boolean => true, - :show_options => true, - :exit => 0 + short: "-h", + long: "--help", + description: "Show this message", + on: :tail, + boolean: true, + show_options: true, + exit: 0 option :user, - :short => "-u USER", - :long => "--user USER", - :description => "User to set privilege to", - :proc => nil + short: "-u USER", + long: "--user USER", + description: "User to set privilege to", + proc: nil option :group, - :short => "-g GROUP", - :long => "--group GROUP", - :description => "Group to set privilege to", - :proc => nil + short: "-g GROUP", + long: "--group GROUP", + description: "Group to set privilege to", + proc: nil unless Chef::Platform.windows? option :daemonize, - :short => "-d [WAIT]", - :long => "--daemonize [WAIT]", - :description => - "Daemonize the process. Accepts an optional integer which is the " \ + short: "-d [WAIT]", + long: "--daemonize [WAIT]", + description: "Daemonize the process. Accepts an optional integer which is the " \ "number of seconds to wait before the first daemonized run.", - :proc => lambda { |wait| wait =~ /^\d+$/ ? wait.to_i : true } + proc: lambda { |wait| wait =~ /^\d+$/ ? wait.to_i : true } end option :pid_file, - :short => "-P PID_FILE", - :long => "--pid PIDFILE", - :description => "Set the PID file location, for the chef-client daemon process. Defaults to /tmp/chef-client.pid", - :proc => nil + short: "-P PID_FILE", + long: "--pid PIDFILE", + description: "Set the PID file location, for the chef-client daemon process. Defaults to /tmp/chef-client.pid", + proc: nil option :lockfile, - :long => "--lockfile LOCKFILE", - :description => "Set the lockfile location. Prevents multiple client processes from converging at the same time", - :proc => nil + long: "--lockfile LOCKFILE", + description: "Set the lockfile location. Prevents multiple client processes from converging at the same time", + proc: nil option :interval, - :short => "-i SECONDS", - :long => "--interval SECONDS", - :description => "Run chef-client periodically, in seconds", - :proc => lambda { |s| s.to_i } + short: "-i SECONDS", + long: "--interval SECONDS", + description: "Run chef-client periodically, in seconds", + proc: lambda { |s| s.to_i } option :once, - :long => "--once", - :description => "Cancel any interval or splay options, run chef once and exit", - :boolean => true + long: "--once", + description: "Cancel any interval or splay options, run chef once and exit", + boolean: true option :json_attribs, - :short => "-j JSON_ATTRIBS", - :long => "--json-attributes JSON_ATTRIBS", - :description => "Load attributes from a JSON file or URL", - :proc => nil + short: "-j JSON_ATTRIBS", + long: "--json-attributes JSON_ATTRIBS", + description: "Load attributes from a JSON file or URL", + proc: nil option :node_name, - :short => "-N NODE_NAME", - :long => "--node-name NODE_NAME", - :description => "The node name for this client", - :proc => nil + short: "-N NODE_NAME", + long: "--node-name NODE_NAME", + description: "The node name for this client", + proc: nil option :splay, - :short => "-s SECONDS", - :long => "--splay SECONDS", - :description => "The splay time for running at intervals, in seconds", - :proc => lambda { |s| s.to_i } + short: "-s SECONDS", + long: "--splay SECONDS", + description: "The splay time for running at intervals, in seconds", + proc: lambda { |s| s.to_i } option :chef_server_url, - :short => "-S CHEFSERVERURL", - :long => "--server CHEFSERVERURL", - :description => "The chef server URL", - :proc => nil + short: "-S CHEFSERVERURL", + long: "--server CHEFSERVERURL", + description: "The chef server URL", + proc: nil option :validation_key, - :short => "-K KEY_FILE", - :long => "--validation_key KEY_FILE", - :description => "Set the validation key file location, used for registering new clients", - :proc => nil + short: "-K KEY_FILE", + long: "--validation_key KEY_FILE", + description: "Set the validation key file location, used for registering new clients", + proc: nil option :client_key, - :short => "-k KEY_FILE", - :long => "--client_key KEY_FILE", - :description => "Set the client key file location", - :proc => nil + short: "-k KEY_FILE", + long: "--client_key KEY_FILE", + description: "Set the client key file location", + proc: nil option :named_run_list, - :short => "-n NAMED_RUN_LIST", - :long => "--named-run-list NAMED_RUN_LIST", - :description => "Use a policyfile's named run list instead of the default run list" + short: "-n NAMED_RUN_LIST", + long: "--named-run-list NAMED_RUN_LIST", + description: "Use a policyfile's named run list instead of the default run list" option :environment, - :short => "-E ENVIRONMENT", - :long => "--environment ENVIRONMENT", - :description => "Set the Chef Environment on the node" + short: "-E ENVIRONMENT", + long: "--environment ENVIRONMENT", + description: "Set the Chef Environment on the node" option :version, - :short => "-v", - :long => "--version", - :description => "Show chef version", - :boolean => true, - :proc => lambda { |v| puts "Chef: #{::Chef::VERSION}" }, - :exit => 0 + short: "-v", + long: "--version", + description: "Show chef version", + boolean: true, + proc: lambda { |v| puts "Chef: #{::Chef::VERSION}" }, + exit: 0 option :override_runlist, - :short => "-o RunlistItem,RunlistItem...", - :long => "--override-runlist RunlistItem,RunlistItem...", - :description => "Replace current run list with specified items for a single run", - :proc => lambda { |items| + short: "-o RunlistItem,RunlistItem...", + long: "--override-runlist RunlistItem,RunlistItem...", + description: "Replace current run list with specified items for a single run", + proc: lambda { |items| items = items.split(",") items.compact.map do |item| Chef::RunList::RunListItem.new(item) @@ -211,97 +210,97 @@ class Chef::Application::Client < Chef::Application } option :runlist, - :short => "-r RunlistItem,RunlistItem...", - :long => "--runlist RunlistItem,RunlistItem...", - :description => "Permanently replace current run list with specified items", - :proc => lambda { |items| + short: "-r RunlistItem,RunlistItem...", + long: "--runlist RunlistItem,RunlistItem...", + description: "Permanently replace current run list with specified items", + proc: lambda { |items| items = items.split(",") items.compact.map do |item| Chef::RunList::RunListItem.new(item) end } option :why_run, - :short => "-W", - :long => "--why-run", - :description => "Enable whyrun mode", - :boolean => true + short: "-W", + long: "--why-run", + description: "Enable whyrun mode", + boolean: true option :client_fork, - :short => "-f", - :long => "--[no-]fork", - :description => "Fork client" + short: "-f", + long: "--[no-]fork", + description: "Fork client" option :recipe_url, - :long => "--recipe-url=RECIPE_URL", - :description => "Pull down a remote archive of recipes and unpack it to the cookbook cache. Only used in local mode." + long: "--recipe-url=RECIPE_URL", + description: "Pull down a remote archive of recipes and unpack it to the cookbook cache. Only used in local mode." option :enable_reporting, - :short => "-R", - :long => "--enable-reporting", - :description => "Enable reporting data collection for chef runs", - :boolean => true + short: "-R", + long: "--enable-reporting", + description: "Enable reporting data collection for chef runs", + boolean: true option :local_mode, - :short => "-z", - :long => "--local-mode", - :description => "Point chef-client at local repository", - :boolean => true + short: "-z", + long: "--local-mode", + description: "Point chef-client at local repository", + boolean: true option :chef_zero_host, - :long => "--chef-zero-host HOST", - :description => "Host to start chef-zero on" + long: "--chef-zero-host HOST", + description: "Host to start chef-zero on" option :chef_zero_port, - :long => "--chef-zero-port PORT", - :description => "Port (or port range) to start chef-zero on. Port ranges like 1000,1010 or 8889-9999 will try all given ports until one works." + long: "--chef-zero-port PORT", + description: "Port (or port range) to start chef-zero on. Port ranges like 1000,1010 or 8889-9999 will try all given ports until one works." option :disable_config, - :long => "--disable-config", - :description => "Refuse to load a config file and use defaults. This is for development and not a stable API", - :boolean => true + long: "--disable-config", + description: "Refuse to load a config file and use defaults. This is for development and not a stable API", + boolean: true option :run_lock_timeout, - :long => "--run-lock-timeout SECONDS", - :description => "Set maximum duration to wait for another client run to finish, default is indefinitely.", - :proc => lambda { |s| s.to_i } + long: "--run-lock-timeout SECONDS", + description: "Set maximum duration to wait for another client run to finish, default is indefinitely.", + proc: lambda { |s| s.to_i } if Chef::Platform.windows? option :fatal_windows_admin_check, - :short => "-A", - :long => "--fatal-windows-admin-check", - :description => "Fail the run when chef-client doesn't have administrator privileges on Windows", - :boolean => true + short: "-A", + long: "--fatal-windows-admin-check", + description: "Fail the run when chef-client doesn't have administrator privileges on Windows", + boolean: true end option :audit_mode, - :long => "--audit-mode MODE", - :description => "Enable audit-mode with `enabled`. Disable audit-mode with `disabled`. Skip converge and only perform audits with `audit-only`", - :proc => lambda { |mo| mo.tr("-", "_").to_sym } + long: "--audit-mode MODE", + description: "Enable audit-mode with `enabled`. Disable audit-mode with `disabled`. Skip converge and only perform audits with `audit-only`", + proc: lambda { |mo| mo.tr("-", "_").to_sym } option :minimal_ohai, - :long => "--minimal-ohai", - :description => "Only run the bare minimum ohai plugins chef needs to function", - :boolean => true + long: "--minimal-ohai", + description: "Only run the bare minimum ohai plugins chef needs to function", + boolean: true option :listen, - :long => "--[no-]listen", - :description => "Whether a local mode (-z) server binds to a port", - :boolean => false + long: "--[no-]listen", + description: "Whether a local mode (-z) server binds to a port", + boolean: false option :fips, - :long => "--[no-]fips", - :description => "Enable fips mode", - :boolean => true + long: "--[no-]fips", + description: "Enable fips mode", + boolean: true option :delete_entire_chef_repo, - :long => "--delete-entire-chef-repo", - :description => "DANGEROUS: does what it says, only useful with --recipe-url", - :boolean => true + long: "--delete-entire-chef-repo", + description: "DANGEROUS: does what it says, only useful with --recipe-url", + boolean: true option :skip_cookbook_sync, - :long => "--[no-]skip-cookbook-sync", - :description => "Use cached cookbooks without overwriting local differences from the server", - :boolean => false + long: "--[no-]skip-cookbook-sync", + description: "Use cached cookbooks without overwriting local differences from the server", + boolean: false IMMEDIATE_RUN_SIGNAL = "1".freeze RECONFIGURE_SIGNAL = "H".freeze @@ -338,7 +337,7 @@ class Chef::Application::Client < Chef::Application else if Chef::Config[:delete_entire_chef_repo] Chef::Log.trace "Cleanup path #{Chef::Config.chef_repo_path} before extract recipes into it" - FileUtils.rm_rf(recipes_path, :secure => true) + FileUtils.rm_rf(recipes_path, secure: true) end Chef::Log.trace "Creating path #{Chef::Config.chef_repo_path} to extract recipes into" FileUtils.mkdir_p(Chef::Config.chef_repo_path) diff --git a/lib/chef/application/knife.rb b/lib/chef/application/knife.rb index c972e9313e..2c8d886b27 100644 --- a/lib/chef/application/knife.rb +++ b/lib/chef/application/knife.rb @@ -28,129 +28,129 @@ class Chef::Application::Knife < Chef::Application banner "Usage: knife sub-command (options)" option :config_file, - :short => "-c CONFIG", - :long => "--config CONFIG", - :description => "The configuration file to use", - :proc => lambda { |path| File.expand_path(path, Dir.pwd) } + short: "-c CONFIG", + long: "--config CONFIG", + description: "The configuration file to use", + proc: lambda { |path| File.expand_path(path, Dir.pwd) } option :config_option, - :long => "--config-option OPTION=VALUE", - :description => "Override a single configuration option", - :proc => lambda { |option, existing| + long: "--config-option OPTION=VALUE", + description: "Override a single configuration option", + proc: lambda { |option, existing| (existing ||= []) << option existing } verbosity_level = 0 option :verbosity, - :short => "-V", - :long => "--verbose", - :description => "More verbose output. Use twice for max verbosity", - :proc => Proc.new { verbosity_level += 1 }, - :default => 0 + short: "-V", + long: "--verbose", + description: "More verbose output. Use twice for max verbosity", + proc: Proc.new { verbosity_level += 1 }, + default: 0 option :color, - :long => "--[no-]color", - :boolean => true, - :default => true, - :description => "Use colored output, defaults to enabled" + long: "--[no-]color", + boolean: true, + default: true, + description: "Use colored output, defaults to enabled" option :environment, - :short => "-E ENVIRONMENT", - :long => "--environment ENVIRONMENT", - :description => "Set the Chef environment (except for in searches, where this will be flagrantly ignored)" + short: "-E ENVIRONMENT", + long: "--environment ENVIRONMENT", + description: "Set the Chef environment (except for in searches, where this will be flagrantly ignored)" option :editor, - :short => "-e EDITOR", - :long => "--editor EDITOR", - :description => "Set the editor to use for interactive commands", - :default => ENV["EDITOR"] + short: "-e EDITOR", + long: "--editor EDITOR", + description: "Set the editor to use for interactive commands", + default: ENV["EDITOR"] option :disable_editing, - :short => "-d", - :long => "--disable-editing", - :description => "Do not open EDITOR, just accept the data as is", - :boolean => true, - :default => false + short: "-d", + long: "--disable-editing", + description: "Do not open EDITOR, just accept the data as is", + boolean: true, + default: false option :help, - :short => "-h", - :long => "--help", - :description => "Show this message", - :on => :tail, - :boolean => true + short: "-h", + long: "--help", + description: "Show this message", + on: :tail, + boolean: true option :node_name, - :short => "-u USER", - :long => "--user USER", - :description => "API Client Username" + short: "-u USER", + long: "--user USER", + description: "API Client Username" option :client_key, - :short => "-k KEY", - :long => "--key KEY", - :description => "API Client Key", - :proc => lambda { |path| File.expand_path(path, Dir.pwd) } + short: "-k KEY", + long: "--key KEY", + description: "API Client Key", + proc: lambda { |path| File.expand_path(path, Dir.pwd) } option :chef_server_url, - :short => "-s URL", - :long => "--server-url URL", - :description => "Chef Server URL" + short: "-s URL", + long: "--server-url URL", + description: "Chef Server URL" option :yes, - :short => "-y", - :long => "--yes", - :description => "Say yes to all prompts for confirmation" + short: "-y", + long: "--yes", + description: "Say yes to all prompts for confirmation" option :defaults, - :long => "--defaults", - :description => "Accept default values for all questions" + long: "--defaults", + description: "Accept default values for all questions" option :print_after, - :long => "--print-after", - :description => "Show the data after a destructive operation" + long: "--print-after", + description: "Show the data after a destructive operation" option :format, - :short => "-F FORMAT", - :long => "--format FORMAT", - :description => "Which format to use for output", - :default => "summary" + short: "-F FORMAT", + long: "--format FORMAT", + description: "Which format to use for output", + default: "summary" option :local_mode, - :short => "-z", - :long => "--local-mode", - :description => "Point knife commands at local repository instead of server", - :boolean => true + short: "-z", + long: "--local-mode", + description: "Point knife commands at local repository instead of server", + boolean: true option :chef_zero_host, - :long => "--chef-zero-host HOST", - :description => "Host to start chef-zero on" + long: "--chef-zero-host HOST", + description: "Host to start chef-zero on" option :chef_zero_port, - :long => "--chef-zero-port PORT", - :description => "Port (or port range) to start chef-zero on. Port ranges like 1000,1010 or 8889-9999 will try all given ports until one works." + long: "--chef-zero-port PORT", + description: "Port (or port range) to start chef-zero on. Port ranges like 1000,1010 or 8889-9999 will try all given ports until one works." option :listen, - :long => "--[no-]listen", - :description => "Whether a local mode (-z) server binds to a port", - :boolean => false + long: "--[no-]listen", + description: "Whether a local mode (-z) server binds to a port", + boolean: false option :version, - :short => "-v", - :long => "--version", - :description => "Show chef version", - :boolean => true, - :proc => lambda { |v| puts "Chef: #{::Chef::VERSION}" }, - :exit => 0 + short: "-v", + long: "--version", + description: "Show chef version", + boolean: true, + proc: lambda { |v| puts "Chef: #{::Chef::VERSION}" }, + exit: 0 option :fips, - :long => "--[no-]fips", - :description => "Enable fips mode", - :boolean => true, - :default => nil + long: "--[no-]fips", + description: "Enable fips mode", + boolean: true, + default: nil option :profile, - :long => "--profile PROFILE", - :description => "The credentials profile to select" + long: "--profile PROFILE", + description: "The credentials profile to select" # Run knife def run diff --git a/lib/chef/application/solo.rb b/lib/chef/application/solo.rb index 646d68182c..345cf40e65 100644 --- a/lib/chef/application/solo.rb +++ b/lib/chef/application/solo.rb @@ -35,137 +35,137 @@ class Chef::Application::Solo < Chef::Application include ChefConfig::Mixin::DotD option :config_file, - :short => "-c CONFIG", - :long => "--config CONFIG", - :default => Chef::Config.platform_specific_path("/etc/chef/solo.rb"), - :description => "The configuration file to use" + short: "-c CONFIG", + long: "--config CONFIG", + default: Chef::Config.platform_specific_path("/etc/chef/solo.rb"), + description: "The configuration file to use" option :config_option, - :long => "--config-option OPTION=VALUE", - :description => "Override a single configuration option", - :proc => lambda { |option, existing| + long: "--config-option OPTION=VALUE", + description: "Override a single configuration option", + proc: lambda { |option, existing| (existing ||= []) << option existing } option :formatter, - :short => "-F FORMATTER", - :long => "--format FORMATTER", - :description => "output format to use", - :proc => lambda { |format| Chef::Config.add_formatter(format) } + short: "-F FORMATTER", + long: "--format FORMATTER", + description: "output format to use", + proc: lambda { |format| Chef::Config.add_formatter(format) } option :force_logger, - :long => "--force-logger", - :description => "Use logger output instead of formatter output", - :boolean => true, - :default => false + long: "--force-logger", + description: "Use logger output instead of formatter output", + boolean: true, + default: false option :force_formatter, - :long => "--force-formatter", - :description => "Use formatter output instead of logger output", - :boolean => true, - :default => false + long: "--force-formatter", + description: "Use formatter output instead of logger output", + boolean: true, + default: false option :profile_ruby, - :long => "--[no-]profile-ruby", - :description => "Dump complete Ruby call graph stack of entire Chef run (expert only)", - :boolean => true, - :default => false + long: "--[no-]profile-ruby", + description: "Dump complete Ruby call graph stack of entire Chef run (expert only)", + boolean: true, + default: false option :color, - :long => "--[no-]color", - :boolean => true, - :default => !Chef::Platform.windows?, - :description => "Use colored output, defaults to enabled" + long: "--[no-]color", + boolean: true, + default: !Chef::Platform.windows?, + description: "Use colored output, defaults to enabled" option :log_level, - :short => "-l LEVEL", - :long => "--log_level LEVEL", - :description => "Set the log level (trace, debug, info, warn, error, fatal)", - :proc => lambda { |l| l.to_sym } + short: "-l LEVEL", + long: "--log_level LEVEL", + description: "Set the log level (trace, debug, info, warn, error, fatal)", + proc: lambda { |l| l.to_sym } option :log_location, - :short => "-L LOGLOCATION", - :long => "--logfile LOGLOCATION", - :description => "Set the log file location, defaults to STDOUT", - :proc => nil + short: "-L LOGLOCATION", + long: "--logfile LOGLOCATION", + description: "Set the log file location, defaults to STDOUT", + proc: nil option :help, - :short => "-h", - :long => "--help", - :description => "Show this message", - :on => :tail, - :boolean => true, - :show_options => true, - :exit => 0 + short: "-h", + long: "--help", + description: "Show this message", + on: :tail, + boolean: true, + show_options: true, + exit: 0 option :user, - :short => "-u USER", - :long => "--user USER", - :description => "User to set privilege to", - :proc => nil + short: "-u USER", + long: "--user USER", + description: "User to set privilege to", + proc: nil option :group, - :short => "-g GROUP", - :long => "--group GROUP", - :description => "Group to set privilege to", - :proc => nil + short: "-g GROUP", + long: "--group GROUP", + description: "Group to set privilege to", + proc: nil unless Chef::Platform.windows? option :daemonize, - :short => "-d", - :long => "--daemonize", - :description => "Daemonize the process", - :proc => lambda { |p| true } + short: "-d", + long: "--daemonize", + description: "Daemonize the process", + proc: lambda { |p| true } end option :lockfile, - :long => "--lockfile LOCKFILE", - :description => "Set the lockfile location. Prevents multiple processes from converging at the same time", - :proc => nil + long: "--lockfile LOCKFILE", + description: "Set the lockfile location. Prevents multiple processes from converging at the same time", + proc: nil option :interval, - :short => "-i SECONDS", - :long => "--interval SECONDS", - :description => "Run chef-client periodically, in seconds", - :proc => lambda { |s| s.to_i } + short: "-i SECONDS", + long: "--interval SECONDS", + description: "Run chef-client periodically, in seconds", + proc: lambda { |s| s.to_i } option :json_attribs, - :short => "-j JSON_ATTRIBS", - :long => "--json-attributes JSON_ATTRIBS", - :description => "Load attributes from a JSON file or URL", - :proc => nil + short: "-j JSON_ATTRIBS", + long: "--json-attributes JSON_ATTRIBS", + description: "Load attributes from a JSON file or URL", + proc: nil option :node_name, - :short => "-N NODE_NAME", - :long => "--node-name NODE_NAME", - :description => "The node name for this client", - :proc => nil + short: "-N NODE_NAME", + long: "--node-name NODE_NAME", + description: "The node name for this client", + proc: nil option :splay, - :short => "-s SECONDS", - :long => "--splay SECONDS", - :description => "The splay time for running at intervals, in seconds", - :proc => lambda { |s| s.to_i } + short: "-s SECONDS", + long: "--splay SECONDS", + description: "The splay time for running at intervals, in seconds", + proc: lambda { |s| s.to_i } option :recipe_url, - :short => "-r RECIPE_URL", - :long => "--recipe-url RECIPE_URL", - :description => "Pull down a remote gzipped tarball of recipes and untar it to the cookbook cache." + short: "-r RECIPE_URL", + long: "--recipe-url RECIPE_URL", + description: "Pull down a remote gzipped tarball of recipes and untar it to the cookbook cache." option :version, - :short => "-v", - :long => "--version", - :description => "Show chef version", - :boolean => true, - :proc => lambda { |v| puts "Chef: #{::Chef::VERSION}" }, - :exit => 0 + short: "-v", + long: "--version", + description: "Show chef version", + boolean: true, + proc: lambda { |v| puts "Chef: #{::Chef::VERSION}" }, + exit: 0 option :override_runlist, - :short => "-o RunlistItem,RunlistItem...", - :long => "--override-runlist RunlistItem,RunlistItem...", - :description => "Replace current run list with specified items", - :proc => lambda { |items| + short: "-o RunlistItem,RunlistItem...", + long: "--override-runlist RunlistItem,RunlistItem...", + description: "Replace current run list with specified items", + proc: lambda { |items| items = items.split(",") items.compact.map do |item| Chef::RunList::RunListItem.new(item) @@ -173,45 +173,45 @@ class Chef::Application::Solo < Chef::Application } option :client_fork, - :short => "-f", - :long => "--[no-]fork", - :description => "Fork client" + short: "-f", + long: "--[no-]fork", + description: "Fork client" option :why_run, - :short => "-W", - :long => "--why-run", - :description => "Enable whyrun mode", - :boolean => true + short: "-W", + long: "--why-run", + description: "Enable whyrun mode", + boolean: true option :ez, - :long => "--ez", - :description => "A memorial for Ezra Zygmuntowicz", - :boolean => true + long: "--ez", + description: "A memorial for Ezra Zygmuntowicz", + boolean: true option :environment, - :short => "-E ENVIRONMENT", - :long => "--environment ENVIRONMENT", - :description => "Set the Chef Environment on the node" + short: "-E ENVIRONMENT", + long: "--environment ENVIRONMENT", + description: "Set the Chef Environment on the node" option :run_lock_timeout, - :long => "--run-lock-timeout SECONDS", - :description => "Set maximum duration to wait for another client run to finish, default is indefinitely.", - :proc => lambda { |s| s.to_i } + long: "--run-lock-timeout SECONDS", + description: "Set maximum duration to wait for another client run to finish, default is indefinitely.", + proc: lambda { |s| s.to_i } option :minimal_ohai, - :long => "--minimal-ohai", - :description => "Only run the bare minimum ohai plugins chef needs to function", - :boolean => true + long: "--minimal-ohai", + description: "Only run the bare minimum ohai plugins chef needs to function", + boolean: true option :delete_entire_chef_repo, - :long => "--delete-entire-chef-repo", - :description => "DANGEROUS: does what it says, only useful with --recipe-url", - :boolean => true + long: "--delete-entire-chef-repo", + description: "DANGEROUS: does what it says, only useful with --recipe-url", + boolean: true option :solo_legacy_mode, - :long => "--legacy-mode", - :description => "Run chef-solo in legacy mode", - :boolean => true + long: "--legacy-mode", + description: "Run chef-solo in legacy mode", + boolean: true attr_reader :chef_client_json @@ -273,7 +273,7 @@ class Chef::Application::Solo < Chef::Application if Chef::Config[:delete_entire_chef_repo] Chef::Log.trace "Cleanup path #{recipes_path} before extract recipes into it" - FileUtils.rm_rf(recipes_path, :secure => true) + FileUtils.rm_rf(recipes_path, secure: true) end Chef::Log.trace "Creating path #{recipes_path} to extract recipes into" FileUtils.mkdir_p(recipes_path) diff --git a/lib/chef/application/windows_service.rb b/lib/chef/application/windows_service.rb index 41dcc55d70..7ebfa762df 100644 --- a/lib/chef/application/windows_service.rb +++ b/lib/chef/application/windows_service.rb @@ -37,27 +37,27 @@ class Chef include Chef::Mixin::ShellOut option :config_file, - :short => "-c CONFIG", - :long => "--config CONFIG", - :default => "#{ENV['SYSTEMDRIVE']}/chef/client.rb", - :description => "" + short: "-c CONFIG", + long: "--config CONFIG", + default: "#{ENV['SYSTEMDRIVE']}/chef/client.rb", + description: "" option :log_location, - :short => "-L LOGLOCATION", - :long => "--logfile LOGLOCATION", - :description => "Set the log file location" + short: "-L LOGLOCATION", + long: "--logfile LOGLOCATION", + description: "Set the log file location" option :splay, - :short => "-s SECONDS", - :long => "--splay SECONDS", - :description => "The splay time for running at intervals, in seconds", - :proc => lambda { |s| s.to_i } + short: "-s SECONDS", + long: "--splay SECONDS", + description: "The splay time for running at intervals, in seconds", + proc: lambda { |s| s.to_i } option :interval, - :short => "-i SECONDS", - :long => "--interval SECONDS", - :description => "Set the number of seconds to wait between chef-client runs", - :proc => lambda { |s| s.to_i } + short: "-i SECONDS", + long: "--interval SECONDS", + description: "Set the number of seconds to wait between chef-client runs", + proc: lambda { |s| s.to_i } DEFAULT_LOG_LOCATION ||= "#{ENV['SYSTEMDRIVE']}/chef/client.log" @@ -197,8 +197,8 @@ class Chef result = shell_out( "chef-client.bat #{config_params}", - :timeout => Chef::Config[:windows_service][:watchdog_timeout], - :logger => Chef::Log + timeout: Chef::Config[:windows_service][:watchdog_timeout], + logger: Chef::Log ) Chef::Log.trace "#{result.stdout}" Chef::Log.trace "#{result.stderr}" diff --git a/lib/chef/application/windows_service_manager.rb b/lib/chef/application/windows_service_manager.rb index 5c572bc260..bff4a7511a 100644 --- a/lib/chef/application/windows_service_manager.rb +++ b/lib/chef/application/windows_service_manager.rb @@ -37,38 +37,38 @@ class Chef include Mixlib::CLI option :action, - :short => "-a ACTION", - :long => "--action ACTION", - :default => "status", - :description => "Action to carry out on chef-service (install, uninstall, status, start, stop, pause, or resume)" + short: "-a ACTION", + long: "--action ACTION", + default: "status", + description: "Action to carry out on chef-service (install, uninstall, status, start, stop, pause, or resume)" option :config_file, - :short => "-c CONFIG", - :long => "--config CONFIG", - :default => "#{ENV['SYSTEMDRIVE']}/chef/client.rb", - :description => "The configuration file to use for chef runs" + short: "-c CONFIG", + long: "--config CONFIG", + default: "#{ENV['SYSTEMDRIVE']}/chef/client.rb", + description: "The configuration file to use for chef runs" option :log_location, - :short => "-L LOGLOCATION", - :long => "--logfile LOGLOCATION", - :description => "Set the log file location for chef-service" + short: "-L LOGLOCATION", + long: "--logfile LOGLOCATION", + description: "Set the log file location for chef-service" option :help, - :short => "-h", - :long => "--help", - :description => "Show this message", - :on => :tail, - :boolean => true, - :show_options => true, - :exit => 0 + short: "-h", + long: "--help", + description: "Show this message", + on: :tail, + boolean: true, + show_options: true, + exit: 0 option :version, - :short => "-v", - :long => "--version", - :description => "Show chef version", - :boolean => true, - :proc => lambda { |v| puts "Chef: #{::Chef::VERSION}" }, - :exit => 0 + short: "-v", + long: "--version", + description: "Show chef version", + boolean: true, + proc: lambda { |v| puts "Chef: #{::Chef::VERSION}" }, + exit: 0 def initialize(service_options) # having to call super in initialize is the most annoying @@ -114,22 +114,22 @@ class Chef cmd = "\"#{ruby}\" \"#{@service_file_path}\" #{opts}".gsub(File::SEPARATOR, File::ALT_SEPARATOR) ::Win32::Service.new( - :service_name => @service_name, - :display_name => @service_display_name, - :description => @service_description, + service_name: @service_name, + display_name: @service_display_name, + description: @service_description, # Prior to 0.8.5, win32-service creates interactive services by default, # and we don't want that, so we need to override the service type. - :service_type => ::Win32::Service::SERVICE_WIN32_OWN_PROCESS, - :start_type => ::Win32::Service::SERVICE_AUTO_START, - :binary_path_name => cmd, - :service_start_name => @service_start_name, - :password => @password, - :dependencies => @dependencies + service_type: ::Win32::Service::SERVICE_WIN32_OWN_PROCESS, + start_type: ::Win32::Service::SERVICE_AUTO_START, + binary_path_name: cmd, + service_start_name: @service_start_name, + password: @password, + dependencies: @dependencies ) unless @delayed_start.nil? ::Win32::Service.configure( - :service_name => @service_name, - :delayed_start => @delayed_start + service_name: @service_name, + delayed_start: @delayed_start ) end puts "Service '#{@service_name}' has successfully been installed." diff --git a/lib/chef/audit/audit_event_proxy.rb b/lib/chef/audit/audit_event_proxy.rb index e2e6ab1ede..1cb8545d28 100644 --- a/lib/chef/audit/audit_event_proxy.rb +++ b/lib/chef/audit/audit_event_proxy.rb @@ -79,12 +79,12 @@ class Chef outermost_group_desc = describe_groups.shift [outermost_group_desc, { - :name => example.description, - :desc => example.full_description, - :resource_type => resource_type, - :resource_name => resource_name, - :context => describe_groups, - :line_number => example.metadata[:line_number], + name: example.description, + desc: example.full_description, + resource_type: resource_type, + resource_name: resource_name, + context: describe_groups, + line_number: example.metadata[:line_number], }] end diff --git a/lib/chef/audit/control_group_data.rb b/lib/chef/audit/control_group_data.rb index 476ebe95e9..8825860023 100644 --- a/lib/chef/audit/control_group_data.rb +++ b/lib/chef/audit/control_group_data.rb @@ -37,11 +37,11 @@ class Chef def to_hash { - :node_name => node_name, - :run_id => run_id, - :start_time => start_time, - :end_time => end_time, - :control_groups => control_groups.collect { |c| c.to_hash }, + node_name: node_name, + run_id: run_id, + start_time: start_time, + end_time: end_time, + control_groups: control_groups.collect { |c| c.to_hash }, } end end @@ -81,11 +81,11 @@ class Chef # they appeared in the recipe controls.sort! { |x, y| x.line_number <=> y.line_number } h = { - :name => name, - :status => status, - :number_succeeded => number_succeeded, - :number_failed => number_failed, - :controls => controls.collect { |c| c.to_hash }, + name: name, + status: status, + number_succeeded: number_succeeded, + number_failed: number_failed, + controls: controls.collect { |c| c.to_hash }, } # If there is a duplicate key, metadata will overwrite it add_display_only_data(h).merge(metadata) @@ -124,11 +124,11 @@ class Chef def to_hash h = { - :name => name, - :status => status, - :details => details, - :resource_type => resource_type, - :resource_name => resource_name, + name: name, + status: status, + details: details, + resource_type: resource_type, + resource_name: resource_name, } h[:context] = context || [] h diff --git a/lib/chef/audit/runner.rb b/lib/chef/audit/runner.rb index f6fed3fc64..847d5efbd5 100644 --- a/lib/chef/audit/runner.rb +++ b/lib/chef/audit/runner.rb @@ -148,7 +148,7 @@ class Chef def configure_specinfra if Chef::Platform.windows? Specinfra.configuration.backend = :cmd - Specinfra.configuration.os = { :family => "windows" } + Specinfra.configuration.os = { family: "windows" } else Specinfra.configuration.backend = :exec end diff --git a/lib/chef/chef_fs/config.rb b/lib/chef/chef_fs/config.rb index 0725426275..2a41fb5870 100644 --- a/lib/chef/chef_fs/config.rb +++ b/lib/chef/chef_fs/config.rb @@ -173,7 +173,7 @@ class Chef def create_chef_fs require "chef/chef_fs/file_system/chef_server/chef_server_root_dir" - Chef::ChefFS::FileSystem::ChefServer::ChefServerRootDir.new("remote", @chef_config, :cookbook_version => @cookbook_version) + Chef::ChefFS::FileSystem::ChefServer::ChefServerRootDir.new("remote", @chef_config, cookbook_version: @cookbook_version) end def local_fs diff --git a/lib/chef/chef_fs/file_system/chef_server/chef_server_root_dir.rb b/lib/chef/chef_fs/file_system/chef_server/chef_server_root_dir.rb index 63ce71ef40..3447e3500a 100644 --- a/lib/chef/chef_fs/file_system/chef_server/chef_server_root_dir.rb +++ b/lib/chef/chef_fs/file_system/chef_server/chef_server_root_dir.rb @@ -99,7 +99,7 @@ class Chef end def rest - Chef::ServerAPI.new(chef_server_url, :client_name => chef_username, :signing_key_filename => chef_private_key, :raw_output => true, :api_version => "0") + Chef::ServerAPI.new(chef_server_url, client_name: chef_username, signing_key_filename: chef_private_key, raw_output: true, api_version: "0") end def get_json(path) @@ -107,7 +107,7 @@ class Chef end def chef_rest - Chef::ServerAPI.new(chef_server_url, :client_name => chef_username, :signing_key_filename => chef_private_key, :api_version => "0") + Chef::ServerAPI.new(chef_server_url, client_name: chef_username, signing_key_filename: chef_private_key, api_version: "0") end def api_path diff --git a/lib/chef/chef_fs/file_system/chef_server/cookbooks_dir.rb b/lib/chef/chef_fs/file_system/chef_server/cookbooks_dir.rb index 4e8e68e364..e0eca5f6de 100644 --- a/lib/chef/chef_fs/file_system/chef_server/cookbooks_dir.rb +++ b/lib/chef/chef_fs/file_system/chef_server/cookbooks_dir.rb @@ -74,7 +74,7 @@ class Chef def upload_cookbook(other, options) cookbook_to_upload = other.chef_object cookbook_to_upload.freeze_version if options[:freeze] - uploader = Chef::CookbookUploader.new(cookbook_to_upload, :force => options[:force], :rest => chef_rest) + uploader = Chef::CookbookUploader.new(cookbook_to_upload, force: options[:force], rest: chef_rest) with_actual_cookbooks_dir(other.parent.file_path) do uploader.upload_cookbooks diff --git a/lib/chef/chef_fs/file_system/chef_server/organization_invites_entry.rb b/lib/chef/chef_fs/file_system/chef_server/organization_invites_entry.rb index adaffb99a7..344a3deecc 100644 --- a/lib/chef/chef_fs/file_system/chef_server/organization_invites_entry.rb +++ b/lib/chef/chef_fs/file_system/chef_server/organization_invites_entry.rb @@ -40,7 +40,7 @@ class Chef end def write(contents) - desired_invites = minimize_value(Chef::JSONCompat.parse(contents, :create_additions => false)) + desired_invites = minimize_value(Chef::JSONCompat.parse(contents, create_additions: false)) actual_invites = _read_json.inject({}) { |h, val| h[val["username"]] = val["id"]; h } invites = actual_invites.keys (desired_invites - invites).each do |invite| diff --git a/lib/chef/chef_fs/file_system/chef_server/organization_members_entry.rb b/lib/chef/chef_fs/file_system/chef_server/organization_members_entry.rb index 7e9c7141c4..a780ddd97b 100644 --- a/lib/chef/chef_fs/file_system/chef_server/organization_members_entry.rb +++ b/lib/chef/chef_fs/file_system/chef_server/organization_members_entry.rb @@ -40,7 +40,7 @@ class Chef end def write(contents) - desired_members = minimize_value(Chef::JSONCompat.parse(contents, :create_additions => false)) + desired_members = minimize_value(Chef::JSONCompat.parse(contents, create_additions: false)) members = minimize_value(_read_json) (desired_members - members).each do |member| begin diff --git a/lib/chef/chef_fs/file_system/chef_server/versioned_cookbooks_dir.rb b/lib/chef/chef_fs/file_system/chef_server/versioned_cookbooks_dir.rb index 8da3718136..94c1a5b695 100644 --- a/lib/chef/chef_fs/file_system/chef_server/versioned_cookbooks_dir.rb +++ b/lib/chef/chef_fs/file_system/chef_server/versioned_cookbooks_dir.rb @@ -78,7 +78,7 @@ class Chef cookbook_to_upload.freeze_version if options[:freeze] # Instantiate a new uploader based on the proxy loader - uploader = Chef::CookbookUploader.new(cookbook_to_upload, :force => options[:force], :rest => chef_rest) + uploader = Chef::CookbookUploader.new(cookbook_to_upload, force: options[:force], rest: chef_rest) with_actual_cookbooks_dir(temp_cookbooks_path) do uploader.upload_cookbooks diff --git a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb index b296901dd1..8e64e3ca06 100644 --- a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb +++ b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb @@ -64,7 +64,7 @@ class Chef def write(cookbook_path, cookbook_version_json, from_fs) # Use the copy/diff algorithm to copy it down so we don't destroy # chefignored data. This is terribly un-thread-safe. - Chef::ChefFS::FileSystem.copy_to(Chef::ChefFS::FilePattern.new("/#{cookbook_path}"), from_fs, self, nil, { :purge => true }) + Chef::ChefFS::FileSystem.copy_to(Chef::ChefFS::FilePattern.new("/#{cookbook_path}"), from_fs, self, nil, { purge: true }) # Write out .uploaded-cookbook-version.json # cookbook_file_path = File.join(file_path, cookbook_name) <- this should be the same as self.file_path diff --git a/lib/chef/chef_fs/knife.rb b/lib/chef/chef_fs/knife.rb index 1731e19ce1..36445e5680 100644 --- a/lib/chef/chef_fs/knife.rb +++ b/lib/chef/chef_fs/knife.rb @@ -45,16 +45,16 @@ class Chef end option :repo_mode, - :long => "--repo-mode MODE", - :description => "Specifies the local repository layout. Values: static, everything, hosted_everything. Default: everything/hosted_everything" + long: "--repo-mode MODE", + description: "Specifies the local repository layout. Values: static, everything, hosted_everything. 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 :concurrency, - :long => "--concurrency THREADS", - :description => "Maximum number of simultaneous requests to send (default: 10)" + long: "--concurrency THREADS", + description: "Maximum number of simultaneous requests to send (default: 10)" def configure_chef super diff --git a/lib/chef/chef_fs/parallelizer.rb b/lib/chef/chef_fs/parallelizer.rb index 32de61e048..eee555fc93 100644 --- a/lib/chef/chef_fs/parallelizer.rb +++ b/lib/chef/chef_fs/parallelizer.rb @@ -45,7 +45,7 @@ class Chef end def parallel_do(enumerable, options = {}, &block) - ParallelEnumerable.new(@tasks, enumerable, options.merge(:ordered => false), &block).wait + ParallelEnumerable.new(@tasks, enumerable, options.merge(ordered: false), &block).wait end def stop(wait = true, timeout = nil) diff --git a/lib/chef/cookbook/cookbook_version_loader.rb b/lib/chef/cookbook/cookbook_version_loader.rb index b139a8d489..c864c30505 100644 --- a/lib/chef/cookbook/cookbook_version_loader.rb +++ b/lib/chef/cookbook/cookbook_version_loader.rb @@ -34,7 +34,7 @@ class Chef @relative_path = /#{Regexp.escape(@cookbook_path)}\/(.+)$/ @metadata_loaded = false @cookbook_settings = { - :all_files => {}, + all_files: {}, } @metadata_filenames = [] diff --git a/lib/chef/cookbook/metadata.rb b/lib/chef/cookbook/metadata.rb index c378cb75b6..94604ea0d9 100644 --- a/lib/chef/cookbook/metadata.rb +++ b/lib/chef/cookbook/metadata.rb @@ -61,10 +61,10 @@ class Chef :source_url, :issues_url, :privacy, :chef_versions, :ohai_versions, :gems ] - VERSION_CONSTRAINTS = { :depends => DEPENDENCIES, - :provides => PROVIDING, - :chef_version => CHEF_VERSIONS, - :ohai_version => OHAI_VERSIONS } + VERSION_CONSTRAINTS = { depends: DEPENDENCIES, + provides: PROVIDING, + chef_version: CHEF_VERSIONS, + ohai_version: OHAI_VERSIONS } include Chef::Mixin::ParamsValidate include Chef::Mixin::FromFile @@ -161,7 +161,7 @@ class Chef set_or_return( :maintainer, arg, - :kind_of => [ String ] + kind_of: [ String ] ) end @@ -176,7 +176,7 @@ class Chef set_or_return( :maintainer_email, arg, - :kind_of => [ String ] + kind_of: [ String ] ) end @@ -191,7 +191,7 @@ class Chef set_or_return( :license, arg, - :kind_of => [ String ] + kind_of: [ String ] ) end @@ -206,7 +206,7 @@ class Chef set_or_return( :description, arg, - :kind_of => [ String ] + kind_of: [ String ] ) end @@ -221,7 +221,7 @@ class Chef set_or_return( :long_description, arg, - :kind_of => [ String ] + kind_of: [ String ] ) end @@ -252,7 +252,7 @@ class Chef set_or_return( :name, arg, - :kind_of => [ String ] + kind_of: [ String ] ) end @@ -409,17 +409,17 @@ class Chef validate( options, { - :display_name => { :kind_of => String }, - :description => { :kind_of => String }, - :choice => { :kind_of => [ Array ], :default => [] }, - :calculated => { :equal_to => [ true, false ], :default => false }, - :type => { :equal_to => %w{string array hash symbol boolean numeric}, :default => "string" }, - :required => { :equal_to => [ "required", "recommended", "optional", true, false ], :default => "optional" }, - :recipes => { :kind_of => [ Array ], :default => [] }, - :default => { :kind_of => [ String, Array, Hash, Symbol, Numeric, TrueClass, FalseClass ] }, - :source_url => { :kind_of => String }, - :issues_url => { :kind_of => String }, - :privacy => { :kind_of => [ TrueClass, FalseClass ] }, + display_name: { kind_of: String }, + description: { kind_of: String }, + choice: { kind_of: [ Array ], default: [] }, + calculated: { equal_to: [ true, false ], default: false }, + type: { equal_to: %w{string array hash symbol boolean numeric}, default: "string" }, + required: { equal_to: [ "required", "recommended", "optional", true, false ], default: "optional" }, + recipes: { kind_of: [ Array ], default: [] }, + default: { kind_of: [ String, Array, Hash, Symbol, Numeric, TrueClass, FalseClass ] }, + source_url: { kind_of: String }, + issues_url: { kind_of: String }, + privacy: { kind_of: [ TrueClass, FalseClass ] }, } ) options[:required] = remap_required_attribute(options[:required]) unless options[:required].nil? @@ -556,7 +556,7 @@ class Chef set_or_return( :source_url, arg, - :kind_of => [ String ] + kind_of: [ String ] ) end @@ -571,7 +571,7 @@ class Chef set_or_return( :issues_url, arg, - :kind_of => [ String ] + kind_of: [ String ] ) end @@ -588,7 +588,7 @@ class Chef set_or_return( :privacy, arg, - :kind_of => [ TrueClass, FalseClass ] + kind_of: [ TrueClass, FalseClass ] ) end @@ -689,7 +689,7 @@ INVALID def validate_string_array(arry) if arry.kind_of?(Array) arry.each do |choice| - validate( { :choice => choice }, { :choice => { :kind_of => String } } ) + validate( { choice: choice }, { choice: { kind_of: String } } ) end end end @@ -717,7 +717,7 @@ INVALID end opts[:choice].each do |choice| - validate( { :choice => choice }, { :choice => { :kind_of => validator } } ) + validate( { choice: choice }, { choice: { kind_of: validator } } ) end end end diff --git a/lib/chef/cookbook_manifest.rb b/lib/chef/cookbook_manifest.rb index 9adcee6b78..c0c5b57a60 100644 --- a/lib/chef/cookbook_manifest.rb +++ b/lib/chef/cookbook_manifest.rb @@ -236,13 +236,13 @@ class Chef csum = checksum_cookbook_file(file) @checksums[csum] = file rs = Mash.new({ - :name => name, - :path => path, - :checksum => csum, - :specificity => specificity, + name: name, + path: path, + checksum: csum, + specificity: specificity, # full_path is not a part of the normal manifest, but is very useful to keep around. # uploaders should strip this out. - :full_path => file, + full_path: file, }) manifest[:all_files] << rs diff --git a/lib/chef/cookbook_site_streaming_uploader.rb b/lib/chef/cookbook_site_streaming_uploader.rb index e4b45532f0..8611357e1a 100644 --- a/lib/chef/cookbook_site_streaming_uploader.rb +++ b/lib/chef/cookbook_site_streaming_uploader.rb @@ -115,10 +115,10 @@ class Chef content_file.rewind if content_file # we consumed the file for the above operation, so rewind it. signing_options = { - :http_method => http_verb, - :path => url.path, - :user_id => user_id, - :timestamp => timestamp } + http_method: http_verb, + path: url.path, + user_id: user_id, + timestamp: timestamp } (content_file && signing_options[:file] = content_file) || (signing_options[:body] = (content_body || "")) headers.merge!(Mixlib::Authentication::SignedHeaderAuth.signing_object(signing_options).sign(secret_key)) diff --git a/lib/chef/cookbook_uploader.rb b/lib/chef/cookbook_uploader.rb index e79a7774eb..5780c61cc9 100644 --- a/lib/chef/cookbook_uploader.rb +++ b/lib/chef/cookbook_uploader.rb @@ -56,7 +56,7 @@ class Chef end checksums = checksum_files.inject({}) { |memo, elt| memo[elt.first] = nil; memo } - new_sandbox = rest.post("sandboxes", { :checksums => checksums }) + new_sandbox = rest.post("sandboxes", { checksums: checksums }) Chef::Log.info("Uploading files") @@ -83,7 +83,7 @@ class Chef # in eventual consistency) retries = 0 begin - rest.put(sandbox_url, { :is_completed => true }) + rest.put(sandbox_url, { is_completed: true }) rescue Net::HTTPServerException => e if e.message =~ /^400/ && (retries += 1) <= 5 sleep 2 diff --git a/lib/chef/data_bag.rb b/lib/chef/data_bag.rb index c5e2b38c94..1e23cdfb1c 100644 --- a/lib/chef/data_bag.rb +++ b/lib/chef/data_bag.rb @@ -54,7 +54,7 @@ class Chef set_or_return( :name, arg, - :regex => VALID_NAME + regex: VALID_NAME ) end diff --git a/lib/chef/data_bag_item.rb b/lib/chef/data_bag_item.rb index 388da78dad..01ec4cf77e 100644 --- a/lib/chef/data_bag_item.rb +++ b/lib/chef/data_bag_item.rb @@ -81,7 +81,7 @@ class Chef set_or_return( :data_bag, arg, - :regex => /^[\-[:alnum:]_]+$/ + regex: /^[\-[:alnum:]_]+$/ ) end diff --git a/lib/chef/dsl/reboot_pending.rb b/lib/chef/dsl/reboot_pending.rb index 2ebad7e039..1dc0a8d41b 100644 --- a/lib/chef/dsl/reboot_pending.rb +++ b/lib/chef/dsl/reboot_pending.rb @@ -37,7 +37,7 @@ class Chef # due to a file being in use (usually a temporary file and a system file) # \??\c:\temp\test.sys!\??\c:\winnt\system32\test.sys # http://technet.microsoft.com/en-us/library/cc960241.aspx - registry_value_exists?('HKLM\SYSTEM\CurrentControlSet\Control\Session Manager', { :name => "PendingFileRenameOperations" }) || + registry_value_exists?('HKLM\SYSTEM\CurrentControlSet\Control\Session Manager', { name: "PendingFileRenameOperations" }) || # RebootRequired key contains Update IDs with a value of 1 if they require a reboot. # The existence of RebootRequired alone is sufficient on my Windows 8.1 workstation in Windows Update diff --git a/lib/chef/encrypted_data_bag_item/encryptor.rb b/lib/chef/encrypted_data_bag_item/encryptor.rb index 8d34033db6..21783503f4 100644 --- a/lib/chef/encrypted_data_bag_item/encryptor.rb +++ b/lib/chef/encrypted_data_bag_item/encryptor.rb @@ -123,7 +123,7 @@ class Chef::EncryptedDataBagItem # Strings) that do not produce valid JSON when serialized without the # wrapper. def serialized_data - FFI_Yajl::Encoder.encode(:json_wrapper => plaintext_data) + FFI_Yajl::Encoder.encode(json_wrapper: plaintext_data) end def self.encryptor_keys diff --git a/lib/chef/environment.rb b/lib/chef/environment.rb index be05b58989..61777fb7b4 100644 --- a/lib/chef/environment.rb +++ b/lib/chef/environment.rb @@ -57,7 +57,7 @@ class Chef set_or_return( :name, arg, - { :regex => /^[\-[:alnum:]_]+$/, :kind_of => String } + { regex: /^[\-[:alnum:]_]+$/, kind_of: String } ) end @@ -65,7 +65,7 @@ class Chef set_or_return( :description, arg, - :kind_of => String + kind_of: String ) end @@ -73,7 +73,7 @@ class Chef set_or_return( :default_attributes, arg, - :kind_of => Hash + kind_of: Hash ) end @@ -85,7 +85,7 @@ class Chef set_or_return( :override_attributes, arg, - :kind_of => Hash + kind_of: Hash ) end @@ -98,8 +98,8 @@ class Chef :cookbook_versions, arg, { - :kind_of => Hash, - :callbacks => { + kind_of: Hash, + callbacks: { "should be a valid set of cookbook version requirements" => lambda { |cv| Chef::Environment.validate_cookbook_versions(cv) }, }, } @@ -108,10 +108,10 @@ class Chef def cookbook(cookbook, version) validate({ - :version => version, + version: version, }, { - :version => { - :callbacks => { "should be a valid version requirement" => lambda { |v| Chef::Environment.validate_cookbook_version(v) } }, + version: { + callbacks: { "should be a valid version requirement" => lambda { |v| Chef::Environment.validate_cookbook_version(v) } }, }, }) @cookbook_versions[cookbook] = version diff --git a/lib/chef/event_loggers/windows_eventlog.rb b/lib/chef/event_loggers/windows_eventlog.rb index 1ff87945e7..a9473ed1f6 100644 --- a/lib/chef/event_loggers/windows_eventlog.rb +++ b/lib/chef/event_loggers/windows_eventlog.rb @@ -47,29 +47,29 @@ class Chef def run_start(version) @eventlog.report_event( - :event_type => ::Win32::EventLog::INFO_TYPE, - :source => SOURCE, - :event_id => RUN_START_EVENT_ID, - :data => [version] + event_type: ::Win32::EventLog::INFO_TYPE, + source: SOURCE, + event_id: RUN_START_EVENT_ID, + data: [version] ) end def run_started(run_status) @run_status = run_status @eventlog.report_event( - :event_type => ::Win32::EventLog::INFO_TYPE, - :source => SOURCE, - :event_id => RUN_STARTED_EVENT_ID, - :data => [run_status.run_id] + event_type: ::Win32::EventLog::INFO_TYPE, + source: SOURCE, + event_id: RUN_STARTED_EVENT_ID, + data: [run_status.run_id] ) end def run_completed(node) @eventlog.report_event( - :event_type => ::Win32::EventLog::INFO_TYPE, - :source => SOURCE, - :event_id => RUN_COMPLETED_EVENT_ID, - :data => [@run_status.run_id, @run_status.elapsed_time.to_s] + event_type: ::Win32::EventLog::INFO_TYPE, + source: SOURCE, + event_id: RUN_COMPLETED_EVENT_ID, + data: [@run_status.run_id, @run_status.elapsed_time.to_s] ) end @@ -87,10 +87,10 @@ class Chef end @eventlog.report_event( - :event_type => ::Win32::EventLog::ERROR_TYPE, - :source => SOURCE, - :event_id => RUN_FAILED_EVENT_ID, - :data => data + [e.class.name, + event_type: ::Win32::EventLog::ERROR_TYPE, + source: SOURCE, + event_id: RUN_FAILED_EVENT_ID, + data: data + [e.class.name, e.message, e.backtrace.join("\n")] ) diff --git a/lib/chef/file_cache.rb b/lib/chef/file_cache.rb index 8e9bb1e3e4..f1c261ecd0 100644 --- a/lib/chef/file_cache.rb +++ b/lib/chef/file_cache.rb @@ -42,12 +42,12 @@ class Chef def store(path, contents, perm = 0640) validate( { - :path => path, - :contents => contents, + path: path, + contents: contents, }, { - :path => { :kind_of => String }, - :contents => { :kind_of => String }, + path: { kind_of: String }, + contents: { kind_of: String }, } ) @@ -68,12 +68,12 @@ class Chef def move_to(file, path) validate( { - :file => file, - :path => path, + file: file, + path: path, }, { - :file => { :kind_of => String }, - :path => { :kind_of => String }, + file: { kind_of: String }, + path: { kind_of: String }, } ) @@ -105,10 +105,10 @@ class Chef def load(path, read = true) validate( { - :path => path, + path: path, }, { - :path => { :kind_of => String }, + path: { kind_of: String }, } ) cache_path = create_cache_path(path, false) @@ -131,10 +131,10 @@ class Chef def delete(path) validate( { - :path => path, + path: path, }, { - :path => { :kind_of => String }, + path: { kind_of: String }, } ) cache_path = create_cache_path(path, false) @@ -178,10 +178,10 @@ class Chef def has_key?(path) validate( { - :path => path, + path: path, }, { - :path => { :kind_of => String }, + path: { kind_of: String }, } ) full_path = create_cache_path(path, false) diff --git a/lib/chef/formatters/doc.rb b/lib/chef/formatters/doc.rb index d47ab73a30..d498ef7c72 100644 --- a/lib/chef/formatters/doc.rb +++ b/lib/chef/formatters/doc.rb @@ -285,7 +285,7 @@ class Chef indent end # TODO: info about notifies - start_line "* #{resource} action #{action}", :stream => resource + start_line "* #{resource} action #{action}", stream: resource indent end @@ -318,7 +318,7 @@ class Chef def resource_skipped(resource, action, conditional) @skipped_resources += 1 # TODO: more info about conditional - puts " (skipped due to #{conditional.short_description})", :stream => resource + puts " (skipped due to #{conditional.short_description})", stream: resource unindent end @@ -329,12 +329,12 @@ class Chef # Called when a resource has no converge actions, e.g., it was already correct. def resource_up_to_date(resource, action) @up_to_date_resources += 1 - puts " (up to date)", :stream => resource + puts " (up to date)", stream: resource unindent end def resource_bypassed(resource, action, provider) - puts " (Skipped: whyrun not supported by provider #{provider.class.name})", :stream => resource + puts " (Skipped: whyrun not supported by provider #{provider.class.name})", stream: resource unindent end @@ -375,7 +375,7 @@ class Chef end def stream_output(stream, output, options = {}) - print(output, { :stream => stream }.merge(options)) + print(output, { stream: stream }.merge(options)) end # Called before handlers run diff --git a/lib/chef/formatters/indentable_output_stream.rb b/lib/chef/formatters/indentable_output_stream.rb index e5e84e0f65..7882527327 100644 --- a/lib/chef/formatters/indentable_output_stream.rb +++ b/lib/chef/formatters/indentable_output_stream.rb @@ -35,19 +35,19 @@ class Chef # cause indentation but will not move to the next line yet (future 'print' # and 'puts' statements will stay on this line). def start_line(string, *args) - print(string, from_args(args, :start_line => true)) + print(string, from_args(args, start_line: true)) end # Print a line. This will continue from the last start_line or print, # or start a new line and indent if necessary. def puts(string, *args) - print(string, from_args(args, :end_line => true)) + print(string, from_args(args, end_line: true)) end # Print an entire line from start to end. This will terminate any existing # lines and cause indentation. def puts_line(string, *args) - print(string, from_args(args, :start_line => true, :end_line => true)) + print(string, from_args(args, start_line: true, end_line: true)) end # Print a raw chunk @@ -103,7 +103,7 @@ class Chef if colors.size == 1 && colors[0].kind_of?(Hash) merge_options.merge(colors[0]) else - merge_options.merge({ :colors => colors }) + merge_options.merge({ colors: colors }) end end diff --git a/lib/chef/guard_interpreter/resource_guard_interpreter.rb b/lib/chef/guard_interpreter/resource_guard_interpreter.rb index e245eab2c7..b1d497181b 100644 --- a/lib/chef/guard_interpreter/resource_guard_interpreter.rb +++ b/lib/chef/guard_interpreter/resource_guard_interpreter.rb @@ -42,9 +42,9 @@ class Chef # We need to make sure we check for Script first because any resource # that can get to here is an Execute resource. if @resource.is_a? Chef::Resource::Script - block_attributes = @command_opts.merge({ :code => @command }) + block_attributes = @command_opts.merge({ code: @command }) else - block_attributes = @command_opts.merge({ :command => @command }) + block_attributes = @command_opts.merge({ command: @command }) end # Handles cases like powershell_script where default diff --git a/lib/chef/http/auth_credentials.rb b/lib/chef/http/auth_credentials.rb index eeb9136607..e84f6a0c5b 100644 --- a/lib/chef/http/auth_credentials.rb +++ b/lib/chef/http/auth_credentials.rb @@ -50,7 +50,7 @@ class Chef host = request_params.delete(:host) || "localhost" sign_obj = Mixlib::Authentication::SignedHeaderAuth.signing_object(request_params) - signed = sign_obj.sign(key, use_ssh_agent: @use_ssh_agent).merge({ :host => host }) + signed = sign_obj.sign(key, use_ssh_agent: @use_ssh_agent).merge({ host: host }) signed.inject({}) { |memo, kv| memo["#{kv[0].to_s.upcase}"] = kv[1]; memo } end diff --git a/lib/chef/http/authenticator.rb b/lib/chef/http/authenticator.rb index 8e050832f0..bfb85785c8 100644 --- a/lib/chef/http/authenticator.rb +++ b/lib/chef/http/authenticator.rb @@ -104,11 +104,11 @@ class Chef def authentication_headers(method, url, json_body = nil, headers = nil) request_params = { - :http_method => method, - :path => url.path, - :body => json_body, - :host => "#{url.host}:#{url.port}", - :headers => headers, + http_method: method, + path: url.path, + body: json_body, + host: "#{url.host}:#{url.port}", + headers: headers, } request_params[:body] ||= "" auth_credentials.signature_headers(request_params) diff --git a/lib/chef/key.rb b/lib/chef/key.rb index bf8e533d62..ef006f8ace 100644 --- a/lib/chef/key.rb +++ b/lib/chef/key.rb @@ -77,23 +77,23 @@ class Chef def actor(arg = nil) set_or_return(:actor, arg, - :regex => /^[a-z0-9\-_]+$/) + regex: /^[a-z0-9\-_]+$/) end def name(arg = nil) set_or_return(:name, arg, - :kind_of => String) + kind_of: String) end def public_key(arg = nil) raise Chef::Exceptions::InvalidKeyAttribute, "you cannot set the public_key if create_key is true" if !arg.nil? && @create_key set_or_return(:public_key, arg, - :kind_of => String) + kind_of: String) end def private_key(arg = nil) set_or_return(:private_key, arg, - :kind_of => String) + kind_of: String) end def delete_public_key @@ -107,12 +107,12 @@ class Chef def create_key(arg = nil) raise Chef::Exceptions::InvalidKeyAttribute, "you cannot set create_key to true if the public_key field exists" if arg == true && !@public_key.nil? set_or_return(:create_key, arg, - :kind_of => [TrueClass, FalseClass]) + kind_of: [TrueClass, FalseClass]) end def expiration_date(arg = nil) set_or_return(:expiration_date, arg, - :regex => /^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z|infinity)$/) + regex: /^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z|infinity)$/) end def to_hash diff --git a/lib/chef/knife/bootstrap.rb b/lib/chef/knife/bootstrap.rb index 15d0f1be18..797080abe3 100644 --- a/lib/chef/knife/bootstrap.rb +++ b/lib/chef/knife/bootstrap.rb @@ -45,180 +45,180 @@ class Chef banner "knife bootstrap [SSH_USER@]FQDN (options)" option :ssh_user, - :short => "-x USERNAME", - :long => "--ssh-user USERNAME", - :description => "The ssh username", - :default => "root" + short: "-x USERNAME", + long: "--ssh-user USERNAME", + description: "The ssh username", + default: "root" option :ssh_password, - :short => "-P PASSWORD", - :long => "--ssh-password PASSWORD", - :description => "The ssh password" + short: "-P PASSWORD", + long: "--ssh-password PASSWORD", + description: "The ssh password" option :ssh_port, - :short => "-p PORT", - :long => "--ssh-port PORT", - :description => "The ssh port", - :proc => Proc.new { |key| Chef::Config[:knife][:ssh_port] = key } + short: "-p PORT", + long: "--ssh-port PORT", + description: "The ssh port", + proc: Proc.new { |key| Chef::Config[:knife][:ssh_port] = key } option :ssh_gateway, - :short => "-G GATEWAY", - :long => "--ssh-gateway GATEWAY", - :description => "The ssh gateway", - :proc => Proc.new { |key| Chef::Config[:knife][:ssh_gateway] = key } + short: "-G GATEWAY", + long: "--ssh-gateway GATEWAY", + description: "The ssh gateway", + proc: Proc.new { |key| Chef::Config[:knife][:ssh_gateway] = key } option :ssh_gateway_identity, - :long => "--ssh-gateway-identity SSH_GATEWAY_IDENTITY", - :description => "The SSH identity file used for gateway authentication", - :proc => Proc.new { |key| Chef::Config[:knife][:ssh_gateway_identity] = key } + long: "--ssh-gateway-identity SSH_GATEWAY_IDENTITY", + description: "The SSH identity file used for gateway authentication", + proc: Proc.new { |key| Chef::Config[:knife][:ssh_gateway_identity] = key } option :forward_agent, - :short => "-A", - :long => "--forward-agent", - :description => "Enable SSH agent forwarding", - :boolean => true + short: "-A", + long: "--forward-agent", + description: "Enable SSH agent forwarding", + boolean: true option :identity_file, - :long => "--identity-file IDENTITY_FILE", - :description => "The SSH identity file used for authentication. [DEPRECATED] Use --ssh-identity-file instead." + long: "--identity-file IDENTITY_FILE", + description: "The SSH identity file used for authentication. [DEPRECATED] Use --ssh-identity-file instead." option :ssh_identity_file, - :short => "-i IDENTITY_FILE", - :long => "--ssh-identity-file IDENTITY_FILE", - :description => "The SSH identity file used for authentication" + short: "-i IDENTITY_FILE", + long: "--ssh-identity-file IDENTITY_FILE", + description: "The SSH identity file used for authentication" option :chef_node_name, - :short => "-N NAME", - :long => "--node-name NAME", - :description => "The Chef node name for your new node" + short: "-N NAME", + long: "--node-name NAME", + description: "The Chef node name for your new node" option :prerelease, - :long => "--prerelease", - :description => "Install the pre-release chef gems" + long: "--prerelease", + description: "Install the pre-release chef gems" option :bootstrap_version, - :long => "--bootstrap-version VERSION", - :description => "The version of Chef to install", - :proc => lambda { |v| Chef::Config[:knife][:bootstrap_version] = v } + long: "--bootstrap-version VERSION", + description: "The version of Chef to install", + proc: lambda { |v| Chef::Config[:knife][:bootstrap_version] = v } option :bootstrap_proxy, - :long => "--bootstrap-proxy PROXY_URL", - :description => "The proxy server for the node being bootstrapped", - :proc => Proc.new { |p| Chef::Config[:knife][:bootstrap_proxy] = p } + long: "--bootstrap-proxy PROXY_URL", + description: "The proxy server for the node being bootstrapped", + proc: Proc.new { |p| Chef::Config[:knife][:bootstrap_proxy] = p } option :bootstrap_proxy_user, - :long => "--bootstrap-proxy-user PROXY_USER", - :description => "The proxy authentication username for the node being bootstrapped" + long: "--bootstrap-proxy-user PROXY_USER", + description: "The proxy authentication username for the node being bootstrapped" option :bootstrap_proxy_pass, - :long => "--bootstrap-proxy-pass PROXY_PASS", - :description => "The proxy authentication password for the node being bootstrapped" + long: "--bootstrap-proxy-pass PROXY_PASS", + description: "The proxy authentication password for the node being bootstrapped" option :bootstrap_no_proxy, - :long => "--bootstrap-no-proxy [NO_PROXY_URL|NO_PROXY_IP]", - :description => "Do not proxy locations for the node being bootstrapped; this option is used internally by Opscode", - :proc => Proc.new { |np| Chef::Config[:knife][:bootstrap_no_proxy] = np } + long: "--bootstrap-no-proxy [NO_PROXY_URL|NO_PROXY_IP]", + description: "Do not proxy locations for the node being bootstrapped; this option is used internally by Opscode", + proc: Proc.new { |np| Chef::Config[:knife][:bootstrap_no_proxy] = np } option :bootstrap_template, - :short => "-t TEMPLATE", - :long => "--bootstrap-template TEMPLATE", - :description => "Bootstrap Chef using a built-in or custom template. Set to the full path of an erb template or use one of the built-in templates." + short: "-t TEMPLATE", + long: "--bootstrap-template TEMPLATE", + description: "Bootstrap Chef using a built-in or custom template. Set to the full path of an erb template or use one of the built-in templates." option :use_sudo, - :long => "--sudo", - :description => "Execute the bootstrap via sudo", - :boolean => true + long: "--sudo", + description: "Execute the bootstrap via sudo", + boolean: true option :preserve_home, - :long => "--sudo-preserve-home", - :description => "Preserve non-root user HOME environment variable with sudo", - :boolean => true + long: "--sudo-preserve-home", + description: "Preserve non-root user HOME environment variable with sudo", + boolean: true option :use_sudo_password, - :long => "--use-sudo-password", - :description => "Execute the bootstrap via sudo with password", - :boolean => false + long: "--use-sudo-password", + description: "Execute the bootstrap via sudo with password", + boolean: false option :run_list, - :short => "-r RUN_LIST", - :long => "--run-list RUN_LIST", - :description => "Comma separated list of roles/recipes to apply", - :proc => lambda { |o| o.split(/[\s,]+/) }, - :default => [] + short: "-r RUN_LIST", + long: "--run-list RUN_LIST", + description: "Comma separated list of roles/recipes to apply", + proc: lambda { |o| o.split(/[\s,]+/) }, + default: [] option :policy_name, - :long => "--policy-name POLICY_NAME", - :description => "Policyfile name to use (--policy-group must also be given)", - :default => nil + long: "--policy-name POLICY_NAME", + description: "Policyfile name to use (--policy-group must also be given)", + default: nil option :policy_group, - :long => "--policy-group POLICY_GROUP", - :description => "Policy group name to use (--policy-name must also be given)", - :default => nil + long: "--policy-group POLICY_GROUP", + description: "Policy group name to use (--policy-name must also be given)", + default: nil option :tags, - :long => "--tags TAGS", - :description => "Comma separated list of tags to apply to the node", - :proc => lambda { |o| o.split(/[\s,]+/) }, - :default => [] + long: "--tags TAGS", + description: "Comma separated list of tags to apply to the node", + proc: lambda { |o| o.split(/[\s,]+/) }, + default: [] option :first_boot_attributes, - :short => "-j JSON_ATTRIBS", - :long => "--json-attributes", - :description => "A JSON string to be added to the first run of chef-client", - :proc => lambda { |o| Chef::JSONCompat.parse(o) }, - :default => nil + short: "-j JSON_ATTRIBS", + long: "--json-attributes", + description: "A JSON string to be added to the first run of chef-client", + proc: lambda { |o| Chef::JSONCompat.parse(o) }, + default: nil option :first_boot_attributes_from_file, - :long => "--json-attribute-file FILE", - :description => "A JSON file to be used to the first run of chef-client", - :proc => lambda { |o| Chef::JSONCompat.parse(File.read(o)) }, - :default => nil + long: "--json-attribute-file FILE", + description: "A JSON file to be used to the first run of chef-client", + proc: lambda { |o| Chef::JSONCompat.parse(File.read(o)) }, + default: nil option :host_key_verify, - :long => "--[no-]host-key-verify", - :description => "Verify host key, enabled by default.", - :boolean => true, - :default => true + long: "--[no-]host-key-verify", + description: "Verify host key, enabled by default.", + boolean: true, + default: true option :hint, - :long => "--hint HINT_NAME[=HINT_FILE]", - :description => "Specify Ohai Hint to be set on the bootstrap target. Use multiple --hint options to specify multiple hints.", - :proc => Proc.new { |h| + long: "--hint HINT_NAME[=HINT_FILE]", + description: "Specify Ohai Hint to be set on the bootstrap target. Use multiple --hint options to specify multiple hints.", + proc: Proc.new { |h| Chef::Config[:knife][:hints] ||= Hash.new name, path = h.split("=") Chef::Config[:knife][:hints][name] = path ? Chef::JSONCompat.parse(::File.read(path)) : Hash.new } option :bootstrap_url, - :long => "--bootstrap-url URL", - :description => "URL to a custom installation script", - :proc => Proc.new { |u| Chef::Config[:knife][:bootstrap_url] = u } + long: "--bootstrap-url URL", + description: "URL to a custom installation script", + proc: Proc.new { |u| Chef::Config[:knife][:bootstrap_url] = u } option :bootstrap_install_command, - :long => "--bootstrap-install-command COMMANDS", - :description => "Custom command to install chef-client", - :proc => Proc.new { |ic| Chef::Config[:knife][:bootstrap_install_command] = ic } + long: "--bootstrap-install-command COMMANDS", + description: "Custom command to install chef-client", + proc: Proc.new { |ic| Chef::Config[:knife][:bootstrap_install_command] = ic } option :bootstrap_preinstall_command, - :long => "--bootstrap-preinstall-command COMMANDS", - :description => "Custom commands to run before installing chef-client", - :proc => Proc.new { |preic| Chef::Config[:knife][:bootstrap_preinstall_command] = preic } + long: "--bootstrap-preinstall-command COMMANDS", + description: "Custom commands to run before installing chef-client", + proc: Proc.new { |preic| Chef::Config[:knife][:bootstrap_preinstall_command] = preic } option :bootstrap_wget_options, - :long => "--bootstrap-wget-options OPTIONS", - :description => "Add options to wget when installing chef-client", - :proc => Proc.new { |wo| Chef::Config[:knife][:bootstrap_wget_options] = wo } + long: "--bootstrap-wget-options OPTIONS", + description: "Add options to wget when installing chef-client", + proc: Proc.new { |wo| Chef::Config[:knife][:bootstrap_wget_options] = wo } option :bootstrap_curl_options, - :long => "--bootstrap-curl-options OPTIONS", - :description => "Add options to curl when install chef-client", - :proc => Proc.new { |co| Chef::Config[:knife][:bootstrap_curl_options] = co } + long: "--bootstrap-curl-options OPTIONS", + description: "Add options to curl when install chef-client", + proc: Proc.new { |co| Chef::Config[:knife][:bootstrap_curl_options] = co } option :node_ssl_verify_mode, - :long => "--node-ssl-verify-mode [peer|none]", - :description => "Whether or not to verify the SSL cert for all HTTPS requests.", - :proc => Proc.new { |v| + long: "--node-ssl-verify-mode [peer|none]", + description: "Whether or not to verify the SSL cert for all HTTPS requests.", + proc: Proc.new { |v| valid_values = %w{none peer} unless valid_values.include?(v) raise "Invalid value '#{v}' for --node-ssl-verify-mode. Valid values are: #{valid_values.join(", ")}" @@ -227,22 +227,22 @@ class Chef } option :node_verify_api_cert, - :long => "--[no-]node-verify-api-cert", - :description => "Verify the SSL cert for HTTPS requests to the Chef server API.", - :boolean => true + long: "--[no-]node-verify-api-cert", + description: "Verify the SSL cert for HTTPS requests to the Chef server API.", + 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", - :description => 'A single vault and item to update as "vault:item"', - :proc => Proc.new { |i| + 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(/:/) Chef::Config[:knife][:bootstrap_vault_item] ||= {} Chef::Config[:knife][:bootstrap_vault_item][vault] ||= [] diff --git a/lib/chef/knife/bootstrap/client_builder.rb b/lib/chef/knife/bootstrap/client_builder.rb index cab33cd811..f5c49ab620 100644 --- a/lib/chef/knife/bootstrap/client_builder.rb +++ b/lib/chef/knife/bootstrap/client_builder.rb @@ -194,7 +194,7 @@ class Chef # @return [Chef::ServerAPI] REST client using the client credentials def client_rest - @client_rest ||= Chef::ServerAPI.new(chef_server_url, :client_name => node_name, :signing_key_filename => client_path) + @client_rest ||= Chef::ServerAPI.new(chef_server_url, client_name: node_name, signing_key_filename: client_path) end # @return [Chef::ServerAPI] REST client using the cli user's knife credentials diff --git a/lib/chef/knife/client_bulk_delete.rb b/lib/chef/knife/client_bulk_delete.rb index a7fa7142c8..a5fe94681d 100644 --- a/lib/chef/knife/client_bulk_delete.rb +++ b/lib/chef/knife/client_bulk_delete.rb @@ -28,9 +28,9 @@ class Chef end option :delete_validators, - :short => "-D", - :long => "--delete-validators", - :description => "Force deletion of clients if they're validators" + short: "-D", + long: "--delete-validators", + description: "Force deletion of clients if they're validators" banner "knife client bulk delete REGEX (options)" diff --git a/lib/chef/knife/client_create.rb b/lib/chef/knife/client_create.rb index e28378cd4a..b821a8a56b 100644 --- a/lib/chef/knife/client_create.rb +++ b/lib/chef/knife/client_create.rb @@ -28,31 +28,31 @@ class Chef end option :file, - :short => "-f FILE", - :long => "--file FILE", - :description => "Write the private key to a file if the server generated one." + short: "-f FILE", + long: "--file FILE", + description: "Write the private key to a file if the server generated one." option :admin, - :short => "-a", - :long => "--admin", - :description => "Open Source Chef Server 11 only. Create the client as an admin.", - :boolean => true + short: "-a", + long: "--admin", + description: "Open Source Chef Server 11 only. Create the client as an admin.", + boolean: true option :validator, - :long => "--validator", - :description => "Create the client as a validator.", - :boolean => true + long: "--validator", + description: "Create the client as a validator.", + boolean: true option :public_key, - :short => "-p FILE", - :long => "--public-key", - :description => "Set the initial default key for the client from a file on disk (cannot pass with --prevent-keygen)." + short: "-p FILE", + long: "--public-key", + description: "Set the initial default key for the client from a file on disk (cannot pass with --prevent-keygen)." option :prevent_keygen, - :short => "-k", - :long => "--prevent-keygen", - :description => "API V1 (Chef Server 12.1+) only. Prevent server from generating a default key pair for you. Cannot be passed with --public-key.", - :boolean => true + short: "-k", + long: "--prevent-keygen", + description: "API V1 (Chef Server 12.1+) only. Prevent server from generating a default key pair for you. Cannot be passed with --public-key.", + boolean: true banner "knife client create CLIENTNAME (options)" diff --git a/lib/chef/knife/client_delete.rb b/lib/chef/knife/client_delete.rb index 82b521c7d1..a043b6f731 100644 --- a/lib/chef/knife/client_delete.rb +++ b/lib/chef/knife/client_delete.rb @@ -28,9 +28,9 @@ class Chef end option :delete_validators, - :short => "-D", - :long => "--delete-validators", - :description => "Force deletion of client if it's a validator" + short: "-D", + long: "--delete-validators", + description: "Force deletion of client if it's a validator" banner "knife client delete [CLIENT [CLIENT]] (options)" diff --git a/lib/chef/knife/client_list.rb b/lib/chef/knife/client_list.rb index b17de0f3ad..794d8c9411 100644 --- a/lib/chef/knife/client_list.rb +++ b/lib/chef/knife/client_list.rb @@ -30,9 +30,9 @@ class Chef banner "knife client list (options)" option :with_uri, - :short => "-w", - :long => "--with-uri", - :description => "Show corresponding URIs" + short: "-w", + long: "--with-uri", + description: "Show corresponding URIs" def run output(format_list_for_display(Chef::ApiClientV1.list)) diff --git a/lib/chef/knife/client_reregister.rb b/lib/chef/knife/client_reregister.rb index cc2b218e87..ce34884803 100644 --- a/lib/chef/knife/client_reregister.rb +++ b/lib/chef/knife/client_reregister.rb @@ -30,9 +30,9 @@ class Chef banner "knife client reregister CLIENT (options)" option :file, - :short => "-f FILE", - :long => "--file FILE", - :description => "Write the key to a file" + short: "-f FILE", + long: "--file FILE", + description: "Write the key to a file" def run @client_name = @name_args[0] diff --git a/lib/chef/knife/configure.rb b/lib/chef/knife/configure.rb index df021826ae..fb2954c982 100644 --- a/lib/chef/knife/configure.rb +++ b/lib/chef/knife/configure.rb @@ -34,31 +34,31 @@ class Chef banner "knife configure (options)" option :repository, - :short => "-r REPO", - :long => "--repository REPO", - :description => "The path to the chef-repo" + short: "-r REPO", + long: "--repository REPO", + description: "The path to the chef-repo" option :initial, - :short => "-i", - :long => "--initial", - :boolean => true, - :description => "Use to create a API client, typically an administrator client on a freshly-installed server" + short: "-i", + long: "--initial", + boolean: true, + description: "Use to create a API client, typically an administrator client on a freshly-installed server" option :admin_client_name, - :long => "--admin-client-name NAME", - :description => "The name of the client, typically the name of the admin client" + long: "--admin-client-name NAME", + description: "The name of the client, typically the name of the admin client" option :admin_client_key, - :long => "--admin-client-key PATH", - :description => "The path to the private key used by the client, typically a file named admin.pem" + long: "--admin-client-key PATH", + description: "The path to the private key used by the client, typically a file named admin.pem" option :validation_client_name, - :long => "--validation-client-name NAME", - :description => "The name of the validation client, typically a client named chef-validator" + long: "--validation-client-name NAME", + description: "The name of the validation client, typically a client named chef-validator" option :validation_key, - :long => "--validation-key PATH", - :description => "The path to the validation key used by the client, typically a file named validation.pem" + long: "--validation-key PATH", + description: "The path to the validation key used by the client, typically a file named validation.pem" def configure_chef # We are just faking out the system so that you can do this without a key specified @@ -112,14 +112,14 @@ EOH def ask_user_for_config server_name = guess_servername - @chef_server = config[:chef_server_url] || ask_question("Please enter the chef server URL: ", :default => "https://#{server_name}/organizations/myorg") + @chef_server = config[:chef_server_url] || ask_question("Please enter the chef server URL: ", default: "https://#{server_name}/organizations/myorg") 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") + @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_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) + @new_client_name = config[:node_name] || ask_question("Please enter an existing username or clientname for the API: ", default: Etc.getlogin) end @new_client_key = config[:client_key] || File.join(chef_config_path, "#{@new_client_name}.pem") diff --git a/lib/chef/knife/cookbook_bulk_delete.rb b/lib/chef/knife/cookbook_bulk_delete.rb index cdd1584e36..a68e8f00f4 100644 --- a/lib/chef/knife/cookbook_bulk_delete.rb +++ b/lib/chef/knife/cookbook_bulk_delete.rb @@ -28,7 +28,7 @@ class Chef 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_delete.rb b/lib/chef/knife/cookbook_delete.rb index b1bb88b388..4f2ada53cb 100644 --- a/lib/chef/knife/cookbook_delete.rb +++ b/lib/chef/knife/cookbook_delete.rb @@ -28,9 +28,9 @@ class Chef 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)" diff --git a/lib/chef/knife/cookbook_download.rb b/lib/chef/knife/cookbook_download.rb index 77e7aa0d09..a321d217db 100644 --- a/lib/chef/knife/cookbook_download.rb +++ b/lib/chef/knife/cookbook_download.rb @@ -33,21 +33,21 @@ class Chef banner "knife cookbook download COOKBOOK [VERSION] (options)" option :latest, - :short => "-N", - :long => "--latest", - :description => "The version of the cookbook to download", - :boolean => true + short: "-N", + long: "--latest", + description: "The version of the cookbook to download", + boolean: true option :download_directory, - :short => "-d DOWNLOAD_DIRECTORY", - :long => "--dir DOWNLOAD_DIRECTORY", - :description => "The directory to download the cookbook into", - :default => Dir.pwd + short: "-d DOWNLOAD_DIRECTORY", + long: "--dir DOWNLOAD_DIRECTORY", + description: "The directory to download the cookbook into", + default: Dir.pwd option :force, - :short => "-f", - :long => "--force", - :description => "Force download over the download directory if it exists" + short: "-f", + long: "--force", + description: "Force download over the download directory if it exists" # TODO: tim/cw: 5-23-2010: need to implement knife-side # specificity for downloads - need to implement --platform and diff --git a/lib/chef/knife/cookbook_list.rb b/lib/chef/knife/cookbook_list.rb index ea81f5d286..deb36baef4 100644 --- a/lib/chef/knife/cookbook_list.rb +++ b/lib/chef/knife/cookbook_list.rb @@ -26,14 +26,14 @@ class Chef banner "knife cookbook list (options)" option :with_uri, - :short => "-w", - :long => "--with-uri", - :description => "Show corresponding URIs" + short: "-w", + long: "--with-uri", + description: "Show corresponding URIs" option :all_versions, - :short => "-a", - :long => "--all", - :description => "Show all available versions." + short: "-a", + long: "--all", + description: "Show all available versions." def run env = config[:environment] diff --git a/lib/chef/knife/cookbook_metadata.rb b/lib/chef/knife/cookbook_metadata.rb index babb4ac4d1..8a9c57f1c3 100644 --- a/lib/chef/knife/cookbook_metadata.rb +++ b/lib/chef/knife/cookbook_metadata.rb @@ -30,15 +30,15 @@ class Chef banner "knife cookbook metadata COOKBOOK (options)" option :cookbook_path, - :short => "-o PATH:PATH", - :long => "--cookbook-path PATH:PATH", - :description => "A colon-separated path to look for cookbooks in", - :proc => lambda { |o| o.split(":") } + short: "-o PATH:PATH", + long: "--cookbook-path PATH:PATH", + description: "A colon-separated path to look for cookbooks in", + proc: lambda { |o| o.split(":") } option :all, - :short => "-a", - :long => "--all", - :description => "Generate metadata for all cookbooks, rather than just a single cookbook" + short: "-a", + long: "--all", + description: "Generate metadata for all cookbooks, rather than just a single cookbook" def run config[:cookbook_path] ||= Chef::Config[:cookbook_path] diff --git a/lib/chef/knife/cookbook_show.rb b/lib/chef/knife/cookbook_show.rb index 1d9983632d..78951d00c7 100644 --- a/lib/chef/knife/cookbook_show.rb +++ b/lib/chef/knife/cookbook_show.rb @@ -31,24 +31,24 @@ class Chef banner "knife cookbook show COOKBOOK [VERSION] [PART] [FILENAME] (options)" option :fqdn, - :short => "-f FQDN", - :long => "--fqdn FQDN", - :description => "The FQDN of the host to see the file for" + short: "-f FQDN", + long: "--fqdn FQDN", + description: "The FQDN of the host to see the file for" option :platform, - :short => "-p PLATFORM", - :long => "--platform PLATFORM", - :description => "The platform to see the file for" + short: "-p PLATFORM", + long: "--platform PLATFORM", + description: "The platform to see the file for" option :platform_version, - :short => "-V VERSION", - :long => "--platform-version VERSION", - :description => "The platform version to see the file for" + short: "-V VERSION", + long: "--platform-version VERSION", + description: "The platform version to see the file for" option :with_uri, - :short => "-w", - :long => "--with-uri", - :description => "Show corresponding URIs" + short: "-w", + long: "--with-uri", + description: "Show corresponding URIs" def run cookbook_name, cookbook_version, segment, filename = @name_args diff --git a/lib/chef/knife/cookbook_site_download.rb b/lib/chef/knife/cookbook_site_download.rb index b957b0a362..ad4a2a83a2 100644 --- a/lib/chef/knife/cookbook_site_download.rb +++ b/lib/chef/knife/cookbook_site_download.rb @@ -30,20 +30,20 @@ class Chef category "cookbook site" option :file, - :short => "-f FILE", - :long => "--file FILE", - :description => "The filename to write to" + short: "-f FILE", + long: "--file FILE", + description: "The filename to write to" option :force, - :long => "--force", - :description => "Force download deprecated version" + long: "--force", + description: "Force download deprecated version" option :supermarket_site, - :short => "-m SUPERMARKET_SITE", - :long => "--supermarket-site SUPERMARKET_SITE", - :description => "Supermarket Site", - :default => "https://supermarket.chef.io", - :proc => Proc.new { |supermarket| Chef::Config[:knife][:supermarket_site] = supermarket } + short: "-m SUPERMARKET_SITE", + long: "--supermarket-site SUPERMARKET_SITE", + description: "Supermarket Site", + default: "https://supermarket.chef.io", + proc: Proc.new { |supermarket| Chef::Config[:knife][:supermarket_site] = supermarket } def run if current_cookbook_deprecated? diff --git a/lib/chef/knife/cookbook_site_install.rb b/lib/chef/knife/cookbook_site_install.rb index f4d692e13c..faa8c54c4b 100644 --- a/lib/chef/knife/cookbook_site_install.rb +++ b/lib/chef/knife/cookbook_site_install.rb @@ -35,37 +35,37 @@ class Chef category "cookbook site" option :no_deps, - :short => "-D", - :long => "--skip-dependencies", - :boolean => true, - :default => false, - :description => "Skips automatic dependency installation." + short: "-D", + long: "--skip-dependencies", + boolean: true, + default: false, + description: "Skips automatic dependency installation." option :cookbook_path, - :short => "-o PATH:PATH", - :long => "--cookbook-path PATH:PATH", - :description => "A colon-separated path to look for cookbooks in", - :proc => lambda { |o| o.split(":") } + short: "-o PATH:PATH", + long: "--cookbook-path PATH:PATH", + description: "A colon-separated path to look for cookbooks in", + proc: lambda { |o| o.split(":") } option :default_branch, - :short => "-B BRANCH", - :long => "--branch BRANCH", - :description => "Default branch to work with", - :default => "master" + short: "-B BRANCH", + long: "--branch BRANCH", + description: "Default branch to work with", + default: "master" option :use_current_branch, - :short => "-b", - :long => "--use-current-branch", - :description => "Use the current branch", - :boolean => true, - :default => false + short: "-b", + long: "--use-current-branch", + description: "Use the current branch", + boolean: true, + default: false option :supermarket_site, - :short => "-m SUPERMARKET_SITE", - :long => "--supermarket-site SUPERMARKET_SITE", - :description => "Supermarket Site", - :default => "https://supermarket.chef.io", - :proc => Proc.new { |supermarket| Chef::Config[:knife][:supermarket_site] = supermarket } + short: "-m SUPERMARKET_SITE", + long: "--supermarket-site SUPERMARKET_SITE", + description: "Supermarket Site", + default: "https://supermarket.chef.io", + proc: Proc.new { |supermarket| Chef::Config[:knife][:supermarket_site] = supermarket } attr_reader :cookbook_name attr_reader :vendor_path diff --git a/lib/chef/knife/cookbook_site_list.rb b/lib/chef/knife/cookbook_site_list.rb index 3bdef8abe5..3b0b20a4df 100644 --- a/lib/chef/knife/cookbook_site_list.rb +++ b/lib/chef/knife/cookbook_site_list.rb @@ -26,16 +26,16 @@ class Chef category "cookbook site" option :with_uri, - :short => "-w", - :long => "--with-uri", - :description => "Show corresponding URIs" + short: "-w", + long: "--with-uri", + description: "Show corresponding URIs" option :supermarket_site, - :short => "-m SUPERMARKET_SITE", - :long => "--supermarket-site SUPERMARKET_SITE", - :description => "Supermarket Site", - :default => "https://supermarket.chef.io", - :proc => Proc.new { |supermarket| Chef::Config[:knife][:supermarket_site] = supermarket } + short: "-m SUPERMARKET_SITE", + long: "--supermarket-site SUPERMARKET_SITE", + description: "Supermarket Site", + default: "https://supermarket.chef.io", + proc: Proc.new { |supermarket| Chef::Config[:knife][:supermarket_site] = supermarket } def run if config[:with_uri] diff --git a/lib/chef/knife/cookbook_site_search.rb b/lib/chef/knife/cookbook_site_search.rb index 0fee993f30..6a598bd22b 100644 --- a/lib/chef/knife/cookbook_site_search.rb +++ b/lib/chef/knife/cookbook_site_search.rb @@ -26,11 +26,11 @@ class Chef category "cookbook site" option :supermarket_site, - :short => "-m SUPERMARKET_SITE", - :long => "--supermarket-site SUPERMARKET_SITE", - :description => "Supermarket Site", - :default => "https://supermarket.chef.io", - :proc => Proc.new { |supermarket| Chef::Config[:knife][:supermarket_site] = supermarket } + short: "-m SUPERMARKET_SITE", + long: "--supermarket-site SUPERMARKET_SITE", + description: "Supermarket Site", + default: "https://supermarket.chef.io", + proc: Proc.new { |supermarket| Chef::Config[:knife][:supermarket_site] = supermarket } def run output(search_cookbook(name_args[0])) diff --git a/lib/chef/knife/cookbook_site_share.rb b/lib/chef/knife/cookbook_site_share.rb index 5d5b3ddcc4..144085c2a2 100644 --- a/lib/chef/knife/cookbook_site_share.rb +++ b/lib/chef/knife/cookbook_site_share.rb @@ -39,24 +39,24 @@ class Chef category "cookbook site" option :cookbook_path, - :short => "-o PATH:PATH", - :long => "--cookbook-path PATH:PATH", - :description => "A colon-separated path to look for cookbooks in", - :proc => lambda { |o| Chef::Config.cookbook_path = o.split(":") } + short: "-o PATH:PATH", + long: "--cookbook-path PATH:PATH", + description: "A colon-separated path to look for cookbooks in", + proc: lambda { |o| Chef::Config.cookbook_path = o.split(":") } option :dry_run, - :long => "--dry-run", - :short => "-n", - :boolean => true, - :default => false, - :description => "Don't take action, only print what files will be uploaded to Supermarket." + long: "--dry-run", + short: "-n", + boolean: true, + default: false, + description: "Don't take action, only print what files will be uploaded to Supermarket." option :supermarket_site, - :short => "-m SUPERMARKET_SITE", - :long => "--supermarket-site SUPERMARKET_SITE", - :description => "Supermarket Site", - :default => "https://supermarket.chef.io", - :proc => Proc.new { |supermarket| Chef::Config[:knife][:supermarket_site] = supermarket } + short: "-m SUPERMARKET_SITE", + long: "--supermarket-site SUPERMARKET_SITE", + description: "Supermarket Site", + default: "https://supermarket.chef.io", + proc: Proc.new { |supermarket| Chef::Config[:knife][:supermarket_site] = supermarket } def run config[:cookbook_path] ||= Chef::Config[:cookbook_path] @@ -81,7 +81,7 @@ class Chef begin Chef::Log.trace("Temp cookbook directory is #{tmp_cookbook_dir.inspect}") ui.info("Making tarball #{cookbook_name}.tgz") - shell_out!("#{tar_cmd} -czf #{cookbook_name}.tgz #{cookbook_name}", :cwd => tmp_cookbook_dir) + shell_out!("#{tar_cmd} -czf #{cookbook_name}.tgz #{cookbook_name}", cwd: tmp_cookbook_dir) rescue => e ui.error("Error making tarball #{cookbook_name}.tgz: #{e.message}. Increase log verbosity (-VV) for more information.") Chef::Log.trace("\n#{e.backtrace.join("\n")}") @@ -90,7 +90,7 @@ class Chef if config[:dry_run] ui.info("Not uploading #{cookbook_name}.tgz due to --dry-run flag.") - result = shell_out!("#{tar_cmd} -tzf #{cookbook_name}.tgz", :cwd => tmp_cookbook_dir) + result = shell_out!("#{tar_cmd} -tzf #{cookbook_name}.tgz", cwd: tmp_cookbook_dir) ui.info(result.stdout) FileUtils.rm_rf tmp_cookbook_dir return @@ -129,8 +129,8 @@ class Chef 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), - :cookbook => category_string, + tarball: File.open(cookbook_filename), + cookbook: category_string, }) res = Chef::JSONCompat.from_json(http_resp.body) diff --git a/lib/chef/knife/cookbook_site_show.rb b/lib/chef/knife/cookbook_site_show.rb index 397d0067ad..1ae242d051 100644 --- a/lib/chef/knife/cookbook_site_show.rb +++ b/lib/chef/knife/cookbook_site_show.rb @@ -26,11 +26,11 @@ class Chef category "cookbook site" option :supermarket_site, - :short => "-m SUPERMARKET_SITE", - :long => "--supermarket-site SUPERMARKET_SITE", - :description => "Supermarket Site", - :default => "https://supermarket.chef.io", - :proc => Proc.new { |supermarket| Chef::Config[:knife][:supermarket_site] = supermarket } + short: "-m SUPERMARKET_SITE", + long: "--supermarket-site SUPERMARKET_SITE", + description: "Supermarket Site", + default: "https://supermarket.chef.io", + proc: Proc.new { |supermarket| Chef::Config[:knife][:supermarket_site] = supermarket } def run output(format_for_display(get_cookbook_data)) diff --git a/lib/chef/knife/cookbook_site_unshare.rb b/lib/chef/knife/cookbook_site_unshare.rb index bdabff0b94..5f24781f38 100644 --- a/lib/chef/knife/cookbook_site_unshare.rb +++ b/lib/chef/knife/cookbook_site_unshare.rb @@ -31,11 +31,11 @@ class Chef category "cookbook site" option :supermarket_site, - :short => "-m SUPERMARKET_SITE", - :long => "--supermarket-site SUPERMARKET_SITE", - :description => "Supermarket Site", - :default => "https://supermarket.chef.io", - :proc => Proc.new { |supermarket| Chef::Config[:knife][:supermarket_site] = supermarket } + short: "-m SUPERMARKET_SITE", + long: "--supermarket-site SUPERMARKET_SITE", + description: "Supermarket Site", + default: "https://supermarket.chef.io", + proc: Proc.new { |supermarket| Chef::Config[:knife][:supermarket_site] = supermarket } def run @cookbook_name = @name_args[0] diff --git a/lib/chef/knife/cookbook_test.rb b/lib/chef/knife/cookbook_test.rb index b4adf6c84f..2f600bf964 100644 --- a/lib/chef/knife/cookbook_test.rb +++ b/lib/chef/knife/cookbook_test.rb @@ -32,15 +32,15 @@ class Chef banner "knife cookbook test [COOKBOOKS...] (options)" option :cookbook_path, - :short => "-o PATH:PATH", - :long => "--cookbook-path PATH:PATH", - :description => "A colon-separated path to look for cookbooks in", - :proc => lambda { |o| o.split(":") } + short: "-o PATH:PATH", + long: "--cookbook-path PATH:PATH", + description: "A colon-separated path to look for cookbooks in", + proc: lambda { |o| o.split(":") } option :all, - :short => "-a", - :long => "--all", - :description => "Test all cookbooks, rather than just a single cookbook" + short: "-a", + long: "--all", + description: "Test all cookbooks, rather than just a single cookbook" def run ui.warn("DEPRECATED: Please use ChefSpec or Cookstyle to syntax-check cookbooks.") diff --git a/lib/chef/knife/cookbook_upload.rb b/lib/chef/knife/cookbook_upload.rb index f67a26dc9a..241eb03862 100644 --- a/lib/chef/knife/cookbook_upload.rb +++ b/lib/chef/knife/cookbook_upload.rb @@ -37,42 +37,42 @@ class Chef banner "knife cookbook upload [COOKBOOKS...] (options)" option :cookbook_path, - :short => "-o PATH:PATH", - :long => "--cookbook-path PATH:PATH", - :description => "A colon-separated path to look for cookbooks in", - :proc => lambda { |o| o.split(":") } + short: "-o PATH:PATH", + long: "--cookbook-path PATH:PATH", + description: "A colon-separated path to look for cookbooks in", + proc: lambda { |o| o.split(":") } option :freeze, - :long => "--freeze", - :description => "Freeze this version of the cookbook so that it cannot be overwritten", - :boolean => true + long: "--freeze", + description: "Freeze this version of the cookbook so that it cannot be overwritten", + boolean: true option :all, - :short => "-a", - :long => "--all", - :description => "Upload all cookbooks, rather than just a single cookbook" + short: "-a", + long: "--all", + description: "Upload all cookbooks, rather than just a single cookbook" option :force, - :long => "--force", - :boolean => true, - :description => "Update cookbook versions even if they have been frozen" + long: "--force", + boolean: true, + description: "Update cookbook versions even if they have been frozen" option :concurrency, - :long => "--concurrency NUMBER_OF_THREADS", - :description => "How many concurrent threads will be used", - :default => 10, - :proc => lambda { |o| o.to_i } + 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", - :description => "Set ENVIRONMENT's version dependency match the version you're uploading.", - :default => nil + short: "-E", + long: "--environment ENVIRONMENT", + description: "Set ENVIRONMENT's version dependency match the version you're uploading.", + default: nil option :depends, - :short => "-d", - :long => "--include-dependencies", - :description => "Also upload cookbook dependencies" + short: "-d", + long: "--include-dependencies", + description: "Also upload cookbook dependencies" def run # Sanity check before we load anything from the server @@ -242,7 +242,7 @@ WARNING check_for_broken_links!(cb) check_for_dependencies!(cb) end - Chef::CookbookUploader.new(cookbooks, :force => config[:force], :concurrency => config[:concurrency]).upload_cookbooks + Chef::CookbookUploader.new(cookbooks, force: config[:force], concurrency: config[:concurrency]).upload_cookbooks rescue Chef::Exceptions::CookbookFrozen => e ui.error e raise diff --git a/lib/chef/knife/core/bootstrap_context.rb b/lib/chef/knife/core/bootstrap_context.rb index deb7f8a3b4..17d62f597f 100644 --- a/lib/chef/knife/core/bootstrap_context.rb +++ b/lib/chef/knife/core/bootstrap_context.rb @@ -228,7 +228,7 @@ validation_client_name "#{@chef_config[:validation_client_name]}" end attributes.delete(:run_list) if attributes[:policy_name] && !attributes[:policy_name].empty? - attributes.merge!(:tags => @config[:tags]) if @config[:tags] && !@config[:tags].empty? + attributes.merge!(tags: @config[:tags]) if @config[:tags] && !@config[:tags].empty? end end diff --git a/lib/chef/knife/core/cookbook_scm_repo.rb b/lib/chef/knife/core/cookbook_scm_repo.rb index 38f432e5bb..f583f0bd8e 100644 --- a/lib/chef/knife/core/cookbook_scm_repo.rb +++ b/lib/chef/knife/core/cookbook_scm_repo.rb @@ -151,7 +151,7 @@ class Chef end def git(command) - shell_out!("git #{command}", :cwd => repo_path) + shell_out!("git #{command}", cwd: repo_path) end end diff --git a/lib/chef/knife/core/generic_presenter.rb b/lib/chef/knife/core/generic_presenter.rb index 861bf1510d..7b3fee00b5 100644 --- a/lib/chef/knife/core/generic_presenter.rb +++ b/lib/chef/knife/core/generic_presenter.rb @@ -29,15 +29,15 @@ class Chef def self.included(includer) includer.class_eval do option :field_separator, - :short => "-S SEPARATOR", - :long => "--field-separator SEPARATOR", - :description => "Character separator used to delineate nesting in --attribute filters (default \".\")" + short: "-S SEPARATOR", + long: "--field-separator SEPARATOR", + description: "Character separator used to delineate nesting in --attribute filters (default \".\")" option :attribute, - :short => "-a ATTR1 [-a ATTR2]", - :long => "--attribute ATTR1 [--attribute ATTR2] ", - :description => "Show one or more attributes", - :proc => Proc.new { |a| + short: "-a ATTR1 [-a ATTR2]", + long: "--attribute ATTR1 [--attribute ATTR2] ", + description: "Show one or more attributes", + proc: Proc.new { |a| Chef::Config[:knife][:attribute] ||= [] Chef::Config[:knife][:attribute].push(a) } diff --git a/lib/chef/knife/core/node_presenter.rb b/lib/chef/knife/core/node_presenter.rb index cdb664ec33..0c00601981 100644 --- a/lib/chef/knife/core/node_presenter.rb +++ b/lib/chef/knife/core/node_presenter.rb @@ -32,18 +32,18 @@ class Chef def self.included(includer) includer.class_eval do option :medium_output, - :short => "-m", - :long => "--medium", - :boolean => true, - :default => false, - :description => "Include normal attributes in the output" + short: "-m", + long: "--medium", + boolean: true, + default: false, + description: "Include normal attributes in the output" option :long_output, - :short => "-l", - :long => "--long", - :boolean => true, - :default => false, - :description => "Include all attributes in the output" + short: "-l", + long: "--long", + boolean: true, + default: false, + description: "Include all attributes in the output" end end end diff --git a/lib/chef/knife/core/status_presenter.rb b/lib/chef/knife/core/status_presenter.rb index 1e2d9b41b6..4bb27d1277 100644 --- a/lib/chef/knife/core/status_presenter.rb +++ b/lib/chef/knife/core/status_presenter.rb @@ -32,18 +32,18 @@ class Chef def self.included(includer) includer.class_eval do option :medium_output, - :short => "-m", - :long => "--medium", - :boolean => true, - :default => false, - :description => "Include normal attributes in the output" + short: "-m", + long: "--medium", + boolean: true, + default: false, + description: "Include normal attributes in the output" option :long_output, - :short => "-l", - :long => "--long", - :boolean => true, - :default => false, - :description => "Include all attributes in the output" + short: "-l", + long: "--long", + boolean: true, + default: false, + description: "Include all attributes in the output" end end end diff --git a/lib/chef/knife/data_bag_from_file.rb b/lib/chef/knife/data_bag_from_file.rb index 30b9de3386..3e8d3b6f59 100644 --- a/lib/chef/knife/data_bag_from_file.rb +++ b/lib/chef/knife/data_bag_from_file.rb @@ -38,9 +38,9 @@ class Chef category "data bag" option :all, - :short => "-a", - :long => "--all", - :description => "Upload all data bags or all items for specified data bags" + short: "-a", + long: "--all", + description: "Upload all data bags or all items for specified data bags" def loader @loader ||= Knife::Core::ObjectLoader.new(DataBagItem, ui) diff --git a/lib/chef/knife/data_bag_list.rb b/lib/chef/knife/data_bag_list.rb index d507925ec8..454b0a4908 100644 --- a/lib/chef/knife/data_bag_list.rb +++ b/lib/chef/knife/data_bag_list.rb @@ -30,9 +30,9 @@ class Chef category "data bag" option :with_uri, - :short => "-w", - :long => "--with-uri", - :description => "Show corresponding URIs" + short: "-w", + long: "--with-uri", + description: "Show corresponding URIs" def run output(format_list_for_display(Chef::DataBag.list)) diff --git a/lib/chef/knife/data_bag_secret_options.rb b/lib/chef/knife/data_bag_secret_options.rb index a612004e15..62a3e71ec5 100644 --- a/lib/chef/knife/data_bag_secret_options.rb +++ b/lib/chef/knife/data_bag_secret_options.rb @@ -35,23 +35,23 @@ class Chef def self.included(base) base.option :secret, - :short => "-s SECRET", - :long => "--secret ", - :description => "The secret key to use to encrypt data bag item values. Can also be defaulted in your config with the key 'secret'", + short: "-s SECRET", + long: "--secret ", + description: "The secret key to use to encrypt data bag item values. Can also be defaulted in your config with the key 'secret'", # Need to store value from command line in separate variable - knife#merge_configs populates same keys # on config object from - :proc => Proc.new { |s| set_cl_secret(s) } + proc: Proc.new { |s| set_cl_secret(s) } base.option :secret_file, - :long => "--secret-file SECRET_FILE", - :description => "A file containing the secret key to use to encrypt data bag item values. Can also be defaulted in your config with the key 'secret_file'", - :proc => Proc.new { |sf| set_cl_secret_file(sf) } + long: "--secret-file SECRET_FILE", + description: "A file containing the secret key to use to encrypt data bag item values. Can also be defaulted in your config with the key 'secret_file'", + proc: Proc.new { |sf| set_cl_secret_file(sf) } base.option :encrypt, - :long => "--encrypt", - :description => "If 'secret' or 'secret_file' is present in your config, then encrypt data bags using it", - :boolean => true, - :default => false + long: "--encrypt", + description: "If 'secret' or 'secret_file' is present in your config, then encrypt data bags using it", + boolean: true, + default: false end def encryption_secret_provided? diff --git a/lib/chef/knife/delete.rb b/lib/chef/knife/delete.rb index 19f75df012..1c05fba3cf 100644 --- a/lib/chef/knife/delete.rb +++ b/lib/chef/knife/delete.rb @@ -28,21 +28,21 @@ class Chef end option :recurse, - :short => "-r", - :long => "--[no-]recurse", - :boolean => true, - :default => false, - :description => "Delete directories recursively." + short: "-r", + long: "--[no-]recurse", + boolean: true, + default: false, + description: "Delete directories recursively." option :both, - :long => "--both", - :boolean => true, - :default => false, - :description => "Delete both the local and remote copies." + long: "--both", + boolean: true, + default: false, + description: "Delete both the local and remote copies." option :local, - :long => "--local", - :boolean => true, - :default => false, - :description => "Delete the local copy (leave the remote copy)." + long: "--local", + boolean: true, + default: false, + description: "Delete the local copy (leave the remote copy)." def run if name_args.length == 0 diff --git a/lib/chef/knife/deps.rb b/lib/chef/knife/deps.rb index fb2a8bb40f..4cb77eea46 100644 --- a/lib/chef/knife/deps.rb +++ b/lib/chef/knife/deps.rb @@ -29,17 +29,17 @@ class Chef end option :recurse, - :long => "--[no-]recurse", - :boolean => true, - :description => "List dependencies recursively (default: true). Only works with --tree." + long: "--[no-]recurse", + boolean: true, + description: "List dependencies recursively (default: true). Only works with --tree." option :tree, - :long => "--tree", - :boolean => true, - :description => "Show dependencies in a visual tree. May show duplicates." + long: "--tree", + boolean: true, + description: "Show dependencies in a visual tree. May show duplicates." option :remote, - :long => "--remote", - :boolean => true, - :description => "List dependencies on the server instead of the local filesystem" + long: "--remote", + boolean: true, + description: "List dependencies on the server instead of the local filesystem" attr_accessor :exit_code diff --git a/lib/chef/knife/diff.rb b/lib/chef/knife/diff.rb index a14335c296..aac42ed5c5 100644 --- a/lib/chef/knife/diff.rb +++ b/lib/chef/knife/diff.rb @@ -28,29 +28,29 @@ class Chef end option :recurse, - :long => "--[no-]recurse", - :boolean => true, - :default => true, - :description => "List directories recursively." + long: "--[no-]recurse", + boolean: true, + default: true, + description: "List directories recursively." option :name_only, - :long => "--name-only", - :boolean => true, - :description => "Only show names of modified files." + long: "--name-only", + boolean: true, + description: "Only show names of modified files." option :name_status, - :long => "--name-status", - :boolean => true, - :description => "Only show names and statuses of modified files: Added, Deleted, Modified, and Type Changed." + 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)...[*]]", - :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 + 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 942d17d330..f1dfd13326 100644 --- a/lib/chef/knife/download.rb +++ b/lib/chef/knife/download.rb @@ -28,39 +28,39 @@ class Chef end option :recurse, - :long => "--[no-]recurse", - :boolean => true, - :default => true, - :description => "List directories recursively." + long: "--[no-]recurse", + boolean: true, + default: true, + description: "List directories recursively." option :purge, - :long => "--[no-]purge", - :boolean => true, - :default => false, - :description => "Delete matching local files and directories that do not exist remotely." + long: "--[no-]purge", + boolean: true, + default: false, + description: "Delete matching local files and directories that do not exist remotely." option :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)" + 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", - :boolean => true, - :default => false, - :description => "Don't take action, only print what would happen" + long: "--dry-run", + short: "-n", + boolean: true, + default: false, + description: "Don't take action, only print what would happen" option :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" + long: "--[no-]diff", + boolean: true, + default: true, + 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 597b284356..e150babc31 100644 --- a/lib/chef/knife/edit.rb +++ b/lib/chef/knife/edit.rb @@ -29,9 +29,9 @@ class Chef end option :local, - :long => "--local", - :boolean => true, - :description => "Show local files instead of remote" + long: "--local", + boolean: true, + description: "Show local files instead of remote" def run # Get the matches (recursively) diff --git a/lib/chef/knife/environment_compare.rb b/lib/chef/knife/environment_compare.rb index 9131f06068..1395db3f34 100644 --- a/lib/chef/knife/environment_compare.rb +++ b/lib/chef/knife/environment_compare.rb @@ -29,16 +29,16 @@ class Chef banner "knife environment compare [ENVIRONMENT..] (options)" option :all, - :short => "-a", - :long => "--all", - :description => "Show all cookbooks", - :boolean => true + short: "-a", + long: "--all", + description: "Show all cookbooks", + boolean: true option :mismatch, - :short => "-m", - :long => "--mismatch", - :description => "Only show mismatching versions", - :boolean => true + short: "-m", + long: "--mismatch", + description: "Only show mismatching versions", + boolean: true def run # Get the commandline environments or all if none are provided. diff --git a/lib/chef/knife/environment_create.rb b/lib/chef/knife/environment_create.rb index cfc1bc268c..e533a70172 100644 --- a/lib/chef/knife/environment_create.rb +++ b/lib/chef/knife/environment_create.rb @@ -30,9 +30,9 @@ class Chef banner "knife environment create ENVIRONMENT (options)" option :description, - :short => "-d DESCRIPTION", - :long => "--description DESCRIPTION", - :description => "The environment description" + short: "-d DESCRIPTION", + long: "--description DESCRIPTION", + description: "The environment description" def run env_name = @name_args[0] diff --git a/lib/chef/knife/environment_from_file.rb b/lib/chef/knife/environment_from_file.rb index b16c3331bd..6e22e8b0f6 100644 --- a/lib/chef/knife/environment_from_file.rb +++ b/lib/chef/knife/environment_from_file.rb @@ -30,9 +30,9 @@ class Chef banner "knife environment from file FILE [FILE..] (options)" option :all, - :short => "-a", - :long => "--all", - :description => "Upload all environments" + short: "-a", + long: "--all", + description: "Upload all environments" def loader @loader ||= Knife::Core::ObjectLoader.new(Chef::Environment, ui) diff --git a/lib/chef/knife/environment_list.rb b/lib/chef/knife/environment_list.rb index f278046bf9..c3f2ef2e39 100644 --- a/lib/chef/knife/environment_list.rb +++ b/lib/chef/knife/environment_list.rb @@ -30,9 +30,9 @@ class Chef banner "knife environment list (options)" option :with_uri, - :short => "-w", - :long => "--with-uri", - :description => "Show corresponding URIs" + short: "-w", + long: "--with-uri", + description: "Show corresponding URIs" def run output(format_list_for_display(Chef::Environment.list)) diff --git a/lib/chef/knife/exec.rb b/lib/chef/knife/exec.rb index 7b27a51b85..ed7101c0cc 100644 --- a/lib/chef/knife/exec.rb +++ b/lib/chef/knife/exec.rb @@ -24,15 +24,15 @@ class Chef::Knife::Exec < Chef::Knife banner "knife exec [SCRIPT] (options)" option :exec, - :short => "-E CODE", - :long => "--exec CODE", - :description => "a string of Chef code to execute" + short: "-E CODE", + long: "--exec CODE", + description: "a string of Chef code to execute" option :script_path, - :short => "-p PATH:PATH", - :long => "--script-path PATH:PATH", - :description => "A colon-separated path to look for scripts in", - :proc => lambda { |o| o.split(":") } + short: "-p PATH:PATH", + long: "--script-path PATH:PATH", + description: "A colon-separated path to look for scripts in", + proc: lambda { |o| o.split(":") } deps do require "chef/shell/ext" diff --git a/lib/chef/knife/key_create_base.rb b/lib/chef/knife/key_create_base.rb index d02d5ee180..d69f442e71 100644 --- a/lib/chef/knife/key_create_base.rb +++ b/lib/chef/knife/key_create_base.rb @@ -25,24 +25,24 @@ class Chef def self.included(includer) includer.class_eval do option :public_key, - :short => "-p FILENAME", - :long => "--public-key FILENAME", - :description => "Public key for newly created key. If not passed, the server will create a key pair for you, but you must pass --key-name NAME in that case." + short: "-p FILENAME", + long: "--public-key FILENAME", + description: "Public key for newly created key. If not passed, the server will create a key pair for you, but you must pass --key-name NAME in that case." option :file, - :short => "-f FILE", - :long => "--file FILE", - :description => "Write the private key to a file, if you requested the server to create one." + short: "-f FILE", + long: "--file FILE", + description: "Write the private key to a file, if you requested the server to create one." option :key_name, - :short => "-k NAME", - :long => "--key-name NAME", - :description => "The name for your key. If you do not pass a name, you must pass --public-key, and the name will default to the fingerprint of the public key passed." + short: "-k NAME", + long: "--key-name NAME", + description: "The name for your key. If you do not pass a name, you must pass --public-key, and the name will default to the fingerprint of the public key passed." option :expiration_date, - :short => "-e DATE", - :long => "--expiration-date DATE", - :description => "Optionally pass the expiration date for the key in ISO 8601 fomatted string: YYYY-MM-DDTHH:MM:SSZ e.g. 2013-12-24T21:00:00Z. Defaults to infinity if not passed. UTC timezone assumed." + short: "-e DATE", + long: "--expiration-date DATE", + description: "Optionally pass the expiration date for the key in ISO 8601 fomatted string: YYYY-MM-DDTHH:MM:SSZ e.g. 2013-12-24T21:00:00Z. Defaults to infinity if not passed. UTC timezone assumed." end end end diff --git a/lib/chef/knife/key_edit_base.rb b/lib/chef/knife/key_edit_base.rb index 1a613ef1bc..ecdb4b0038 100644 --- a/lib/chef/knife/key_edit_base.rb +++ b/lib/chef/knife/key_edit_base.rb @@ -25,29 +25,29 @@ class Chef def self.included(includer) includer.class_eval do option :public_key, - :short => "-p FILENAME", - :long => "--public-key FILENAME", - :description => "Replace the public_key field from a file on disk. If not passed, the public_key field will not change." + short: "-p FILENAME", + long: "--public-key FILENAME", + description: "Replace the public_key field from a file on disk. If not passed, the public_key field will not change." option :create_key, - :short => "-c", - :long => "--create-key", - :description => "Replace the public_key field with a key generated by the server. The private key will be returned." + short: "-c", + long: "--create-key", + description: "Replace the public_key field with a key generated by the server. The private key will be returned." option :file, - :short => "-f FILE", - :long => "--file FILE", - :description => "Write the private key to a file, if you requested the server to create one via --create-key." + short: "-f FILE", + long: "--file FILE", + description: "Write the private key to a file, if you requested the server to create one via --create-key." option :key_name, - :short => "-k NAME", - :long => "--key-name NAME", - :description => "The new name for your key. Pass if you wish to update the name field of your key." + short: "-k NAME", + long: "--key-name NAME", + description: "The new name for your key. Pass if you wish to update the name field of your key." option :expiration_date, - :short => "-e DATE", - :long => "--expiration-date DATE", - :description => "Updates the expiration_date field of your key if passed. Pass in ISO 8601 fomatted string: YYYY-MM-DDTHH:MM:SSZ e.g. 2013-12-24T21:00:00Z or infinity. UTC timezone assumed." + short: "-e DATE", + long: "--expiration-date DATE", + description: "Updates the expiration_date field of your key if passed. Pass in ISO 8601 fomatted string: YYYY-MM-DDTHH:MM:SSZ e.g. 2013-12-24T21:00:00Z or infinity. UTC timezone assumed." end end end diff --git a/lib/chef/knife/key_list_base.rb b/lib/chef/knife/key_list_base.rb index 95858e9ba1..6470bf78ad 100644 --- a/lib/chef/knife/key_list_base.rb +++ b/lib/chef/knife/key_list_base.rb @@ -25,19 +25,19 @@ class Chef def self.included(includer) includer.class_eval do option :with_details, - :short => "-w", - :long => "--with-details", - :description => "Show corresponding URIs and whether the key has expired or not." + short: "-w", + long: "--with-details", + description: "Show corresponding URIs and whether the key has expired or not." option :only_expired, - :short => "-e", - :long => "--only-expired", - :description => "Only show expired keys." + short: "-e", + long: "--only-expired", + description: "Only show expired keys." option :only_non_expired, - :short => "-n", - :long => "--only-non-expired", - :description => "Only show non-expired keys." + short: "-n", + long: "--only-non-expired", + description: "Only show non-expired keys." end end end diff --git a/lib/chef/knife/list.rb b/lib/chef/knife/list.rb index 7dc91d7266..9452478ddb 100644 --- a/lib/chef/knife/list.rb +++ b/lib/chef/knife/list.rb @@ -29,30 +29,30 @@ class Chef end option :recursive, - :short => "-R", - :boolean => true, - :description => "List directories recursively" + short: "-R", + boolean: true, + description: "List directories recursively" option :bare_directories, - :short => "-d", - :boolean => true, - :description => "When directories match the pattern, do not show the directories' children" + short: "-d", + boolean: true, + description: "When directories match the pattern, do not show the directories' children" option :local, - :long => "--local", - :boolean => true, - :description => "List local directory instead of remote" + long: "--local", + boolean: true, + description: "List local directory instead of remote" option :flat, - :short => "-f", - :long => "--flat", - :boolean => true, - :description => "Show a list of filenames rather than the prettified ls-like output normally produced" + 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", - :boolean => true, - :description => "Show only one column of results" + short: "-1", + boolean: true, + description: "Show only one column of results" option :trailing_slashes, - :short => "-p", - :boolean => true, - :description => "Show trailing slashes after directories" + short: "-p", + boolean: true, + description: "Show trailing slashes after directories" attr_accessor :exit_code diff --git a/lib/chef/knife/node_edit.rb b/lib/chef/knife/node_edit.rb index 4632c0a5b4..7551a8a7da 100644 --- a/lib/chef/knife/node_edit.rb +++ b/lib/chef/knife/node_edit.rb @@ -32,10 +32,10 @@ class Chef banner "knife node edit NODE (options)" option :all_attributes, - :short => "-a", - :long => "--all", - :boolean => true, - :description => "Display all attributes when editing" + short: "-a", + long: "--all", + boolean: true, + description: "Display all attributes when editing" def run if node_name.nil? diff --git a/lib/chef/knife/node_list.rb b/lib/chef/knife/node_list.rb index 4885208136..4bc2c34508 100644 --- a/lib/chef/knife/node_list.rb +++ b/lib/chef/knife/node_list.rb @@ -30,9 +30,9 @@ class Chef banner "knife node list (options)" option :with_uri, - :short => "-w", - :long => "--with-uri", - :description => "Show corresponding URIs" + short: "-w", + long: "--with-uri", + description: "Show corresponding URIs" def run env = Chef::Config[:environment] diff --git a/lib/chef/knife/node_run_list_add.rb b/lib/chef/knife/node_run_list_add.rb index fb4ce3bc12..3fc28c041d 100644 --- a/lib/chef/knife/node_run_list_add.rb +++ b/lib/chef/knife/node_run_list_add.rb @@ -30,14 +30,14 @@ class Chef banner "knife node run_list add [NODE] [ENTRY [ENTRY]] (options)" option :after, - :short => "-a ITEM", - :long => "--after ITEM", - :description => "Place the ENTRY in the run list after ITEM" + short: "-a ITEM", + long: "--after ITEM", + description: "Place the ENTRY in the run list after ITEM" option :before, - :short => "-b ITEM", - :long => "--before ITEM", - :description => "Place the ENTRY in the run list before ITEM" + short: "-b ITEM", + long: "--before ITEM", + description: "Place the ENTRY in the run list before ITEM" def run node = Chef::Node.load(@name_args[0]) diff --git a/lib/chef/knife/node_show.rb b/lib/chef/knife/node_show.rb index 3092b3fc27..43e7e9dbee 100644 --- a/lib/chef/knife/node_show.rb +++ b/lib/chef/knife/node_show.rb @@ -34,14 +34,14 @@ class Chef banner "knife node show NODE (options)" option :run_list, - :short => "-r", - :long => "--run-list", - :description => "Show only the run list" + short: "-r", + long: "--run-list", + description: "Show only the run list" option :environment, - :short => "-E", - :long => "--environment", - :description => "Show only the Chef environment" + short: "-E", + long: "--environment", + description: "Show only the Chef environment" def run ui.use_presenter Knife::Core::NodePresenter diff --git a/lib/chef/knife/osc_user_create.rb b/lib/chef/knife/osc_user_create.rb index 74b50a4ef4..9ebf268110 100644 --- a/lib/chef/knife/osc_user_create.rb +++ b/lib/chef/knife/osc_user_create.rb @@ -32,25 +32,25 @@ class Chef end option :file, - :short => "-f FILE", - :long => "--file FILE", - :description => "Write the private key to a file" + short: "-f FILE", + long: "--file FILE", + description: "Write the private key to a file" option :admin, - :short => "-a", - :long => "--admin", - :description => "Create the user as an admin", - :boolean => true + short: "-a", + long: "--admin", + description: "Create the user as an admin", + boolean: true option :user_password, - :short => "-p PASSWORD", - :long => "--password PASSWORD", - :description => "Password for newly created user", - :default => "" + short: "-p PASSWORD", + long: "--password PASSWORD", + description: "Password for newly created user", + default: "" option :user_key, - :long => "--user-key FILENAME", - :description => "Public key for newly created user. By default a key will be created for you." + long: "--user-key FILENAME", + description: "Public key for newly created user. By default a key will be created for you." banner "knife osc_user create USER (options)" diff --git a/lib/chef/knife/osc_user_list.rb b/lib/chef/knife/osc_user_list.rb index f1002c4f54..17a7a781d9 100644 --- a/lib/chef/knife/osc_user_list.rb +++ b/lib/chef/knife/osc_user_list.rb @@ -35,9 +35,9 @@ class Chef banner "knife osc_user list (options)" option :with_uri, - :short => "-w", - :long => "--with-uri", - :description => "Show corresponding URIs" + short: "-w", + long: "--with-uri", + description: "Show corresponding URIs" def run output(format_list_for_display(Chef::User.list)) diff --git a/lib/chef/knife/osc_user_reregister.rb b/lib/chef/knife/osc_user_reregister.rb index dee1cf41b1..5f5d3fb246 100644 --- a/lib/chef/knife/osc_user_reregister.rb +++ b/lib/chef/knife/osc_user_reregister.rb @@ -35,9 +35,9 @@ class Chef banner "knife osc_user reregister USER (options)" option :file, - :short => "-f FILE", - :long => "--file FILE", - :description => "Write the private key to a file" + short: "-f FILE", + long: "--file FILE", + description: "Write the private key to a file" def run @user_name = @name_args[0] diff --git a/lib/chef/knife/raw.rb b/lib/chef/knife/raw.rb index dfbf423e92..2d49c457fc 100644 --- a/lib/chef/knife/raw.rb +++ b/lib/chef/knife/raw.rb @@ -33,27 +33,27 @@ class Chef end option :method, - :long => "--method METHOD", - :short => "-m METHOD", - :default => "GET", - :description => "Request method (GET, POST, PUT or DELETE). Default: GET" + long: "--method METHOD", + short: "-m METHOD", + default: "GET", + description: "Request method (GET, POST, PUT or DELETE). Default: GET" option :pretty, - :long => "--[no-]pretty", - :boolean => true, - :default => true, - :description => "Pretty-print JSON output. Default: true" + long: "--[no-]pretty", + boolean: true, + default: true, + description: "Pretty-print JSON output. Default: true" option :input, - :long => "--input FILE", - :short => "-i FILE", - :description => "Name of file to use for PUT or POST" + long: "--input FILE", + short: "-i FILE", + description: "Name of file to use for PUT or POST" option :proxy_auth, - :long => "--proxy-auth", - :boolean => true, - :default => false, - :description => "Use webui proxy authentication. Client key must be the webui key." + long: "--proxy-auth", + boolean: true, + default: false, + description: "Use webui proxy authentication. Client key must be the webui key." # We need a custom HTTP client class here because we don't want to even # try to decode the body, in case we get back corrupted JSON or whatnot. @@ -105,7 +105,7 @@ class Chef result = Chef::JSONCompat.to_json_pretty(result) end else - chef_rest = RawInputServerAPI.new(:raw_output => true) + chef_rest = RawInputServerAPI.new(raw_output: true) result = chef_rest.request(method, name_args[0], headers, data) end output result diff --git a/lib/chef/knife/role_create.rb b/lib/chef/knife/role_create.rb index a389d849f7..6b953f31c8 100644 --- a/lib/chef/knife/role_create.rb +++ b/lib/chef/knife/role_create.rb @@ -30,9 +30,9 @@ class Chef banner "knife role create ROLE (options)" option :description, - :short => "-d DESC", - :long => "--description DESC", - :description => "The role description" + short: "-d DESC", + long: "--description DESC", + description: "The role description" def run @role_name = @name_args[0] diff --git a/lib/chef/knife/role_env_run_list_add.rb b/lib/chef/knife/role_env_run_list_add.rb index c24ae3d331..0f4bee9dbf 100644 --- a/lib/chef/knife/role_env_run_list_add.rb +++ b/lib/chef/knife/role_env_run_list_add.rb @@ -31,9 +31,9 @@ class Chef banner "knife role env_run_list add [ROLE] [ENVIRONMENT] [ENTRY [ENTRY]] (options)" option :after, - :short => "-a ITEM", - :long => "--after ITEM", - :description => "Place the ENTRY in the run list after ITEM" + short: "-a ITEM", + long: "--after ITEM", + description: "Place the ENTRY in the run list after ITEM" def add_to_env_run_list(role, environment, entries, after = nil) if after diff --git a/lib/chef/knife/role_list.rb b/lib/chef/knife/role_list.rb index 1247478ef5..3d6c3b4574 100644 --- a/lib/chef/knife/role_list.rb +++ b/lib/chef/knife/role_list.rb @@ -30,9 +30,9 @@ class Chef banner "knife role list (options)" option :with_uri, - :short => "-w", - :long => "--with-uri", - :description => "Show corresponding URIs" + short: "-w", + long: "--with-uri", + description: "Show corresponding URIs" def run output(format_list_for_display(Chef::Role.list)) diff --git a/lib/chef/knife/role_run_list_add.rb b/lib/chef/knife/role_run_list_add.rb index df06d91725..c6564f9d04 100644 --- a/lib/chef/knife/role_run_list_add.rb +++ b/lib/chef/knife/role_run_list_add.rb @@ -31,9 +31,9 @@ class Chef banner "knife role run_list add [ROLE] [ENTRY [ENTRY]] (options)" option :after, - :short => "-a ITEM", - :long => "--after ITEM", - :description => "Place the ENTRY in the run list after ITEM" + short: "-a ITEM", + long: "--after ITEM", + description: "Place the ENTRY in the run list after ITEM" def add_to_env_run_list(role, environment, entries, after = nil) if after diff --git a/lib/chef/knife/search.rb b/lib/chef/knife/search.rb index 94c33aa594..1bc9ce9f7e 100644 --- a/lib/chef/knife/search.rb +++ b/lib/chef/knife/search.rb @@ -38,38 +38,38 @@ class Chef banner "knife search INDEX QUERY (options)" option :start, - :short => "-b ROW", - :long => "--start ROW", - :description => "The row to start returning results at", - :default => 0, - :proc => lambda { |i| i.to_i } + short: "-b ROW", + long: "--start ROW", + description: "The row to start returning results at", + default: 0, + proc: lambda { |i| i.to_i } option :rows, - :short => "-R INT", - :long => "--rows INT", - :description => "The number of rows to return", - :default => nil, - :proc => lambda { |i| i.to_i } + short: "-R INT", + long: "--rows INT", + description: "The number of rows to return", + default: nil, + proc: lambda { |i| i.to_i } option :run_list, - :short => "-r", - :long => "--run-list", - :description => "Show only the run list" + short: "-r", + long: "--run-list", + description: "Show only the run list" option :id_only, - :short => "-i", - :long => "--id-only", - :description => "Show only the ID of matching objects" + short: "-i", + long: "--id-only", + description: "Show only the ID of matching objects" option :query, - :short => "-q QUERY", - :long => "--query QUERY", - :description => "The search query; useful to protect queries starting with -" + short: "-q QUERY", + long: "--query QUERY", + description: "The search query; useful to protect queries starting with -" option :filter_result, - :short => "-f FILTER", - :long => "--filter-result FILTER", - :description => "Only return specific attributes of the matching objects; for example: \"ServerName=name, Kernel=kernel.version\"" + short: "-f FILTER", + long: "--filter-result FILTER", + description: "Only return specific attributes of the matching objects; for example: \"ServerName=name, Kernel=kernel.version\"" def run read_cli_args @@ -116,7 +116,7 @@ class Chef end if ui.interchange? - output({ :results => result_count, :rows => result_items }) + output({ results: result_count, rows: result_items }) else ui.log "#{result_count} items found" ui.log("\n") diff --git a/lib/chef/knife/serve.rb b/lib/chef/knife/serve.rb index cac7fe8884..eb5c98963c 100644 --- a/lib/chef/knife/serve.rb +++ b/lib/chef/knife/serve.rb @@ -24,16 +24,16 @@ class Chef banner "knife serve (options)" option :repo_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" + 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 92b7ce1483..4511a86004 100644 --- a/lib/chef/knife/show.rb +++ b/lib/chef/knife/show.rb @@ -29,9 +29,9 @@ class Chef end option :local, - :long => "--local", - :boolean => true, - :description => "Show local files instead of remote" + long: "--local", + boolean: true, + description: "Show local files instead of remote" def run # Get the matches (recursively) diff --git a/lib/chef/knife/ssh.rb b/lib/chef/knife/ssh.rb index c38dc43e74..5bdbfd5498 100644 --- a/lib/chef/knife/ssh.rb +++ b/lib/chef/knife/ssh.rb @@ -40,100 +40,100 @@ class Chef banner "knife ssh QUERY COMMAND (options)" option :concurrency, - :short => "-C NUM", - :long => "--concurrency NUM", - :description => "The number of concurrent connections", - :default => nil, - :proc => lambda { |o| o.to_i } + short: "-C NUM", + long: "--concurrency NUM", + description: "The number of concurrent connections", + default: nil, + proc: lambda { |o| o.to_i } option :ssh_attribute, - :short => "-a ATTR", - :long => "--attribute ATTR", - :description => "The attribute to use for opening the connection - default depends on the context" + short: "-a ATTR", + long: "--attribute ATTR", + description: "The attribute to use for opening the connection - default depends on the context" option :manual, - :short => "-m", - :long => "--manual-list", - :boolean => true, - :description => "QUERY is a space separated list of servers", - :default => false + short: "-m", + long: "--manual-list", + boolean: true, + description: "QUERY is a space separated list of servers", + default: false option :prefix_attribute, - :long => "--prefix-attribute ATTR", - :description => "The attribute to use for prefixing the ouput - default depends on the context" + long: "--prefix-attribute ATTR", + description: "The attribute to use for prefixing the ouput - default depends on the context" option :ssh_user, - :short => "-x USERNAME", - :long => "--ssh-user USERNAME", - :description => "The ssh username" + short: "-x USERNAME", + long: "--ssh-user USERNAME", + description: "The ssh username" option :ssh_password_ng, - :short => "-P [PASSWORD]", - :long => "--ssh-password [PASSWORD]", - :description => "The ssh password - will prompt if flag is specified but no password is given", + short: "-P [PASSWORD]", + long: "--ssh-password [PASSWORD]", + description: "The ssh password - will prompt if flag is specified but no password is given", # default to a value that can not be a password (boolean) # so we can effectively test if this parameter was specified # without a value - :default => false + default: false option :ssh_port, - :short => "-p PORT", - :long => "--ssh-port PORT", - :description => "The ssh port", - :proc => Proc.new { |key| Chef::Config[:knife][:ssh_port] = key.strip } + short: "-p PORT", + long: "--ssh-port PORT", + description: "The ssh port", + proc: Proc.new { |key| Chef::Config[:knife][:ssh_port] = key.strip } option :ssh_timeout, - :short => "-t SECONDS", - :long => "--ssh-timeout SECONDS", - :description => "The ssh connection timeout", - :proc => Proc.new { |key| Chef::Config[:knife][:ssh_timeout] = key.strip.to_i }, - :default => 120 + short: "-t SECONDS", + long: "--ssh-timeout SECONDS", + description: "The ssh connection timeout", + proc: Proc.new { |key| Chef::Config[:knife][:ssh_timeout] = key.strip.to_i }, + default: 120 option :ssh_gateway, - :short => "-G GATEWAY", - :long => "--ssh-gateway GATEWAY", - :description => "The ssh gateway", - :proc => Proc.new { |key| Chef::Config[:knife][:ssh_gateway] = key.strip } + short: "-G GATEWAY", + long: "--ssh-gateway GATEWAY", + description: "The ssh gateway", + proc: Proc.new { |key| Chef::Config[:knife][:ssh_gateway] = key.strip } option :ssh_gateway_identity, - :long => "--ssh-gateway-identity SSH_GATEWAY_IDENTITY", - :description => "The SSH identity file used for gateway authentication" + long: "--ssh-gateway-identity SSH_GATEWAY_IDENTITY", + description: "The SSH identity file used for gateway authentication" option :forward_agent, - :short => "-A", - :long => "--forward-agent", - :description => "Enable SSH agent forwarding", - :boolean => true + short: "-A", + long: "--forward-agent", + description: "Enable SSH agent forwarding", + boolean: true option :ssh_identity_file, - :short => "-i IDENTITY_FILE", - :long => "--ssh-identity-file IDENTITY_FILE", - :description => "The SSH identity file used for authentication" + short: "-i IDENTITY_FILE", + long: "--ssh-identity-file IDENTITY_FILE", + description: "The SSH identity file used for authentication" option :host_key_verify, - :long => "--[no-]host-key-verify", - :description => "Verify host key, enabled by default.", - :boolean => true, - :default => true + long: "--[no-]host-key-verify", + description: "Verify host key, enabled by default.", + boolean: true, + default: true option :on_error, - :short => "-e", - :long => "--exit-on-error", - :description => "Immediately exit if an error is encountered", - :boolean => true, - :default => false + short: "-e", + long: "--exit-on-error", + description: "Immediately exit if an error is encountered", + boolean: true, + default: false option :duplicated_fqdns, - :long => "--duplicated-fqdns", - :description => "Behavior if FQDNs are duplicated, ignored by default", - :proc => Proc.new { |key| Chef::Config[:knife][:duplicated_fqdns] = key.strip.to_sym }, - :default => :ignore + long: "--duplicated-fqdns", + description: "Behavior if FQDNs are duplicated, ignored by default", + proc: Proc.new { |key| Chef::Config[:knife][:duplicated_fqdns] = key.strip.to_sym }, + default: :ignore option :tmux_split, - :long => "--tmux-split", - :description => "Split tmux window.", - :boolean => true, - :default => false + long: "--tmux-split", + description: "Split tmux window.", + boolean: true, + default: false def session ssh_error_handler = Proc.new do |server| @@ -146,7 +146,7 @@ class Chef end end - @session ||= Net::SSH::Multi.start(:concurrent_connections => config[:concurrency], :on_error => ssh_error_handler) + @session ||= Net::SSH::Multi.start(concurrent_connections: config[:concurrency], on_error: ssh_error_handler) end def configure_gateway @@ -505,18 +505,18 @@ class Chef end Appscript.app("/Applications/Utilities/Terminal.app").windows.first.activate - Appscript.app("System Events").application_processes["Terminal.app"].keystroke("n", :using => :command_down) + Appscript.app("System Events").application_processes["Terminal.app"].keystroke("n", using: :command_down) term = Appscript.app("Terminal") window = term.windows.first.get (session.servers_for.size - 1).times do |i| window.activate - Appscript.app("System Events").application_processes["Terminal.app"].keystroke("t", :using => :command_down) + Appscript.app("System Events").application_processes["Terminal.app"].keystroke("t", using: :command_down) end 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/status.rb b/lib/chef/knife/status.rb index 0e3cd7e7d6..413bff4f66 100644 --- a/lib/chef/knife/status.rb +++ b/lib/chef/knife/status.rb @@ -32,23 +32,23 @@ class Chef banner "knife status QUERY (options)" option :run_list, - :short => "-r", - :long => "--run-list", - :description => "Show the run list" + short: "-r", + long: "--run-list", + description: "Show the run list" option :sort_reverse, - :short => "-s", - :long => "--sort-reverse", - :description => "Sort the status list by last run time descending" + short: "-s", + long: "--sort-reverse", + description: "Sort the status list by last run time descending" option :hide_healthy, - :short => "-H", - :long => "--hide-healthy", - :description => "Hide nodes that have run chef in the last hour. [DEPRECATED] Use --hide-by-mins MINS instead" + short: "-H", + long: "--hide-healthy", + description: "Hide nodes that have run chef in the last hour. [DEPRECATED] Use --hide-by-mins MINS instead" option :hide_by_mins, - :long => "--hide-by-mins MINS", - :description => "Hide nodes that have run chef in the last MINS minutes" + long: "--hide-by-mins MINS", + description: "Hide nodes that have run chef in the last MINS minutes" def append_to_query(term) @query << " AND " unless @query.empty? diff --git a/lib/chef/knife/upload.rb b/lib/chef/knife/upload.rb index 063ed26892..e4e0a74b28 100644 --- a/lib/chef/knife/upload.rb +++ b/lib/chef/knife/upload.rb @@ -28,41 +28,41 @@ class Chef end option :recurse, - :long => "--[no-]recurse", - :boolean => true, - :default => true, - :description => "List directories recursively." + long: "--[no-]recurse", + boolean: true, + default: true, + description: "List directories recursively." option :purge, - :long => "--[no-]purge", - :boolean => true, - :default => false, - :description => "Delete matching local files and directories that do not exist remotely." + long: "--[no-]purge", + boolean: true, + default: false, + description: "Delete matching local files and directories that do not exist remotely." option :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." + 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", - :boolean => true, - :default => false, - :description => "Freeze cookbooks that get uploaded." + long: "--[no-]freeze", + boolean: true, + default: false, + description: "Freeze cookbooks that get uploaded." option :dry_run, - :long => "--dry-run", - :short => "-n", - :boolean => true, - :default => false, - :description => "Don't take action, only print what would happen" + long: "--dry-run", + short: "-n", + boolean: true, + default: false, + description: "Don't take action, only print what would happen" option :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" + long: "--[no-]diff", + boolean: true, + default: true, + 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 c4a89f3707..9273f0344d 100644 --- a/lib/chef/knife/user_create.rb +++ b/lib/chef/knife/user_create.rb @@ -32,31 +32,31 @@ class Chef end option :file, - :short => "-f FILE", - :long => "--file FILE", - :description => "Write the private key to a file if the server generated one." + short: "-f FILE", + long: "--file FILE", + description: "Write the private key to a file if the server generated one." option :user_key, - :long => "--user-key FILENAME", - :description => "Set the initial default key for the user from a file on disk (cannot pass with --prevent-keygen)." + long: "--user-key FILENAME", + description: "Set the initial default key for the user from a file on disk (cannot pass with --prevent-keygen)." option :prevent_keygen, - :short => "-k", - :long => "--prevent-keygen", - :description => "API V1 (Chef Server 12.1+) only. Prevent server from generating a default key pair for you. Cannot be passed with --user-key.", - :boolean => true + short: "-k", + long: "--prevent-keygen", + description: "API V1 (Chef Server 12.1+) only. Prevent server from generating a default key pair for you. Cannot be passed with --user-key.", + boolean: true option :admin, - :short => "-a", - :long => "--admin", - :description => "DEPRECATED: Open Source Chef 11 only. Create the user as an admin.", - :boolean => true + short: "-a", + long: "--admin", + description: "DEPRECATED: Open Source Chef 11 only. Create the user as an admin.", + boolean: true option :user_password, - :short => "-p PASSWORD", - :long => "--password PASSWORD", - :description => "DEPRECATED: Open Source Chef 11 only. Password for newly created user.", - :default => "" + short: "-p PASSWORD", + long: "--password PASSWORD", + description: "DEPRECATED: Open Source Chef 11 only. Password for newly created user.", + default: "" banner "knife user create USERNAME DISPLAY_NAME FIRST_NAME LAST_NAME EMAIL PASSWORD (options)" diff --git a/lib/chef/knife/user_list.rb b/lib/chef/knife/user_list.rb index 88e834025d..eccb8d15a4 100644 --- a/lib/chef/knife/user_list.rb +++ b/lib/chef/knife/user_list.rb @@ -32,9 +32,9 @@ class Chef banner "knife user list (options)" option :with_uri, - :short => "-w", - :long => "--with-uri", - :description => "Show corresponding URIs" + short: "-w", + long: "--with-uri", + description: "Show corresponding URIs" def run output(format_list_for_display(Chef::UserV1.list)) diff --git a/lib/chef/knife/user_reregister.rb b/lib/chef/knife/user_reregister.rb index fec6792134..b993dfc636 100644 --- a/lib/chef/knife/user_reregister.rb +++ b/lib/chef/knife/user_reregister.rb @@ -50,9 +50,9 @@ EOF end option :file, - :short => "-f FILE", - :long => "--file FILE", - :description => "Write the private key to a file" + short: "-f FILE", + long: "--file FILE", + description: "Write the private key to a file" def run @user_name = @name_args[0] diff --git a/lib/chef/knife/xargs.rb b/lib/chef/knife/xargs.rb index f663b480e8..bb3ce39717 100644 --- a/lib/chef/knife/xargs.rb +++ b/lib/chef/knife/xargs.rb @@ -30,61 +30,61 @@ class Chef # TODO modify to remote-only / local-only pattern (more like delete) option :local, - :long => "--local", - :boolean => true, - :description => "Xargs local files instead of remote" + long: "--local", + boolean: true, + description: "Xargs local files instead of remote" option :patterns, - :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] + 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", - :default => true, - :boolean => true, - :description => "Whether to show a diff when files change (default: true)" + long: "--[no-]diff", + default: true, + boolean: true, + description: "Whether to show a diff when files change (default: true)" option :dry_run, - :long => "--dry-run", - :boolean => true, - :description => "Prevents changes from actually being uploaded to the server." + long: "--dry-run", + boolean: true, + description: "Prevents changes from actually being uploaded to the server." option :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)" + 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", - :description => "String to replace with filenames. -J will only replace the FIRST occurrence of the replacement string." + 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", - :description => "String to replace with filenames. -I will replace ALL occurrence of the replacement string." + 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", - :description => "Maximum number of arguments per command line." + 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", - :description => "Maximum size of command line, in characters" + long: "--max-chars LENGTH", + short: "-s LENGTH", + description: "Maximum size of command line, in characters" option :verbose_commands, - :short => "-t", - :description => "Print command to be run on the command line" + short: "-t", + description: "Print command to be run on the command line" option :null_separator, - :short => "-0", - :boolean => true, - :description => "Use the NULL character (\0) as a separator, instead of whitespace" + short: "-0", + boolean: true, + description: "Use the NULL character (\0) as a separator, instead of whitespace" def run error = false @@ -175,7 +175,7 @@ class Chef # Create the temporary files files.each do |file| tempfile = Tempfile.new(file.name) - tempfiles[tempfile] = { :file => file } + tempfiles[tempfile] = { file: file } end rescue destroy_tempfiles(files) diff --git a/lib/chef/log/winevt.rb b/lib/chef/log/winevt.rb index 506d4c9a6c..a35f99c52c 100644 --- a/lib/chef/log/winevt.rb +++ b/lib/chef/log/winevt.rb @@ -51,46 +51,46 @@ class Chef def info(msg) @eventlog.report_event( - :event_type => ::Win32::EventLog::INFO_TYPE, - :source => SOURCE, - :event_id => INFO_EVENT_ID, - :data => [msg] + event_type: ::Win32::EventLog::INFO_TYPE, + source: SOURCE, + event_id: INFO_EVENT_ID, + data: [msg] ) end def warn(msg) @eventlog.report_event( - :event_type => ::Win32::EventLog::WARN_TYPE, - :source => SOURCE, - :event_id => WARN_EVENT_ID, - :data => [msg] + event_type: ::Win32::EventLog::WARN_TYPE, + source: SOURCE, + event_id: WARN_EVENT_ID, + data: [msg] ) end def debug(msg) @eventlog.report_event( - :event_type => ::Win32::EventLog::INFO_TYPE, - :source => SOURCE, - :event_id => DEBUG_EVENT_ID, - :data => [msg] + event_type: ::Win32::EventLog::INFO_TYPE, + source: SOURCE, + event_id: DEBUG_EVENT_ID, + data: [msg] ) end def error(msg) @eventlog.report_event( - :event_type => ::Win32::EventLog::ERROR_TYPE, - :source => SOURCE, - :event_id => ERROR_EVENT_ID, - :data => [msg] + event_type: ::Win32::EventLog::ERROR_TYPE, + source: SOURCE, + event_id: ERROR_EVENT_ID, + data: [msg] ) end def fatal(msg) @eventlog.report_event( - :event_type => ::Win32::EventLog::ERROR_TYPE, - :source => SOURCE, - :event_id => FATAL_EVENT_ID, - :data => [msg] + event_type: ::Win32::EventLog::ERROR_TYPE, + source: SOURCE, + event_id: FATAL_EVENT_ID, + data: [msg] ) end diff --git a/lib/chef/mixin/deprecation.rb b/lib/chef/mixin/deprecation.rb index 6621555585..06726b5252 100644 --- a/lib/chef/mixin/deprecation.rb +++ b/lib/chef/mixin/deprecation.rb @@ -33,7 +33,7 @@ class Chef # Chef::Mixin::RecipeDefinitionDSLCore is deprecated, use Chef::DSL::Recipe instead. # EOM def self.deprecate_constant(name, replacement, message) - deprecated_constants[name] = { :replacement => replacement, :message => message } + deprecated_constants[name] = { replacement: replacement, message: message } end # Const missing hook to look up deprecated constants defined with diff --git a/lib/chef/mixin/securable.rb b/lib/chef/mixin/securable.rb index 788b236d94..eb59f184d1 100644 --- a/lib/chef/mixin/securable.rb +++ b/lib/chef/mixin/securable.rb @@ -24,7 +24,7 @@ class Chef set_or_return( :owner, arg, - :regex => Chef::Config[:user_valid_regex] + regex: Chef::Config[:user_valid_regex] ) end @@ -34,7 +34,7 @@ class Chef set_or_return( :group, arg, - :regex => Chef::Config[:group_valid_regex] + regex: Chef::Config[:group_valid_regex] ) end @@ -42,7 +42,7 @@ class Chef set_or_return( :mode, arg, - :callbacks => { + callbacks: { "not in valid numeric range" => lambda do |m| if m.kind_of?(String) m =~ /^0/ || m = "0#{m}" @@ -110,16 +110,16 @@ class Chef rights = instance_variable_get("@#{name}".to_sym) unless permissions.nil? input = { - :permissions => permissions, - :principals => principals, + permissions: permissions, + principals: principals, } input.merge!(args_hash) unless args_hash.nil? - validations = { :permissions => { :required => true }, - :principals => { :required => true, :kind_of => [String, Array] }, - :applies_to_children => { :equal_to => [ true, false, :containers_only, :objects_only ] }, - :applies_to_self => { :kind_of => [ TrueClass, FalseClass ] }, - :one_level_deep => { :kind_of => [ TrueClass, FalseClass ] }, + validations = { permissions: { required: true }, + principals: { required: true, kind_of: [String, Array] }, + applies_to_children: { equal_to: [ true, false, :containers_only, :objects_only ] }, + applies_to_self: { kind_of: [ TrueClass, FalseClass ] }, + one_level_deep: { kind_of: [ TrueClass, FalseClass ] }, } validate(input, validations) @@ -167,7 +167,7 @@ class Chef set_or_return( :inherits, arg, - :kind_of => [ TrueClass, FalseClass ] + kind_of: [ TrueClass, FalseClass ] ) end end diff --git a/lib/chef/node.rb b/lib/chef/node.rb index f03e0ca0b1..10cad24921 100644 --- a/lib/chef/node.rb +++ b/lib/chef/node.rb @@ -115,10 +115,10 @@ class Chef def name(arg = nil) if !arg.nil? validate( - { :name => arg }, - { :name => { :kind_of => String, - :cannot_be => :blank, - :regex => /^[\-[:alnum:]_:.]+$/ }, + { name: arg }, + { name: { kind_of: String, + cannot_be: :blank, + regex: /^[\-[:alnum:]_:.]+$/ }, }) @name = arg else @@ -130,7 +130,7 @@ class Chef set_or_return( :chef_environment, arg, - { :regex => /^[\-[:alnum:]_]+$/, :kind_of => String } + { regex: /^[\-[:alnum:]_]+$/, kind_of: String } ) end diff --git a/lib/chef/org.rb b/lib/chef/org.rb index 73a129c7c1..ea1c411b67 100644 --- a/lib/chef/org.rb +++ b/lib/chef/org.rb @@ -40,22 +40,22 @@ class Chef def name(arg = nil) set_or_return(:name, arg, - :regex => /^[a-z0-9\-_]+$/) + regex: /^[a-z0-9\-_]+$/) end def full_name(arg = nil) set_or_return(:full_name, - arg, :kind_of => String) + arg, kind_of: String) end def private_key(arg = nil) set_or_return(:private_key, - arg, :kind_of => String) + arg, kind_of: String) end def guid(arg = nil) set_or_return(:guid, - arg, :kind_of => String) + arg, kind_of: String) end def to_hash @@ -73,13 +73,13 @@ class Chef end def create - payload = { :name => name, :full_name => full_name } + payload = { name: name, full_name: full_name } new_org = chef_rest.post("organizations", payload) Chef::Org.from_hash(to_hash.merge(new_org)) end def update - payload = { :name => name, :full_name => full_name } + payload = { name: name, full_name: full_name } new_org = chef_rest.put("organizations/#{name}", payload) Chef::Org.from_hash(to_hash.merge(new_org)) end @@ -99,10 +99,10 @@ class Chef end def associate_user(username) - request_body = { :user => username } + request_body = { user: username } response = chef_rest.post "organizations/#{@name}/association_requests", request_body association_id = response["uri"].split("/").last - chef_rest.put "users/#{username}/association_requests/#{association_id}", { :response => "accept" } + chef_rest.put "users/#{username}/association_requests/#{association_id}", { response: "accept" } end def dissociate_user(username) diff --git a/lib/chef/policy_builder/expand_node_object.rb b/lib/chef/policy_builder/expand_node_object.rb index b390042ea7..c91c74b047 100644 --- a/lib/chef/policy_builder/expand_node_object.rb +++ b/lib/chef/policy_builder/expand_node_object.rb @@ -175,7 +175,7 @@ class Chef begin events.cookbook_resolution_start(@expanded_run_list_with_versions) cookbook_hash = api_service.post("environments/#{node.chef_environment}/cookbook_versions", - { :run_list => @expanded_run_list_with_versions }) + { run_list: @expanded_run_list_with_versions }) cookbook_hash = cookbook_hash.inject({}) do |memo, (key, value)| memo[key] = Chef::CookbookVersion.from_hash(value) diff --git a/lib/chef/provider/cron/unix.rb b/lib/chef/provider/cron/unix.rb index 15195dbb88..4edd5ba206 100644 --- a/lib/chef/provider/cron/unix.rb +++ b/lib/chef/provider/cron/unix.rb @@ -33,7 +33,7 @@ class Chef private def read_crontab - crontab = shell_out("/usr/bin/crontab -l", :user => @new_resource.user) + crontab = shell_out("/usr/bin/crontab -l", user: @new_resource.user) status = crontab.status.exitstatus logger.trace crontab.format_for_exception if status > 0 @@ -53,7 +53,7 @@ class Chef exit_status = 0 error_message = "" begin - crontab_write = shell_out("/usr/bin/crontab #{tempcron.path}", :user => @new_resource.user) + crontab_write = shell_out("/usr/bin/crontab #{tempcron.path}", user: @new_resource.user) stderr = crontab_write.stderr exit_status = crontab_write.status.exitstatus # solaris9, 10 on some failures for example invalid 'mins' in crontab fails with exit code of zero :( diff --git a/lib/chef/provider/dsc_resource.rb b/lib/chef/provider/dsc_resource.rb index 9c147cb634..3a209a08a1 100644 --- a/lib/chef/provider/dsc_resource.rb +++ b/lib/chef/provider/dsc_resource.rb @@ -169,7 +169,7 @@ class Chef "Invoke-DscResource #{switches}", output_format ) - cmdlet.run!({}, { :timeout => new_resource.timeout }) + cmdlet.run!({}, { timeout: new_resource.timeout }) end def return_dsc_resource_result(result, property_name) diff --git a/lib/chef/provider/dsc_script.rb b/lib/chef/provider/dsc_script.rb index 7a101fa68b..fd20f34786 100644 --- a/lib/chef/provider/dsc_script.rb +++ b/lib/chef/provider/dsc_script.rb @@ -32,10 +32,10 @@ class Chef @dsc_resource = dsc_resource @resource_converged = false @operations = { - :set => Proc.new do |config_manager, document, shellout_flags| + set: Proc.new do |config_manager, document, shellout_flags| config_manager.set_configuration(document, shellout_flags) end, - :test => Proc.new do |config_manager, document, shellout_flags| + test: Proc.new do |config_manager, document, shellout_flags| config_manager.test_configuration(document, shellout_flags) end } end @@ -86,9 +86,9 @@ class Chef config_manager = Chef::Util::DSC::LocalConfigurationManager.new(@run_context.node, config_directory) shellout_flags = { - :cwd => @dsc_resource.cwd, - :environment => @dsc_resource.environment, - :timeout => @dsc_resource.timeout, + cwd: @dsc_resource.cwd, + environment: @dsc_resource.environment, + timeout: @dsc_resource.timeout, } begin @@ -113,9 +113,9 @@ class Chef def generate_configuration_document(config_directory, configuration_flags) shellout_flags = { - :cwd => @dsc_resource.cwd, - :environment => @dsc_resource.environment, - :timeout => @dsc_resource.timeout, + cwd: @dsc_resource.cwd, + environment: @dsc_resource.environment, + timeout: @dsc_resource.timeout, } generator = Chef::Util::DSC::ConfigurationGenerator.new(@run_context.node, config_directory) diff --git a/lib/chef/provider/execute.rb b/lib/chef/provider/execute.rb index 3d3255260f..1b97dbf464 100644 --- a/lib/chef/provider/execute.rb +++ b/lib/chef/provider/execute.rb @@ -102,7 +102,7 @@ class Chef opts[:log_tag] = new_resource.to_s if (logger.info? || live_stream?) && !sensitive? if run_context.events.formatter? - opts[:live_stream] = Chef::EventDispatch::EventsOutputStream.new(run_context.events, :name => :execute) + opts[:live_stream] = Chef::EventDispatch::EventsOutputStream.new(run_context.events, name: :execute) elsif stream_to_stdout? opts[:live_stream] = STDOUT end diff --git a/lib/chef/provider/mdadm.rb b/lib/chef/provider/mdadm.rb index c5f15a851a..9b023b1a65 100644 --- a/lib/chef/provider/mdadm.rb +++ b/lib/chef/provider/mdadm.rb @@ -31,7 +31,7 @@ class Chef logger.trace("#{new_resource} checking for software raid device #{current_resource.raid_device}") device_not_found = 4 - mdadm = shell_out!("mdadm --detail --test #{new_resource.raid_device}", :returns => [0, device_not_found]) + mdadm = shell_out!("mdadm --detail --test #{new_resource.raid_device}", returns: [0, device_not_found]) exists = (mdadm.status == 0) current_resource.exists(exists) end diff --git a/lib/chef/provider/mount/windows.rb b/lib/chef/provider/mount/windows.rb index 590b2bfa52..0fb9184783 100644 --- a/lib/chef/provider/mount/windows.rb +++ b/lib/chef/provider/mount/windows.rb @@ -61,10 +61,10 @@ class Chef def mount_fs unless @current_resource.mounted - @mount.add(:remote => @new_resource.device, - :username => @new_resource.username, - :domainname => @new_resource.domain, - :password => @new_resource.password) + @mount.add(remote: @new_resource.device, + username: @new_resource.username, + domainname: @new_resource.domain, + password: @new_resource.password) logger.trace("#{@new_resource} is mounted at #{@new_resource.mount_point}") else logger.trace("#{@new_resource} is already mounted at #{@new_resource.mount_point}") diff --git a/lib/chef/provider/reboot.rb b/lib/chef/provider/reboot.rb index f054af0567..dd07e7448d 100644 --- a/lib/chef/provider/reboot.rb +++ b/lib/chef/provider/reboot.rb @@ -45,10 +45,10 @@ class Chef # @return [void] def request_reboot node.run_context.request_reboot( - :delay_mins => new_resource.delay_mins, - :reason => new_resource.reason, - :timestamp => Time.now, - :requested_by => new_resource.name + delay_mins: new_resource.delay_mins, + reason: new_resource.reason, + timestamp: Time.now, + requested_by: new_resource.name ) end diff --git a/lib/chef/provider/remote_file/sftp.rb b/lib/chef/provider/remote_file/sftp.rb index 21c5c4ca04..66540fea8c 100644 --- a/lib/chef/provider/remote_file/sftp.rb +++ b/lib/chef/provider/remote_file/sftp.rb @@ -58,7 +58,7 @@ class Chef def sftp host = port ? "#{hostname}:#{port}" : hostname - @sftp ||= Net::SFTP.start(host, user, :password => pass) + @sftp ||= Net::SFTP.start(host, user, password: pass) end def pass diff --git a/lib/chef/provider/service/redhat.rb b/lib/chef/provider/service/redhat.rb index 1da3d7c01a..18ef245083 100644 --- a/lib/chef/provider/service/redhat.rb +++ b/lib/chef/provider/service/redhat.rb @@ -81,7 +81,7 @@ class Chef super if ::File.exists?("/sbin/chkconfig") - chkconfig = shell_out!("/sbin/chkconfig --list #{current_resource.service_name}", :returns => [0, 1]) + chkconfig = shell_out!("/sbin/chkconfig --list #{current_resource.service_name}", returns: [0, 1]) unless run_levels.nil? || run_levels.empty? all_levels_match = true chkconfig.stdout.split(/\s+/)[1..-1].each do |level| diff --git a/lib/chef/provider/service/solaris.rb b/lib/chef/provider/service/solaris.rb index f2b1ec4262..51105bd06f 100644 --- a/lib/chef/provider/service/solaris.rb +++ b/lib/chef/provider/service/solaris.rb @@ -80,7 +80,7 @@ class Chef end def service_status - cmd = shell_out!(@status_command, "-l", @current_resource.service_name, :returns => [0, 1]) + cmd = shell_out!(@status_command, "-l", @current_resource.service_name, returns: [0, 1]) # Example output # $ svcs -l rsyslog # fmri svc:/application/rsyslog:default diff --git a/lib/chef/provider/service/systemd.rb b/lib/chef/provider/service/systemd.rb index badd7695a5..6d5bc338c7 100644 --- a/lib/chef/provider/service/systemd.rb +++ b/lib/chef/provider/service/systemd.rb @@ -79,10 +79,10 @@ class Chef::Provider::Service::Systemd < Chef::Provider::Service::Simple if new_resource.user uid = Etc.getpwnam(new_resource.user).uid options = { - :environment => { + environment: { "DBUS_SESSION_BUS_ADDRESS" => "unix:path=/run/user/#{uid}/bus", }, - :user => new_resource.user, + user: new_resource.user, } args = "--user" else diff --git a/lib/chef/provider/service/windows.rb b/lib/chef/provider/service/windows.rb index 487940e84e..3e177d744b 100644 --- a/lib/chef/provider/service/windows.rb +++ b/lib/chef/provider/service/windows.rb @@ -361,8 +361,8 @@ class Chef::Provider::Service::Windows < Chef::Provider::Service logger.trace "#{@new_resource.name} setting start_type to #{type}" Win32::Service.configure( - :service_name => @new_resource.service_name, - :start_type => startup_type + service_name: @new_resource.service_name, + start_type: startup_type ) @new_resource.updated_by_last_action(true) end diff --git a/lib/chef/provider/subversion.rb b/lib/chef/provider/subversion.rb index abcc260a78..c5c2439d84 100644 --- a/lib/chef/provider/subversion.rb +++ b/lib/chef/provider/subversion.rb @@ -126,7 +126,7 @@ class Chef new_resource.revision else command = scm(:info, new_resource.repository, new_resource.svn_info_args, authentication, "-r#{new_resource.revision}") - svn_info = shell_out!(command, run_options(:cwd => cwd, :returns => [0, 1])).stdout + svn_info = shell_out!(command, run_options(cwd: cwd, returns: [0, 1])).stdout extract_revision_info(svn_info) end @@ -138,7 +138,7 @@ class Chef def find_current_revision return nil unless ::File.exist?(::File.join(new_resource.destination, ".svn")) command = scm(:info) - svn_info = shell_out!(command, run_options(:cwd => cwd, :returns => [0, 1])).stdout + svn_info = shell_out!(command, run_options(cwd: cwd, returns: [0, 1])).stdout extract_revision_info(svn_info) end diff --git a/lib/chef/provider/systemd_unit.rb b/lib/chef/provider/systemd_unit.rb index 0450516d58..44f34fb8d7 100644 --- a/lib/chef/provider/systemd_unit.rb +++ b/lib/chef/provider/systemd_unit.rb @@ -247,8 +247,8 @@ class Chef if new_resource.user uid = Etc.getpwnam(new_resource.user).uid { - :user => new_resource.user, - :environment => { + user: new_resource.user, + environment: { "DBUS_SESSION_BUS_ADDRESS" => "unix:path=/run/user/#{uid}/bus", }, } diff --git a/lib/chef/provider/template/content.rb b/lib/chef/provider/template/content.rb index b40794564a..9ac5a89b3e 100644 --- a/lib/chef/provider/template/content.rb +++ b/lib/chef/provider/template/content.rb @@ -29,7 +29,7 @@ class Chef def template_location @template_file_cache_location ||= begin - template_finder.find(new_resource.source, :local => new_resource.local, :cookbook => new_resource.cookbook) + template_finder.find(new_resource.source, local: new_resource.local, cookbook: new_resource.cookbook) end end diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb index 478637ff4e..a30504bc91 100644 --- a/lib/chef/resource.rb +++ b/lib/chef/resource.rb @@ -469,7 +469,7 @@ class Chef if arg.nil? @guard_interpreter || @default_guard_interpreter else - set_or_return(:guard_interpreter, arg, :kind_of => Symbol) + set_or_return(:guard_interpreter, arg, kind_of: Symbol) end end diff --git a/lib/chef/resource/cron.rb b/lib/chef/resource/cron.rb index ea6d692709..57cc483c8a 100644 --- a/lib/chef/resource/cron.rb +++ b/lib/chef/resource/cron.rb @@ -55,7 +55,7 @@ class Chef set_or_return( :minute, converted_arg, - :kind_of => String + kind_of: String ) end @@ -72,7 +72,7 @@ class Chef set_or_return( :hour, converted_arg, - :kind_of => String + kind_of: String ) end @@ -89,7 +89,7 @@ class Chef set_or_return( :day, converted_arg, - :kind_of => String + kind_of: String ) end @@ -106,7 +106,7 @@ class Chef set_or_return( :month, converted_arg, - :kind_of => String + kind_of: String ) end @@ -130,7 +130,7 @@ class Chef set_or_return( :weekday, converted_arg, - :kind_of => [String, Symbol] + kind_of: [String, Symbol] ) end diff --git a/lib/chef/resource/dsc_script.rb b/lib/chef/resource/dsc_script.rb index f3fa5d0314..7d1e11b659 100644 --- a/lib/chef/resource/dsc_script.rb +++ b/lib/chef/resource/dsc_script.rb @@ -54,7 +54,7 @@ class Chef set_or_return( :code, arg, - :kind_of => [ String ] + kind_of: [ String ] ) end @@ -65,7 +65,7 @@ class Chef set_or_return( :configuration_name, arg, - :kind_of => [ String ] + kind_of: [ String ] ) end @@ -76,7 +76,7 @@ class Chef set_or_return( :command, arg, - :kind_of => [ String ] + kind_of: [ String ] ) end @@ -87,7 +87,7 @@ class Chef set_or_return( :configuration_data, arg, - :kind_of => [ String ] + kind_of: [ String ] ) end @@ -98,7 +98,7 @@ class Chef set_or_return( :configuration_data_script, arg, - :kind_of => [ String ] + kind_of: [ String ] ) end diff --git a/lib/chef/resource/execute.rb b/lib/chef/resource/execute.rb index 7003b546fe..dfccfeb138 100644 --- a/lib/chef/resource/execute.rb +++ b/lib/chef/resource/execute.rb @@ -52,7 +52,7 @@ class Chef set_or_return( :command, arg, - :kind_of => [ String, Array ] + kind_of: [ String, Array ] ) end property :umask, [ String, Integer ] diff --git a/lib/chef/resource/file/verification.rb b/lib/chef/resource/file/verification.rb index 578e6066a2..ae4f9043b2 100644 --- a/lib/chef/resource/file/verification.rb +++ b/lib/chef/resource/file/verification.rb @@ -113,7 +113,7 @@ class Chef if @command.include?("%{file}") raise ArgumentError, "The %{file} expansion for verify commands has been removed. Please use %{path} instead." end - command = @command % { :path => path } + command = @command % { path: path } interpreter = Chef::GuardInterpreter.for_resource(@parent_resource, command, @command_opts) interpreter.evaluate end diff --git a/lib/chef/resource/freebsd_package.rb b/lib/chef/resource/freebsd_package.rb index e85a75e906..f5e4010ee7 100644 --- a/lib/chef/resource/freebsd_package.rb +++ b/lib/chef/resource/freebsd_package.rb @@ -46,7 +46,7 @@ class Chef # # @return [Boolean] do we support pkgng def supports_pkgng? - ships_with_pkgng? || !!shell_out!("make", "-V", "WITH_PKGNG", :env => nil).stdout.match(/yes/i) + ships_with_pkgng? || !!shell_out!("make", "-V", "WITH_PKGNG", env: nil).stdout.match(/yes/i) end private diff --git a/lib/chef/resource/group.rb b/lib/chef/resource/group.rb index 9298fbc150..b67bfe188e 100644 --- a/lib/chef/resource/group.rb +++ b/lib/chef/resource/group.rb @@ -41,7 +41,7 @@ class Chef set_or_return( :members, converted_members, - :kind_of => [ Array ] + kind_of: [ Array ] ) end @@ -52,7 +52,7 @@ class Chef set_or_return( :excluded_members, converted_members, - :kind_of => [ Array ] + kind_of: [ Array ] ) end diff --git a/lib/chef/resource/hostname.rb b/lib/chef/resource/hostname.rb index 02996f4464..f213ae47ad 100644 --- a/lib/chef/resource/hostname.rb +++ b/lib/chef/resource/hostname.rb @@ -132,7 +132,7 @@ class Chef # this must come before other methods like /etc/hostname and /etc/sysconfig/network declare_resource(:execute, "hostnamectl set-hostname #{new_resource.hostname}") do notifies :reload, "ohai[reload hostname]" - not_if { shell_out!("hostnamectl status", { :returns => [0, 1] }).stdout =~ /Static hostname:\s*#{new_resource.hostname}\s*$/ } + not_if { shell_out!("hostnamectl status", { returns: [0, 1] }).stdout =~ /Static hostname:\s*#{new_resource.hostname}\s*$/ } end when ::File.exist?("/etc/hostname") # debian family uses /etc/hostname diff --git a/lib/chef/resource/http_request.rb b/lib/chef/resource/http_request.rb index 3493cec9db..6e92fb821c 100644 --- a/lib/chef/resource/http_request.rb +++ b/lib/chef/resource/http_request.rb @@ -48,7 +48,7 @@ class Chef set_or_return( :message, args, - :kind_of => Object + kind_of: Object ) end diff --git a/lib/chef/resource/powershell_script.rb b/lib/chef/resource/powershell_script.rb index 99821bcefd..95efadd4e6 100644 --- a/lib/chef/resource/powershell_script.rb +++ b/lib/chef/resource/powershell_script.rb @@ -40,7 +40,7 @@ class Chef set_or_return( :convert_boolean_return, arg, - :kind_of => [ FalseClass, TrueClass ] + kind_of: [ FalseClass, TrueClass ] ) end @@ -52,7 +52,7 @@ class Chef # guard context and recipe resource context will have the # same behavior. def self.get_default_attributes(opts) - { :convert_boolean_return => true } + { convert_boolean_return: true } end end end diff --git a/lib/chef/resource/remote_directory.rb b/lib/chef/resource/remote_directory.rb index daeb7b35bb..f03b13ef02 100644 --- a/lib/chef/resource/remote_directory.rb +++ b/lib/chef/resource/remote_directory.rb @@ -63,7 +63,7 @@ class Chef set_or_return( :files_group, arg, - :regex => Chef::Config[:group_valid_regex] + regex: Chef::Config[:group_valid_regex] ) end @@ -71,7 +71,7 @@ class Chef set_or_return( :files_mode, arg, - :regex => /^\d{3,4}$/ + regex: /^\d{3,4}$/ ) end @@ -79,7 +79,7 @@ class Chef set_or_return( :files_owner, arg, - :regex => Chef::Config[:user_valid_regex] + regex: Chef::Config[:user_valid_regex] ) end end diff --git a/lib/chef/resource/remote_file.rb b/lib/chef/resource/remote_file.rb index 832fd3568e..3607a3cbc5 100644 --- a/lib/chef/resource/remote_file.rb +++ b/lib/chef/resource/remote_file.rb @@ -48,8 +48,8 @@ class Chef arg = parse_source_args(args) ret = set_or_return(:source, arg, - { :callbacks => { - :validate_source => method(:validate_source), + { callbacks: { + validate_source: method(:validate_source), } }) if ret.is_a? String Array(ret) diff --git a/lib/chef/resource/service.rb b/lib/chef/resource/service.rb index 07473c9709..fe13c433cb 100644 --- a/lib/chef/resource/service.rb +++ b/lib/chef/resource/service.rb @@ -62,7 +62,7 @@ class Chef set_or_return( :service_name, arg, - :kind_of => [ String ] + kind_of: [ String ] ) end @@ -71,7 +71,7 @@ class Chef set_or_return( :pattern, arg, - :kind_of => [ String ] + kind_of: [ String ] ) end @@ -80,7 +80,7 @@ class Chef set_or_return( :start_command, arg, - :kind_of => [ String, NilClass, FalseClass ] + kind_of: [ String, NilClass, FalseClass ] ) end @@ -89,7 +89,7 @@ class Chef set_or_return( :stop_command, arg, - :kind_of => [ String, NilClass, FalseClass ] + kind_of: [ String, NilClass, FalseClass ] ) end @@ -98,7 +98,7 @@ class Chef set_or_return( :status_command, arg, - :kind_of => [ String, NilClass, FalseClass ] + kind_of: [ String, NilClass, FalseClass ] ) end @@ -107,7 +107,7 @@ class Chef set_or_return( :restart_command, arg, - :kind_of => [ String, NilClass, FalseClass ] + kind_of: [ String, NilClass, FalseClass ] ) end @@ -115,7 +115,7 @@ class Chef set_or_return( :reload_command, arg, - :kind_of => [ String, NilClass, FalseClass ] + kind_of: [ String, NilClass, FalseClass ] ) end @@ -128,7 +128,7 @@ class Chef set_or_return( :init_command, arg, - :kind_of => [ String ] + kind_of: [ String ] ) end @@ -137,7 +137,7 @@ class Chef set_or_return( :enabled, arg, - :kind_of => [ TrueClass, FalseClass ] + kind_of: [ TrueClass, FalseClass ] ) end @@ -146,7 +146,7 @@ class Chef set_or_return( :running, arg, - :kind_of => [ TrueClass, FalseClass ] + kind_of: [ TrueClass, FalseClass ] ) end @@ -155,7 +155,7 @@ class Chef set_or_return( :masked, arg, - :kind_of => [ TrueClass, FalseClass ] + kind_of: [ TrueClass, FalseClass ] ) end @@ -163,7 +163,7 @@ class Chef set_or_return( :options, arg.respond_to?(:split) ? arg.shellsplit : arg, - :kind_of => [ Array, String ] + kind_of: [ Array, String ] ) end @@ -181,7 +181,7 @@ class Chef set_or_return( :priority, arg, - :kind_of => [ Integer, String, Hash ] + kind_of: [ Integer, String, Hash ] ) end @@ -190,7 +190,7 @@ class Chef set_or_return( :timeout, arg, - :kind_of => Integer + kind_of: Integer ) end @@ -198,7 +198,7 @@ class Chef set_or_return( :parameters, arg, - :kind_of => [ Hash ] + kind_of: [ Hash ] ) end @@ -206,14 +206,14 @@ class Chef set_or_return( :run_levels, arg, - :kind_of => [ Array ] ) + kind_of: [ Array ] ) end def user(arg = nil) set_or_return( :user, arg, - :kind_of => [ String ] + kind_of: [ String ] ) end end diff --git a/lib/chef/resource/template.rb b/lib/chef/resource/template.rb index 5fc29ec1c6..45879db8e6 100644 --- a/lib/chef/resource/template.rb +++ b/lib/chef/resource/template.rb @@ -53,7 +53,7 @@ class Chef set_or_return( :source, file, - :kind_of => [ String, Array ] + kind_of: [ String, Array ] ) end diff --git a/lib/chef/resource/user.rb b/lib/chef/resource/user.rb index 39d8159d4f..df52ebb083 100644 --- a/lib/chef/resource/user.rb +++ b/lib/chef/resource/user.rb @@ -51,7 +51,7 @@ class Chef set_or_return( :username, arg, - :kind_of => [ String ] + kind_of: [ String ] ) end @@ -59,7 +59,7 @@ class Chef set_or_return( :comment, arg, - :kind_of => [ String ] + kind_of: [ String ] ) end @@ -67,8 +67,8 @@ class Chef set_or_return( :uid, arg, - :kind_of => [ String, Integer, NilClass ], - :coerce => proc { |x| x || nil } + kind_of: [ String, Integer, NilClass ], + coerce: proc { |x| x || nil } ) end @@ -76,8 +76,8 @@ class Chef set_or_return( :gid, arg, - :kind_of => [ String, Integer, NilClass ], - :coerce => proc { |x| x || nil } + kind_of: [ String, Integer, NilClass ], + coerce: proc { |x| x || nil } ) end @@ -87,7 +87,7 @@ class Chef set_or_return( :home, arg, - :kind_of => [ String ] + kind_of: [ String ] ) end @@ -95,7 +95,7 @@ class Chef set_or_return( :shell, arg, - :kind_of => [ String ] + kind_of: [ String ] ) end @@ -103,7 +103,7 @@ class Chef set_or_return( :password, arg, - :kind_of => [ String ] + kind_of: [ String ] ) end @@ -111,7 +111,7 @@ class Chef set_or_return( :salt, arg, - :kind_of => [ String ] + kind_of: [ String ] ) end @@ -119,7 +119,7 @@ class Chef set_or_return( :iterations, arg, - :kind_of => [ Integer ] + kind_of: [ Integer ] ) end @@ -127,7 +127,7 @@ class Chef set_or_return( :system, arg, - :kind_of => [ TrueClass, FalseClass ] + kind_of: [ TrueClass, FalseClass ] ) end @@ -135,7 +135,7 @@ class Chef set_or_return( :manage_home, arg, - :kind_of => [ TrueClass, FalseClass ] + kind_of: [ TrueClass, FalseClass ] ) end @@ -143,7 +143,7 @@ class Chef set_or_return( :force, arg, - :kind_of => [ TrueClass, FalseClass ] + kind_of: [ TrueClass, FalseClass ] ) end @@ -151,7 +151,7 @@ class Chef set_or_return( :non_unique, arg, - :kind_of => [ TrueClass, FalseClass ] + kind_of: [ TrueClass, FalseClass ] ) end end diff --git a/lib/chef/resource/windows_script.rb b/lib/chef/resource/windows_script.rb index 7c39d9fba0..fe3e37989d 100644 --- a/lib/chef/resource/windows_script.rb +++ b/lib/chef/resource/windows_script.rb @@ -45,7 +45,7 @@ class Chef result = set_or_return( :architecture, arg, - :kind_of => Symbol + kind_of: Symbol ) end diff --git a/lib/chef/resource_reporter.rb b/lib/chef/resource_reporter.rb index c76ac0a4a3..aa1e427bc5 100644 --- a/lib/chef/resource_reporter.rb +++ b/lib/chef/resource_reporter.rb @@ -120,8 +120,8 @@ class Chef if reporting_enabled? begin resource_history_url = "reports/nodes/#{node_name}/runs" - server_response = @rest_client.post(resource_history_url, { :action => :start, :run_id => run_id, - :start_time => start_time.to_s }, headers) + server_response = @rest_client.post(resource_history_url, { action: :start, run_id: run_id, + start_time: start_time.to_s }, headers) rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e handle_error_starting_run(e, resource_history_url) end diff --git a/lib/chef/role.rb b/lib/chef/role.rb index ad01e9fa26..96aa2185ff 100644 --- a/lib/chef/role.rb +++ b/lib/chef/role.rb @@ -55,7 +55,7 @@ class Chef set_or_return( :name, arg, - :regex => /^[\-[:alnum:]_]+$/ + regex: /^[\-[:alnum:]_]+$/ ) end @@ -63,7 +63,7 @@ class Chef set_or_return( :description, arg, - :kind_of => String + kind_of: String ) end @@ -118,7 +118,7 @@ class Chef set_or_return( :default_attributes, arg, - :kind_of => Hash + kind_of: Hash ) end @@ -126,7 +126,7 @@ class Chef set_or_return( :override_attributes, arg, - :kind_of => Hash + kind_of: Hash ) end diff --git a/lib/chef/run_list/run_list_expansion.rb b/lib/chef/run_list/run_list_expansion.rb index b895b53523..085dd9f6be 100644 --- a/lib/chef/run_list/run_list_expansion.rb +++ b/lib/chef/run_list/run_list_expansion.rb @@ -148,8 +148,8 @@ class Chef end def to_hash - seen_items = { :recipe => {}, :role => {} } - { :id => @environment, :run_list => convert_run_list_trace("top level", seen_items) } + seen_items = { recipe: {}, role: {} } + { id: @environment, run_list: convert_run_list_trace("top level", seen_items) } end private @@ -185,12 +185,12 @@ class Chef seen_items[item.type][item.name] = true case item.type when :recipe - { :type => "recipe", :name => item.name, :version => item.version, :skipped => !!skipped } + { type: "recipe", name: item.name, version: item.version, skipped: !!skipped } when :role error = @role_errors[item.name] missing = @all_missing_roles[item.name] - { :type => :role, :name => item.name, :children => (missing || error || skipped) ? [] : convert_run_list_trace(item.to_s, seen_items), - :missing => missing, :error => error, :skipped => skipped } + { type: :role, name: item.name, children: (missing || error || skipped) ? [] : convert_run_list_trace(item.to_s, seen_items), + missing: missing, error: error, skipped: skipped } end end end diff --git a/lib/chef/run_list/versioned_recipe_list.rb b/lib/chef/run_list/versioned_recipe_list.rb index ad769ee952..d9b3c17db3 100644 --- a/lib/chef/run_list/versioned_recipe_list.rb +++ b/lib/chef/run_list/versioned_recipe_list.rb @@ -40,7 +40,7 @@ class Chef end def with_versions - map { |recipe_name| { :name => recipe_name, :version => @versions[recipe_name] } } + map { |recipe_name| { name: recipe_name, version: @versions[recipe_name] } } end # Return an Array of Hashes, each of the form: @@ -48,7 +48,7 @@ class Chef def with_version_constraints map do |recipe_name| constraint = Chef::VersionConstraint.new(@versions[recipe_name]) - { :name => recipe_name, :version_constraint => constraint } + { name: recipe_name, version_constraint: constraint } end end diff --git a/lib/chef/run_status.rb b/lib/chef/run_status.rb index c3b7945bc9..9a52f846c7 100644 --- a/lib/chef/run_status.rb +++ b/lib/chef/run_status.rb @@ -104,16 +104,16 @@ class Chef::RunStatus # * :backtrace def to_hash # use a flat hash here so we can't errors from intermediate values being nil - { :node => node, - :success => success?, - :start_time => start_time, - :end_time => end_time, - :elapsed_time => elapsed_time, - :all_resources => all_resources, - :updated_resources => updated_resources, - :exception => formatted_exception, - :backtrace => backtrace, - :run_id => run_id } + { node: node, + success: success?, + start_time: start_time, + end_time: end_time, + elapsed_time: elapsed_time, + all_resources: all_resources, + updated_resources: updated_resources, + exception: formatted_exception, + backtrace: backtrace, + run_id: run_id } end # Returns a string of the format "ExceptionClass: message" or +nil+ if no diff --git a/lib/chef/shell.rb b/lib/chef/shell.rb index 88d26e78fc..70c93f653b 100644 --- a/lib/chef/shell.rb +++ b/lib/chef/shell.rb @@ -218,80 +218,80 @@ When no CONFIG is specified, chef-shell attempts to load a default configuration FOOTER option :config_file, - :short => "-c CONFIG", - :long => "--config CONFIG", - :description => "The configuration file to use" + short: "-c CONFIG", + long: "--config CONFIG", + description: "The configuration file to use" option :help, - :short => "-h", - :long => "--help", - :description => "Show this message", - :on => :tail, - :boolean => true, - :proc => proc { print_help } + short: "-h", + long: "--help", + description: "Show this message", + on: :tail, + boolean: true, + proc: proc { print_help } option :log_level, - :short => "-l LOG_LEVEL", - :long => "--log-level LOG_LEVEL", - :description => "Set the logging level", - :proc => proc { |level| Chef::Config.log_level = level.to_sym; Shell.setup_logger } + short: "-l LOG_LEVEL", + long: "--log-level LOG_LEVEL", + description: "Set the logging level", + proc: proc { |level| Chef::Config.log_level = level.to_sym; Shell.setup_logger } option :standalone, - :short => "-a", - :long => "--standalone", - :description => "standalone session", - :default => true, - :boolean => true + short: "-a", + long: "--standalone", + description: "standalone session", + default: true, + boolean: true option :solo_shell, - :short => "-s", - :long => "--solo", - :description => "chef-solo session", - :boolean => true, - :proc => proc { Chef::Config[:solo] = true } + short: "-s", + long: "--solo", + description: "chef-solo session", + boolean: true, + proc: proc { Chef::Config[:solo] = true } option :client, - :short => "-z", - :long => "--client", - :description => "chef-client session", - :boolean => true + short: "-z", + long: "--client", + description: "chef-client session", + boolean: true option :solo_legacy_shell, - :long => "--solo-legacy-mode", - :description => "chef-solo legacy session", - :boolean => true, - :proc => proc { Chef::Config[:solo_legacy_mode] = true } + long: "--solo-legacy-mode", + description: "chef-solo legacy session", + boolean: true, + proc: proc { Chef::Config[:solo_legacy_mode] = true } option :json_attribs, - :short => "-j JSON_ATTRIBS", - :long => "--json-attributes JSON_ATTRIBS", - :description => "Load attributes from a JSON file or URL", - :proc => nil + short: "-j JSON_ATTRIBS", + long: "--json-attributes JSON_ATTRIBS", + description: "Load attributes from a JSON file or URL", + proc: nil option :chef_server_url, - :short => "-S CHEFSERVERURL", - :long => "--server CHEFSERVERURL", - :description => "The chef server URL", - :proc => nil + short: "-S CHEFSERVERURL", + long: "--server CHEFSERVERURL", + description: "The chef server URL", + proc: nil option :version, - :short => "-v", - :long => "--version", - :description => "Show chef version", - :boolean => true, - :proc => lambda { |v| puts "Chef: #{::Chef::VERSION}" }, - :exit => 0 + short: "-v", + long: "--version", + description: "Show chef version", + boolean: true, + proc: lambda { |v| puts "Chef: #{::Chef::VERSION}" }, + exit: 0 option :override_runlist, - :short => "-o RunlistItem,RunlistItem...", - :long => "--override-runlist RunlistItem,RunlistItem...", - :description => "Replace current run list with specified items", - :proc => lambda { |items| items.split(",").map { |item| Chef::RunList::RunListItem.new(item) } } + short: "-o RunlistItem,RunlistItem...", + long: "--override-runlist RunlistItem,RunlistItem...", + description: "Replace current run list with specified items", + proc: lambda { |items| items.split(",").map { |item| Chef::RunList::RunListItem.new(item) } } option :skip_cookbook_sync, - :long => "--[no-]skip-cookbook-sync", - :description => "Use cached cookbooks without overwriting local differences from the server", - :boolean => false + long: "--[no-]skip-cookbook-sync", + description: "Use cached cookbooks without overwriting local differences from the server", + boolean: false def self.print_help instance = new diff --git a/lib/chef/shell/ext.rb b/lib/chef/shell/ext.rb index fb0733e96e..727eb6b344 100644 --- a/lib/chef/shell/ext.rb +++ b/lib/chef/shell/ext.rb @@ -239,10 +239,10 @@ module Shell end desc "returns an object to control a paused chef run" - subcommands :resume => "resume the chef run", - :step => "run only the next resource", - :skip_back => "move back in the run list", - :skip_forward => "move forward in the run list" + subcommands resume: "resume the chef run", + step: "run only the next resource", + skip_back: "move back in the run list", + skip_forward: "move forward in the run list" def chef_run Shell.session.resource_collection.iterator end @@ -393,18 +393,18 @@ module Shell This will strip the admin privileges from any client named after borat. E - subcommands :all => "list all api clients", - :show => "load an api client by name", - :search => "search for API clients", - :transform => "edit all api clients via a code block and save them" + subcommands all: "list all api clients", + show: "load an api client by name", + search: "search for API clients", + transform: "edit all api clients via a code block and save them" def clients @clients ||= Shell::ModelWrapper.new(Chef::ApiClient, :client) end desc "Find and edit cookbooks" - subcommands :all => "list all cookbooks", - :show => "load a cookbook by name", - :transform => "edit all cookbooks via a code block and save them" + subcommands all: "list all cookbooks", + show: "load a cookbook by name", + transform: "edit all cookbooks via a code block and save them" def cookbooks @cookbooks ||= Shell::ModelWrapper.new(Chef::CookbookVersion) end @@ -455,10 +455,10 @@ module Shell This will assign the attribute to every node with a FQDN matching the regex. E - subcommands :all => "list all nodes", - :show => "load a node by name", - :search => "search for nodes", - :transform => "edit all nodes via a code block and save them" + subcommands all: "list all nodes", + show: "load a node by name", + search: "search for nodes", + transform: "edit all nodes via a code block and save them" def nodes @nodes ||= Shell::ModelWrapper.new(Chef::Node) end @@ -477,10 +477,10 @@ module Shell ## SEE ALSO ## See the help for +nodes+ for more information about the subcommands. E - subcommands :all => "list all roles", - :show => "load a role by name", - :search => "search for roles", - :transform => "edit all roles via a code block and save them" + subcommands all: "list all roles", + show: "load a role by name", + search: "search for roles", + transform: "edit all roles via a code block and save them" def roles @roles ||= Shell::ModelWrapper.new(Chef::Role) end @@ -503,10 +503,10 @@ module Shell See the help for +nodes+ for more information about the subcommands. E - subcommands :all => "list all items in the data bag", - :show => "load a data bag item by id", - :search => "search for items in the data bag", - :transform => "edit all items via a code block and save them" + subcommands all: "list all items in the data bag", + show: "load a data bag item by id", + search: "search for items in the data bag", + transform: "edit all items via a code block and save them" def databags(databag_name) @named_databags_wrappers ||= {} @named_databags_wrappers[databag_name] ||= Shell::NamedDataBagWrapper.new(databag_name) @@ -526,10 +526,10 @@ module Shell ## SEE ALSO ## See the help for +nodes+ for more information about the subcommands. E - subcommands :all => "list all environments", - :show => "load an environment by name", - :search => "search for environments", - :transform => "edit all environments via a code block and save them" + subcommands all: "list all environments", + show: "load an environment by name", + search: "search for environments", + transform: "edit all environments via a code block and save them" def environments @environments ||= Shell::ModelWrapper.new(Chef::Environment) end diff --git a/lib/chef/shell/shell_session.rb b/lib/chef/shell/shell_session.rb index aec2152063..789a022b56 100644 --- a/lib/chef/shell/shell_session.rb +++ b/lib/chef/shell/shell_session.rb @@ -264,8 +264,8 @@ module Shell end def register - @rest = Chef::ServerAPI.new(Chef::Config[:chef_server_url], :client_name => Chef::Config[:node_name], - :signing_key_filename => Chef::Config[:client_key]) + @rest = Chef::ServerAPI.new(Chef::Config[:chef_server_url], client_name: Chef::Config[:node_name], + signing_key_filename: Chef::Config[:client_key]) end end diff --git a/lib/chef/user.rb b/lib/chef/user.rb index f52d0e2555..eba55c4186 100644 --- a/lib/chef/user.rb +++ b/lib/chef/user.rb @@ -49,32 +49,32 @@ class Chef end def chef_rest_v0 - @chef_rest_v0 ||= Chef::ServerAPI.new(Chef::Config[:chef_server_url], { :api_version => "0" }) + @chef_rest_v0 ||= Chef::ServerAPI.new(Chef::Config[:chef_server_url], { api_version: "0" }) end def name(arg = nil) set_or_return(:name, arg, - :regex => /^[a-z0-9\-_]+$/) + regex: /^[a-z0-9\-_]+$/) end def admin(arg = nil) set_or_return(:admin, - arg, :kind_of => [TrueClass, FalseClass]) + arg, kind_of: [TrueClass, FalseClass]) end def public_key(arg = nil) set_or_return(:public_key, - arg, :kind_of => String) + arg, kind_of: String) end def private_key(arg = nil) set_or_return(:private_key, - arg, :kind_of => String) + arg, kind_of: String) end def password(arg = nil) set_or_return(:password, - arg, :kind_of => String) + arg, kind_of: String) end def to_hash @@ -97,14 +97,14 @@ class Chef end def create - payload = { :name => name, :admin => admin, :password => password } + payload = { name: name, admin: admin, password: password } payload[:public_key] = public_key if public_key new_user = chef_rest_v0.post("users", payload) Chef::User.from_hash(to_hash.merge(new_user)) end def update(new_key = false) - payload = { :name => name, :admin => admin } + payload = { name: name, admin: admin } payload[:private_key] = new_key if new_key payload[:password] = password if password updated_user = chef_rest_v0.put("users/#{name}", payload) @@ -122,7 +122,7 @@ class Chef end def reregister - reregistered_self = chef_rest_v0.put("users/#{name}", { :name => name, :admin => admin, :private_key => true }) + reregistered_self = chef_rest_v0.put("users/#{name}", { name: name, admin: admin, private_key: true }) private_key(reregistered_self["private_key"]) self end @@ -153,7 +153,7 @@ class Chef end def self.list(inflate = false) - response = Chef::ServerAPI.new(Chef::Config[:chef_server_url], { :api_version => "0" }).get("users") + response = Chef::ServerAPI.new(Chef::Config[:chef_server_url], { api_version: "0" }).get("users") users = if response.is_a?(Array) transform_ohc_list_response(response) # OHC/OPC else @@ -170,7 +170,7 @@ class Chef end def self.load(name) - response = Chef::ServerAPI.new(Chef::Config[:chef_server_url], { :api_version => "0" }).get("users/#{name}") + response = Chef::ServerAPI.new(Chef::Config[:chef_server_url], { api_version: "0" }).get("users/#{name}") Chef::User.from_hash(response) end diff --git a/lib/chef/user_v1.rb b/lib/chef/user_v1.rb index 0ca17c6ed6..8bd92dfab8 100644 --- a/lib/chef/user_v1.rb +++ b/lib/chef/user_v1.rb @@ -55,61 +55,61 @@ class Chef end def chef_root_rest_v0 - @chef_root_rest_v0 ||= Chef::ServerAPI.new(Chef::Config[:chef_server_root], { :api_version => "0" }) + @chef_root_rest_v0 ||= Chef::ServerAPI.new(Chef::Config[:chef_server_root], { api_version: "0" }) end def chef_root_rest_v1 - @chef_root_rest_v1 ||= Chef::ServerAPI.new(Chef::Config[:chef_server_root], { :api_version => "1" }) + @chef_root_rest_v1 ||= Chef::ServerAPI.new(Chef::Config[:chef_server_root], { api_version: "1" }) end def username(arg = nil) set_or_return(:username, arg, - :regex => /^[a-z0-9\-_]+$/) + regex: /^[a-z0-9\-_]+$/) end def display_name(arg = nil) set_or_return(:display_name, - arg, :kind_of => String) + arg, kind_of: String) end def first_name(arg = nil) set_or_return(:first_name, - arg, :kind_of => String) + arg, kind_of: String) end def middle_name(arg = nil) set_or_return(:middle_name, - arg, :kind_of => String) + arg, kind_of: String) end def last_name(arg = nil) set_or_return(:last_name, - arg, :kind_of => String) + arg, kind_of: String) end def email(arg = nil) set_or_return(:email, - arg, :kind_of => String) + arg, kind_of: String) end def create_key(arg = nil) set_or_return(:create_key, arg, - :kind_of => [TrueClass, FalseClass]) + kind_of: [TrueClass, FalseClass]) end def public_key(arg = nil) set_or_return(:public_key, - arg, :kind_of => String) + arg, kind_of: String) end def private_key(arg = nil) set_or_return(:private_key, - arg, :kind_of => String) + arg, kind_of: String) end def password(arg = nil) set_or_return(:password, - arg, :kind_of => String) + arg, kind_of: String) end def to_hash @@ -141,12 +141,12 @@ class Chef # try v1, fail back to v0 if v1 not supported begin payload = { - :username => @username, - :display_name => @display_name, - :first_name => @first_name, - :last_name => @last_name, - :email => @email, - :password => @password, + username: @username, + display_name: @display_name, + first_name: @first_name, + last_name: @last_name, + email: @email, + password: @password, } payload[:public_key] = @public_key unless @public_key.nil? payload[:create_key] = @create_key unless @create_key.nil? @@ -167,12 +167,12 @@ class Chef supported_versions = server_client_api_version_intersection(e, SUPPORTED_API_VERSIONS) raise e unless supported_versions && supported_versions.include?(0) payload = { - :username => @username, - :display_name => @display_name, - :first_name => @first_name, - :last_name => @last_name, - :email => @email, - :password => @password, + username: @username, + display_name: @display_name, + first_name: @first_name, + last_name: @last_name, + email: @email, + password: @password, } payload[:middle_name] = @middle_name unless @middle_name.nil? payload[:public_key] = @public_key unless @public_key.nil? @@ -185,7 +185,7 @@ class Chef def update(new_key = false) begin - payload = { :username => username } + payload = { username: username } payload[:display_name] = display_name unless display_name.nil? payload[:first_name] = first_name unless first_name.nil? payload[:middle_name] = middle_name unless middle_name.nil? diff --git a/lib/chef/util/backup.rb b/lib/chef/util/backup.rb index 8bf2b3f25b..a14f006d59 100644 --- a/lib/chef/util/backup.rb +++ b/lib/chef/util/backup.rb @@ -69,7 +69,7 @@ class Chef def do_backup FileUtils.mkdir_p(::File.dirname(backup_path)) if Chef::Config[:file_backup_path] - FileUtils.cp(path, backup_path, :preserve => true) + FileUtils.cp(path, backup_path, preserve: true) Chef::Log.info("#{@new_resource} backed up to #{backup_path}") end diff --git a/lib/chef/util/diff.rb b/lib/chef/util/diff.rb index b5c85df56d..decff35d85 100644 --- a/lib/chef/util/diff.rb +++ b/lib/chef/util/diff.rb @@ -176,7 +176,7 @@ class Chef end def encode_diff_for_json(diff_str) - diff_str.encode!("UTF-8", :invalid => :replace, :undef => :replace, :replace => "?") + diff_str.encode!("UTF-8", invalid: :replace, undef: :replace, replace: "?") end end diff --git a/lib/chef/util/dsc/configuration_generator.rb b/lib/chef/util/dsc/configuration_generator.rb index 3e9475bac2..78092b3c0d 100644 --- a/lib/chef/util/dsc/configuration_generator.rb +++ b/lib/chef/util/dsc/configuration_generator.rb @@ -68,7 +68,7 @@ class Chef::Util::DSC end def get_merged_configuration_flags!(configuration_flags, configuration_name) - merged_configuration_flags = { :outputpath => configuration_document_directory(configuration_name) } + merged_configuration_flags = { outputpath: configuration_document_directory(configuration_name) } if configuration_flags configuration_flags.map do |switch, value| if merged_configuration_flags.key?(switch.to_s.downcase.to_sym) diff --git a/lib/chef/util/dsc/lcm_output_parser.rb b/lib/chef/util/dsc/lcm_output_parser.rb index 658d5c7d8f..b164db6b19 100644 --- a/lib/chef/util/dsc/lcm_output_parser.rb +++ b/lib/chef/util/dsc/lcm_output_parser.rb @@ -128,7 +128,7 @@ class Chef if current_resource[:name] resources.push(current_resource) end - current_resource = { :name => info } + current_resource = { name: info } else Chef::Log.trace("Ignoring op_action #{op_action}: Read line #{line}") end diff --git a/lib/chef/util/file_edit.rb b/lib/chef/util/file_edit.rb index 5aa33fd169..74e2ca6a5f 100644 --- a/lib/chef/util/file_edit.rb +++ b/lib/chef/util/file_edit.rb @@ -84,7 +84,7 @@ class Chef def write_file if @changes backup_pathname = original_pathname + ".old" - FileUtils.cp(original_pathname, backup_pathname, :preserve => true) + FileUtils.cp(original_pathname, backup_pathname, preserve: true) File.open(original_pathname, "w") do |newfile| editor.lines.each do |line| newfile.puts(line) diff --git a/lib/chef/util/powershell/cmdlet.rb b/lib/chef/util/powershell/cmdlet.rb index e300266b1e..edd3e92da1 100644 --- a/lib/chef/util/powershell/cmdlet.rb +++ b/lib/chef/util/powershell/cmdlet.rb @@ -48,8 +48,8 @@ class Chef attr_reader :output_format def run(switches = {}, execution_options = {}, *arguments) - streams = { :json => CmdletStream.new("json"), - :verbose => CmdletStream.new("verbose"), + streams = { json: CmdletStream.new("json"), + verbose: CmdletStream.new("verbose"), } arguments_string = arguments.join(" ") @@ -74,7 +74,7 @@ class Chef "#{arguments_string} #{redirections}"\ "#{json_command}\";if ( ! $? ) { exit 1 }" - augmented_options = { :returns => [0], :live_stream => false }.merge(execution_options) + augmented_options = { returns: [0], live_stream: false }.merge(execution_options) command = Mixlib::ShellOut.new(command_string, augmented_options) status = nil diff --git a/lib/chef/util/selinux.rb b/lib/chef/util/selinux.rb index fb0c98cff5..a46e486f96 100644 --- a/lib/chef/util/selinux.rb +++ b/lib/chef/util/selinux.rb @@ -72,7 +72,7 @@ class Chef def check_selinux_enabled? if selinuxenabled_path - cmd = shell_out!(selinuxenabled_path, :returns => [0, 1]) + cmd = shell_out!(selinuxenabled_path, returns: [0, 1]) case cmd.exitstatus when 1 return false diff --git a/lib/chef/win32/registry.rb b/lib/chef/win32/registry.rb index 1193911b00..b1365fd61b 100644 --- a/lib/chef/win32/registry.rb +++ b/lib/chef/win32/registry.rb @@ -56,7 +56,7 @@ class Chef hive, key = get_hive_and_key(key_path) key_exists!(key_path) values = hive.open(key, ::Win32::Registry::KEY_READ | registry_system_architecture) do |reg| - reg.map { |name, type, data| { :name => name, :type => get_name_from_type(type), :data => data } } + reg.map { |name, type, data| { name: name, type: get_name_from_type(type), data: data } } end end @@ -321,13 +321,13 @@ class Chef def _type_name_map { - :binary => ::Win32::Registry::REG_BINARY, - :string => ::Win32::Registry::REG_SZ, - :multi_string => ::Win32::Registry::REG_MULTI_SZ, - :expand_string => ::Win32::Registry::REG_EXPAND_SZ, - :dword => ::Win32::Registry::REG_DWORD, - :dword_big_endian => ::Win32::Registry::REG_DWORD_BIG_ENDIAN, - :qword => ::Win32::Registry::REG_QWORD, + binary: ::Win32::Registry::REG_BINARY, + string: ::Win32::Registry::REG_SZ, + multi_string: ::Win32::Registry::REG_MULTI_SZ, + expand_string: ::Win32::Registry::REG_EXPAND_SZ, + dword: ::Win32::Registry::REG_DWORD, + dword_big_endian: ::Win32::Registry::REG_DWORD_BIG_ENDIAN, + qword: ::Win32::Registry::REG_QWORD, } end diff --git a/lib/chef/win32/security/securable_object.rb b/lib/chef/win32/security/securable_object.rb index aef1a72c8c..16841413b7 100644 --- a/lib/chef/win32/security/securable_object.rb +++ b/lib/chef/win32/security/securable_object.rb @@ -71,36 +71,36 @@ class Chef end def dacl=(val) - Security.set_named_security_info(path, type, :dacl => val) + Security.set_named_security_info(path, type, dacl: val) end # You don't set dacl_inherits without also setting dacl, # because Windows gets angry and denies you access. So # if you want to do that, you may as well do both at once. def set_dacl(dacl, dacl_inherits) - Security.set_named_security_info(path, type, :dacl => dacl, :dacl_inherits => dacl_inherits) + Security.set_named_security_info(path, type, dacl: dacl, dacl_inherits: dacl_inherits) end def group=(val) - Security.set_named_security_info(path, type, :group => val) + Security.set_named_security_info(path, type, group: val) end def owner=(val) # TODO to fix serious permissions problems, we may need to enable SeBackupPrivilege. But we might need it (almost) everywhere else, too. Security.with_privileges("SeTakeOwnershipPrivilege", "SeRestorePrivilege") do - Security.set_named_security_info(path, type, :owner => val) + Security.set_named_security_info(path, type, owner: val) end end def sacl=(val) Security.with_privileges("SeSecurityPrivilege") do - Security.set_named_security_info(path, type, :sacl => val) + Security.set_named_security_info(path, type, sacl: val) end end def set_sacl(sacl, sacl_inherits) Security.with_privileges("SeSecurityPrivilege") do - Security.set_named_security_info(path, type, :sacl => sacl, :sacl_inherits => sacl_inherits) + Security.set_named_security_info(path, type, sacl: sacl, sacl_inherits: sacl_inherits) end end end diff --git a/lib/chef/win32/version.rb b/lib/chef/win32/version.rb index 944cb207f5..f96fd18316 100644 --- a/lib/chef/win32/version.rb +++ b/lib/chef/win32/version.rb @@ -50,21 +50,21 @@ class Chef private_class_method :method_name_from_marketing_name WIN_VERSIONS = { - "Windows 10" => { :major => 10, :minor => 0, :callable => lambda { |product_type, suite_mask| product_type == VER_NT_WORKSTATION } }, - "Windows Server 2016" => { :major => 10, :minor => 0, :callable => lambda { |product_type, suite_mask| product_type != VER_NT_WORKSTATION } }, - "Windows 8.1" => { :major => 6, :minor => 3, :callable => lambda { |product_type, suite_mask| product_type == VER_NT_WORKSTATION } }, - "Windows Server 2012 R2" => { :major => 6, :minor => 3, :callable => lambda { |product_type, suite_mask| product_type != VER_NT_WORKSTATION } }, - "Windows 8" => { :major => 6, :minor => 2, :callable => lambda { |product_type, suite_mask| product_type == VER_NT_WORKSTATION } }, - "Windows Server 2012" => { :major => 6, :minor => 2, :callable => lambda { |product_type, suite_mask| product_type != VER_NT_WORKSTATION } }, - "Windows 7" => { :major => 6, :minor => 1, :callable => lambda { |product_type, suite_mask| product_type == VER_NT_WORKSTATION } }, - "Windows Server 2008 R2" => { :major => 6, :minor => 1, :callable => lambda { |product_type, suite_mask| product_type != VER_NT_WORKSTATION } }, - "Windows Server 2008" => { :major => 6, :minor => 0, :callable => lambda { |product_type, suite_mask| product_type != VER_NT_WORKSTATION } }, - "Windows Vista" => { :major => 6, :minor => 0, :callable => lambda { |product_type, suite_mask| product_type == VER_NT_WORKSTATION } }, - "Windows Server 2003 R2" => { :major => 5, :minor => 2, :callable => lambda { |product_type, suite_mask| get_system_metrics(SM_SERVERR2) != 0 } }, - "Windows Home Server" => { :major => 5, :minor => 2, :callable => lambda { |product_type, suite_mask| (suite_mask & VER_SUITE_WH_SERVER) == VER_SUITE_WH_SERVER } }, - "Windows Server 2003" => { :major => 5, :minor => 2, :callable => lambda { |product_type, suite_mask| get_system_metrics(SM_SERVERR2) == 0 } }, - "Windows XP" => { :major => 5, :minor => 1 }, - "Windows 2000" => { :major => 5, :minor => 0 }, + "Windows 10" => { major: 10, minor: 0, callable: lambda { |product_type, suite_mask| product_type == VER_NT_WORKSTATION } }, + "Windows Server 2016" => { major: 10, minor: 0, callable: lambda { |product_type, suite_mask| product_type != VER_NT_WORKSTATION } }, + "Windows 8.1" => { major: 6, minor: 3, callable: lambda { |product_type, suite_mask| product_type == VER_NT_WORKSTATION } }, + "Windows Server 2012 R2" => { major: 6, minor: 3, callable: lambda { |product_type, suite_mask| product_type != VER_NT_WORKSTATION } }, + "Windows 8" => { major: 6, minor: 2, callable: lambda { |product_type, suite_mask| product_type == VER_NT_WORKSTATION } }, + "Windows Server 2012" => { major: 6, minor: 2, callable: lambda { |product_type, suite_mask| product_type != VER_NT_WORKSTATION } }, + "Windows 7" => { major: 6, minor: 1, callable: lambda { |product_type, suite_mask| product_type == VER_NT_WORKSTATION } }, + "Windows Server 2008 R2" => { major: 6, minor: 1, callable: lambda { |product_type, suite_mask| product_type != VER_NT_WORKSTATION } }, + "Windows Server 2008" => { major: 6, minor: 0, callable: lambda { |product_type, suite_mask| product_type != VER_NT_WORKSTATION } }, + "Windows Vista" => { major: 6, minor: 0, callable: lambda { |product_type, suite_mask| product_type == VER_NT_WORKSTATION } }, + "Windows Server 2003 R2" => { major: 5, minor: 2, callable: lambda { |product_type, suite_mask| get_system_metrics(SM_SERVERR2) != 0 } }, + "Windows Home Server" => { major: 5, minor: 2, callable: lambda { |product_type, suite_mask| (suite_mask & VER_SUITE_WH_SERVER) == VER_SUITE_WH_SERVER } }, + "Windows Server 2003" => { major: 5, minor: 2, callable: lambda { |product_type, suite_mask| get_system_metrics(SM_SERVERR2) == 0 } }, + "Windows XP" => { major: 5, minor: 1 }, + "Windows 2000" => { major: 5, minor: 0 }, } def initialize |