diff options
author | Marc Chamberland <mchamberland@pbsc.com> | 2019-05-05 18:55:51 -0400 |
---|---|---|
committer | Marc Chamberland <mchamberland@pbsc.com> | 2019-05-23 12:29:44 -0400 |
commit | 44aae2c29d0c4ba28b4dbfc8c638036d8a2663ec (patch) | |
tree | 1b1c1aff271923af23e987f36f98183ba20a59c9 /lib | |
parent | f5de2c58ea3705a20a6784251a3cd8a58618f24d (diff) | |
download | chef-44aae2c29d0c4ba28b4dbfc8c638036d8a2663ec.tar.gz |
distro constants for solo, zero and automate
Signed-off-by: Marc Chamberland <mchamberland@pbsc.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/application/client.rb | 4 | ||||
-rw-r--r-- | lib/chef/application/knife.rb | 4 | ||||
-rw-r--r-- | lib/chef/application/solo.rb | 4 | ||||
-rw-r--r-- | lib/chef/data_collector.rb | 4 | ||||
-rw-r--r-- | lib/chef/data_collector/run_end_message.rb | 3 | ||||
-rw-r--r-- | lib/chef/data_collector/run_start_message.rb | 3 | ||||
-rw-r--r-- | lib/chef/dist.rb | 15 | ||||
-rw-r--r-- | lib/chef/environment.rb | 3 | ||||
-rw-r--r-- | lib/chef/http/socketless_chef_zero_client.rb | 3 | ||||
-rw-r--r-- | lib/chef/knife/serve.rb | 3 | ||||
-rw-r--r-- | lib/chef/shell.rb | 4 |
11 files changed, 35 insertions, 15 deletions
diff --git a/lib/chef/application/client.rb b/lib/chef/application/client.rb index 9ba1502409..6363b9cdc7 100644 --- a/lib/chef/application/client.rb +++ b/lib/chef/application/client.rb @@ -252,11 +252,11 @@ class Chef::Application::Client < Chef::Application option :chef_zero_host, long: "--chef-zero-host HOST", - description: "Host to start chef-zero on." + description: "Host to start #{Chef::Dist::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." + description: "Port (or port range) to start #{Chef::Dist::ZERO} on. Port ranges like 1000,1010 or 8889-9999 will try all given ports until one works." option :disable_config, long: "--disable-config", diff --git a/lib/chef/application/knife.rb b/lib/chef/application/knife.rb index 82493d5140..6f192a3e1f 100644 --- a/lib/chef/application/knife.rb +++ b/lib/chef/application/knife.rb @@ -124,11 +124,11 @@ class Chef::Application::Knife < Chef::Application option :chef_zero_host, long: "--chef-zero-host HOST", - description: "Host to start chef-zero on." + description: "Host to start #{Chef::Dist::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." + description: "Port (or port range) to start #{Chef::Dist::ZERO} on. Port ranges like 1000,1010 or 8889-9999 will try all given ports until one works." option :listen, long: "--[no-]listen", diff --git a/lib/chef/application/solo.rb b/lib/chef/application/solo.rb index f11654ddd5..5cb6e56807 100644 --- a/lib/chef/application/solo.rb +++ b/lib/chef/application/solo.rb @@ -124,7 +124,7 @@ class Chef::Application::Solo < Chef::Application option :lockfile, long: "--lockfile LOCKFILE", - description: "Set the lockfile location. Prevents multiple solo processes from converging at the same time.", + description: "Set the lockfile location. Prevents multiple #{Chef::Dist::SOLO} processes from converging at the same time.", proc: nil option :interval, @@ -213,7 +213,7 @@ class Chef::Application::Solo < Chef::Application option :solo_legacy_mode, long: "--legacy-mode", - description: "Run chef-solo in legacy mode.", + description: "Run #{Chef::Dist::SOLO} in legacy mode.", boolean: true attr_reader :chef_client_json diff --git a/lib/chef/data_collector.rb b/lib/chef/data_collector.rb index eb349be928..677dc99faf 100644 --- a/lib/chef/data_collector.rb +++ b/lib/chef/data_collector.rb @@ -192,7 +192,7 @@ class Chef raise else # Make the message non-scary for folks who don't have automate: - msg << " (This is normal if you do not have Chef Automate)" + msg << " (This is normal if you do not have #{Chef::Dist::AUTOMATE})" Chef::Log.info(msg) end end @@ -312,7 +312,7 @@ class Chef return true when running_mode == :solo && !Chef::Config[:data_collector][:token] # we are in solo mode and are not logging to a file, so must have a token - Chef::Log.trace("Data collector token must be configured to use Chef Automate data collector with #{Chef::Dist::PRODUCT} Solo") + Chef::Log.trace("Data collector token must be configured to use #{Chef::Dist::AUTOMATE} data collector with #{Chef::Dist::SOLO}") return false else return true diff --git a/lib/chef/data_collector/run_end_message.rb b/lib/chef/data_collector/run_end_message.rb index 70a0b59650..f89639be8c 100644 --- a/lib/chef/data_collector/run_end_message.rb +++ b/lib/chef/data_collector/run_end_message.rb @@ -16,6 +16,7 @@ # require_relative "message_helpers" +require_relative "../../dist" class Chef class DataCollector @@ -61,7 +62,7 @@ class Chef "policy_group" => node&.policy_group, "start_time" => run_status.start_time.utc.iso8601, "end_time" => run_status.end_time.utc.iso8601, - "source" => solo_run? ? "chef_solo" : "chef_client", + "source" => solo_run? ? Chef::Dist::SOLOEXEC : CHEF::DIST::CLIENT, "status" => status, "total_resource_count" => all_action_records(action_collection).count, "updated_resource_count" => updated_resource_count(action_collection), diff --git a/lib/chef/data_collector/run_start_message.rb b/lib/chef/data_collector/run_start_message.rb index fd070da8e4..2fc7204194 100644 --- a/lib/chef/data_collector/run_start_message.rb +++ b/lib/chef/data_collector/run_start_message.rb @@ -16,6 +16,7 @@ # require_relative "message_helpers" +require_relative "../../dist" class Chef class DataCollector @@ -50,7 +51,7 @@ class Chef "node_name" => node&.name || data_collector.node_name, "organization_name" => organization, "run_id" => run_status&.run_id, - "source" => solo_run? ? "chef_solo" : "chef_client", + "source" => solo_run? ? Chef::Dist::SOLOEXEC : Chef::Dist::CLIENT, "start_time" => run_status.start_time.utc.iso8601, } end diff --git a/lib/chef/dist.rb b/lib/chef/dist.rb index ed9307900b..68205fb74d 100644 --- a/lib/chef/dist.rb +++ b/lib/chef/dist.rb @@ -10,10 +10,25 @@ class Chef # The client's alias (chef-client) CLIENT = "chef-client".freeze + # name of the automate product + AUTOMATE = "Chef Automate" + # The chef executable, as in `chef gem install` or `chef generate cookbook` EXEC = "chef".freeze # product website address WEBSITE = "https://chef.io".freeze + + # Chef-Zero's product name + ZERO = "Chef Infra Zero" + + # Chef-Solo's product name + SOLO = "Chef Infra Solo" + + # The chef-zero executable (local mode) + ZEROEXEC = "chef-zero" + + # The chef-solo executable (legacy local mode) + SOLOEXEC = "chef-solo" end end diff --git a/lib/chef/environment.rb b/lib/chef/environment.rb index bd966e9b57..7e1c583fa3 100644 --- a/lib/chef/environment.rb +++ b/lib/chef/environment.rb @@ -25,6 +25,7 @@ require_relative "mixin/params_validate" require_relative "mixin/from_file" require_relative "version_constraint" require_relative "server_api" +require_relative "../dist" class Chef class Environment @@ -306,7 +307,7 @@ class Chef def self.validate_cookbook_version(version) if Chef::Config[:solo_legacy_mode] raise Chef::Exceptions::IllegalVersionConstraint, - "Environment cookbook version constraints not allowed in chef-solo" + "Environment cookbook version constraints not allowed in #{Chef::Dist::SOLO}" else Chef::VersionConstraint.new version true diff --git a/lib/chef/http/socketless_chef_zero_client.rb b/lib/chef/http/socketless_chef_zero_client.rb index e3823481d4..61673c28a6 100644 --- a/lib/chef/http/socketless_chef_zero_client.rb +++ b/lib/chef/http/socketless_chef_zero_client.rb @@ -44,6 +44,7 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require "chef_zero/server" +require "chef/dist" class Chef class HTTP @@ -63,7 +64,7 @@ class Chef # or else streaming-style responses won't work. def read_body(dest = nil, &block) if dest - raise "responses from socketless chef zero can't be written to specific destination" + raise "responses from socketless #{Chef::Dist::ZERO} can't be written to specific destination" end if block_given? diff --git a/lib/chef/knife/serve.rb b/lib/chef/knife/serve.rb index ccb5d4ea29..cf49621a88 100644 --- a/lib/chef/knife/serve.rb +++ b/lib/chef/knife/serve.rb @@ -16,6 +16,7 @@ require_relative "../knife" require_relative "../local_mode" +require_relative "../dist" class Chef class Knife @@ -33,7 +34,7 @@ class Chef option :chef_zero_host, long: "--chef-zero-host IP", - description: "Overrides the host upon which chef-zero listens. Default is 127.0.0.1." + description: "Overrides the host upon which #{Chef::Dist::ZERO} listens. Default is 127.0.0.1." def configure_chef super diff --git a/lib/chef/shell.rb b/lib/chef/shell.rb index 831b3438ef..f8a8dfdca2 100644 --- a/lib/chef/shell.rb +++ b/lib/chef/shell.rb @@ -248,7 +248,7 @@ module Shell option :solo_shell, short: "-s", long: "--solo", - description: "chef-solo session", + description: "#{Chef::Dist::SOLO} session", boolean: true, proc: proc { Chef::Config[:solo] = true } @@ -260,7 +260,7 @@ module Shell option :solo_legacy_shell, long: "--solo-legacy-mode", - description: "chef-solo legacy session", + description: "#{Chef::Dist::SOLO} legacy session", boolean: true, proc: proc { Chef::Config[:solo_legacy_mode] = true } |