summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2019-04-23 16:41:17 -0700
committerGitHub <noreply@github.com>2019-04-23 16:41:17 -0700
commit466372e1020098094cec9d0777157fb12d37750c (patch)
tree8cdb868d866ed7be8dd8ebc82182524b72a97496
parentd53fff5b2d5f3998aac556c49b9d3092326197a1 (diff)
parent8f51e17d6e2e6769fd70bfe75c44a84e5deb2b3b (diff)
downloadchef-466372e1020098094cec9d0777157fb12d37750c.tar.gz
Merge pull request #8368 from cc-build/distro_identity
Add Chef::Dist to abstract branding details to a single location
-rw-r--r--lib/chef/application/apply.rb9
-rw-r--r--lib/chef/application/client.rb35
-rw-r--r--lib/chef/application/knife.rb9
-rw-r--r--lib/chef/application/solo.rb17
-rw-r--r--lib/chef/application/windows_service.rb25
-rw-r--r--lib/chef/client.rb15
-rw-r--r--lib/chef/dist.rb16
-rw-r--r--lib/chef/http/http_request.rb3
-rw-r--r--lib/chef/knife.rb15
-rw-r--r--lib/chef/knife/bootstrap/templates/chef-full.erb4
-rw-r--r--lib/chef/run_lock.rb3
-rw-r--r--lib/chef/shell.rb9
-rw-r--r--spec/functional/version_spec.rb2
-rw-r--r--spec/integration/solo/solo_spec.rb6
-rw-r--r--spec/unit/application/client_spec.rb8
-rw-r--r--spec/unit/application/solo_spec.rb4
-rw-r--r--spec/unit/knife_spec.rb22
17 files changed, 114 insertions, 88 deletions
diff --git a/lib/chef/application/apply.rb b/lib/chef/application/apply.rb
index 5b697703d7..c25f0ed46e 100644
--- a/lib/chef/application/apply.rb
+++ b/lib/chef/application/apply.rb
@@ -26,6 +26,7 @@ require "fileutils"
require "tempfile"
require "chef/providers"
require "chef/resources"
+require "chef/dist"
class Chef::Application::Apply < Chef::Application
@@ -85,9 +86,9 @@ class Chef::Application::Apply < Chef::Application
option :version,
short: "-v",
long: "--version",
- description: "Show chef version",
+ description: "Show #{Chef::Dist::PRODUCT} version",
boolean: true,
- proc: lambda { |v| puts "Chef: #{::Chef::VERSION}" },
+ proc: lambda { |v| puts "#{Chef::Dist::PRODUCT}: #{::Chef::VERSION}" },
exit: 0
option :why_run,
@@ -98,7 +99,7 @@ class Chef::Application::Apply < Chef::Application
option :profile_ruby,
long: "--[no-]profile-ruby",
- description: "Dump complete Ruby call graph stack of entire Chef run (expert only)",
+ description: "Dump complete Ruby call graph stack of entire #{Chef::Dist::PRODUCT} run (expert only)",
boolean: true,
default: false
@@ -110,7 +111,7 @@ class Chef::Application::Apply < Chef::Application
option :minimal_ohai,
long: "--minimal-ohai",
- description: "Only run the bare minimum ohai plugins chef needs to function",
+ description: "Only run the bare minimum ohai plugins #{Chef::Dist::CLIENT} needs to function",
boolean: true
attr_reader :json_attribs
diff --git a/lib/chef/application/client.rb b/lib/chef/application/client.rb
index 789b938213..ee3e0f7f04 100644
--- a/lib/chef/application/client.rb
+++ b/lib/chef/application/client.rb
@@ -29,6 +29,7 @@ require "chef/mixin/shell_out"
require "chef-config/mixin/dot_d"
require "mixlib/archive"
require "uri"
+require "chef/dist"
class Chef::Application::Client < Chef::Application
include Chef::Mixin::ShellOut
@@ -70,7 +71,7 @@ class Chef::Application::Client < Chef::Application
option :profile_ruby,
long: "--[no-]profile-ruby",
- description: "Dump complete Ruby call graph stack of entire Chef run (expert only)",
+ description: "Dump complete Ruby call graph stack of entire #{Chef::Dist::PRODUCT} run (expert only)",
boolean: true,
default: false
@@ -125,7 +126,7 @@ class Chef::Application::Client < Chef::Application
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",
+ description: "Set the PID file location, for the #{Chef::Dist::CLIENT} daemon process. Defaults to /tmp/chef-client.pid",
proc: nil
option :lockfile,
@@ -136,12 +137,12 @@ class Chef::Application::Client < Chef::Application
option :interval,
short: "-i SECONDS",
long: "--interval SECONDS",
- description: "Run chef-client periodically, in seconds",
+ description: "Run #{Chef::Dist::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",
+ description: "Cancel any interval or splay options, run #{Chef::Dist::CLIENT} once and exit",
boolean: true
option :json_attribs,
@@ -165,7 +166,7 @@ class Chef::Application::Client < Chef::Application
option :chef_server_url,
short: "-S CHEFSERVERURL",
long: "--server CHEFSERVERURL",
- description: "The chef server URL",
+ description: "The #{Chef::Dist::PRODUCT} server URL",
proc: nil
option :validation_key,
@@ -188,14 +189,14 @@ class Chef::Application::Client < Chef::Application
option :environment,
short: "-E ENVIRONMENT",
long: "--environment ENVIRONMENT",
- description: "Set the Chef Environment on the node"
+ description: "Set the #{Chef::Dist::PRODUCT} Environment on the node"
option :version,
short: "-v",
long: "--version",
- description: "Show chef version",
+ description: "Show #{Chef::Dist::PRODUCT} version",
boolean: true,
- proc: lambda { |v| puts "Chef: #{::Chef::VERSION}" },
+ proc: lambda { |v| puts "#{Chef::Dist::PRODUCT}: #{::Chef::VERSION}" },
exit: 0
option :override_runlist,
@@ -237,13 +238,13 @@ class Chef::Application::Client < Chef::Application
option :enable_reporting,
short: "-R",
long: "--enable-reporting",
- description: "Enable reporting data collection for chef runs",
+ description: "Enable reporting data collection for #{Chef::Dist::PRODUCT} runs",
boolean: true
option :local_mode,
short: "-z",
long: "--local-mode",
- description: "Point chef-client at local repository",
+ description: "Point #{Chef::Dist::CLIENT} at local repository",
boolean: true
option :chef_zero_host,
@@ -268,13 +269,13 @@ class Chef::Application::Client < Chef::Application
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",
+ description: "Fail the run when #{Chef::Dist::CLIENT} doesn't have administrator privileges on Windows",
boolean: true
end
option :minimal_ohai,
long: "--minimal-ohai",
- description: "Only run the bare minimum ohai plugins chef needs to function",
+ description: "Only run the bare minimum ohai plugins #{Chef::Dist::CLIENT} needs to function",
boolean: true
option :listen,
@@ -328,7 +329,7 @@ class Chef::Application::Client < Chef::Application
if Chef::Config[:recipe_url]
if !Chef::Config.local_mode
- Chef::Application.fatal!("chef-client recipe-url can be used only in local-mode")
+ Chef::Application.fatal!("recipe-url can be used only in local-mode")
else
if Chef::Config[:delete_entire_chef_repo]
Chef::Log.trace "Cleanup path #{Chef::Config.chef_repo_path} before extract recipes into it"
@@ -419,7 +420,7 @@ class Chef::Application::Client < Chef::Application
# Run the chef client, optionally daemonizing or looping at intervals.
def run_application
if Chef::Config[:version]
- puts "Chef version: #{::Chef::VERSION}"
+ puts "#{Chef::Dist::PRODUCT} version: #{::Chef::VERSION}"
end
if !Chef::Config[:client_fork] || Chef::Config[:once]
@@ -440,7 +441,7 @@ class Chef::Application::Client < Chef::Application
def interval_run_chef_client
if Chef::Config[:daemonize]
- Chef::Daemon.daemonize("chef-client")
+ Chef::Daemon.daemonize(Chef::Dist::CLIENT)
# Start first daemonized run after configured number of seconds
if Chef::Config[:daemonize].is_a?(Integer)
@@ -503,10 +504,10 @@ class Chef::Application::Client < Chef::Application
end
def unforked_interval_error_message
- "Unforked chef-client interval runs are disabled in Chef 12." +
+ "Unforked #{Chef::Dist::CLIENT} interval runs are disabled in #{Chef::Dist::PRODUCT} 12." +
"\nConfiguration settings:" +
("\n interval = #{Chef::Config[:interval]} seconds" if Chef::Config[:interval]).to_s +
- "\nEnable chef-client interval runs by setting `:client_fork = true` in your config file or adding `--fork` to your command line options."
+ "\nEnable #{Chef::Dist::CLIENT} interval runs by setting `:client_fork = true` in your config file or adding `--fork` to your command line options."
end
def fetch_recipe_tarball(url, path)
diff --git a/lib/chef/application/knife.rb b/lib/chef/application/knife.rb
index 76dd5707fe..bdf1b7e7a7 100644
--- a/lib/chef/application/knife.rb
+++ b/lib/chef/application/knife.rb
@@ -20,6 +20,7 @@ require "chef/application"
require "mixlib/log"
require "ohai/config"
require "chef/monkey_patches/net_http.rb"
+require "chef/dist"
class Chef::Application::Knife < Chef::Application
@@ -58,7 +59,7 @@ class Chef::Application::Knife < Chef::Application
option :environment,
short: "-E ENVIRONMENT",
long: "--environment ENVIRONMENT",
- description: "Set the Chef environment (except for in searches, where this will be flagrantly ignored)"
+ description: "Set the #{Chef::Dist::PRODUCT} environment (except for in searches, where this will be flagrantly ignored)"
option :editor,
short: "-e EDITOR",
@@ -94,7 +95,7 @@ class Chef::Application::Knife < Chef::Application
option :chef_server_url,
short: "-s URL",
long: "--server-url URL",
- description: "Chef Server URL"
+ description: "#{Chef::Dist::PRODUCT} Server URL"
option :yes,
short: "-y",
@@ -137,9 +138,9 @@ class Chef::Application::Knife < Chef::Application
option :version,
short: "-v",
long: "--version",
- description: "Show chef version",
+ description: "Show #{Chef::Dist::PRODUCT} version",
boolean: true,
- proc: lambda { |v| puts "Chef: #{::Chef::VERSION}" },
+ proc: lambda { |v| puts "#{Chef::Dist::PRODUCT}: #{::Chef::VERSION}" },
exit: 0
option :fips,
diff --git a/lib/chef/application/solo.rb b/lib/chef/application/solo.rb
index 43bf31530c..457cb1578c 100644
--- a/lib/chef/application/solo.rb
+++ b/lib/chef/application/solo.rb
@@ -29,6 +29,7 @@ require "chef/mixin/shell_out"
require "pathname"
require "chef-config/mixin/dot_d"
require "mixlib/archive"
+require "chef/dist"
class Chef::Application::Solo < Chef::Application
include Chef::Mixin::ShellOut
@@ -68,7 +69,7 @@ class Chef::Application::Solo < Chef::Application
option :profile_ruby,
long: "--[no-]profile-ruby",
- description: "Dump complete Ruby call graph stack of entire Chef run (expert only)",
+ description: "Dump complete Ruby call graph stack of entire #{Chef::Dist::PRODUCT} run (expert only)",
boolean: true,
default: false
@@ -127,7 +128,7 @@ class Chef::Application::Solo < Chef::Application
option :interval,
short: "-i SECONDS",
long: "--interval SECONDS",
- description: "Run chef-client periodically, in seconds",
+ description: "Run #{Chef::Dist::CLIENT} periodically, in seconds",
proc: lambda { |s| s.to_i }
option :json_attribs,
@@ -156,9 +157,9 @@ class Chef::Application::Solo < Chef::Application
option :version,
short: "-v",
long: "--version",
- description: "Show chef version",
+ description: "Show #{Chef::Dist::EXEC} version",
boolean: true,
- proc: lambda { |v| puts "Chef: #{::Chef::VERSION}" },
+ proc: lambda { |v| puts "#{Chef::Dist::PRODUCT}: #{::Chef::VERSION}" },
exit: 0
option :override_runlist,
@@ -191,7 +192,7 @@ class Chef::Application::Solo < Chef::Application
option :environment,
short: "-E ENVIRONMENT",
long: "--environment ENVIRONMENT",
- description: "Set the Chef Environment on the node"
+ description: "Set the #{Chef::Dist::PRODUCT} Environment on the node"
option :run_lock_timeout,
long: "--run-lock-timeout SECONDS",
@@ -200,7 +201,7 @@ class Chef::Application::Solo < Chef::Application
option :minimal_ohai,
long: "--minimal-ohai",
- description: "Only run the bare minimum ohai plugins chef needs to function",
+ description: "Only run the bare minimum ohai plugins #{Chef::Dist::PRODUCT} needs to function",
boolean: true
option :delete_entire_chef_repo,
@@ -365,9 +366,9 @@ class Chef::Application::Solo < Chef::Application
end
def unforked_interval_error_message
- "Unforked chef-client interval runs are disabled in Chef 12." +
+ "Unforked #{Chef::Dist::CLIENT} interval runs are disabled in #{Chef::Dist::PRODUCT} 12." +
"\nConfiguration settings:" +
("\n interval = #{Chef::Config[:interval]} seconds" if Chef::Config[:interval]).to_s +
- "\nEnable chef-client interval runs by setting `:client_fork = true` in your config file or adding `--fork` to your command line options."
+ "\nEnable #{Chef::Dist::CLIENT} interval runs by setting `:client_fork = true` in your config file or adding `--fork` to your command line options."
end
end
diff --git a/lib/chef/application/windows_service.rb b/lib/chef/application/windows_service.rb
index a9da048ab8..6fbb1a36a2 100644
--- a/lib/chef/application/windows_service.rb
+++ b/lib/chef/application/windows_service.rb
@@ -29,6 +29,7 @@ require "socket"
require "uri"
require "win32/daemon"
require "chef/mixin/shell_out"
+require "chef/dist"
class Chef
class Application
@@ -66,7 +67,7 @@ class Chef
@service_signal = ConditionVariable.new
reconfigure
- Chef::Log.info("Chef Client Service initialized")
+ Chef::Log.info("#{Chef::Dist::CLIENT} Service initialized")
end
def service_main(*startup_parameters)
@@ -78,7 +79,7 @@ class Chef
# Grab the service_action_mutex to make a chef-client run
@service_action_mutex.synchronize do
begin
- Chef::Log.info("Next chef-client run will happen in #{timeout} seconds")
+ Chef::Log.info("Next #{Chef::Dist::CLIENT} run will happen in #{timeout} seconds")
@service_signal.wait(@service_action_mutex, timeout)
# Continue only if service is RUNNING
@@ -95,7 +96,7 @@ class Chef
# run chef-client only if service is in RUNNING state
next if state != RUNNING
- Chef::Log.info("Chef-Client service is starting a chef-client run...")
+ Chef::Log.info("#{Chef::Dist::CLIENT} service is starting a #{Chef::Dist::CLIENT} run...")
run_chef_client
rescue SystemExit => e
# Do not raise any of the errors here in order to
@@ -130,12 +131,12 @@ class Chef
break
else
unless run_warning_displayed
- Chef::Log.info("Currently a chef run is happening on this system.")
- Chef::Log.info("Service will stop when run is completed.")
+ Chef::Log.info("Currently a #{Chef::Dist::PRODUCT} run is happening on this system.")
+ Chef::Log.info("Service will stop when run is completed.")
run_warning_displayed = true
end
- Chef::Log.trace("Waiting for chef-client run...")
+ Chef::Log.trace("Waiting for #{Chef::Dist::CLIENT} run...")
sleep 1
end
end
@@ -149,7 +150,7 @@ class Chef
# since this is a PAUSE signal.
if @service_action_mutex.locked?
- Chef::Log.info("Currently a chef-client run is happening.")
+ Chef::Log.info("Currently a #{Chef::Dist::CLIENT} run is happening.")
Chef::Log.info("Service will pause once it's completed.")
else
Chef::Log.info("Service is pausing....")
@@ -184,7 +185,7 @@ class Chef
# The log_location and config_file of the parent process is passed to the new chef-client process.
# We need to add the --no-fork, as by default it is set to fork=true.
- Chef::Log.info "Starting chef-client in a new process"
+ Chef::Log.info "Starting #{Chef::Dist::CLIENT} in a new process"
# Pass config params to the new process
config_params = " --no-fork"
config_params += " -c #{Chef::Config[:config_file]}" unless Chef::Config[:config_file].nil?
@@ -196,20 +197,20 @@ class Chef
# Starts a new process and waits till the process exits
result = shell_out(
- "chef-client.bat #{config_params}",
+ "#{Chef::Dist::CLIENT}.bat #{config_params}",
timeout: Chef::Config[:windows_service][:watchdog_timeout],
logger: Chef::Log
)
Chef::Log.trace (result.stdout).to_s
Chef::Log.trace (result.stderr).to_s
rescue Mixlib::ShellOut::CommandTimeout => e
- Chef::Log.error "chef-client timed out\n(#{e})"
+ Chef::Log.error "#{Chef::Dist::CLIENT} timed out\n(#{e})"
Chef::Log.error(<<-EOF)
- Your chef-client run timed out. You can increase the time chef-client is given
+ Your #{Chef::Dist::CLIENT} run timed out. You can increase the time #{Chef::Dist::CLIENT} is given
to complete by configuring windows_service.watchdog_timeout in your client.rb.
EOF
rescue Mixlib::ShellOut::ShellCommandFailed => e
- Chef::Log.warn "Not able to start chef-client in new process (#{e})"
+ Chef::Log.warn "Not able to start #{Chef::Dist::CLIENT} in new process (#{e})"
rescue => e
Chef::Log.error e
ensure
diff --git a/lib/chef/client.rb b/lib/chef/client.rb
index 40266df64d..0c4acc0a8d 100644
--- a/lib/chef/client.rb
+++ b/lib/chef/client.rb
@@ -54,6 +54,7 @@ require "chef/platform/rebooter"
require "chef/mixin/deprecation"
require "ohai"
require "rbconfig"
+require "chef/dist"
class Chef
# == Chef::Client
@@ -240,10 +241,10 @@ class Chef
events.run_start(Chef::VERSION, run_status)
- logger.info("*** Chef #{Chef::VERSION} ***")
+ logger.info("*** #{Chef::Dist::PRODUCT} #{Chef::VERSION} ***")
logger.info("Platform: #{RUBY_PLATFORM}")
- logger.info "Chef-client pid: #{Process.pid}"
- logger.debug("Chef-client request_id: #{request_id}")
+ logger.info "#{Chef::Dist::CLIENT.capitalize} pid: #{Process.pid}"
+ logger.debug("#{Chef::Dist::CLIENT.capitalize} request_id: #{request_id}")
enforce_path_sanity
run_ohai
@@ -262,7 +263,7 @@ class Chef
build_node
run_status.start_clock
- logger.info("Starting Chef Run for #{node.name}")
+ logger.info("Starting #{Chef::Dist::PRODUCT} Run for #{node.name}")
run_started
do_windows_admin_check
@@ -277,7 +278,7 @@ class Chef
converge_and_save(run_context)
run_status.stop_clock
- logger.info("Chef Run complete in #{run_status.elapsed_time} seconds")
+ logger.info("#{Chef::Dist::PRODUCT} Run complete in #{run_status.elapsed_time} seconds")
run_completed_successfully
events.run_completed(node, run_status)
@@ -715,7 +716,7 @@ class Chef
logger.trace("Checking for administrator privileges....")
if !has_admin_privileges?
- message = "chef-client doesn't have administrator privileges on node #{node_name}."
+ message = "#{Chef::Dist::CLIENT} doesn't have administrator privileges on node #{node_name}."
if Chef::Config[:fatal_windows_admin_check]
logger.fatal(message)
logger.fatal("fatal_windows_admin_check is set to TRUE.")
@@ -724,7 +725,7 @@ class Chef
logger.warn("#{message} This might cause unexpected resource failures.")
end
else
- logger.trace("chef-client has administrator privileges on node #{node_name}.")
+ logger.trace("#{Chef::Dist::CLIENT} has administrator privileges on node #{node_name}.")
end
end
end
diff --git a/lib/chef/dist.rb b/lib/chef/dist.rb
new file mode 100644
index 0000000000..51dd03e965
--- /dev/null
+++ b/lib/chef/dist.rb
@@ -0,0 +1,16 @@
+class Chef
+ class Dist
+ # This class is not fully implemented, depending on it is not recommended!
+ # When referencing a product directly, like Chef (Now Chef Infra)
+ PRODUCT = "Chef Infra".freeze
+
+ # The client's alias (chef-client)
+ CLIENT = "chef-client".freeze
+
+ # The chef executable, as in `chef gem install` or `chef generate cookbook`
+ EXEC = "chef".freeze
+
+ # product website address
+ WEBSITE = "https://chef.io".freeze
+ end
+end
diff --git a/lib/chef/http/http_request.rb b/lib/chef/http/http_request.rb
index c38ac08133..18a4648443 100644
--- a/lib/chef/http/http_request.rb
+++ b/lib/chef/http/http_request.rb
@@ -22,6 +22,7 @@
#
require "uri"
require "net/http"
+require "chef/dist"
# To load faster, we only want ohai's version string.
# However, in ohai before 0.6.0, the version is defined
@@ -40,7 +41,7 @@ class Chef
engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : "ruby"
- UA_COMMON = "/#{::Chef::VERSION} (#{engine}-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}; ohai-#{Ohai::VERSION}; #{RUBY_PLATFORM}; +https://chef.io)".freeze
+ UA_COMMON = "/#{::Chef::VERSION} (#{engine}-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}; ohai-#{Ohai::VERSION}; #{RUBY_PLATFORM}; +#{Chef::Dist::WEBSITE})".freeze
DEFAULT_UA = "Chef Client" << UA_COMMON
USER_AGENT = "User-Agent".freeze
diff --git a/lib/chef/knife.rb b/lib/chef/knife.rb
index 2bb6169cc9..b5b32cb193 100644
--- a/lib/chef/knife.rb
+++ b/lib/chef/knife.rb
@@ -31,11 +31,12 @@ require "chef/http/authenticator"
require "chef/http/http_request"
require "chef/http"
require "pp"
+require "chef/dist"
class Chef
class Knife
- Chef::HTTP::HTTPRequest.user_agent = "Chef Knife#{Chef::HTTP::HTTPRequest::UA_COMMON}"
+ Chef::HTTP::HTTPRequest.user_agent = "#{Chef::Dist::PRODUCT} Knife#{Chef::HTTP::HTTPRequest::UA_COMMON}"
include Mixlib::CLI
include Chef::Mixin::PathSanity
@@ -272,7 +273,7 @@ class Chef
if category_commands = guess_category(args)
list_commands(category_commands)
elsif OFFICIAL_PLUGINS.include?(args[0]) # command was an uninstalled official chef knife plugin
- ui.info("Use `chef gem install knife-#{args[0]}` to install the plugin into ChefDK")
+ ui.info("Use `#{Chef::Dist::EXEC} gem install knife-#{args[0]}` to install the plugin into ChefDK")
else
list_commands
end
@@ -460,7 +461,7 @@ class Chef
when OpenSSL::SSL::SSLError
ui.error "Could not establish a secure connection to the server."
ui.info "Use `knife ssl check` to troubleshoot your SSL configuration."
- ui.info "If your Chef Server uses a self-signed certificate, you can use"
+ ui.info "If your #{Chef::Dist::PRODUCT} Server uses a self-signed certificate, you can use"
ui.info "`knife ssl fetch` to make knife trust the server's certificates."
ui.info ""
ui.info "Original Exception: #{e.class.name}: #{e.message}"
@@ -493,7 +494,7 @@ class Chef
ui.error "You authenticated successfully to #{server_url} as #{username} but you are not authorized for this action."
proxy_env_vars = ENV.to_hash.keys.map(&:downcase) & %w{http_proxy https_proxy ftp_proxy socks_proxy no_proxy}
unless proxy_env_vars.empty?
- ui.error "There are proxy servers configured, your Chef server may need to be added to NO_PROXY."
+ ui.error "There are proxy servers configured, your #{Chef::Dist::PRODUCT} server may need to be added to NO_PROXY."
end
ui.info "Response: #{format_rest_error(response)}"
when Net::HTTPBadRequest
@@ -516,10 +517,10 @@ class Chef
client_api_version = version_header["request_version"]
min_server_version = version_header["min_version"]
max_server_version = version_header["max_version"]
- ui.error "The version of Chef that Knife is using is not supported by the Chef server you sent this request to"
+ ui.error "The version of #{Chef::Dist::PRODUCT} that Knife is using is not supported by the #{Chef::Dist::PRODUCT} server you sent this request to"
ui.info "The request that Knife sent was using API version #{client_api_version}"
- ui.info "The Chef server you sent the request to supports a min API verson of #{min_server_version} and a max API version of #{max_server_version}"
- ui.info "Please either update your Chef client or server to be a compatible set"
+ ui.info "The #{Chef::Dist::PRODUCT} server you sent the request to supports a min API verson of #{min_server_version} and a max API version of #{max_server_version}"
+ ui.info "Please either update your #{Chef::Dist::PRODUCT} client or server to be a compatible set"
else
ui.error response.message
ui.info "Response: #{format_rest_error(response)}"
diff --git a/lib/chef/knife/bootstrap/templates/chef-full.erb b/lib/chef/knife/bootstrap/templates/chef-full.erb
index 094cca1c08..ec1f7e72c9 100644
--- a/lib/chef/knife/bootstrap/templates/chef-full.erb
+++ b/lib/chef/knife/bootstrap/templates/chef-full.erb
@@ -173,7 +173,7 @@ do_download() {
<% else %>
install_sh="<%= knife_config[:bootstrap_url] ? knife_config[:bootstrap_url] : "https://omnitruck.chef.io/chef/install.sh" %>"
if test -f /usr/bin/chef-client; then
- echo "-----> Existing Chef installation detected"
+ echo "-----> Existing <%= Chef::Dist::PRODUCT %> installation detected"
else
echo "-----> Installing Chef Omnibus (<%= latest_current_chef_version_string %>)"
do_download ${install_sh} $tmp_dir/install.sh
@@ -237,6 +237,6 @@ mkdir -p /etc/chef/client.d
<%= client_d %>
<% end -%>
-echo "Starting the first Chef Client run..."
+echo "Starting the first <%= Chef::Dist::PRODUCT %> Client run..."
<%= start_chef %>'
diff --git a/lib/chef/run_lock.rb b/lib/chef/run_lock.rb
index 08d58fd164..513bfd8849 100644
--- a/lib/chef/run_lock.rb
+++ b/lib/chef/run_lock.rb
@@ -23,6 +23,7 @@ end
require "chef/config"
require "chef/exceptions"
require "timeout"
+require "chef/dist"
class Chef
@@ -95,7 +96,7 @@ class Chef
# Waits until acquiring the system-wide lock.
#
def wait
- Chef::Log.warn("Chef client #{runpid} is running, will wait for it to finish and then run.")
+ Chef::Log.warn("#{Chef::Dist::PRODUCT} client #{runpid} is running, will wait for it to finish and then run.")
if Chef::Platform.windows?
mutex.wait
else
diff --git a/lib/chef/shell.rb b/lib/chef/shell.rb
index e717c3705e..f05e63b420 100644
--- a/lib/chef/shell.rb
+++ b/lib/chef/shell.rb
@@ -25,6 +25,7 @@ require "chef/version"
require "chef/client"
require "chef/config"
require "chef/config_fetcher"
+require "chef/dist"
require "chef/shell/shell_session"
require "chef/workstation_config_loader"
@@ -253,7 +254,7 @@ module Shell
option :client,
short: "-z",
long: "--client",
- description: "chef-client session",
+ description: "#{Chef::Dist::CLIENT} session",
boolean: true
option :solo_legacy_shell,
@@ -271,15 +272,15 @@ module Shell
option :chef_server_url,
short: "-S CHEFSERVERURL",
long: "--server CHEFSERVERURL",
- description: "The chef server URL",
+ description: "The #{Chef::Dist::PRODUCT} server URL",
proc: nil
option :version,
short: "-v",
long: "--version",
- description: "Show chef version",
+ description: "Show #{Chef::Dist::PRODUCT} version",
boolean: true,
- proc: lambda { |v| puts "Chef: #{::Chef::VERSION}" },
+ proc: lambda { |v| puts "#{Chef::Dist::PRODUCT}: #{::Chef::VERSION}" },
exit: 0
option :override_runlist,
diff --git a/spec/functional/version_spec.rb b/spec/functional/version_spec.rb
index dc323e9d3a..d968c36e8c 100644
--- a/spec/functional/version_spec.rb
+++ b/spec/functional/version_spec.rb
@@ -28,7 +28,7 @@ describe "Chef Versions" do
binaries.each do |binary|
it "#{binary} version should be sane" do
- expect(shell_out!("ruby #{File.join("bin", binary)} -v", cwd: chef_dir).stdout.chomp).to include("Chef: #{Chef::VERSION}")
+ expect(shell_out!("ruby #{File.join("bin", binary)} -v", cwd: chef_dir).stdout.chomp).to match(/.*: #{Chef::VERSION}/)
end
end
diff --git a/spec/integration/solo/solo_spec.rb b/spec/integration/solo/solo_spec.rb
index 12826eb586..efd889c5d0 100644
--- a/spec/integration/solo/solo_spec.rb
+++ b/spec/integration/solo/solo_spec.rb
@@ -163,7 +163,7 @@ describe "chef-solo" do
ruby_block "sleeping" do
block do
retries = 200
- while IO.read(Chef::Config[:log_location]) !~ /Chef client .* is running, will wait for it to finish and then run./
+ while IO.read(Chef::Config[:log_location]) !~ /.* client .* is running, will wait for it to finish and then run./
sleep 0.1
raise "we ran out of retries" if ( retries -= 1 ) <= 0
end
@@ -207,10 +207,10 @@ describe "chef-solo" do
run_log = File.read(path_to("logs/runs.log"))
# second run should have a message which indicates it's waiting for the first run
- expect(run_log).to match(/Chef client .* is running, will wait for it to finish and then run./)
+ expect(run_log).to match(/.* client .* is running, will wait for it to finish and then run./)
# both of the runs should succeed
- expect(run_log.lines.reject { |l| !l.include? "INFO: Chef Run complete in" }.length).to eq(2)
+ expect(run_log.lines.reject { |l| !l.include? "Run complete in" }.length).to eq(2)
end
end
diff --git a/spec/unit/application/client_spec.rb b/spec/unit/application/client_spec.rb
index f971848c5b..8daba1d660 100644
--- a/spec/unit/application/client_spec.rb
+++ b/spec/unit/application/client_spec.rb
@@ -1,4 +1,4 @@
-#
+
# Author:: AJ Christensen (<aj@junglist.gen.nz>)
# Copyright:: Copyright 2008-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
@@ -226,7 +226,7 @@ describe Chef::Application::Client, "reconfigure" do
context "local mode not set" do
it "fails with a message stating local mode required" do
- expect(Chef::Application).to receive(:fatal!).with("chef-client recipe-url can be used only in local-mode").and_raise("error occured")
+ expect(Chef::Application).to receive(:fatal!).with("recipe-url can be used only in local-mode").and_raise("error occured")
ARGV.replace(["--recipe-url=test_url"])
expect { app.reconfigure }.to raise_error "error occured"
end
@@ -326,10 +326,10 @@ describe Chef::Application::Client, "reconfigure" do
Chef::Config[:interval] = 600
allow(ChefConfig).to receive(:windows?).and_return(false)
expect(Chef::Application).to receive(:fatal!).with(
- "Unforked chef-client interval runs are disabled in Chef 12.
+ /Unforked .* interval runs are disabled in .* 12\.
Configuration settings:
interval = 600 seconds
-Enable chef-client interval runs by setting `:client_fork = true` in your config file or adding `--fork` to your command line options."
+Enable .* interval runs by setting `:client_fork = true` in your config file or adding `--fork` to your command line options\./
)
app.reconfigure
end
diff --git a/spec/unit/application/solo_spec.rb b/spec/unit/application/solo_spec.rb
index 939300b7e4..1a4961f025 100644
--- a/spec/unit/application/solo_spec.rb
+++ b/spec/unit/application/solo_spec.rb
@@ -64,10 +64,10 @@ describe Chef::Application::Solo do
it "should terminate with message" do
expect(Chef::Application).to receive(:fatal!).with(
- "Unforked chef-client interval runs are disabled in Chef 12.
+ /Unforked .* interval runs are disabled in .* 12\.
Configuration settings:
interval = 600 seconds
-Enable chef-client interval runs by setting `:client_fork = true` in your config file or adding `--fork` to your command line options."
+Enable .* interval runs by setting `:client_fork = true` in your config file or adding `--fork` to your command line options\./
)
app.reconfigure
end
diff --git a/spec/unit/knife_spec.rb b/spec/unit/knife_spec.rb
index d727501b60..ff89bc6f30 100644
--- a/spec/unit/knife_spec.rb
+++ b/spec/unit/knife_spec.rb
@@ -458,7 +458,7 @@ describe Chef::Knife do
allow(knife).to receive(:username).and_return("sadpanda")
knife.run_with_pretty_exceptions
expect(stderr.string).to match(%r{ERROR: You authenticated successfully to http.+ as sadpanda but you are not authorized for this action})
- expect(stderr.string).to match(%r{ERROR: There are proxy servers configured, your Chef server may need to be added to NO_PROXY.})
+ expect(stderr.string).to match(%r{ERROR: There are proxy servers configured, your .* server may need to be added to NO_PROXY.})
expect(stderr.string).to match(%r{Response: y u no administrator})
end
end
@@ -494,9 +494,9 @@ describe Chef::Knife do
allow(knife).to receive(:run).and_raise(Net::HTTPClientException.new("406 Not Acceptable", response))
knife.run_with_pretty_exceptions
- expect(stderr.string).to include("The request that Knife sent was using API version 10000000")
- expect(stderr.string).to include("The Chef server you sent the request to supports a min API verson of 0 and a max API version of 1")
- expect(stderr.string).to include("Please either update your Chef client or server to be a compatible set")
+ expect(stderr.string).to match(/The request that .* sent was using API version 10000000/)
+ expect(stderr.string).to match(/The .* server you sent the request to supports a min API verson of 0 and a max API version of 1/)
+ expect(stderr.string).to match(/Please either update your .* client or server to be a compatible set/)
end
it "formats 500s nicely" do
@@ -542,8 +542,8 @@ describe Chef::Knife do
it "formats NameError and NoMethodError nicely" do
allow(knife).to receive(:run).and_raise(NameError.new("Undefined constant FUUU"))
knife.run_with_pretty_exceptions
- expect(stderr.string).to match(%r{ERROR: knife encountered an unexpected error})
- expect(stderr.string).to match(%r{This may be a bug in the 'knife' knife command or plugin})
+ expect(stderr.string).to match(%r{ERROR: .* encountered an unexpected error})
+ expect(stderr.string).to match(%r{This may be a bug in the 'knife' .* command or plugin})
expect(stderr.string).to match(%r{Exception: NameError: Undefined constant FUUU})
end
@@ -562,7 +562,7 @@ describe Chef::Knife do
# *nix = Errno::ECONNREFUSED: Connection refused
# win32: Errno::ECONNREFUSED: No connection could be made because the target machine actively refused it.
expect(stderr.string).to match(%r{ERROR: Network Error: .* - y u no shut up})
- expect(stderr.string).to match(%r{Check your knife configuration and network settings})
+ expect(stderr.string).to match(%r{Check your .* configuration and network settings})
end
it "formats SSL errors nicely and suggests to use `knife ssl check` and `knife ssl fetch`" do
@@ -573,11 +573,11 @@ describe Chef::Knife do
expected_message = <<~MSG
ERROR: Could not establish a secure connection to the server.
- Use `knife ssl check` to troubleshoot your SSL configuration.
- If your Chef Server uses a self-signed certificate, you can use
- `knife ssl fetch` to make knife trust the server's certificates.
+ Use `.* ssl check` to troubleshoot your SSL configuration.
+ If your .* Server uses a self-signed certificate, you can use
+ `.* ssl fetch` to make .* trust the server's certificates.
MSG
- expect(stderr.string).to include(expected_message)
+ expect(stderr.string).to match(expected_message)
end
end