summaryrefslogtreecommitdiff
path: root/chef-config
diff options
context:
space:
mode:
Diffstat (limited to 'chef-config')
-rw-r--r--chef-config/lib/chef-config/config.rb16
-rw-r--r--chef-config/lib/chef-config/dist.rb11
-rw-r--r--chef-config/lib/chef-config/mixin/credentials.rb4
-rw-r--r--chef-config/lib/chef-config/workstation_config_loader.rb6
4 files changed, 23 insertions, 14 deletions
diff --git a/chef-config/lib/chef-config/config.rb b/chef-config/lib/chef-config/config.rb
index d146051672..b2dff9a764 100644
--- a/chef-config/lib/chef-config/config.rb
+++ b/chef-config/lib/chef-config/config.rb
@@ -158,7 +158,7 @@ module ChefConfig
if config_file
PathHelper.dirname(PathHelper.canonical_path(config_file, false))
else
- PathHelper.join(PathHelper.cleanpath(user_home), ".chef", "")
+ PathHelper.join(PathHelper.cleanpath(user_home), ChefConfig::Dist::USER_CONF_DIR, "")
end
end
@@ -237,7 +237,7 @@ module ChefConfig
end
path = new_path
end
- ChefConfig.logger.info("Auto-discovered chef repository at #{path}")
+ ChefConfig.logger.info("Auto-discovered #{ChefConfig::Dist::SHORT} repository at #{path}")
path
end
@@ -339,7 +339,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, ChefConfig::Dist::USER_CONF_DIR)
secondary_cache_path = target_mode? ? "#{secondary_cache_path}/#{target_mode.host}" : secondary_cache_path
ChefConfig.logger.trace("Unable to access cache at #{primary_cache_path}. Switching cache to #{secondary_cache_path}")
secondary_cache_path
@@ -370,7 +370,7 @@ module ChefConfig
# If your `file_cache_path` resides on a NFS (or non-flock()-supporting
# fs), it's recommended to set this to something like
# '/tmp/chef-client-running.pid'
- default(:lockfile) { PathHelper.join(file_cache_path, "chef-client-running.pid") }
+ default(:lockfile) { PathHelper.join(file_cache_path, "#{ChefConfig::Dist::CLIENT}-running.pid") }
## Daemonization Settings ##
# What user should Chef run as?
@@ -471,7 +471,7 @@ module ChefConfig
# When set to a String, Chef Zero disables multitenant support. This is
# what you want when using Chef Zero to serve a single Chef Repo. Setting
# this to `false` enables multi-tenant.
- default :single_org, "chef"
+ default :single_org, ChefConfig::Dist::SHORT
# Whether Chef Zero should operate in a mode analogous to OSS Chef Server
# 11 (true) or Chef Server 12 (false). Chef Zero can still serve
@@ -764,7 +764,7 @@ module ChefConfig
if chef_server_url.to_s =~ %r{/organizations/(.*)$}
"#{$1}-validator"
else
- "chef-validator"
+ "#{ChefConfig::Dist::SHORT}-validator"
end
end
@@ -838,7 +838,7 @@ module ChefConfig
default :profile, nil
default :chef_guid_path do
- PathHelper.join(config_dir, "chef_guid")
+ PathHelper.join(config_dir, "#{ChefConfig::Dist::SHORT}_guid")
end
default :chef_guid, nil
@@ -1065,7 +1065,7 @@ module ChefConfig
# generated by the DataCollector when Chef is run in Solo mode. This
# allows users to associate their Solo nodes with faux organizations
# without the nodes being connected to an actual Chef Server.
- default :organization, "chef_solo"
+ default :organization, "#{ChefConfig::Dist::SHORT}_solo"
end
configurable(:http_proxy)
diff --git a/chef-config/lib/chef-config/dist.rb b/chef-config/lib/chef-config/dist.rb
index 01db6765fb..d46c9c99d6 100644
--- a/chef-config/lib/chef-config/dist.rb
+++ b/chef-config/lib/chef-config/dist.rb
@@ -1,10 +1,19 @@
module ChefConfig
class Dist
- # The chef executable name. Also used in directory names.
+ # The chef executable name.
EXEC = "chef".freeze
+ # The client's alias (chef-client)
+ CLIENT = "chef-client".freeze
+
+ # A short name for the product
+ SHORT = "chef".freeze
+
# The suffix for Chef's /etc/chef, /var/chef and C:\\Chef directories
# "cinc" => /etc/cinc, /var/cinc, C:\\cinc
DIR_SUFFIX = "chef".freeze
+
+ # The user's configuration directory
+ USER_CONF_DIR = ".chef".freeze
end
end
diff --git a/chef-config/lib/chef-config/mixin/credentials.rb b/chef-config/lib/chef-config/mixin/credentials.rb
index bb4d55f4bc..ec137cb221 100644
--- a/chef-config/lib/chef-config/mixin/credentials.rb
+++ b/chef-config/lib/chef-config/mixin/credentials.rb
@@ -36,7 +36,7 @@ module ChefConfig
# normally set via a command-line option.
# @return [String]
def credentials_profile(profile = nil)
- context_file = PathHelper.home(".chef", "context").freeze
+ context_file = PathHelper.home(ChefConfig::Dist::USER_CONF_DIR, "context").freeze
if !profile.nil?
profile
elsif ENV.include?("CHEF_PROFILE")
@@ -53,7 +53,7 @@ module ChefConfig
# @since 14.4
# @return [String]
def credentials_file_path
- PathHelper.home(".chef", "credentials").freeze
+ PathHelper.home(ChefConfig::Dist::USER_CONF_DIR, "credentials").freeze
end
# Load and parse the credentials file.
diff --git a/chef-config/lib/chef-config/workstation_config_loader.rb b/chef-config/lib/chef-config/workstation_config_loader.rb
index c5eb8b5678..1f50cd3323 100644
--- a/chef-config/lib/chef-config/workstation_config_loader.rb
+++ b/chef-config/lib/chef-config/workstation_config_loader.rb
@@ -59,7 +59,7 @@ module ChefConfig
@chef_config_dir = false
full_path = working_directory.split(File::SEPARATOR)
(full_path.length - 1).downto(0) do |i|
- candidate_directory = File.join(full_path[0..i] + [".chef"])
+ candidate_directory = File.join(full_path[0..i] + [ChefConfig::Dist::USER_CONF_DIR])
if File.exist?(candidate_directory) && File.directory?(candidate_directory)
@chef_config_dir = candidate_directory
break
@@ -129,7 +129,7 @@ module ChefConfig
candidate_configs << File.join(chef_config_dir, "knife.rb")
end
# Look for $HOME/.chef/knife.rb
- PathHelper.home(".chef") do |dot_chef_dir|
+ PathHelper.home(ChefConfig::Dist::USER_CONF_DIR) do |dot_chef_dir|
candidate_configs << File.join(dot_chef_dir, "config.rb")
candidate_configs << File.join(dot_chef_dir, "knife.rb")
end
@@ -186,7 +186,7 @@ module ChefConfig
end
def home_chef_dir
- @home_chef_dir ||= PathHelper.home(".chef")
+ @home_chef_dir ||= PathHelper.home(ChefConfig::Dist::USER_CONF_DIR)
end
def apply_config(config_content, config_file_path)