chef-config 16.4.35 → 16.6.14

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: 51f20c3e7f57cf6748f609f9bbf456889aeff48a3ce3457adecc63c2c4686085
4
- data.tar.gz: 449f8768c9f289352682f34cd242d11509a789804d70e291fd7034667a3fb9f3
3
+ metadata.gz: 49a836a5542d16354dd2413618811e835b443e7cf1824fdf14fe2c5cde0d0470
4
+ data.tar.gz: 4349ec1dc40bf46318850898999654419ee4dec8a1eabea1c5ccb60cf16dd0ad
5
5
  SHA512:
6
- metadata.gz: bb7293d322062c30c48ed4a4d62f5310e91ce2c60f7f71ae6c31d7bf51fa868142ad42f01019805a7b998963744e98127b554ed6d47a1de4be42d86972688296
7
- data.tar.gz: 9adbb97999cedcc8efb039ccbc413724baa64ddb2bd97b764f8f49cb65b01f39a19e59f71ea9fe3e3960120d52afb217898a12571535d5fe9574094c26f686de
6
+ metadata.gz: 0f350f0d1de851051a8214ad1a04b7c1a3766497193d1f3c313a94dff6bf5ade41dbcb96012728ee2eed78f01281ba985b9897a4467f5eb0aa5bd3330f800941
7
+ data.tar.gz: d12ff55d44befeb253724e5445c2ce8b791529d6721ed618d866bc2c3e9c5dd4224cafc4fa39951f925b131ca0db5931c4c4f01d5a10ec38d6df1927c5ffc415
@@ -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
@@ -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.35".freeze
18
+ VERSION = "16.6.14".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)
@@ -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.35
4
+ version: 16.6.14
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-18 00:00:00.000000000 Z
11
+ date: 2020-10-14 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.35
19
+ version: 16.6.14
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.35
26
+ version: 16.6.14
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: mixlib-shellout
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -174,14 +174,13 @@ files:
174
174
  - chef-config.gemspec
175
175
  - lib/chef-config.rb
176
176
  - lib/chef-config/config.rb
177
- - lib/chef-config/dist.rb
178
177
  - lib/chef-config/exceptions.rb
179
178
  - lib/chef-config/fips.rb
180
179
  - lib/chef-config/logger.rb
181
- - lib/chef-config/mixin/chef_cloud.rb
182
180
  - lib/chef-config/mixin/credentials.rb
183
181
  - lib/chef-config/mixin/dot_d.rb
184
182
  - lib/chef-config/mixin/fuzzy_hostname_matcher.rb
183
+ - lib/chef-config/mixin/train_transport.rb
185
184
  - lib/chef-config/path_helper.rb
186
185
  - lib/chef-config/version.rb
187
186
  - lib/chef-config/windows.rb
@@ -210,7 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
210
209
  - !ruby/object:Gem::Version
211
210
  version: '0'
212
211
  requirements: []
213
- rubygems_version: 3.1.2
212
+ rubygems_version: 3.1.4
214
213
  signing_key:
215
214
  specification_version: 4
216
215
  summary: Chef's default configuration and config loading
@@ -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
@@ -1,55 +0,0 @@
1
- #
2
- # Author:: Jon Morrow (jmorrow@chef.io)
3
- # Copyright:: Copyright (c) Chef Software Inc.
4
- # License:: Apache License, Version 2.0
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
-
18
- require_relative "../path_helper"
19
-
20
- module ChefConfig
21
- module Mixin
22
- module ChefCloud
23
- CHEF_CLOUD_CLIENT_CONFIG = "/Library/Managed Preferences/io.chef.chef_client.plist"
24
-
25
- def cloud_config?
26
- File.file?(CHEF_CLOUD_CLIENT_CONFIG)
27
- end
28
- module_function :cloud_config?
29
-
30
- def parse_cloud_config(path)
31
- return nil unless cloud_config?
32
-
33
- begin
34
- plist_cmd = Mixlib::ShellOut.new("plutil -convert json '" + CHEF_CLOUD_CLIENT_CONFIG + "' -o -")
35
- plist_cmd.run_command
36
- plist_cmd.error!
37
- JSON.parse(plist_cmd.stdout)
38
- rescue => e
39
- # TOML's error messages are mostly rubbish, so we'll just give a generic one
40
- message = "Unable to parse chef client cloud config.\n"
41
- message << e.message
42
- raise ChefConfig::ConfigurationError, message
43
- end
44
- end
45
-
46
- # Load chef client cloud config configuration.
47
- #
48
- # @api internal
49
- # @return [void]
50
- def load_cloud_config
51
- Config.merge!(Hash[parse_cloud_config.map { |k, v| [k.to_sym, v] }])
52
- end
53
- end
54
- end
55
- end