summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Chamberland <mchamberland@pbsc.com>2019-05-05 18:55:51 -0400
committerMarc Chamberland <mchamberland@pbsc.com>2019-05-23 12:29:44 -0400
commit44aae2c29d0c4ba28b4dbfc8c638036d8a2663ec (patch)
tree1b1c1aff271923af23e987f36f98183ba20a59c9
parentf5de2c58ea3705a20a6784251a3cd8a58618f24d (diff)
downloadchef-44aae2c29d0c4ba28b4dbfc8c638036d8a2663ec.tar.gz
distro constants for solo, zero and automate
Signed-off-by: Marc Chamberland <mchamberland@pbsc.com>
-rw-r--r--lib/chef/application/client.rb4
-rw-r--r--lib/chef/application/knife.rb4
-rw-r--r--lib/chef/application/solo.rb4
-rw-r--r--lib/chef/data_collector.rb4
-rw-r--r--lib/chef/data_collector/run_end_message.rb3
-rw-r--r--lib/chef/data_collector/run_start_message.rb3
-rw-r--r--lib/chef/dist.rb15
-rw-r--r--lib/chef/environment.rb3
-rw-r--r--lib/chef/http/socketless_chef_zero_client.rb3
-rw-r--r--lib/chef/knife/serve.rb3
-rw-r--r--lib/chef/shell.rb4
-rw-r--r--spec/functional/version_spec.rb3
-rw-r--r--spec/integration/client/client_spec.rb5
-rw-r--r--spec/integration/solo/solo_spec.rb5
-rw-r--r--spec/unit/cookbook/synchronizer_spec.rb3
-rw-r--r--spec/unit/environment_spec.rb2
-rw-r--r--spec/unit/policy_builder/policyfile_spec.rb2
17 files changed, 47 insertions, 23 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 }
diff --git a/spec/functional/version_spec.rb b/spec/functional/version_spec.rb
index b12d235405..246b3a021a 100644
--- a/spec/functional/version_spec.rb
+++ b/spec/functional/version_spec.rb
@@ -19,12 +19,13 @@ require File.expand_path("../../spec_helper", __FILE__)
require "chef/mixin/shell_out"
require "chef/version"
require "ohai/version"
+require "chef/dist"
describe "Chef Versions" do
include Chef::Mixin::ShellOut
let(:chef_dir) { File.join(File.dirname(__FILE__), "..", "..") }
- binaries = [ "chef-client", "chef-shell", "chef-apply", "knife", "chef-solo" ]
+ binaries = [ Chef::Dist::CLIENT, "chef-shell", "chef-apply", "knife", Chef::Dist::SOLOEXEC ]
binaries.each do |binary|
it "#{binary} version should be sane" do
diff --git a/spec/integration/client/client_spec.rb b/spec/integration/client/client_spec.rb
index cde25662c1..c2dc740025 100644
--- a/spec/integration/client/client_spec.rb
+++ b/spec/integration/client/client_spec.rb
@@ -2,6 +2,7 @@ require "support/shared/integration/integration_helper"
require "chef/mixin/shell_out"
require "tiny_server"
require "tmpdir"
+require "chef/dist"
describe "chef-client" do
@@ -45,8 +46,8 @@ describe "chef-client" do
# machine that has omnibus chef installed. In that case we need to ensure
# we're running `chef-client` from the source tree and not the external one.
# cf. CHEF-4914
- let(:chef_client) { "bundle exec chef-client --minimal-ohai" }
- let(:chef_solo) { "bundle exec chef-solo --legacy-mode --minimal-ohai" }
+ let(:chef_client) { "bundle exec #{Chef::Dist::CLIENT} --minimal-ohai" }
+ let(:chef_solo) { "bundle exec #{Chef::Dist::SOLOEXEC} --legacy-mode --minimal-ohai" }
when_the_repository "has a cookbook with a no-op recipe" do
before { file "cookbooks/x/recipes/default.rb", "" }
diff --git a/spec/integration/solo/solo_spec.rb b/spec/integration/solo/solo_spec.rb
index 3d2efe703c..0d24269199 100644
--- a/spec/integration/solo/solo_spec.rb
+++ b/spec/integration/solo/solo_spec.rb
@@ -5,8 +5,9 @@ require "chef/config"
require "timeout"
require "fileutils"
require "chef/win32/security" if Chef::Platform.windows?
+require "chef/dist"
-describe "chef-solo" do
+describe Chef::Dist::SOLOEXEC do
include IntegrationSupport
include Chef::Mixin::ShellOut
@@ -16,7 +17,7 @@ describe "chef-solo" do
let(:cookbook_ancient_100_metadata_rb) { cb_metadata("ancient", "1.0.0") }
- let(:chef_solo) { "bundle exec chef-solo --legacy-mode --minimal-ohai" }
+ let(:chef_solo) { "bundle exec #{Chef::Dist::SOLOEXEC} --legacy-mode --minimal-ohai" }
when_the_repository "creates nodes" do
let(:nodes_dir) { File.join(@repository_dir, "nodes") }
diff --git a/spec/unit/cookbook/synchronizer_spec.rb b/spec/unit/cookbook/synchronizer_spec.rb
index 1291b230c1..dc68bf1824 100644
--- a/spec/unit/cookbook/synchronizer_spec.rb
+++ b/spec/unit/cookbook/synchronizer_spec.rb
@@ -1,6 +1,7 @@
require "spec_helper"
require "chef/cookbook/synchronizer"
require "chef/cookbook_version"
+require "chef/dist"
describe Chef::CookbookCacheCleaner do
describe "when cleaning up unused cookbook components" do
@@ -49,7 +50,7 @@ describe Chef::CookbookCacheCleaner do
cleaner.cleanup_file_cache
end
- it "does not remove anything on chef-solo" do
+ it "does not remove anything on #{Chef::Dist::SOLOEXEC}" do
Chef::Config[:solo_legacy_mode] = true
allow(cleaner.cache).to receive(:find).and_return(%w{cookbooks/valid1/recipes/default.rb cookbooks/valid2/recipes/default.rb})
expect(cleaner.cache).not_to receive(:delete)
diff --git a/spec/unit/environment_spec.rb b/spec/unit/environment_spec.rb
index 1841707c2d..07d8f5f552 100644
--- a/spec/unit/environment_spec.rb
+++ b/spec/unit/environment_spec.rb
@@ -299,7 +299,7 @@ describe Chef::Environment do
expect do
Chef::Environment.validate_cookbook_version("= 1.2.3.4")
end.to raise_error Chef::Exceptions::IllegalVersionConstraint,
- "Environment cookbook version constraints not allowed in chef-solo"
+ "Environment cookbook version constraints not allowed in .*"
end
end
diff --git a/spec/unit/policy_builder/policyfile_spec.rb b/spec/unit/policy_builder/policyfile_spec.rb
index f22e2a74b3..1293d6ebc6 100644
--- a/spec/unit/policy_builder/policyfile_spec.rb
+++ b/spec/unit/policy_builder/policyfile_spec.rb
@@ -150,7 +150,7 @@ describe Chef::PolicyBuilder::Policyfile do
expect(initialize_pb.temporary_policy?).to be_falsey
end
- context "chef-solo" do
+ context "#{Chef::Dist::SOLOEXEC}" do
before { Chef::Config[:solo_legacy_mode] = true }
it "errors on create" do