summaryrefslogtreecommitdiff
path: root/chef-config/lib
diff options
context:
space:
mode:
Diffstat (limited to 'chef-config/lib')
-rw-r--r--chef-config/lib/chef-config/config.rb11
-rw-r--r--chef-config/lib/chef-config/exceptions.rb2
-rw-r--r--chef-config/lib/chef-config/fips.rb6
-rw-r--r--chef-config/lib/chef-config/path_helper.rb15
-rw-r--r--chef-config/lib/chef-config/version.rb17
-rw-r--r--chef-config/lib/chef-config/windows.rb12
-rw-r--r--chef-config/lib/chef-config/workstation_config_loader.rb5
7 files changed, 27 insertions, 41 deletions
diff --git a/chef-config/lib/chef-config/config.rb b/chef-config/lib/chef-config/config.rb
index 02acdf4ca2..d1c4001739 100644
--- a/chef-config/lib/chef-config/config.rb
+++ b/chef-config/lib/chef-config/config.rb
@@ -21,6 +21,7 @@
require "mixlib/config" unless defined?(Mixlib::Config)
require "pathname" unless defined?(Pathname)
+require "chef-utils" unless defined?(ChefUtils::CANARY)
require_relative "fips"
require_relative "logger"
@@ -60,7 +61,7 @@ module ChefConfig
# @return [String] a platform specific path
def self.platform_specific_path(path)
path = PathHelper.cleanpath(path)
- if ChefConfig.windows?
+ if ChefUtils.windows?
# turns \etc\chef\client.rb and \var\chef\client.rb into C:/chef/client.rb
# Some installations will be on different drives so use the drive that
# the expanded path to __FILE__ is found.
@@ -78,7 +79,7 @@ module ChefConfig
#
# @return [String] the drive letter
def self.windows_installation_drive
- if ChefConfig.windows?
+ if ChefUtils.windows?
drive = File.expand_path(__FILE__).split("/", 2)[0]
drive = ENV["SYSTEMDRIVE"] if drive.to_s == ""
drive
@@ -573,7 +574,7 @@ module ChefConfig
# Path to the default CA bundle files.
default :ssl_ca_path, nil
default(:ssl_ca_file) do
- if ChefConfig.windows? && embedded_dir
+ if ChefUtils.windows? && embedded_dir
cacert_path = File.join(embedded_dir, "ssl/certs/cacert.pem")
cacert_path if File.exist?(cacert_path)
else
@@ -841,7 +842,7 @@ module ChefConfig
# Those lists of regular expressions define what chef considers a
# valid user and group name
- if ChefConfig.windows?
+ if ChefUtils.windows?
set_defaults_for_windows
else
set_defaults_for_nix
@@ -1138,7 +1139,7 @@ module ChefConfig
end
end
rescue
- if ChefConfig.windows?
+ if ChefUtils.windows?
ChefConfig.logger.trace "Defaulting to locale en_US.UTF-8 on Windows, until it matters that we do something else."
else
ChefConfig.logger.trace "No usable locale -a command found, assuming you have en_US.UTF-8 installed."
diff --git a/chef-config/lib/chef-config/exceptions.rb b/chef-config/lib/chef-config/exceptions.rb
index 86d34374ab..2bd2fb415d 100644
--- a/chef-config/lib/chef-config/exceptions.rb
+++ b/chef-config/lib/chef-config/exceptions.rb
@@ -1,5 +1,5 @@
#
-# Copyright:: Copyright 2015-2016, Chef Software, Inc.
+# Copyright:: Copyright 2015-2019, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/chef-config/lib/chef-config/fips.rb b/chef-config/lib/chef-config/fips.rb
index 4c365301d5..06d039eb9e 100644
--- a/chef-config/lib/chef-config/fips.rb
+++ b/chef-config/lib/chef-config/fips.rb
@@ -1,6 +1,6 @@
#
# Author:: Matt Wrock (<matt@mattwrock.com>)
-# Copyright:: Copyright (c) 2016 Chef Software, Inc.
+# Copyright:: Copyright (c) 2016-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,10 +16,12 @@
# limitations under the License.
#
+require "chef-utils" unless defined?(ChefUtils::CANARY)
+
module ChefConfig
def self.fips?
- if ChefConfig.windows?
+ if ChefUtils.windows?
begin
require "win32/registry" unless defined?(Win32::Registry)
rescue LoadError
diff --git a/chef-config/lib/chef-config/path_helper.rb b/chef-config/lib/chef-config/path_helper.rb
index 6c60b82b89..9ffdd0be56 100644
--- a/chef-config/lib/chef-config/path_helper.rb
+++ b/chef-config/lib/chef-config/path_helper.rb
@@ -1,6 +1,6 @@
#
# Author:: Bryan McLellan <btm@loftninjas.org>
-# Copyright:: Copyright 2014-2018, Chef Software, Inc.
+# Copyright:: Copyright 2014-2019, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,6 +16,7 @@
# limitations under the License.
#
+require "chef-utils" unless defined?(ChefUtils::CANARY)
require_relative "windows"
require_relative "logger"
require_relative "exceptions"
@@ -26,7 +27,7 @@ module ChefConfig
WIN_MAX_PATH = 259
def self.dirname(path)
- if ChefConfig.windows?
+ if ChefUtils.windows?
# Find the first slash, not counting trailing slashes
end_slash = path.size
loop do
@@ -47,7 +48,7 @@ module ChefConfig
BACKSLASH = '\\'.freeze
def self.path_separator
- if ChefConfig.windows?
+ if ChefUtils.windows?
File::ALT_SEPARATOR || BACKSLASH
else
File::SEPARATOR
@@ -71,7 +72,7 @@ module ChefConfig
end
def self.validate_path(path)
- if ChefConfig.windows?
+ if ChefUtils.windows?
unless printable?(path)
msg = "Path '#{path}' contains non-printable characters. Check that backslashes are escaped with another backslash (e.g. C:\\\\Windows) in double-quoted strings."
ChefConfig.logger.error(msg)
@@ -114,7 +115,7 @@ module ChefConfig
# First remove extra separators and resolve any relative paths
abs_path = File.absolute_path(path)
- if ChefConfig.windows?
+ if ChefUtils.windows?
# Add the \\?\ API prefix on Windows unless add_prefix is false
# Downcase on Windows where paths are still case-insensitive
abs_path.gsub!(::File::SEPARATOR, path_separator)
@@ -142,7 +143,7 @@ module ChefConfig
def self.cleanpath(path)
path = Pathname.new(path).cleanpath.to_s
# ensure all forward slashes are backslashes
- if ChefConfig.windows?
+ if ChefUtils.windows?
path = path.gsub(File::SEPARATOR, path_separator)
end
path
@@ -219,7 +220,7 @@ module ChefConfig
paths = []
paths << ENV[@@per_tool_home_environment] if defined?(@@per_tool_home_environment) && @@per_tool_home_environment && ENV[@@per_tool_home_environment]
paths << ENV["CHEF_HOME"] if ENV["CHEF_HOME"]
- if ChefConfig.windows?
+ if ChefUtils.windows?
# By default, Ruby uses the the following environment variables to determine Dir.home:
# HOME
# HOMEDRIVE HOMEPATH
diff --git a/chef-config/lib/chef-config/version.rb b/chef-config/lib/chef-config/version.rb
index d345e107b5..3225d4f3cf 100644
--- a/chef-config/lib/chef-config/version.rb
+++ b/chef-config/lib/chef-config/version.rb
@@ -1,4 +1,4 @@
-# Copyright:: Copyright 2010-2016, Chef Software, Inc.
+# Copyright:: Copyright 2010-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,22 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-# NOTE: This file is generated by running `rake version` in the top level of
-# this repo. Do not edit this manually. Edit the VERSION file and run the rake
-# task instead.
-# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
module ChefConfig
CHEFCONFIG_ROOT = File.expand_path("../..", __FILE__)
VERSION = "15.4.69".freeze
end
-
-#
-# NOTE: the Chef::Version class is defined in version_class.rb
-#
-# NOTE: DO NOT Use the Chef::Version class on ChefConfig::VERSIONs. The
-# Chef::Version class is for _cookbooks_ only, and cannot handle
-# pre-release versions like "10.14.0.rc.2". Please use Rubygem's
-# Gem::Version class instead.
-#
diff --git a/chef-config/lib/chef-config/windows.rb b/chef-config/lib/chef-config/windows.rb
index 9c606110a4..ae39246f55 100644
--- a/chef-config/lib/chef-config/windows.rb
+++ b/chef-config/lib/chef-config/windows.rb
@@ -1,5 +1,5 @@
#
-# Copyright:: Copyright 2015-2016, Chef Software, Inc.
+# Copyright:: Copyright 2015-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,14 +15,10 @@
# limitations under the License.
#
-module ChefConfig
+require "chef-utils" unless defined?(ChefUtils::CANARY)
+module ChefConfig
def self.windows?
- if RUBY_PLATFORM =~ /mswin|mingw|windows/
- true
- else
- false
- end
+ ChefUtils.windows?
end
-
end
diff --git a/chef-config/lib/chef-config/workstation_config_loader.rb b/chef-config/lib/chef-config/workstation_config_loader.rb
index d38cae3d88..c5eb8b5678 100644
--- a/chef-config/lib/chef-config/workstation_config_loader.rb
+++ b/chef-config/lib/chef-config/workstation_config_loader.rb
@@ -1,6 +1,6 @@
#
# Author:: Daniel DeLeo (<dan@chef.io>)
-# Copyright:: Copyright 2014-2016, Chef Software, Inc.
+# Copyright:: Copyright 2014-2019, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,6 +16,7 @@
# limitations under the License.
#
+require "chef-utils" unless defined?(ChefUtils::CANARY)
require_relative "config"
require_relative "exceptions"
require_relative "logger"
@@ -139,7 +140,7 @@ module ChefConfig
end
def working_directory
- a = if ChefConfig.windows?
+ a = if ChefUtils.windows?
env["CD"]
else
env["PWD"]