summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLance Albertson <lance@osuosl.org>2020-08-18 09:51:08 -0700
committerLance Albertson <lance@osuosl.org>2020-09-14 11:07:05 -0700
commit357b689652d46299a1956a8293b3da8a932ea037 (patch)
tree775995c23994b51da4698c13e2553106dd154f74
parente404dfa694f0bdb372731890f57d21b216456d02 (diff)
downloadchef-357b689652d46299a1956a8293b3da8a932ea037.tar.gz
Move chef-config/dist to chef-utils/dist
This migrates constants used in chef-config/dist to chef-utils/dist so that they all reside in one place. Other changes include: - Remove Compliance, Inspec, Run, Inspec, Workstation class constants as they are new and not being used yet. Leave this to be added in a later PR. Signed-off-by: Lance Albertson <lance@osuosl.org>
-rw-r--r--chef-config/lib/chef-config/dist.rb33
-rw-r--r--chef-utils/lib/chef-utils/dist.rb75
-rw-r--r--lib/chef/application/client.rb2
-rw-r--r--lib/chef/knife/bootstrap.rb2
-rw-r--r--lib/chef/node_map.rb4
-rw-r--r--lib/chef/resource/chef_gem.rb12
-rw-r--r--lib/chef/resource/gem_package.rb6
-rw-r--r--lib/chef/resource/homebrew_update.rb4
-rw-r--r--lib/chef/resource/macos_userdefaults.rb4
9 files changed, 49 insertions, 93 deletions
diff --git a/chef-config/lib/chef-config/dist.rb b/chef-config/lib/chef-config/dist.rb
deleted file mode 100644
index 67d1063163..0000000000
--- a/chef-config/lib/chef-config/dist.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-module ChefConfig
- class Dist
- # 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
-
- # The legacy conf folder: C:/opscode/chef. Specifically the "opscode" part
- # DIR_SUFFIX is appended to it in code where relevant
- LEGACY_CONF_DIR = "opscode".freeze
-
- # Enable forcing Chef EULA
- ENFORCE_LICENSE = true
-
- # The servers's alias (chef-server)
- SERVER = "chef-server".freeze
-
- # The server's configuration utility
- SERVER_CTL = "chef-server-ctl".freeze
-
- end
-end
diff --git a/chef-utils/lib/chef-utils/dist.rb b/chef-utils/lib/chef-utils/dist.rb
index 0493e65c3a..73c9c463af 100644
--- a/chef-utils/lib/chef-utils/dist.rb
+++ b/chef-utils/lib/chef-utils/dist.rb
@@ -1,52 +1,50 @@
module ChefUtils
+ # This class is not fully implemented, depending on it is not recommended!
module Dist
class Apply
# The chef-apply product name
PRODUCT = "Chef Infra Apply".freeze
+
# The chef-apply binary
EXEC = "chef-apply".freeze
end
+
class Automate
+ # name of the automate product
PRODUCT = "Chef Automate".freeze
end
- class Compliance
- PRODUCT = "Chef Compliance".freeze
- end
+
class Infra
- # When referencing a product directly, as in "Chef Infra"
+ # When referencing a product directly, like Chef (Now Chef Infra)
PRODUCT = "Chef Infra Client".freeze
- # The chef-main-wrapper executable name.
- EXEC = "chef".freeze
+ # A short designation for the product, used in Windows event logs
+ # and some nomenclature.
+ SHORT = "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
- # "chef" => /etc/cinc, /var/cinc, C:\\cinc
- DIR_SUFFIX = "chef".freeze
-
- # The user's configuration directory
- USER_CONF_DIR = ".chef".freeze
+ # The chef executable, as in `chef gem install` or `chef generate cookbook`
+ EXEC = "chef".freeze
- # chef-shell executable
+ # The chef-shell executable
SHELL = "chef-shell".freeze
- # The chef-shell default configuration file
+ # Configuration related constants
+ # The chef-shell configuration file
SHELL_CONF = "chef_shell.rb".freeze
- end
- class Inspec
- PRODUCT = "Chef Inspec".freeze
- EXEC = "inspec".freeze
+ # The user's configuration directory
+ USER_CONF_DIR = ".chef".freeze
- DIR_SUFFIX = "inspec".freeze
+ # The suffix for Chef's /etc/chef, /var/chef and C:\\Chef directories
+ # "chef" => /etc/cinc, /var/cinc, C:\\cinc
+ DIR_SUFFIX = "chef".freeze
end
+
class Org
- # Main Website address
+ # product Website address
WEBSITE = "https://chef.io".freeze
# The downloads site
@@ -55,22 +53,25 @@ module ChefUtils
# The legacy conf folder: C:/opscode/chef. Specifically the "opscode" part
# DIR_SUFFIX is appended to it in code where relevant
LEGACY_CONF_DIR = "opscode".freeze
- end
- class Run
- # chef-run's product name
- PRODUCT = "Chef Infra Run".freeze
- # The chef-run binary
- EXEC = "chef-run".freeze
+ # Enable forcing Chef EULA
+ ENFORCE_LICENSE = true
end
+
class Server
# The name of the server product
PRODUCT = "Chef Infra Server".freeze
- # Assumed location of the chef-server configuration directory
- # TODO: This actually sounds like a job for ChefUtils methods
+ # The server's configuration directory
CONF_DIR = "/etc/chef-server".freeze
+
+ # The servers's alias (chef-server)
+ SERVER = "chef-server".freeze
+
+ # The server's configuration utility
+ SERVER_CTL = "chef-server-ctl".freeze
end
+
class Solo
# Chef-Solo's product name
PRODUCT = "Chef Infra Solo".freeze
@@ -78,19 +79,7 @@ module ChefUtils
# The chef-solo executable (legacy local mode)
EXEC = "chef-solo".freeze
end
- class Workstation
- # The Workstation's product name
- PRODUCT = "Chef Workstation".freeze
- # The old ChefDK product name
- DK = "ChefDK".freeze
-
- # The suffix for workstation's eponymous folders, like /opt/workstation
- DIR_SUFFIX = "chef-workstation".freeze
-
- # The suffix for ChefDK's eponymous folders, like /opt/chef-dk
- LEGACY_DIR_SUFFIX = "chef-dk".freeze
- end
class Zero
# chef-zero executable
PRODUCT = "Chef Infra Zero".freeze
diff --git a/lib/chef/application/client.rb b/lib/chef/application/client.rb
index 77b8de3d0d..d9ab58eced 100644
--- a/lib/chef/application/client.rb
+++ b/lib/chef/application/client.rb
@@ -153,7 +153,7 @@ class Chef::Application::Client < Chef::Application::Base
if config[:local_mode]
config[:config_file] = Chef::WorkstationConfigLoader.new(nil, Chef::Log).config_location
else
- config[:config_file] = "#{ChefConfig::Config.etc_chef_dir}/client.rb"
+ config[:config_file] = Chef::Config.platform_specific_path("#{ChefConfig::Config.etc_chef_dir}/client.rb")
end
end
diff --git a/lib/chef/knife/bootstrap.rb b/lib/chef/knife/bootstrap.rb
index 64943b5a23..e8d1636223 100644
--- a/lib/chef/knife/bootstrap.rb
+++ b/lib/chef/knife/bootstrap.rb
@@ -540,7 +540,7 @@ class Chef
end
def run
- check_license if ChefConfig::Dist::ENFORCE_LICENSE
+ check_license if ChefUtils::Dist::Org::ENFORCE_LICENSE
plugin_setup!
validate_name_args!
diff --git a/lib/chef/node_map.rb b/lib/chef/node_map.rb
index 30a0ed6c4e..ae65d2fc66 100644
--- a/lib/chef/node_map.rb
+++ b/lib/chef/node_map.rb
@@ -36,7 +36,7 @@
# XXX: confusingly, in the *_priority_map the :klass may be an array of Strings of class names
#
-require_relative "dist"
+require "chef-utils/dist"
class Chef
class NodeMap
@@ -86,7 +86,7 @@ class Chef
else
klass.superclass.to_s
end
- Chef::Log.warn( COLLISION_WARNING % { type: type_of_thing, key: key, type_caps: type_of_thing.capitalize, client_name: Chef::Dist::PRODUCT } )
+ Chef::Log.warn( COLLISION_WARNING % { type: type_of_thing, key: key, type_caps: type_of_thing.capitalize, client_name: ChefUtils::Dist::Infra::PRODUCT } )
end
# The map is sorted in order of preference already; we just need to find
diff --git a/lib/chef/resource/chef_gem.rb b/lib/chef/resource/chef_gem.rb
index ba2dae96b9..80aa2e1859 100644
--- a/lib/chef/resource/chef_gem.rb
+++ b/lib/chef/resource/chef_gem.rb
@@ -27,27 +27,27 @@ class Chef
provides :chef_gem
description <<~DESC
- Use the **chef_gem** resource to install a gem only for the instance of Ruby that is dedicated to the #{Chef::Dist::CLIENT}.
+ Use the **chef_gem** resource to install a gem only for the instance of Ruby that is dedicated to the #{ChefUtils::Dist::Infra::CLIENT}.
When a gem is installed from a local file, it must be added to the node using the **remote_file** or **cookbook_file** resources.
The **chef_gem** resource works with all of the same properties and options as the **gem_package** resource, but does not
- accept the `gem_binary` property because it always uses the `CurrentGemEnvironment` under which the `#{Chef::Dist::CLIENT}` is
+ accept the `gem_binary` property because it always uses the `CurrentGemEnvironment` under which the `#{ChefUtils::Dist::Infra::CLIENT}` is
running. In addition to performing actions similar to the **gem_package** resource, the **chef_gem** resource does the
following:
- Runs its actions immediately, before convergence, allowing a gem to be used in a recipe immediately after it is installed.
- Runs `Gem.clear_paths` after the action, ensuring that gem is aware of changes so that it can be required immediately after it is installed.
- Warning: The **chef_gem** and **gem_package** resources are both used to install Ruby gems. For any machine on which #{Chef::Dist::PRODUCT} is
+ Warning: The **chef_gem** and **gem_package** resources are both used to install Ruby gems. For any machine on which #{ChefUtils::Dist::Infra::PRODUCT} is
installed, there are two instances of Ruby. One is the standard, system-wide instance of Ruby and the other is a dedicated instance that is
- available only to #{Chef::Dist::PRODUCT}.
- Use the **chef_gem** resource to install gems into the instance of Ruby that is dedicated to #{Chef::Dist::PRODUCT}.
+ available only to #{ChefUtils::Dist::Infra::PRODUCT}.
+ Use the **chef_gem** resource to install gems into the instance of Ruby that is dedicated to #{ChefUtils::Dist::Infra::PRODUCT}.
Use the **gem_package** resource to install all other gems (i.e. install gems system-wide).
DESC
examples <<~EXAMPLES
**Compile time vs. converge time installation of gems**
- To install a gem while #{Chef::Dist::PRODUCT} is configuring the node (the converge phase), set the `compile_time` property to `false`:
+ To install a gem while #{ChefUtils::Dist::Infra::PRODUCT} is configuring the node (the converge phase), set the `compile_time` property to `false`:
```ruby
chef_gem 'right_aws' do
compile_time false
diff --git a/lib/chef/resource/gem_package.rb b/lib/chef/resource/gem_package.rb
index 63233d5cb6..0fc469b5c9 100644
--- a/lib/chef/resource/gem_package.rb
+++ b/lib/chef/resource/gem_package.rb
@@ -31,10 +31,10 @@ class Chef
Note: The **gem_package** resource must be specified as `gem_package` and cannot be shortened to `package` in a recipe.
- Warning: The **chef_gem** and **gem_package** resources are both used to install Ruby gems. For any machine on which #{Chef::Dist::PRODUCT} is
+ Warning: The **chef_gem** and **gem_package** resources are both used to install Ruby gems. For any machine on which #{ChefUtils::Dist::Infra::PRODUCT} is
installed, there are two instances of Ruby. One is the standard, system-wide instance of Ruby and the other is a dedicated instance that is
- available only to #{Chef::Dist::PRODUCT}.
- Use the **chef_gem** resource to install gems into the instance of Ruby that is dedicated to #{Chef::Dist::PRODUCT}.
+ available only to #{ChefUtils::Dist::Infra::PRODUCT}.
+ Use the **chef_gem** resource to install gems into the instance of Ruby that is dedicated to #{ChefUtils::Dist::Infra::PRODUCT}.
Use the **gem_package** resource to install all other gems (i.e. install gems system-wide).
DESC
diff --git a/lib/chef/resource/homebrew_update.rb b/lib/chef/resource/homebrew_update.rb
index 17d756b039..5298104636 100644
--- a/lib/chef/resource/homebrew_update.rb
+++ b/lib/chef/resource/homebrew_update.rb
@@ -19,7 +19,7 @@
#
require_relative "../resource"
-require_relative "../dist"
+require "chef-utils/dist"
class Chef
class Resource
@@ -38,7 +38,7 @@ class Chef
action :periodic
end
```
- **Update the Homebrew repository at the start of a #{Chef::Dist::PRODUCT} run**:
+ **Update the Homebrew repository at the start of a #{ChefUtils::Dist::Infra::PRODUCT} run**:
```ruby
homebrew_update 'update'
```
diff --git a/lib/chef/resource/macos_userdefaults.rb b/lib/chef/resource/macos_userdefaults.rb
index ab789635e7..7ac4b20a6d 100644
--- a/lib/chef/resource/macos_userdefaults.rb
+++ b/lib/chef/resource/macos_userdefaults.rb
@@ -16,7 +16,7 @@
#
require_relative "../resource"
-require_relative "../dist"
+require "chef-utils/dist"
autoload :Plist, "plist"
class Chef
@@ -97,7 +97,7 @@ class Chef
desired_state: false
property :sudo, [TrueClass, FalseClass],
- description: "Set to true if the setting you wish to modify requires privileged access. This requires passwordless sudo for the '/usr/bin/defaults' command to be setup for the user running #{Chef::Dist::PRODUCT}.",
+ description: "Set to true if the setting you wish to modify requires privileged access. This requires passwordless sudo for the '/usr/bin/defaults' command to be setup for the user running #{ChefUtils::Dist::Infra::PRODUCT}.",
default: false,
desired_state: false