diff options
author | Thom May <thom@chef.io> | 2016-01-14 14:08:03 +0000 |
---|---|---|
committer | Thom May <thom@chef.io> | 2016-01-14 14:08:03 +0000 |
commit | 51cfbdc4d16739caac4d946fadbe678444aafe34 (patch) | |
tree | 56dfd8f1cd9fd933de27268b32402e955a43ac2b /chef-config/lib/chef-config | |
parent | 05064423057d4cf46f4713b81b08829cf6d20af6 (diff) | |
download | chef-51cfbdc4d16739caac4d946fadbe678444aafe34.tar.gz |
Use double quotes by default
This is an entirely mechanically generated (chefstyle -a) change, to go
along with chef/chefstyle#5 . We should pick something and use it
consistently, and my opinion is that double quotes are the appropriate
thing.
Diffstat (limited to 'chef-config/lib/chef-config')
-rw-r--r-- | chef-config/lib/chef-config/config.rb | 86 | ||||
-rw-r--r-- | chef-config/lib/chef-config/exceptions.rb | 4 | ||||
-rw-r--r-- | chef-config/lib/chef-config/package_task.rb | 36 | ||||
-rw-r--r-- | chef-config/lib/chef-config/path_helper.rb | 32 | ||||
-rw-r--r-- | chef-config/lib/chef-config/version.rb | 2 | ||||
-rw-r--r-- | chef-config/lib/chef-config/workstation_config_loader.rb | 34 |
6 files changed, 97 insertions, 97 deletions
diff --git a/chef-config/lib/chef-config/config.rb b/chef-config/lib/chef-config/config.rb index 1ad6266d14..81e9cf3f68 100644 --- a/chef-config/lib/chef-config/config.rb +++ b/chef-config/lib/chef-config/config.rb @@ -19,14 +19,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'mixlib/config' -require 'pathname' +require "mixlib/config" +require "pathname" -require 'chef-config/logger' -require 'chef-config/windows' -require 'chef-config/path_helper' -require 'mixlib/shellout' -require 'uri' +require "chef-config/logger" +require "chef-config/windows" +require "chef-config/path_helper" +require "mixlib/shellout" +require "uri" module ChefConfig @@ -49,8 +49,8 @@ module ChefConfig path = PathHelper.cleanpath(path) if ChefConfig.windows? # turns \etc\chef\client.rb and \var\chef\client.rb into C:/chef/client.rb - if env['SYSTEMDRIVE'] && path[0] == '\\' && path.split('\\')[2] == 'chef' - path = PathHelper.join(env['SYSTEMDRIVE'], path.split('\\', 3)[2]) + if env["SYSTEMDRIVE"] && path[0] == '\\' && path.split('\\')[2] == "chef" + path = PathHelper.join(env["SYSTEMDRIVE"], path.split('\\', 3)[2]) end end path @@ -107,10 +107,10 @@ module ChefConfig default :chef_repo_path do if self.configuration[:cookbook_path] if self.configuration[:cookbook_path].kind_of?(String) - File.expand_path('..', self.configuration[:cookbook_path]) + File.expand_path("..", self.configuration[:cookbook_path]) else self.configuration[:cookbook_path].map do |path| - File.expand_path('..', path) + File.expand_path("..", path) end end else @@ -123,7 +123,7 @@ module ChefConfig # This allows us to run config-free. path = cwd until File.directory?(PathHelper.join(path, "cookbooks")) - new_path = File.expand_path('..', path) + new_path = File.expand_path("..", path) if new_path == path ChefConfig.logger.warn("No cookbooks directory found at or above current directory. Assuming #{Dir.pwd}.") return Dir.pwd @@ -145,66 +145,66 @@ module ChefConfig # Location of acls on disk. String or array of strings. # Defaults to <chef_repo_path>/acls. # Only applies to Enterprise Chef commands. - default(:acl_path) { derive_path_from_chef_repo_path('acls') } + default(:acl_path) { derive_path_from_chef_repo_path("acls") } # Location of clients on disk. String or array of strings. # Defaults to <chef_repo_path>/acls. - default(:client_path) { derive_path_from_chef_repo_path('clients') } + default(:client_path) { derive_path_from_chef_repo_path("clients") } # Location of cookbooks on disk. String or array of strings. # Defaults to <chef_repo_path>/cookbooks. If chef_repo_path # is not specified, this is set to [/var/chef/cookbooks, /var/chef/site-cookbooks]). default(:cookbook_path) do if self.configuration[:chef_repo_path] - derive_path_from_chef_repo_path('cookbooks') + derive_path_from_chef_repo_path("cookbooks") else - Array(derive_path_from_chef_repo_path('cookbooks')).flatten + - Array(derive_path_from_chef_repo_path('site-cookbooks')).flatten + Array(derive_path_from_chef_repo_path("cookbooks")).flatten + + Array(derive_path_from_chef_repo_path("site-cookbooks")).flatten end end # Location of containers on disk. String or array of strings. # Defaults to <chef_repo_path>/containers. # Only applies to Enterprise Chef commands. - default(:container_path) { derive_path_from_chef_repo_path('containers') } + default(:container_path) { derive_path_from_chef_repo_path("containers") } # Location of data bags on disk. String or array of strings. # Defaults to <chef_repo_path>/data_bags. - default(:data_bag_path) { derive_path_from_chef_repo_path('data_bags') } + default(:data_bag_path) { derive_path_from_chef_repo_path("data_bags") } # Location of environments on disk. String or array of strings. # Defaults to <chef_repo_path>/environments. - default(:environment_path) { derive_path_from_chef_repo_path('environments') } + default(:environment_path) { derive_path_from_chef_repo_path("environments") } # Location of groups on disk. String or array of strings. # Defaults to <chef_repo_path>/groups. # Only applies to Enterprise Chef commands. - default(:group_path) { derive_path_from_chef_repo_path('groups') } + default(:group_path) { derive_path_from_chef_repo_path("groups") } # Location of nodes on disk. String or array of strings. # Defaults to <chef_repo_path>/nodes. - default(:node_path) { derive_path_from_chef_repo_path('nodes') } + default(:node_path) { derive_path_from_chef_repo_path("nodes") } # Location of policies on disk. String or array of strings. # Defaults to <chef_repo_path>/policies. - default(:policy_path) { derive_path_from_chef_repo_path('policies') } + default(:policy_path) { derive_path_from_chef_repo_path("policies") } # Location of policy_groups on disk. String or array of strings. # Defaults to <chef_repo_path>/policy_groups. - default(:policy_group_path) { derive_path_from_chef_repo_path('policy_groups') } + default(:policy_group_path) { derive_path_from_chef_repo_path("policy_groups") } # Location of roles on disk. String or array of strings. # Defaults to <chef_repo_path>/roles. - default(:role_path) { derive_path_from_chef_repo_path('roles') } + default(:role_path) { derive_path_from_chef_repo_path("roles") } # Location of users on disk. String or array of strings. # Defaults to <chef_repo_path>/users. # Does not apply to Enterprise Chef commands. - default(:user_path) { derive_path_from_chef_repo_path('users') } + default(:user_path) { derive_path_from_chef_repo_path("users") } # Location of policies on disk. String or array of strings. # Defaults to <chef_repo_path>/policies. - default(:policy_path) { derive_path_from_chef_repo_path('policies') } + default(:policy_path) { derive_path_from_chef_repo_path("policies") } # Turn on "path sanity" by default. See also: http://wiki.opscode.com/display/chef/User+Environment+PATH+Sanity default :enforce_path_sanity, true @@ -222,7 +222,7 @@ module ChefConfig # this is under the user's home directory. default(:cache_path) do if local_mode - PathHelper.join(config_dir, 'local-mode-cache') + PathHelper.join(config_dir, "local-mode-cache") else primary_cache_root = platform_specific_path("/var") primary_cache_path = platform_specific_path("/var/chef") @@ -231,7 +231,7 @@ module ChefConfig # Otherwise, we'll create .chef under the user's home directory and use that as # the cache path. unless path_accessible?(primary_cache_path) || path_accessible?(primary_cache_root) - secondary_cache_path = PathHelper.join(user_home, '.chef') + secondary_cache_path = PathHelper.join(user_home, ".chef") ChefConfig.logger.info("Unable to access cache at #{primary_cache_path}. Switching cache to #{secondary_cache_path}") secondary_cache_path else @@ -318,7 +318,7 @@ module ChefConfig config_context :chef_zero do config_strict_mode true default(:enabled) { ChefConfig::Config.local_mode } - default :host, 'localhost' + default :host, "localhost" default :port, 8889.upto(9999) # Will try ports from 8889-9999 until one works end default :chef_server_url, "https://localhost:443" @@ -327,7 +327,7 @@ module ChefConfig # if the chef_server_url is a path to an organization, aka # 'some_url.../organizations/*' then remove the '/organization/*' by default if self.configuration[:chef_server_url] =~ /\/organizations\/\S*$/ - self.configuration[:chef_server_url].split('/')[0..-3].join('/') + self.configuration[:chef_server_url].split("/")[0..-3].join("/") elsif self.configuration[:chef_server_url] # default to whatever chef_server_url is self.configuration[:chef_server_url] else @@ -742,7 +742,7 @@ module ChefConfig # pass = password # @api private def self.export_proxy(scheme, path, user, pass) - path = "#{scheme}://#{path}" unless path.include?('://') + path = "#{scheme}://#{path}" unless path.include?("://") # URI.split returns the following parts: # [scheme, userinfo, host, port, registry, path, opaque, query, fragment] parts = URI.split(URI.encode(path)) @@ -750,7 +750,7 @@ module ChefConfig # returns a string for the port. parts[3] = parts[3].to_i if parts[3] if user && !user.empty? - userinfo = URI.encode(URI.encode(user), '@:') + userinfo = URI.encode(URI.encode(user), "@:") if pass userinfo << ":#{URI.encode(URI.encode(pass), '@:')}" end @@ -764,8 +764,8 @@ module ChefConfig # @api private def self.export_no_proxy(value) - ENV['no_proxy'] = value unless ENV['no_proxy'] - ENV['NO_PROXY'] = value unless ENV['NO_PROXY'] + ENV["no_proxy"] = value unless ENV["no_proxy"] + ENV["NO_PROXY"] = value unless ENV["NO_PROXY"] end # Chef requires an English-language UTF-8 locale to function properly. We attempt @@ -793,12 +793,12 @@ module ChefConfig cmd.error! locales = cmd.stdout.split case - when locales.include?('C.UTF-8') - 'C.UTF-8' - when locales.include?('en_US.UTF-8'), locales.include?('en_US.utf8') - 'en_US.UTF-8' - when locales.include?('en.UTF-8') - 'en.UTF-8' + when locales.include?("C.UTF-8") + "C.UTF-8" + when locales.include?("en_US.UTF-8"), locales.include?("en_US.utf8") + "en_US.UTF-8" + when locales.include?("en.UTF-8") + "en.UTF-8" else # Will match en_ZZ.UTF-8, en_ZZ.utf-8, en_ZZ.UTF8, en_ZZ.utf8 guesses = locales.select { |l| l =~ /^en_.*UTF-?8$/i } @@ -808,7 +808,7 @@ module ChefConfig guessed_locale.gsub(/UTF-?8$/i, "UTF-8") else ChefConfig.logger.warn "Please install an English UTF-8 locale for Chef to use, falling back to C locale and disabling UTF-8 support." - 'C' + "C" end end rescue @@ -817,7 +817,7 @@ module ChefConfig else ChefConfig.logger.debug "No usable locale -a command found, assuming you have en_US.UTF-8 installed." end - 'en_US.UTF-8' + "en_US.UTF-8" end default :internal_locale, guess_internal_locale diff --git a/chef-config/lib/chef-config/exceptions.rb b/chef-config/lib/chef-config/exceptions.rb index 1f80e505df..b4efe17329 100644 --- a/chef-config/lib/chef-config/exceptions.rb +++ b/chef-config/lib/chef-config/exceptions.rb @@ -15,8 +15,8 @@ # limitations under the License. # -require 'chef-config/windows' -require 'chef-config/logger' +require "chef-config/windows" +require "chef-config/logger" module ChefConfig diff --git a/chef-config/lib/chef-config/package_task.rb b/chef-config/lib/chef-config/package_task.rb index 2e9b36d939..59620ad03a 100644 --- a/chef-config/lib/chef-config/package_task.rb +++ b/chef-config/lib/chef-config/package_task.rb @@ -16,9 +16,9 @@ # limitations under the License. # -require 'rake' -require 'rubygems' -require 'rubygems/package_task' +require "rake" +require "rubygems" +require "rubygems/package_task" module ChefConfig class PackageTask < Rake::TaskLib @@ -70,9 +70,9 @@ module ChefConfig @module_name = module_name @component_paths = [] @module_path = nil - @version_file_path = 'VERSION' - @package_dir = 'pkg' - @git_remote = 'origin' + @version_file_path = "VERSION" + @package_dir = "pkg" + @git_remote = "origin" @generate_version_class = false end @@ -93,7 +93,7 @@ module ChefConfig end def class_or_module - generate_version_class ? 'class' : 'module' + generate_version_class ? "class" : "module" end def with_clean_env(&block) @@ -105,46 +105,46 @@ module ChefConfig end def define - raise 'Need to provide package root and module name' if root_path.nil? || module_name.nil? + raise "Need to provide package root and module name" if root_path.nil? || module_name.nil? - desc 'Build Gems of component dependencies' + desc "Build Gems of component dependencies" task :package_components do component_full_paths.each do |component_path| Dir.chdir(component_path) do - sh 'rake package' + sh "rake package" end end end task :package => :package_components - desc 'Build and install component dependencies' + desc "Build and install component dependencies" task :install_components => :package_components do component_full_paths.each do |component_path| Dir.chdir(component_path) do - sh 'rake install' + sh "rake install" end end end task :install => :install_components - desc 'Clean up builds of component dependencies' + desc "Clean up builds of component dependencies" task :clobber_component_packages do component_full_paths.each do |component_path| Dir.chdir(component_path) do - sh 'rake clobber_package' + sh "rake clobber_package" end end end task :clobber_package => :clobber_component_packages - desc 'Update the version number for component dependencies' + desc "Update the version number for component dependencies" task :update_components_versions do component_full_paths.each do |component_path| Dir.chdir(component_path) do - sh 'rake version' + sh "rake version" end end end @@ -209,11 +209,11 @@ end sh %{gem uninstall #{module_path} -x -v #{version} } end - desc 'Build it, tag it and ship it' + desc "Build it, tag it and ship it" task :ship => [:clobber_package, :gem] do sh("git tag #{version}") sh("git push #{git_remote} --tags") - Dir[File.expand_path('*.gem', full_package_dir)].reverse.each do |built_gem| + Dir[File.expand_path("*.gem", full_package_dir)].reverse.each do |built_gem| sh("gem push #{built_gem}") end end diff --git a/chef-config/lib/chef-config/path_helper.rb b/chef-config/lib/chef-config/path_helper.rb index ce6c440571..05c1cb88b7 100644 --- a/chef-config/lib/chef-config/path_helper.rb +++ b/chef-config/lib/chef-config/path_helper.rb @@ -16,9 +16,9 @@ # limitations under the License. # -require 'chef-config/windows' -require 'chef-config/logger' -require 'chef-config/exceptions' +require "chef-config/windows" +require "chef-config/logger" +require "chef-config/exceptions" module ChefConfig class PathHelper @@ -32,7 +32,7 @@ module ChefConfig loop do slash = path.rindex(/[#{Regexp.escape(File::SEPARATOR)}#{Regexp.escape(path_separator)}]/, end_slash - 1) if !slash - return end_slash == path.size ? '.' : path_separator + return end_slash == path.size ? "." : path_separator elsif slash == end_slash - 1 end_slash = slash else @@ -64,8 +64,8 @@ module ChefConfig leading_slashes = /^[#{path_separator_regex}]+/ args.flatten.inject() do |joined_path, component| - joined_path = joined_path.sub(trailing_slashes, '') - component = component.sub(leading_slashes, '') + joined_path = joined_path.sub(trailing_slashes, "") + component = component.sub(leading_slashes, "") joined_path += "#{path_separator}#{component}" end end @@ -201,12 +201,12 @@ module ChefConfig # HOMESHARE HOMEPATH # USERPROFILE - paths << ENV['HOME'] - paths << ENV['HOMEDRIVE'] + ENV['HOMEPATH'] if ENV['HOMEDRIVE'] && ENV['HOMEPATH'] - paths << ENV['HOMESHARE'] + ENV['HOMEPATH'] if ENV['HOMESHARE'] && ENV['HOMEPATH'] - paths << ENV['USERPROFILE'] + paths << ENV["HOME"] + paths << ENV["HOMEDRIVE"] + ENV["HOMEPATH"] if ENV["HOMEDRIVE"] && ENV["HOMEPATH"] + paths << ENV["HOMESHARE"] + ENV["HOMEPATH"] if ENV["HOMESHARE"] && ENV["HOMEPATH"] + paths << ENV["USERPROFILE"] end - paths << Dir.home if ENV['HOME'] + paths << Dir.home if ENV["HOME"] # Depending on what environment variables we're using, the slashes can go in any which way. # Just change them all to / to keep things consistent. @@ -231,10 +231,10 @@ module ChefConfig # Determine if the given path is protected by OS X System Integrity Protection. def self.is_sip_path?(path, node) - if node['platform'] == 'mac_os_x' and Gem::Version.new(node['platform_version']) >= Gem::Version.new('10.11') + if node["platform"] == "mac_os_x" and Gem::Version.new(node["platform_version"]) >= Gem::Version.new("10.11") # todo: parse rootless.conf for this? sip_paths= [ - '/System', '/bin', '/sbin', '/usr' + "/System", "/bin", "/sbin", "/usr" ] sip_paths.each do |sip_path| ChefConfig.logger.info("This is a SIP path, checking if it in exceptions list.") @@ -249,9 +249,9 @@ module ChefConfig def self.writable_sip_path?(path) # todo: parse rootless.conf for this? sip_exceptions = [ - '/System/Library/Caches', '/System/Library/Extensions', - '/System/Library/Speech', '/System/Library/User Template', - '/usr/libexec/cups', '/usr/local', '/usr/share/man' + "/System/Library/Caches", "/System/Library/Extensions", + "/System/Library/Speech", "/System/Library/User Template", + "/usr/libexec/cups", "/usr/local", "/usr/share/man" ] sip_exceptions.each do |exception_path| return true if path.start_with?(exception_path) diff --git a/chef-config/lib/chef-config/version.rb b/chef-config/lib/chef-config/version.rb index 2c5e2dec8a..dd2a5bb9ad 100644 --- a/chef-config/lib/chef-config/version.rb +++ b/chef-config/lib/chef-config/version.rb @@ -21,7 +21,7 @@ module ChefConfig CHEFCONFIG_ROOT = File.dirname(File.expand_path(File.dirname(__FILE__))) - VERSION = '12.6.0' + VERSION = "12.6.0" end # diff --git a/chef-config/lib/chef-config/workstation_config_loader.rb b/chef-config/lib/chef-config/workstation_config_loader.rb index 177cd776d4..ec291b80a7 100644 --- a/chef-config/lib/chef-config/workstation_config_loader.rb +++ b/chef-config/lib/chef-config/workstation_config_loader.rb @@ -16,11 +16,11 @@ # limitations under the License. # -require 'chef-config/config' -require 'chef-config/exceptions' -require 'chef-config/logger' -require 'chef-config/path_helper' -require 'chef-config/windows' +require "chef-config/config" +require "chef-config/exceptions" +require "chef-config/logger" +require "chef-config/path_helper" +require "chef-config/windows" module ChefConfig class WorkstationConfigLoader @@ -99,24 +99,24 @@ module ChefConfig candidate_configs = [] # Look for $KNIFE_HOME/knife.rb (allow multiple knives config on same machine) - if env['KNIFE_HOME'] - candidate_configs << File.join(env['KNIFE_HOME'], 'config.rb') - candidate_configs << File.join(env['KNIFE_HOME'], 'knife.rb') + if env["KNIFE_HOME"] + candidate_configs << File.join(env["KNIFE_HOME"], "config.rb") + candidate_configs << File.join(env["KNIFE_HOME"], "knife.rb") end # Look for $PWD/knife.rb if Dir.pwd - candidate_configs << File.join(Dir.pwd, 'config.rb') - candidate_configs << File.join(Dir.pwd, 'knife.rb') + candidate_configs << File.join(Dir.pwd, "config.rb") + candidate_configs << File.join(Dir.pwd, "knife.rb") end # Look for $UPWARD/.chef/knife.rb if chef_config_dir - candidate_configs << File.join(chef_config_dir, 'config.rb') - candidate_configs << File.join(chef_config_dir, 'knife.rb') + candidate_configs << File.join(chef_config_dir, "config.rb") + candidate_configs << File.join(chef_config_dir, "knife.rb") end # Look for $HOME/.chef/knife.rb - PathHelper.home('.chef') do |dot_chef_dir| - candidate_configs << File.join(dot_chef_dir, 'config.rb') - candidate_configs << File.join(dot_chef_dir, 'knife.rb') + PathHelper.home(".chef") do |dot_chef_dir| + candidate_configs << File.join(dot_chef_dir, "config.rb") + candidate_configs << File.join(dot_chef_dir, "knife.rb") end candidate_configs.find do | candidate_config | @@ -126,9 +126,9 @@ module ChefConfig def working_directory a = if ChefConfig.windows? - env['CD'] + env["CD"] else - env['PWD'] + env["PWD"] end || Dir.pwd a |