chef-config 16.4.41 → 16.8.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 67e39a5c8e89a20bd23d7b2187c178ce62226d082b8394af6e119de8ae9a795d
4
- data.tar.gz: 54957b26ad4c522a0fd1049fc7993c6b169eec3d96ec90ac5e50af773c3b81d5
3
+ metadata.gz: 48bece5d842109bc65b051a1ab3eebf9b4a565386b6fd0cbd82f1c2dd618df46
4
+ data.tar.gz: 936c29a2bcb8bd469f075e758437cfaeb1cc6e0c32f4ce212f85b18c94d2b070
5
5
  SHA512:
6
- metadata.gz: fb6fe56b7a2847ebec13e5ca5d4838730214f2416f02c47de9519049e02302c7f9a1a55df58ed62c8e067f3093a3f4b6a68b0b7146d9906bcc463c891160e75a
7
- data.tar.gz: 54c77b2de4a193aef3888ec722c7a8c43efb63c8b35b232bef03c53ddc6961b632fa2bd77887aff24215c88bd290a4c945716e813943295d8999a84641f7a12c
6
+ metadata.gz: 31d811b3d5cc5a01212f83350d62eed0cd1113d096f348f41c878c5844c886005a0adc1abd1b7de20c54e9a2e3e247fcc8236371e6ec39ad015d45c1af53675a
7
+ data.tar.gz: e370c2e66a3d3d5a65b8f1222a283580f5ceb1838fc3a0711059015b06fd16faca9abe3913f28822077f4632570a5a472e9415777014902e3389ac3c69fc2631
@@ -8,10 +8,20 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ["Adam Jacob"]
9
9
  spec.email = ["adam@chef.io"]
10
10
 
