diff options
author | Tim Smith <tsmith@chef.io> | 2021-04-09 16:54:08 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-09 16:54:08 -0700 |
commit | 3fcc183d3c6b4d5d05011bc217c540ff81f03e7c (patch) | |
tree | 1feb47e8f77cbbd87293fb0d127c9c9dee52019b | |
parent | 58340a5b13f9d57e02e3082febf75530402d889b (diff) | |
parent | 09bcb4b26e6e1de10829e49a6879a0e53822062b (diff) | |
download | chef-3fcc183d3c6b4d5d05011bc217c540ff81f03e7c.tar.gz |
Merge pull request #11348 from ramereth/chef-16-rubygems-provider-dist-fixes
Chef 16: Use dist constants in rubygems provider for is_omnibus? method
-rw-r--r-- | chef-utils/lib/chef-utils/dist.rb | 5 | ||||
-rw-r--r-- | lib/chef/provider/package/rubygems.rb | 4 | ||||
-rw-r--r-- | spec/unit/provider/package/rubygems_spec.rb | 6 |
3 files changed, 10 insertions, 5 deletions
diff --git a/chef-utils/lib/chef-utils/dist.rb b/chef-utils/lib/chef-utils/dist.rb index c4fe72960d..42e9ec2b9f 100644 --- a/chef-utils/lib/chef-utils/dist.rb +++ b/chef-utils/lib/chef-utils/dist.rb @@ -87,6 +87,11 @@ module ChefUtils EXEC = "chef-solo" end + class Workstation + # The suffix for Chef Workstation's /opt/chef-workstation or C:\\opscode\chef-workstation + DIR_SUFFIX = "chef-workstation" + end + class Zero # chef-zero executable PRODUCT = "Chef Infra Zero" diff --git a/lib/chef/provider/package/rubygems.rb b/lib/chef/provider/package/rubygems.rb index 9ac1e7d31b..83f9cc18a5 100644 --- a/lib/chef/provider/package/rubygems.rb +++ b/lib/chef/provider/package/rubygems.rb @@ -423,11 +423,11 @@ class Chef end def is_omnibus? - if %r{/(opscode|chef|chefdk)/embedded/bin}.match?(RbConfig::CONFIG["bindir"]) + if %r{/(#{ChefUtils::Dist::Org::LEGACY_CONF_DIR}|#{ChefUtils::Dist::Infra::SHORT}|#{ChefUtils::Dist::Workstation::DIR_SUFFIX})/embedded/bin}.match?(RbConfig::CONFIG["bindir"]) logger.trace("#{new_resource} detected omnibus installation in #{RbConfig::CONFIG["bindir"]}") # Omnibus installs to a static path because of linking on unix, find it. true - elsif RbConfig::CONFIG["bindir"].sub(/^\w:/, "") == "/opscode/chef/embedded/bin" + elsif RbConfig::CONFIG["bindir"].sub(/^\w:/, "") == "/#{ChefUtils::Dist::Org::LEGACY_CONF_DIR}/#{ChefUtils::Dist::Infra::SHORT}/embedded/bin" logger.trace("#{new_resource} detected omnibus installation in #{RbConfig::CONFIG["bindir"]}") # windows, with the drive letter removed true diff --git a/spec/unit/provider/package/rubygems_spec.rb b/spec/unit/provider/package/rubygems_spec.rb index 5c947cf275..4529926246 100644 --- a/spec/unit/provider/package/rubygems_spec.rb +++ b/spec/unit/provider/package/rubygems_spec.rb @@ -482,10 +482,10 @@ describe Chef::Provider::Package::Rubygems do end end - context "when in omnibus chefdk" do - let(:bindir) { "/opt/chefdk/embedded/bin" } + context "when in omnibus chef-workstation" do + let(:bindir) { "/opt/chef-workstation/embedded/bin" } - it "recognizes chefdk as omnibus" do + it "recognizes chef-workstation as omnibus" do expect(provider.is_omnibus?).to be true end end |