Skip to content

Commit

Permalink
some leftover/new "Chef" references converted to distro constants
Browse files Browse the repository at this point in the history
Signed-off-by: Marc Chamberland <[email protected]>
  • Loading branch information
bobchaos committed Dec 5, 2019
1 parent e1a8a9d commit 13c693c
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions chef-bin/bin/chef-service-manager
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
$:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
require "chef"
require "chef/application/windows_service_manager"
require "chef/dist"

if Chef::Platform.windows?
chef_client_service = {
Expand Down
6 changes: 3 additions & 3 deletions lib/chef/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ def fork_chef_client
exit 0
end
end
logger.trace "Fork successful. Waiting for new chef pid: #{pid}"
logger.trace "Fork successful. Waiting for new #{Chef::Dist::CLIENT} pid: #{pid}"
result = Process.waitpid2(pid)
handle_child_exit(result)
logger.trace "Forked instance successfully reaped (pid: #{pid})"
Expand All @@ -355,9 +355,9 @@ def handle_child_exit(pid_and_status)
return true if status.success?

message = if status.signaled?
"Chef run process terminated by signal #{status.termsig} (#{Signal.list.invert[status.termsig]})"
"#{Chef::Dist::PRODUCT} run process terminated by signal #{status.termsig} (#{Signal.list.invert[status.termsig]})"
else
"Chef run process exited unsuccessfully (exit code #{status.exitstatus})"
"#{Chef::Dist::PRODUCT} run process exited unsuccessfully (exit code #{status.exitstatus})"
end
raise Exceptions::ChildConvergeError, message
end
Expand Down
3 changes: 2 additions & 1 deletion lib/chef/cookbook_site_streaming_uploader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
require "net/http" unless defined?(Net::HTTP)
require "mixlib/authentication/signedheaderauth"
require "openssl" unless defined?(OpenSSL)
require_relative "dist"

class Chef
# == Chef::CookbookSiteStreamingUploader
Expand All @@ -36,7 +37,7 @@ class CookbookSiteStreamingUploader
class << self

def create_build_dir(cookbook)
tmp_cookbook_path = Tempfile.new("chef-#{cookbook.name}-build")
tmp_cookbook_path = Tempfile.new("#{Chef::Dist::SHORT}-#{cookbook.name}-build")
tmp_cookbook_path.close
tmp_cookbook_dir = tmp_cookbook_path.path
File.unlink(tmp_cookbook_dir)
Expand Down
3 changes: 2 additions & 1 deletion lib/chef/deprecation/warnings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ module Deprecation
module Warnings

require_relative "../version"
require_relative "../dist"

def add_deprecation_warnings_for(method_names)
method_names.each do |name|
define_method(name) do |*args|
message = "Method '#{name}' of '#{self.class}' is deprecated. It will be removed in Chef #{Chef::VERSION.to_i.next}."
message = "Method '#{name}' of '#{self.class}' is deprecated. It will be removed in #{Chef::Dist::PRODUCT} #{Chef::VERSION.to_i.next}."
message << " Please update your cookbooks accordingly."
Chef.deprecated(:internal_api, message)
super(*args)
Expand Down
4 changes: 4 additions & 0 deletions lib/chef/dist.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ class Dist
# The chef executable, as in `chef gem install` or `chef generate cookbook`
EXEC = ChefConfig::Dist::EXEC.freeze

# A short name for the project, used in configurations
# Log messages, descriptions, etc...
SHORT = "chef".freeze

# product website address
WEBSITE = "https://chef.io".freeze

Expand Down
2 changes: 1 addition & 1 deletion lib/chef/exceptions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ def initialize
class CookbookChefVersionMismatch < RuntimeError
def initialize(chef_version, cookbook_name, cookbook_version, *constraints)
constraint_str = constraints.map { |c| c.requirement.as_list.to_s }.join(", ")
super "Cookbook '#{cookbook_name}' version '#{cookbook_version}' depends on chef version #{constraint_str}, but the running chef version is #{chef_version}"
super "Cookbook '#{cookbook_name}' version '#{cookbook_version}' depends on #{Chef::Dist::PRODUCT} version #{constraint_str}, but the running #{Chef::Dist::PRODUCT} version is #{chef_version}"
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/chef/shell/ext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def help(commmand = nil)
end
alias :halp :help

desc "prints information about chef"
desc "prints information about #{Chef::Dist::PRODUCT}"
def version
puts "This is the #{Chef::Dist::SHELL}.\n" +
" #{Chef::Dist::PRODUCT} Version: #{::Chef::VERSION}\n" +
Expand Down

0 comments on commit 13c693c

Please sign in to comment.