11
- spec.summary = %q{Chef's default configuration and config loading}
11
+ spec.summary = %q{Chef Infra's default configuration and config loading library}
12
12
  spec.homepage = "https://github.com/chef/chef"
13
13
  spec.license = "Apache-2.0"
14
14
 
15
+ spec.required_ruby_version = ">= 2.6.0"
16
+
17
+ spec.metadata = {
18
+ "bug_tracker_uri" => "https://github.com/chef/chef/issues",
19
+ "changelog_uri" => "https://github.com/chef/chef/blob/master/CHANGELOG.md",
20
+ "documentation_uri" => "https://github.com/chef/chef/tree/master/chef-config/README.md",
21
+ "homepage_uri" => "https://github.com/chef/chef/tree/master/chef-config",
22
+ "source_code_uri" => "https://github.com/chef/chef/tree/master/chef-config",
23
+ }
24
+
15
25
  spec.require_paths = ["lib"]
16
26
 
17
27
  spec.add_dependency "chef-utils", "= #{ChefConfig::VERSION}"
@@ -21,12 +31,6 @@ Gem::Specification.new do |spec|
21
31
  spec.add_dependency "addressable"
22
32
  spec.add_dependency "tomlrb", "~> 1.2"
23
33
 
24
- spec.add_development_dependency "rake"
25
-
26
- %w{rspec-core rspec-expectations rspec-mocks}.each do |rspec|
27
- spec.add_development_dependency(rspec, "~> 3.2")
28
- end
29
-
30
34
  spec.files = %w{Rakefile LICENSE} + Dir.glob("*.gemspec") +
31
35
  Dir.glob("{lib,spec}/**/*", File::FNM_DOTMATCH).reject { |f| File.directory?(f) }
32
36
 
@@ -20,8 +20,8 @@
20
20
  # limitations under the License.
21
21
 
22
22
  require "mixlib/config" unless defined?(Mixlib::Config)
23
- require "pathname" unless defined?(Pathname)
24
- require "chef-utils" unless defined?(ChefUtils::CANARY)
23
+ autoload :Pathname, "pathname"
24
+ autoload :ChefUtils, "chef-utils"
25
25
 
26
26
  require_relative "fips"
27
27
  require_relative "logger"
@@ -29,12 +29,16 @@ require_relative "windows"
29
29
  require_relative "path_helper"
30
30
  require_relative "mixin/fuzzy_hostname_matcher"
31
31
 
32
- require "mixlib/shellout" unless defined?(Mixlib::ShellOut::DEFAULT_READ_TIMEOUT)
33
- require "uri" unless defined?(URI)
34
- require "addressable/uri" unless defined?(Addressable::URI)
35
- require "openssl" unless defined?(OpenSSL)
36
- require "yaml"
37
- require_relative "dist"
32
+ module Mixlib
33
+ autoload :ShellOut, "mixlib/shellout"
34
+ end
35
+ autoload :URI, "uri"
36
+ module Addressable
37
+ autoload :URI, "addressable/uri"
38
+ end
39
+ autoload :OpenSSL, "openssl"
40
+ autoload :YAML, "yaml"
41
+ require "chef-utils/dist" unless defined?(ChefUtils::Dist)
38
42
 
39
43
  module ChefConfig
40
44
 
@@ -80,7 +84,7 @@ module ChefConfig
80
84
  # @return [String] the platform-specific path
81
85
  #
82
86
  def self.etc_chef_dir(windows: ChefUtils.windows?)
83
- path = windows ? c_chef_dir : PathHelper.join("/etc", ChefConfig::Dist::DIR_SUFFIX, windows: windows)
87
+ path = windows ? c_chef_dir : PathHelper.join("/etc", ChefUtils::Dist::Infra::DIR_SUFFIX, windows: windows)
84
88
  PathHelper.cleanpath(path, windows: windows)
85
89
  end
86
90
 
@@ -90,7 +94,7 @@ module ChefConfig
90
94
  # @return [String] the platform-specific path
91
95
  #
92
96
  def self.var_chef_dir(windows: ChefUtils.windows?)
93
- path = windows ? c_chef_dir : PathHelper.join("/var", ChefConfig::Dist::DIR_SUFFIX, windows: windows)
97
+ path = windows ? c_chef_dir : PathHelper.join("/var", ChefUtils::Dist::Infra::DIR_SUFFIX, windows: windows)
94
98
  PathHelper.cleanpath(path, windows: windows)
95
99
  end
96
100
 
@@ -112,7 +116,7 @@ module ChefConfig
112
116
  #
113
117
  def self.c_chef_dir(windows: ChefUtils.windows?)
114
118
  drive = windows_installation_drive || "C:"
115
- PathHelper.join(drive, ChefConfig::Dist::DIR_SUFFIX, windows: windows)
119
+ PathHelper.join(drive, ChefUtils::Dist::Infra::DIR_SUFFIX, windows: windows)
116
120
  end
117
121
 
118
122
  # On windows, C:/opscode
@@ -123,7 +127,7 @@ module ChefConfig
123
127
  #
124
128
  def self.c_opscode_dir(windows: ChefUtils.windows?)
125
129
  drive = windows_installation_drive || "C:"
126
- PathHelper.join(drive, ChefConfig::Dist::LEGACY_CONF_DIR, ChefConfig::Dist::DIR_SUFFIX, windows: windows)
130
+ PathHelper.join(drive, ChefUtils::Dist::Org::LEGACY_CONF_DIR, ChefUtils::Dist::Infra::DIR_SUFFIX, windows: windows)
127
131
  end
128
132
 
129
133
  # the drive where Chef is installed on a windows host. This is determined
@@ -188,7 +192,7 @@ module ChefConfig
188
192
  if config_file
189
193
  PathHelper.dirname(PathHelper.canonical_path(config_file, false))
190
194
  else
191
- PathHelper.join(PathHelper.cleanpath(user_home), ChefConfig::Dist::USER_CONF_DIR, "")
195
+ PathHelper.join(PathHelper.cleanpath(user_home), ChefUtils::Dist::Infra::USER_CONF_DIR, "")
192
196
  end
193
197
  end
194
198
 
@@ -267,7 +271,7 @@ module ChefConfig
267
271
  end
268
272
  path = new_path
269
273
  end
270
- ChefConfig.logger.info("Auto-discovered #{ChefConfig::Dist::SHORT} repository at #{path}")
274
+ ChefConfig.logger.info("Auto-discovered #{ChefUtils::Dist::Infra::SHORT} repository at #{path}")
271
275
  path
272
276
  end
273
277
 
@@ -365,7 +369,7 @@ module ChefConfig
365
369
  # Otherwise, we'll create .chef under the user's home directory and use that as
366
370
  # the cache path.
367
371
  unless path_accessible?(primary_cache_path) || path_accessible?(primary_cache_root)
368
- secondary_cache_path = PathHelper.join(user_home, ChefConfig::Dist::USER_CONF_DIR)
372
+ secondary_cache_path = PathHelper.join(user_home, ChefUtils::Dist::Infra::USER_CONF_DIR)
369
373
  secondary_cache_path = target_mode? ? PathHelper.join(secondary_cache_path, target_mode.host) : secondary_cache_path
370
374
  ChefConfig.logger.trace("Unable to access cache at #{primary_cache_path}. Switching cache to #{secondary_cache_path}")
371
375
  secondary_cache_path
@@ -396,7 +400,7 @@ module ChefConfig
396
400
  # If your `file_cache_path` resides on a NFS (or non-flock()-supporting
397
401
  # fs), it's recommended to set this to something like
398
402
  # '/tmp/chef-client-running.pid'
399
- default(:lockfile) { PathHelper.join(file_cache_path, "#{ChefConfig::Dist::CLIENT}-running.pid") }
403
+ default(:lockfile) { PathHelper.join(file_cache_path, "#{ChefUtils::Dist::Infra::CLIENT}-running.pid") }
400
404
 
401
405
  ## Daemonization Settings ##
402
406
  # What user should Chef run as?
@@ -645,7 +649,7 @@ module ChefConfig
645
649
  # credentials toml files which doesn't allow ruby symbol values
646
650
  configurable(:ssl_verify_mode).writes_value do |value|
647
651
  if value.is_a?(String) && value[0] == ":"
648
- value[1..-1].to_sym
652
+ value[1..].to_sym
649
653
  else
650
654
  value.to_sym
651
655
  end
@@ -793,7 +797,7 @@ module ChefConfig
793
797
  if chef_server_url.to_s =~ %r{/organizations/(.*)$}
794
798
  "#{$1}-validator"
795
799
  else
796
- "#{ChefConfig::Dist::SHORT}-validator"
800
+ "#{ChefUtils::Dist::Infra::SHORT}-validator"
797
801
  end
798
802
  end
799
803
 
@@ -867,7 +871,7 @@ module ChefConfig
867
871
  default :profile, nil
868
872
 
869
873
  default :chef_guid_path do
870
- PathHelper.join(config_dir, "#{ChefConfig::Dist::SHORT}_guid")
874
+ PathHelper.join(config_dir, "#{ChefUtils::Dist::Infra::SHORT}_guid")
871
875
  end
872
876
 
873
877
  default :chef_guid, nil
@@ -1076,7 +1080,7 @@ module ChefConfig
1076
1080
  # generated by the DataCollector when Chef is run in Solo mode. This
1077
1081
  # allows users to associate their Solo nodes with faux organizations
1078
1082
  # without the nodes being connected to an actual Chef Server.
1079
- default :organization, "#{ChefConfig::Dist::SHORT}_solo"
1083
+ default :organization, "#{ChefUtils::Dist::Infra::SHORT}_solo"
1080
1084
  end
1081
1085
 
1082
1086
  configurable(:http_proxy)
@@ -1102,13 +1106,6 @@ module ChefConfig
1102
1106
  export_no_proxy(no_proxy) if key?(:no_proxy) && no_proxy
1103
1107
  end
1104
1108
 
1105
- # Character classes for Addressable
1106
- # See https://www.ietf.org/rfc/rfc3986.txt 3.2.1
1107
- # The user part may not have a : in it
1108
- USER = Addressable::URI::CharacterClasses::UNRESERVED + Addressable::URI::CharacterClasses::SUB_DELIMS
1109
- # The password part may have any valid USERINFO characters
1110
- PASSWORD = USER + "\\:"
1111
-
1112
1109
  # Builds a proxy uri and exports it to the appropriate environment variables. Examples:
1113
1110
  # http://username:password@hostname:port
1114
1111
  # https://username@hostname:port
@@ -1120,15 +1117,22 @@ module ChefConfig
1120
1117
  # pass = password
1121
1118
  # @api private
1122
1119
  def self.export_proxy(scheme, path, user, pass)
1120
+ # Character classes for Addressable
1121
+ # See https://www.ietf.org/rfc/rfc3986.txt 3.2.1
1122
+ # The user part may not have a : in it
1123
+ user_class = Addressable::URI::CharacterClasses::UNRESERVED + Addressable::URI::CharacterClasses::SUB_DELIMS
1124
+ # The password part may have any valid USERINFO characters
1125
+ password_class = user_class + "\\:"
1126
+
1123
1127
  path = "#{scheme}://#{path}" unless path.include?("://")
1124
1128
  # URI.split returns the following parts:
1125
1129
  # [scheme, userinfo, host, port, registry, path, opaque, query, fragment]
1126
1130
  uri = Addressable::URI.encode(path, Addressable::URI)
1127
1131
 
1128
1132
  if user && !user.empty?
1129
- userinfo = Addressable::URI.encode_component(user, USER)
1133
+ userinfo = Addressable::URI.encode_component(user, user_class)
1130
1134
  if pass
1131
- userinfo << ":#{Addressable::URI.encode_component(pass, PASSWORD)}"
1135
+ userinfo << ":#{Addressable::URI.encode_component(pass, password_class)}"
1132
1136
  end
1133
1137
  uri.userinfo = userinfo
1134
1138
  end
@@ -1203,7 +1207,7 @@ module ChefConfig
1203
1207
  # Transform into the form en_ZZ.UTF-8
1204
1208
  guessed_locale.gsub(/UTF-?8$/i, "UTF-8")
1205
1209
  else
1206
- ChefConfig.logger.warn "Please install an English UTF-8 locale for Chef to use, falling back to C locale and disabling UTF-8 support."
1210
+ ChefConfig.logger.warn "Please install an English UTF-8 locale for #{ChefUtils::Dist::Infra::PRODUCT} to use, falling back to C locale and disabling UTF-8 support."
1207
1211
  "C"
1208
1212
  end
1209
1213
  end
@@ -1256,9 +1260,9 @@ module ChefConfig
1256
1260
  # @api private
1257
1261
  def self.enable_fips_mode
1258
1262
  OpenSSL.fips_mode = true
1259
- require "digest"
1260
- require "digest/sha1"
1261
- require "digest/md5"
1263
+ require "digest" unless defined?(Digest)
1264
+ require "digest/sha1" unless defined?(Digest::SHA1)
1265
+ require "digest/md5" unless defined?(Digest::MD5)
1262
1266
  # Remove pre-existing constants if they do exist to reduce the
1263
1267
  # amount of log spam and warnings.
1264
1268
  Digest.send(:remove_const, "SHA1") if Digest.const_defined?("SHA1")
@@ -15,8 +15,9 @@
15
15
  # limitations under the License.
16
16
  #
17
17
 
18
- require "tomlrb"
18
+ autoload :Tomlrb, "tomlrb"
19
19
  require_relative "../path_helper"
20
+ require "chef-utils/dist" unless defined?(ChefUtils::Dist)
20
21
 
21
22
  module ChefConfig
22
23
  module Mixin
@@ -36,7 +37,7 @@ module ChefConfig
36
37
  # normally set via a command-line option.
37
38
  # @return [String]
38
39
  def credentials_profile(profile = nil)
39
- context_file = PathHelper.home(ChefConfig::Dist::USER_CONF_DIR, "context").freeze
40
+ context_file = PathHelper.home(ChefUtils::Dist::Infra::USER_CONF_DIR, "context").freeze
40
41
  if !profile.nil?
41
42
  profile
42
43
  elsif ENV.include?("CHEF_PROFILE")
@@ -53,7 +54,7 @@ module ChefConfig
53
54
  # @since 14.4
54
55
  # @return [String]
55
56
  def credentials_file_path
56
- PathHelper.home(ChefConfig::Dist::USER_CONF_DIR, "credentials").freeze
57
+ PathHelper.home(ChefUtils::Dist::Infra::USER_CONF_DIR, "credentials").freeze
57
58
  end
58
59
 
59
60
  # Load and parse the credentials file.
@@ -84,17 +85,17 @@ module ChefConfig
84
85
  # @return [void]
85
86
  def load_credentials(profile = nil)
86
87
  profile = credentials_profile(profile)
87
- config = parse_credentials_file
88
- return if config.nil? # No credentials, nothing to do here.
88
+ cred_config = parse_credentials_file
89
+ return if cred_config.nil? # No credentials, nothing to do here.
89
90
 
90
- if config[profile].nil?
91
+ if cred_config[profile].nil?
91
92
  # Unknown profile name. For "default" just silently ignore, otherwise
92
93
  # raise an error.
93
94
  return if profile == "default"
94
95
 
95
96
  raise ChefConfig::ConfigurationError, "Profile #{profile} doesn't exist. Please add it to #{credentials_file_path}."
96
97
  end
97
- apply_credentials(config[profile], profile)
98
+ apply_credentials(cred_config[profile], profile)
98
99
  end
99
100
  end
100
101
  end
@@ -20,6 +20,7 @@ module ChefConfig
20
20
  module Mixin
21
21
  module DotD
22
22
  # Find available configuration files in a `.d/` style include directory.
23
+ # Make sure we exclude anything that's not a file so we avoid directories ending in .rb (just in case)
23
24
  #
24
25
  # @api internal
25
26
  # @param path [String] Base .d/ path to load from.
@@ -20,8 +20,16 @@ module ChefConfig
20
20
  module Mixin
21
21
  module FuzzyHostnameMatcher
22
22
 
23
+ #
24
+ # Check to see if a hostname matches a match string. Used to see if hosts fall under our no_proxy config
25
+ #
26
+ # @param [String] hostname the hostname to check
27
+ # @param [String] matches the pattern to match
28
+ #
29
+ # @return [Boolean]
30
+ #
23
31
  def fuzzy_hostname_match_any?(hostname, matches)
24
- if (!hostname.nil?) && (!matches.nil?)
32
+ if hostname && matches
25
33
  return matches.to_s.split(/\s*,\s*/).compact.any? do |m|
26
34
  fuzzy_hostname_match?(hostname, m)
27
35
  end
@@ -0,0 +1,141 @@
1
+ # Author:: Bryan McLellan <btm@loftninjas.org>
2
+ # Copyright:: Copyright (c) Chef Software Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require_relative "credentials"
19
+ autoload :Train, "train"
20
+ require_relative "../config"
21
+ require "chef-utils/dist" unless defined?(ChefUtils::Dist)
22
+
23
+ module ChefConfig
24
+ module Mixin
25
+ module TrainTransport
26
+ include ChefConfig::Mixin::Credentials
27
+
28
+ attr_accessor :logger
29
+
30
+ def initialize(logger)
31
+ @logger = logger
32
+ end
33
+
34
+ #
35
+ # Returns a RFC099 credentials profile as a hash
36
+ #
37
+ def load_credentials(profile)
38
+ # Tomlrb.load_file returns a hash with keys as strings
39
+ credentials = parse_credentials_file
40
+ if contains_split_fqdn?(credentials, profile)
41
+ logger.warn("Credentials file #{credentials_file_path} contains target '#{profile}' as a Hash, expected a string.")
42
+ logger.warn("Hostnames must be surrounded by single quotes, e.g. ['host.example.org']")
43
+ end
44
+
45
+ # host names must be specified in credentials file as ['foo.example.org'] with quotes
46
+ if !credentials.nil? && !credentials[profile].nil?
47
+ credentials[profile].transform_keys(&:to_sym) # return symbolized keys to match Train.options()
48
+ else
49
+ nil
50
+ end
51
+ end
52
+
53
+ # Toml creates hashes when a key is separated by periods, e.g.
54
+ # [host.example.org] => { host: { example: { org: {} } } }
55
+ #
56
+ # Returns true if the above example is true
57
+ #
58
+ # A hostname has to be specified as ['host.example.org']
59
+ # This will be a common mistake so we should catch it
60
+ #
61
+ def contains_split_fqdn?(hash, fqdn)
62
+ fqdn.split(".").reduce(hash) do |h, k|
63
+ v = h[k]
64
+ if Hash === v
65
+ v
66
+ else
67
+ break false
68
+ end
69
+ end
70
+ end
71
+
72
+ # ChefConfig::Mixin::Credentials.credentials_file_path is designed around knife,
73
+ # overriding it here.
74
+ #
75
+ # Credentials file preference:
76
+ #
77
+ # 1) target_mode.credentials_file
78
+ # 2) /etc/chef/TARGET_MODE_HOST/credentials
79
+ # 3) #credentials_file_path from parent ($HOME/.chef/credentials)
80
+ #
81
+ def credentials_file_path
82
+ tm_config = config.target_mode
83
+ profile = tm_config.host
84
+
85
+ credentials_file =
86
+ if tm_config.credentials_file && File.exist?(tm_config.credentials_file)
87
+ tm_config.credentials_file
88
+ elsif File.exist?(config.platform_specific_path("#{ChefConfig::Config.etc_chef_dir}/#{profile}/credentials"))
89
+ config.platform_specific_path("#{ChefConfig::Config.etc_chef_dir}/#{profile}/credentials")
90
+ else
91
+ super
92
+ end
93
+
94
+ raise ArgumentError, "No credentials file found for target '#{profile}'" unless credentials_file
95
+ raise ArgumentError, "Credentials file specified for target mode does not exist: '#{credentials_file}'" unless File.exist?(credentials_file)
96
+
97
+ logger.debug("Loading credentials file '#{credentials_file}' for target '#{profile}'")
98
+
99
+ credentials_file
100
+ end
101
+
102
+ def build_transport
103
+ return nil unless config.target_mode?
104
+
105
+ # TODO: Consider supporting parsing the protocol from a URI passed to `--target`
106
+ #
107
+ train_config = {}
108
+
109
+ # Load the target_mode config context from config, and place any valid settings into the train configuration
110
+ tm_config = config.target_mode
111
+ protocol = tm_config.protocol
112
+ train_config = tm_config.to_hash.select { |k| Train.options(protocol).key?(k) }
113
+ logger.trace("Using target mode options from #{ChefUtils::Dist::Infra::PRODUCT} config file: #{train_config.keys.join(", ")}") if train_config
114
+
115
+ # Load the credentials file, and place any valid settings into the train configuration
116
+ credentials = load_credentials(tm_config.host)
117
+ if credentials
118
+ valid_settings = credentials.select { |k| Train.options(protocol).key?(k) }
119
+ valid_settings[:enable_password] = credentials[:enable_password] if credentials.key?(:enable_password)
120
+ train_config.merge!(valid_settings)
121
+ logger.trace("Using target mode options from credentials file: #{valid_settings.keys.join(", ")}") if valid_settings
122
+ end
123
+
124
+ train_config[:logger] = logger
125
+
126
+ # Train handles connection retries for us
127
+ Train.create(protocol, train_config)
128
+ rescue SocketError => e # likely a dns failure, not caught by train
129
+ e.message.replace "Error connecting to #{train_config[:target]} - #{e.message}"
130
+ raise e
131
+ rescue Train::PluginLoadError
132
+ logger.error("Invalid target mode protocol: #{protocol}")
133
+ exit(1)
134
+ end
135
+
136
+ def config
137
+ raise NotImplementedError
138
+ end
139
+ end
140
+ end
141
+ end
@@ -15,5 +15,5 @@
15
15
 
16
16
  module ChefConfig
17
17
  CHEFCONFIG_ROOT = File.expand_path("..", __dir__)
18
- VERSION = "16.4.41".freeze
18
+ VERSION = "16.8.9".freeze
19
19
  end
@@ -59,7 +59,7 @@ module ChefConfig
59
59
  @chef_config_dir = false
60
60
  full_path = working_directory.split(File::SEPARATOR)
61
61
  (full_path.length - 1).downto(0) do |i|
62
- candidate_directory = File.join(full_path[0..i] + [ChefConfig::Dist::USER_CONF_DIR])
62
+ candidate_directory = File.join(full_path[0..i] + [ChefUtils::Dist::Infra::USER_CONF_DIR])
63
63
  if File.exist?(candidate_directory) && File.directory?(candidate_directory)
64
64
  @chef_config_dir = candidate_directory
65
65
  break
@@ -129,7 +129,7 @@ module ChefConfig
129
129
  candidate_configs << File.join(chef_config_dir, "knife.rb")
130
130
  end
131
131
  # Look for $HOME/.chef/knife.rb
132
- PathHelper.home(ChefConfig::Dist::USER_CONF_DIR) do |dot_chef_dir|
132
+ PathHelper.home(ChefUtils::Dist::Infra::USER_CONF_DIR) do |dot_chef_dir|
133
133
  candidate_configs << File.join(dot_chef_dir, "config.rb")
134
134
  candidate_configs << File.join(dot_chef_dir, "knife.rb")
135
135
  end
@@ -166,7 +166,7 @@ module ChefConfig
166
166
  when "client_key"
167
167
  extract_key(value, :client_key, :client_key_contents)
168
168
  when "knife"
169
- Config.knife.merge!(Hash[value.map { |k, v| [k.to_sym, v] }])
169
+ Config.knife.merge!(value.transform_keys(&:to_sym))
170
170
  else
171
171
  Config[key.to_sym] = value
172
172
  end
@@ -184,7 +184,7 @@ module ChefConfig
184
184
  end
185
185
 
186
186
  def home_chef_dir
187
- @home_chef_dir ||= PathHelper.home(ChefConfig::Dist::USER_CONF_DIR)
187
+ @home_chef_dir ||= PathHelper.home(ChefUtils::Dist::Infra::USER_CONF_DIR)
188
188
  end
189
189
 
190
190
  def apply_config(config_content, config_file_path)
@@ -195,8 +195,8 @@ module ChefConfig
195
195
  message = ""
196
196
  message << "You have invalid ruby syntax in your config file #{config_file_path}\n\n"
197
197
  message << "#{e.class.name}: #{e.message}\n"
198
- if file_line = e.message[/#{Regexp.escape(config_file_path)}:[\d]+/]
199
- line = file_line[/:([\d]+)$/, 1].to_i
198
+ if file_line = e.message[/#{Regexp.escape(config_file_path)}:\d+/]
199
+ line = file_line[/:(\d+)$/, 1].to_i
200
200
  message << highlight_config_error(config_file_path, line)
201
201
  end
202
202
  raise ChefConfig::ConfigurationError, message
@@ -206,7 +206,7 @@ module ChefConfig
206
206
  filtered_trace = e.backtrace.grep(/#{Regexp.escape(config_file_path)}/)
207
207
  filtered_trace.each { |bt_line| message << " " << bt_line << "\n" }
208
208
  unless filtered_trace.empty?
209
- line_nr = filtered_trace.first[/#{Regexp.escape(config_file_path)}:([\d]+)/, 1]
209
+ line_nr = filtered_trace.first[/#{Regexp.escape(config_file_path)}:(\d+)/, 1]
210
210
  message << highlight_config_error(config_file_path, line_nr.to_i)
211
211
  end
212
212
  raise ChefConfig::ConfigurationError, message
@@ -170,7 +170,7 @@ RSpec.describe ChefConfig::Config do
170
170
  apply_config
171
171
  expect(described_class[:data_bag_path]).to eq("#{current_directory}/data_bags")
172
172
  expect(described_class[:cookbook_path]).to eq("#{current_directory}/cookbooks")
173
- expect(described_class[:chef_repo_path]).to eq("#{current_directory}")
173
+ expect(described_class[:chef_repo_path]).to eq(current_directory)
174
174
  end
175
175
  end
176
176
 
@@ -225,7 +225,7 @@ RSpec.describe ChefConfig::Config do
225
225
  end
226
226
 
227
227
  describe "#var_chef_path" do
228
- let (:dirname) { ChefConfig::Dist::DIR_SUFFIX }
228
+ let (:dirname) { ChefUtils::Dist::Infra::DIR_SUFFIX }
229
229
 
230
230
  context "on unix", :unix_only do
231
231
  it "var_chef_dir is /var/chef" do
@@ -931,7 +931,7 @@ RSpec.describe ChefConfig::Config do
931
931
 
932
932
  shared_examples_for "a suitable locale" do
933
933
  it "returns an English UTF-8 locale" do
934
- expect(ChefConfig.logger).to_not receive(:warn).with(/Please install an English UTF-8 locale for Chef to use/)
934
+ expect(ChefConfig.logger).to_not receive(:warn).with(/Please install an English UTF-8 locale for Chef Infra Client to use/)
935
935
  expect(ChefConfig.logger).to_not receive(:trace).with(/Defaulting to locale en_US.UTF-8 on Windows/)
936
936
  expect(ChefConfig.logger).to_not receive(:trace).with(/No usable locale -a command found/)
937
937
  expect(ChefConfig::Config.guess_internal_locale).to eq expected_locale
@@ -984,7 +984,7 @@ RSpec.describe ChefConfig::Config do
984
984
  let(:locale_array) { ["af_ZA", "af_ZA.ISO8859-1", "af_ZA.ISO8859-15", "af_ZA.UTF-8"] }
985
985
 
986
986
  it "should fall back to C locale" do
987
- expect(ChefConfig.logger).to receive(:warn).with("Please install an English UTF-8 locale for Chef to use, falling back to C locale and disabling UTF-8 support.")
987
+ expect(ChefConfig.logger).to receive(:warn).with("Please install an English UTF-8 locale for Chef Infra Client to use, falling back to C locale and disabling UTF-8 support.")
988
988
  expect(ChefConfig::Config.guess_internal_locale).to eq "C"
989
989
  end
990
990
  end
@@ -20,7 +20,7 @@ require "chef-config/fips"
20
20
  require "spec_helper"
21
21
 
22
22
  begin
23
- require "win32/registry"
23
+ require "win32/registry" unless defined?(Win32::Registry)
24
24
  rescue LoadError
25
25
  # not on unix
26
26
  end
@@ -17,7 +17,7 @@
17
17
  #
18
18
 
19
19
  require "spec_helper"
20
- require "tempfile"
20
+ require "tempfile" unless defined?(Tempfile)
21
21
 
22
22
  require "chef-config/exceptions"
23
23
  require "chef-utils"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-config
3
3
  version: !ruby/object:Gem::Version
4
- version: 16.4.41
4
+ version: 16.8.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Jacob
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-19 00:00:00.000000000 Z
11
+ date: 2020-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef-utils
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 16.4.41
19
+ version: 16.8.9
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 16.4.41
26
+ version: 16.8.9
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: mixlib-shellout
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -106,62 +106,6 @@ dependencies:
106
106
  - - "~>"
107
107
  - !ruby/object:Gem::Version
108
108
  version: '1.2'
109
- - !ruby/object:Gem::Dependency
110
- name: rake
111
- requirement: !ruby/object:Gem::Requirement
112
- requirements:
113
- - - ">="
114
- - !ruby/object:Gem::Version
115
- version: '0'
116
- type: :development
117
- prerelease: false
118
- version_requirements: !ruby/object:Gem::Requirement
119
- requirements:
120
- - - ">="
121
- - !ruby/object:Gem::Version
122
- version: '0'
123
- - !ruby/object:Gem::Dependency
124
- name: rspec-core
125
- requirement: !ruby/object:Gem::Requirement
126
- requirements:
127
- - - "~>"
128
- - !ruby/object:Gem::Version
129
- version: '3.2'
130
- type: :development
131
- prerelease: false
132
- version_requirements: !ruby/object:Gem::Requirement
133
- requirements:
134
- - - "~>"
135
- - !ruby/object:Gem::Version
136
- version: '3.2'
137
- - !ruby/object:Gem::Dependency
138
- name: rspec-expectations
139
- requirement: !ruby/object:Gem::Requirement
140
- requirements:
141
- - - "~>"
142
- - !ruby/object:Gem::Version
143
- version: '3.2'
144
- type: :development
145
- prerelease: false
146
- version_requirements: !ruby/object:Gem::Requirement
147
- requirements:
148
- - - "~>"
149
- - !ruby/object:Gem::Version
150
- version: '3.2'
151
- - !ruby/object:Gem::Dependency
152
- name: rspec-mocks
153
- requirement: !ruby/object:Gem::Requirement
154
- requirements:
155
- - - "~>"
156
- - !ruby/object:Gem::Version
157
- version: '3.2'
158
- type: :development
159
- prerelease: false
160
- version_requirements: !ruby/object:Gem::Requirement
161
- requirements:
162
- - - "~>"
163
- - !ruby/object:Gem::Version
164
- version: '3.2'
165
109
  description:
166
110
  email:
167
111
  - adam@chef.io
@@ -174,13 +118,13 @@ files:
174
118
  - chef-config.gemspec
175
119
  - lib/chef-config.rb
176
120
  - lib/chef-config/config.rb
177
- - lib/chef-config/dist.rb
178
121
  - lib/chef-config/exceptions.rb
179
122
  - lib/chef-config/fips.rb
180
123
  - lib/chef-config/logger.rb
181
124
  - lib/chef-config/mixin/credentials.rb
182
125
  - lib/chef-config/mixin/dot_d.rb
183
126
  - lib/chef-config/mixin/fuzzy_hostname_matcher.rb
127
+ - lib/chef-config/mixin/train_transport.rb
184
128
  - lib/chef-config/path_helper.rb
185
129
  - lib/chef-config/version.rb
186
130
  - lib/chef-config/windows.rb
@@ -193,7 +137,12 @@ files:
193
137
  homepage: https://github.com/chef/chef
194
138
  licenses:
195
139
  - Apache-2.0
196
- metadata: {}
140
+ metadata:
141
+ bug_tracker_uri: https://github.com/chef/chef/issues
142
+ changelog_uri: https://github.com/chef/chef/blob/master/CHANGELOG.md
143
+ documentation_uri: https://github.com/chef/chef/tree/master/chef-config/README.md
144
+ homepage_uri: https://github.com/chef/chef/tree/master/chef-config
145
+ source_code_uri: https://github.com/chef/chef/tree/master/chef-config
197
146
  post_install_message:
198
147
  rdoc_options: []
199
148
  require_paths:
@@ -202,15 +151,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
202
151
  requirements:
203
152
  - - ">="
204
153
  - !ruby/object:Gem::Version
205
- version: '0'
154
+ version: 2.6.0
206
155
  required_rubygems_version: !ruby/object:Gem::Requirement
207
156
  requirements:
208
157
  - - ">="
209
158
  - !ruby/object:Gem::Version
210
159
  version: '0'
211
160
  requirements: []
212
- rubygems_version: 3.1.2
161
+ rubygems_version: 3.1.4
213
162
  signing_key:
214
163
  specification_version: 4
215
- summary: Chef's default configuration and config loading
164
+ summary: Chef Infra's default configuration and config loading library
216
165
  test_files: []
@@ -1,33 +0,0 @@
1
- module ChefConfig
2
- class Dist
3
- # The chef executable name.
4
- EXEC = "chef".freeze
5
-
6
- # The client's alias (chef-client)
7
- CLIENT = "chef-client".freeze
8
-
9
- # A short name for the product
10
- SHORT = "chef".freeze
11
-
12
- # The suffix for Chef's /etc/chef, /var/chef and C:\\Chef directories
13
- # "cinc" => /etc/cinc, /var/cinc, C:\\cinc
14
- DIR_SUFFIX = "chef".freeze
15
-
16
- # The user's configuration directory
17
- USER_CONF_DIR = ".chef".freeze
18
-
19
- # The legacy conf folder: C:/opscode/chef. Specifically the "opscode" part
20
- # DIR_SUFFIX is appended to it in code where relevant
21
- LEGACY_CONF_DIR = "opscode".freeze
22
-
23
- # Enable forcing Chef EULA
24
- ENFORCE_LICENSE = true
25
-
26
- # The servers's alias (chef-server)
27
- SERVER = "chef-server".freeze
28
-
29
- # The server's configuration utility
30
- SERVER_CTL = "chef-server-ctl".freeze
31
-
32
- end
33
- end