chef-config 15.5.17 → 15.6.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/chef-config/config.rb +83 -25
- data/lib/chef-config/dist.rb +10 -0
- data/lib/chef-config/version.rb +1 -1
- data/spec/unit/config_spec.rb +56 -27
- data/spec/unit/workstation_config_loader_spec.rb +30 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d425ace521aa941649fe24dc24ced0b1de4b40cb75ecfeccd076d639979778c
|
4
|
+
data.tar.gz: 64acf5dbac1da768ffd2d4ffc8f2ea52cc230ccc633b72333b94a4b332d29c6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54f37fb7448045119182c9ff3b94e95deb909783ec00ffcfe29a2ecaae6352b9e3fb9597f92355ac09d37f3be80878708a15b980792f275cfa511c43f1024671
|
7
|
+
data.tar.gz: e7082041aaf60be9444d5060ac521796a41c9b2942b5c3dc6288cb31834656d04962e3a32f92e823126a1634852e9782bf6324f362c2d27685ebeae71de1a7b6
|
data/lib/chef-config/config.rb
CHANGED
@@ -34,6 +34,7 @@ require "uri" unless defined?(URI)
|
|
34
34
|
require "addressable/uri" unless defined?(Addressable::URI)
|
35
35
|
require "openssl" unless defined?(OpenSSL)
|
36
36
|
require "yaml"
|
37
|
+
require_relative "dist"
|
37
38
|
|
38
39
|
module ChefConfig
|
39
40
|
|
@@ -73,6 +74,31 @@ module ChefConfig
|
|
73
74
|
path
|
74
75
|
end
|
75
76
|
|
77
|
+
# On *nix, /etc/chef
|
78
|
+
def self.etc_chef_dir
|
79
|
+
path = ChefUtils.windows? ? c_chef_dir : PathHelper.join("/etc", ChefConfig::Dist::DIR_SUFFIX)
|
80
|
+
PathHelper.cleanpath(path)
|
81
|
+
end
|
82
|
+
|
83
|
+
# On *nix, /var/chef
|
84
|
+
def self.var_chef_dir
|
85
|
+
path = ChefUtils.windows? ? c_chef_dir : PathHelper.join("/var", ChefConfig::Dist::DIR_SUFFIX)
|
86
|
+
PathHelper.cleanpath(path)
|
87
|
+
end
|
88
|
+
|
89
|
+
# On *nix, the root of /var/, used to test if we can create and write in /var/chef
|
90
|
+
def self.var_root_dir
|
91
|
+
path = ChefUtils.windows? ? c_chef_dir : "/var"
|
92
|
+
PathHelper.cleanpath(path)
|
93
|
+
end
|
94
|
+
|
95
|
+
# On windows, C:/chef/
|
96
|
+
def self.c_chef_dir
|
97
|
+
drive = windows_installation_drive || "C:"
|
98
|
+
path = PathHelper.join(drive, ChefConfig::Dist::DIR_SUFFIX)
|
99
|
+
PathHelper.cleanpath(path)
|
100
|
+
end
|
101
|
+
|
76
102
|
# the drive where Chef is installed on a windows host. This is determined
|
77
103
|
# either by the drive containing the current file or by the SYSTEMDRIVE ENV
|
78
104
|
# variable
|
@@ -108,12 +134,20 @@ module ChefConfig
|
|
108
134
|
# Split including whitespace if someone does truly odd like
|
109
135
|
# --config-option "foo = bar"
|
110
136
|
key, value = option.split(/\s*=\s*/, 2)
|
137
|
+
|
111
138
|
# Call to_sym because Chef::Config expects only symbol keys. Also
|
112
139
|
# runs a simple parse on the string for some common types.
|
113
140
|
memo[key.to_sym] = YAML.safe_load(value)
|
114
141
|
memo
|
115
142
|
end
|
116
|
-
|
143
|
+
set_extra_config_options(extra_parsed_options)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
# We use :[]= assignment here to not bypass any coercions that happen via mixlib-config writes_value callbacks
|
148
|
+
def self.set_extra_config_options(extra_parsed_options)
|
149
|
+
extra_parsed_options.each do |key, value|
|
150
|
+
self[key.to_sym] = value
|
117
151
|
end
|
118
152
|
end
|
119
153
|
|
@@ -156,6 +190,20 @@ module ChefConfig
|
|
156
190
|
# properly.
|
157
191
|
configurable(:daemonize).writes_value { |v| v }
|
158
192
|
|
193
|
+
def self.expand_relative_paths(path)
|
194
|
+
unless path.nil?
|
195
|
+
if path.is_a?(String)
|
196
|
+
File.expand_path(path)
|
197
|
+
else
|
198
|
+
Array(path).map { |path| File.expand_path(path) }
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
configurable(:cookbook_path).writes_value { |path| expand_relative_paths(path) }
|
204
|
+
|
205
|
+
configurable(:chef_repo_path).writes_value { |path| expand_relative_paths(path) }
|
206
|
+
|
159
207
|
# The root where all local chef object data is stored. cookbooks, data bags,
|
160
208
|
# environments are all assumed to be in separate directories under this.
|
161
209
|
# chef-solo uses these directories for input data. knife commands
|
@@ -204,23 +252,23 @@ module ChefConfig
|
|
204
252
|
|
205
253
|
# Location of acls on disk. String or array of strings.
|
206
254
|
# Defaults to <chef_repo_path>/acls.
|
207
|
-
default(:acl_path) { derive_path_from_chef_repo_path("acls") }
|
255
|
+
default(:acl_path) { derive_path_from_chef_repo_path("acls") }.writes_value { |path| expand_relative_paths(path) }
|
208
256
|
|
209
257
|
# Location of clients on disk. String or array of strings.
|
210
258
|
# Defaults to <chef_repo_path>/clients.
|
211
|
-
default(:client_path) { derive_path_from_chef_repo_path("clients") }
|
259
|
+
default(:client_path) { derive_path_from_chef_repo_path("clients") }.writes_value { |path| expand_relative_paths(path) }
|
212
260
|
|
213
261
|
# Location of client keys on disk. String or array of strings.
|
214
262
|
# Defaults to <chef_repo_path>/client_keys.
|
215
|
-
default(:client_key_path) { derive_path_from_chef_repo_path("client_keys") }
|
263
|
+
default(:client_key_path) { derive_path_from_chef_repo_path("client_keys") }.writes_value { |path| expand_relative_paths(path) }
|
216
264
|
|
217
265
|
# Location of containers on disk. String or array of strings.
|
218
266
|
# Defaults to <chef_repo_path>/containers.
|
219
|
-
default(:container_path) { derive_path_from_chef_repo_path("containers") }
|
267
|
+
default(:container_path) { derive_path_from_chef_repo_path("containers") }.writes_value { |path| expand_relative_paths(path) }
|
220
268
|
|
221
269
|
# Location of cookbook_artifacts on disk. String or array of strings.
|
222
270
|
# Defaults to <chef_repo_path>/cookbook_artifacts.
|
223
|
-
default(:cookbook_artifact_path) { derive_path_from_chef_repo_path("cookbook_artifacts") }
|
271
|
+
default(:cookbook_artifact_path) { derive_path_from_chef_repo_path("cookbook_artifacts") }.writes_value { |path| expand_relative_paths(path) }
|
224
272
|
|
225
273
|
# Location of cookbooks on disk. String or array of strings.
|
226
274
|
# Defaults to <chef_repo_path>/cookbooks. If chef_repo_path
|
@@ -236,35 +284,35 @@ module ChefConfig
|
|
236
284
|
|
237
285
|
# Location of data bags on disk. String or array of strings.
|
238
286
|
# Defaults to <chef_repo_path>/data_bags.
|
239
|
-
default(:data_bag_path) { derive_path_from_chef_repo_path("data_bags") }
|
287
|
+
default(:data_bag_path) { derive_path_from_chef_repo_path("data_bags") }.writes_value { |path| expand_relative_paths(path) }
|
240
288
|
|
241
289
|
# Location of environments on disk. String or array of strings.
|
242
290
|
# Defaults to <chef_repo_path>/environments.
|
243
|
-
default(:environment_path) { derive_path_from_chef_repo_path("environments") }
|
291
|
+
default(:environment_path) { derive_path_from_chef_repo_path("environments") }.writes_value { |path| expand_relative_paths(path) }
|
244
292
|
|
245
293
|
# Location of groups on disk. String or array of strings.
|
246
294
|
# Defaults to <chef_repo_path>/groups.
|
247
|
-
default(:group_path) { derive_path_from_chef_repo_path("groups") }
|
295
|
+
default(:group_path) { derive_path_from_chef_repo_path("groups") }.writes_value { |path| expand_relative_paths(path) }
|
248
296
|
|
249
297
|
# Location of nodes on disk. String or array of strings.
|
250
298
|
# Defaults to <chef_repo_path>/nodes.
|
251
|
-
default(:node_path) { derive_path_from_chef_repo_path("nodes") }
|
299
|
+
default(:node_path) { derive_path_from_chef_repo_path("nodes") }.writes_value { |path| expand_relative_paths(path) }
|
252
300
|
|
253
301
|
# Location of policies on disk. String or array of strings.
|
254
302
|
# Defaults to <chef_repo_path>/policies.
|
255
|
-
default(:policy_path) { derive_path_from_chef_repo_path("policies") }
|
303
|
+
default(:policy_path) { derive_path_from_chef_repo_path("policies") }.writes_value { |path| expand_relative_paths(path) }
|
256
304
|
|
257
305
|
# Location of policy_groups on disk. String or array of strings.
|
258
306
|
# Defaults to <chef_repo_path>/policy_groups.
|
259
|
-
default(:policy_group_path) { derive_path_from_chef_repo_path("policy_groups") }
|
307
|
+
default(:policy_group_path) { derive_path_from_chef_repo_path("policy_groups") }.writes_value { |path| expand_relative_paths(path) }
|
260
308
|
|
261
309
|
# Location of roles on disk. String or array of strings.
|
262
310
|
# Defaults to <chef_repo_path>/roles.
|
263
|
-
default(:role_path) { derive_path_from_chef_repo_path("roles") }
|
311
|
+
default(:role_path) { derive_path_from_chef_repo_path("roles") }.writes_value { |path| expand_relative_paths(path) }
|
264
312
|
|
265
313
|
# Location of users on disk. String or array of strings.
|
266
314
|
# Defaults to <chef_repo_path>/users.
|
267
|
-
default(:user_path) { derive_path_from_chef_repo_path("users") }
|
315
|
+
default(:user_path) { derive_path_from_chef_repo_path("users") }.writes_value { |path| expand_relative_paths(path) }
|
268
316
|
|
269
317
|
# Turn on "path sanity" by default.
|
270
318
|
default :enforce_path_sanity, false
|
@@ -284,8 +332,8 @@ module ChefConfig
|
|
284
332
|
if local_mode
|
285
333
|
PathHelper.join(config_dir, "local-mode-cache")
|
286
334
|
else
|
287
|
-
primary_cache_root =
|
288
|
-
primary_cache_path =
|
335
|
+
primary_cache_root = var_root_dir
|
336
|
+
primary_cache_path = var_chef_dir
|
289
337
|
# Use /var/chef as the cache path only if that folder exists and we can read and write
|
290
338
|
# into it, or /var exists and we can read and write into it (we'll create /var/chef later).
|
291
339
|
# Otherwise, we'll create .chef under the user's home directory and use that as
|
@@ -312,7 +360,7 @@ module ChefConfig
|
|
312
360
|
default(:checksum_path) { PathHelper.join(cache_path, "checksums") }
|
313
361
|
|
314
362
|
# Where chef's cache files should be stored
|
315
|
-
default(:file_cache_path) { PathHelper.join(cache_path, "cache") }
|
363
|
+
default(:file_cache_path) { PathHelper.join(cache_path, "cache") }.writes_value { |path| expand_relative_paths(path) }
|
316
364
|
|
317
365
|
# Where backups of chef-managed files should go
|
318
366
|
default(:file_backup_path) { PathHelper.join(cache_path, "backup") }
|
@@ -564,6 +612,16 @@ module ChefConfig
|
|
564
612
|
# be validated.
|
565
613
|
default :ssl_verify_mode, :verify_peer
|
566
614
|
|
615
|
+
# Needed to coerce string value to a symbol when loading settings from the
|
616
|
+
# credentials toml files which doesn't allow ruby symbol values
|
617
|
+
configurable(:ssl_verify_mode).writes_value do |value|
|
618
|
+
if value.is_a?(String) && value[0] == ":"
|
619
|
+
value[1..-1].to_sym
|
620
|
+
else
|
621
|
+
value.to_sym
|
622
|
+
end
|
623
|
+
end
|
624
|
+
|
567
625
|
# Whether or not to verify the SSL cert for HTTPS requests to the Chef
|
568
626
|
# server API. If set to `true`, the server's cert will be validated
|
569
627
|
# regardless of the :ssl_verify_mode setting. This is set to `true` when
|
@@ -645,9 +703,9 @@ module ChefConfig
|
|
645
703
|
if chef_zero.enabled
|
646
704
|
nil
|
647
705
|
elsif target_mode?
|
648
|
-
|
706
|
+
PathHelper.cleanpath("#{etc_chef_dir}/#{target_mode.host}/client.pem")
|
649
707
|
else
|
650
|
-
|
708
|
+
PathHelper.cleanpath("#{etc_chef_dir}/client.pem")
|
651
709
|
end
|
652
710
|
end
|
653
711
|
|
@@ -669,10 +727,10 @@ module ChefConfig
|
|
669
727
|
|
670
728
|
# This secret is used to decrypt encrypted data bag items.
|
671
729
|
default(:encrypted_data_bag_secret) do
|
672
|
-
if target_mode? && File.exist?(
|
673
|
-
|
674
|
-
elsif File.exist?(
|
675
|
-
|
730
|
+
if target_mode? && File.exist?(PathHelper.cleanpath("#{etc_chef_dir}/#{target_mode.host}/encrypted_data_bag_secret"))
|
731
|
+
PathHelper.cleanpath("#{etc_chef_dir}/#{target_mode.host}/encrypted_data_bag_secret")
|
732
|
+
elsif File.exist?(PathHelper.cleanpath("#{etc_chef_dir}/encrypted_data_bag_secret"))
|
733
|
+
PathHelper.cleanpath("#{etc_chef_dir}/encrypted_data_bag_secret")
|
676
734
|
else
|
677
735
|
nil
|
678
736
|
end
|
@@ -699,7 +757,7 @@ module ChefConfig
|
|
699
757
|
# The `validation_key` is never used if the `client_key` exists.
|
700
758
|
#
|
701
759
|
# If chef-zero is enabled, this defaults to nil (no authentication).
|
702
|
-
default(:validation_key) { chef_zero.enabled ? nil :
|
760
|
+
default(:validation_key) { chef_zero.enabled ? nil : PathHelper.cleanpath("#{etc_chef_dir}/validation.pem") }
|
703
761
|
default :validation_client_name do
|
704
762
|
# If the URL is set and looks like a normal Chef Server URL, extract the
|
705
763
|
# org name and use that as part of the default.
|
@@ -746,7 +804,7 @@ module ChefConfig
|
|
746
804
|
# the new (and preferred) configuration setting. If not set, knife will
|
747
805
|
# fall back to using cache_options[:path], which is deprecated but exists in
|
748
806
|
# many client configs generated by pre-Chef-11 bootstrappers.
|
749
|
-
default(:syntax_check_cache_path) { cache_options[:path] }
|
807
|
+
default(:syntax_check_cache_path) { cache_options[:path] }.writes_value { |path| expand_relative_paths(path) }
|
750
808
|
|
751
809
|
# Deprecated:
|
752
810
|
# Move this to the default value of syntax_cache_path when this is removed.
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module ChefConfig
|
2
|
+
class Dist
|
3
|
+
# The chef executable name. Also used in directory names.
|
4
|
+
EXEC = "chef".freeze
|
5
|
+
|
6
|
+
# The suffix for Chef's /etc/chef, /var/chef and C:\\Chef directories
|
7
|
+
# "cinc" => /etc/cinc, /var/cinc, C:\\cinc
|
8
|
+
DIR_SUFFIX = "chef".freeze
|
9
|
+
end
|
10
|
+
end
|
data/lib/chef-config/version.rb
CHANGED
data/spec/unit/config_spec.rb
CHANGED
@@ -151,6 +151,38 @@ RSpec.describe ChefConfig::Config do
|
|
151
151
|
|
152
152
|
end
|
153
153
|
|
154
|
+
describe "expand relative paths" do
|
155
|
+
let(:current_directory) { Dir.pwd }
|
156
|
+
|
157
|
+
context "when given cookbook_path" do
|
158
|
+
let(:extra_config_options) { [ "cookbook_path=cookbooks/" ] }
|
159
|
+
|
160
|
+
it "expanded cookbook_path" do
|
161
|
+
apply_config
|
162
|
+
expect(described_class[:cookbook_path]).to eq("#{current_directory}/cookbooks")
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
context "when passes multiple config options" do
|
167
|
+
let(:extra_config_options) { ["data_bag_path=data_bags/", "cookbook_path=cookbooks", "chef_repo_path=."] }
|
168
|
+
|
169
|
+
it "expanded paths" do
|
170
|
+
apply_config
|
171
|
+
expect(described_class[:data_bag_path]).to eq("#{current_directory}/data_bags")
|
172
|
+
expect(described_class[:cookbook_path]).to eq("#{current_directory}/cookbooks")
|
173
|
+
expect(described_class[:chef_repo_path]).to eq("#{current_directory}")
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
context "when passes multiple cookbook_paths in config options" do
|
178
|
+
let(:extra_config_options) { ["cookbook_path=[first_cookbook, secound_cookbooks]"] }
|
179
|
+
|
180
|
+
it "expanded paths" do
|
181
|
+
apply_config
|
182
|
+
expect(described_class[:cookbook_path]).to eq(["#{current_directory}/first_cookbook", "#{current_directory}/secound_cookbooks"])
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
154
186
|
end
|
155
187
|
|
156
188
|
describe "when configuring formatters" do
|
@@ -196,9 +228,6 @@ RSpec.describe ChefConfig::Config do
|
|
196
228
|
[ false, true ].each do |is_windows|
|
197
229
|
|
198
230
|
context "On #{is_windows ? "Windows" : "Unix"}" do
|
199
|
-
def to_platform(*args)
|
200
|
-
ChefConfig::Config.platform_specific_path(*args)
|
201
|
-
end
|
202
231
|
|
203
232
|
before :each do
|
204
233
|
allow(ChefUtils).to receive(:windows?).and_return(is_windows)
|
@@ -277,7 +306,7 @@ RSpec.describe ChefConfig::Config do
|
|
277
306
|
end
|
278
307
|
|
279
308
|
describe "ChefConfig::Config[:client_key]" do
|
280
|
-
let(:path_to_client_key) {
|
309
|
+
let(:path_to_client_key) { ChefConfig::Config.etc_chef_dir + ChefConfig::PathHelper.path_separator }
|
281
310
|
|
282
311
|
it "sets the default path to the client key" do
|
283
312
|
expect(ChefConfig::Config.client_key).to eq(path_to_client_key + "client.pem")
|
@@ -412,7 +441,7 @@ RSpec.describe ChefConfig::Config do
|
|
412
441
|
|
413
442
|
context "when /var/chef exists and is accessible" do
|
414
443
|
before do
|
415
|
-
allow(ChefConfig::Config).to receive(:path_accessible?).with(
|
444
|
+
allow(ChefConfig::Config).to receive(:path_accessible?).with(ChefConfig::Config.var_chef_dir).and_return(true)
|
416
445
|
end
|
417
446
|
|
418
447
|
it "defaults to /var/chef" do
|
@@ -430,25 +459,25 @@ RSpec.describe ChefConfig::Config do
|
|
430
459
|
|
431
460
|
context "when /var/chef does not exist and /var is accessible" do
|
432
461
|
it "defaults to /var/chef" do
|
433
|
-
allow(File).to receive(:exists?).with(
|
434
|
-
allow(ChefConfig::Config).to receive(:path_accessible?).with(
|
462
|
+
allow(File).to receive(:exists?).with(ChefConfig::Config.var_chef_dir).and_return(false)
|
463
|
+
allow(ChefConfig::Config).to receive(:path_accessible?).with(ChefConfig::Config.var_root_dir).and_return(true)
|
435
464
|
expect(ChefConfig::Config[:cache_path]).to eq(primary_cache_path)
|
436
465
|
end
|
437
466
|
end
|
438
467
|
|
439
468
|
context "when /var/chef does not exist and /var is not accessible" do
|
440
469
|
it "defaults to $HOME/.chef" do
|
441
|
-
allow(File).to receive(:exists?).with(
|
442
|
-
allow(ChefConfig::Config).to receive(:path_accessible?).with(
|
470
|
+
allow(File).to receive(:exists?).with(ChefConfig::Config.var_chef_dir).and_return(false)
|
471
|
+
allow(ChefConfig::Config).to receive(:path_accessible?).with(ChefConfig::Config.var_root_dir).and_return(false)
|
443
472
|
expect(ChefConfig::Config[:cache_path]).to eq(secondary_cache_path)
|
444
473
|
end
|
445
474
|
end
|
446
475
|
|
447
476
|
context "when /var/chef exists and is not accessible" do
|
448
477
|
before do
|
449
|
-
allow(File).to receive(:exists?).with(
|
450
|
-
allow(File).to receive(:readable?).with(
|
451
|
-
allow(File).to receive(:writable?).with(
|
478
|
+
allow(File).to receive(:exists?).with(ChefConfig::Config.var_chef_dir).and_return(true)
|
479
|
+
allow(File).to receive(:readable?).with(ChefConfig::Config.var_chef_dir).and_return(true)
|
480
|
+
allow(File).to receive(:writable?).with(ChefConfig::Config.var_chef_dir).and_return(false)
|
452
481
|
end
|
453
482
|
|
454
483
|
it "defaults to $HOME/.chef" do
|
@@ -471,21 +500,21 @@ RSpec.describe ChefConfig::Config do
|
|
471
500
|
|
472
501
|
context "and config_dir is /a/b/c" do
|
473
502
|
before do
|
474
|
-
ChefConfig::Config.config_dir
|
503
|
+
ChefConfig::Config.config_dir ChefConfig::PathHelper.cleanpath("/a/b/c")
|
475
504
|
end
|
476
505
|
|
477
506
|
it "cache_path is /a/b/c/local-mode-cache" do
|
478
|
-
expect(ChefConfig::Config.cache_path).to eq(
|
507
|
+
expect(ChefConfig::Config.cache_path).to eq(ChefConfig::PathHelper.cleanpath("/a/b/c/local-mode-cache"))
|
479
508
|
end
|
480
509
|
end
|
481
510
|
|
482
511
|
context "and config_dir is /a/b/c/" do
|
483
512
|
before do
|
484
|
-
ChefConfig::Config.config_dir
|
513
|
+
ChefConfig::Config.config_dir ChefConfig::PathHelper.cleanpath("/a/b/c/")
|
485
514
|
end
|
486
515
|
|
487
516
|
it "cache_path is /a/b/c/local-mode-cache" do
|
488
|
-
expect(ChefConfig::Config.cache_path).to eq(
|
517
|
+
expect(ChefConfig::Config.cache_path).to eq(ChefConfig::PathHelper.cleanpath("/a/b/c/local-mode-cache"))
|
489
518
|
end
|
490
519
|
end
|
491
520
|
end
|
@@ -651,15 +680,15 @@ RSpec.describe ChefConfig::Config do
|
|
651
680
|
end
|
652
681
|
|
653
682
|
it "expands the path when determining config_dir" do
|
654
|
-
# config_dir goes through PathHelper.canonical_path, which
|
683
|
+
# config_dir goes through ChefConfig::PathHelper.canonical_path, which
|
655
684
|
# downcases on windows because the FS is case insensitive, so we
|
656
685
|
# have to downcase expected and actual to make the tests work.
|
657
|
-
expect(ChefConfig::Config.config_dir.downcase).to eq(
|
686
|
+
expect(ChefConfig::Config.config_dir.downcase).to eq(ChefConfig::PathHelper.cleanpath(Dir.pwd).downcase)
|
658
687
|
end
|
659
688
|
|
660
689
|
it "does not set derived paths at FS root" do
|
661
690
|
ChefConfig::Config.local_mode = true
|
662
|
-
expect(ChefConfig::Config.cache_path.downcase).to eq(
|
691
|
+
expect(ChefConfig::Config.cache_path.downcase).to eq(ChefConfig::PathHelper.cleanpath(File.join(Dir.pwd, "local-mode-cache")).downcase)
|
663
692
|
end
|
664
693
|
|
665
694
|
end
|
@@ -667,13 +696,13 @@ RSpec.describe ChefConfig::Config do
|
|
667
696
|
context "when the config file is /etc/chef/client.rb" do
|
668
697
|
|
669
698
|
before do
|
670
|
-
config_location =
|
699
|
+
config_location = ChefConfig::PathHelper.cleanpath(ChefConfig::PathHelper.join(ChefConfig::Config.etc_chef_dir, "client.rb")).downcase
|
671
700
|
allow(File).to receive(:absolute_path).with(config_location).and_return(config_location)
|
672
701
|
ChefConfig::Config.config_file = config_location
|
673
702
|
end
|
674
703
|
|
675
704
|
it "config_dir is /etc/chef" do
|
676
|
-
expect(ChefConfig::Config.config_dir).to eq(
|
705
|
+
expect(ChefConfig::Config.config_dir).to eq(ChefConfig::Config.etc_chef_dir.downcase)
|
677
706
|
end
|
678
707
|
|
679
708
|
context "and chef is running in local mode" do
|
@@ -682,17 +711,17 @@ RSpec.describe ChefConfig::Config do
|
|
682
711
|
end
|
683
712
|
|
684
713
|
it "config_dir is /etc/chef" do
|
685
|
-
expect(ChefConfig::Config.config_dir).to eq(
|
714
|
+
expect(ChefConfig::Config.config_dir).to eq(ChefConfig::Config.etc_chef_dir.downcase)
|
686
715
|
end
|
687
716
|
end
|
688
717
|
|
689
718
|
context "when config_dir is set to /other/config/dir/" do
|
690
719
|
before do
|
691
|
-
ChefConfig::Config.config_dir =
|
720
|
+
ChefConfig::Config.config_dir = ChefConfig::PathHelper.cleanpath("/other/config/dir/")
|
692
721
|
end
|
693
722
|
|
694
723
|
it "yields the explicit value" do
|
695
|
-
expect(ChefConfig::Config.config_dir).to eq(
|
724
|
+
expect(ChefConfig::Config.config_dir).to eq(ChefConfig::PathHelper.cleanpath("/other/config/dir/"))
|
696
725
|
end
|
697
726
|
end
|
698
727
|
|
@@ -721,7 +750,7 @@ RSpec.describe ChefConfig::Config do
|
|
721
750
|
if is_windows
|
722
751
|
context "when the user's home dir is windows specific" do
|
723
752
|
before do
|
724
|
-
ChefConfig::Config.user_home =
|
753
|
+
ChefConfig::Config.user_home = ChefConfig::PathHelper.cleanpath("/home/charlie/")
|
725
754
|
end
|
726
755
|
|
727
756
|
it "config_dir is with backslashes" do
|
@@ -777,7 +806,7 @@ RSpec.describe ChefConfig::Config do
|
|
777
806
|
|
778
807
|
describe "ChefConfig::Config[:user_home]" do
|
779
808
|
it "should set when HOME is provided" do
|
780
|
-
expected =
|
809
|
+
expected = ChefConfig::PathHelper.cleanpath("/home/kitten")
|
781
810
|
allow(ChefConfig::PathHelper).to receive(:home).and_return(expected)
|
782
811
|
expect(ChefConfig::Config[:user_home]).to eq(expected)
|
783
812
|
end
|
@@ -789,7 +818,7 @@ RSpec.describe ChefConfig::Config do
|
|
789
818
|
end
|
790
819
|
|
791
820
|
describe "ChefConfig::Config[:encrypted_data_bag_secret]" do
|
792
|
-
let(:db_secret_default_path) {
|
821
|
+
let(:db_secret_default_path) { ChefConfig::PathHelper.cleanpath("#{ChefConfig::Config.etc_chef_dir}/encrypted_data_bag_secret") }
|
793
822
|
|
794
823
|
before do
|
795
824
|
allow(File).to receive(:exist?).with(db_secret_default_path).and_return(secret_exists)
|
@@ -583,6 +583,36 @@ RSpec.describe ChefConfig::WorkstationConfigLoader do
|
|
583
583
|
end
|
584
584
|
end
|
585
585
|
|
586
|
+
context "and ssl_verify_mode is a symbol string" do
|
587
|
+
let(:content) do
|
588
|
+
content = <<~EOH
|
589
|
+
[default]
|
590
|
+
ssl_verify_mode = ":verify_none"
|
591
|
+
EOH
|
592
|
+
content
|
593
|
+
end
|
594
|
+
|
595
|
+
it "raises a ConfigurationError" do
|
596
|
+
expect { config_loader.load_credentials }.not_to raise_error
|
597
|
+
expect(ChefConfig::Config.ssl_verify_mode).to eq(:verify_none)
|
598
|
+
end
|
599
|
+
end
|
600
|
+
|
601
|
+
context "and ssl_verify_mode is a string" do
|
602
|
+
let(:content) do
|
603
|
+
content = <<~EOH
|
604
|
+
[default]
|
605
|
+
ssl_verify_mode = "verify_none"
|
606
|
+
EOH
|
607
|
+
content
|
608
|
+
end
|
609
|
+
|
610
|
+
it "raises a ConfigurationError" do
|
611
|
+
expect { config_loader.load_credentials }.not_to raise_error
|
612
|
+
expect(ChefConfig::Config.ssl_verify_mode).to eq(:verify_none)
|
613
|
+
end
|
614
|
+
end
|
615
|
+
|
586
616
|
context "and has a syntax error" do
|
587
617
|
let(:content) { "<<<<<" }
|
588
618
|
|
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: 15.
|
4
|
+
version: 15.6.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Jacob
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-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: 15.
|
19
|
+
version: 15.6.10
|
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: 15.
|
26
|
+
version: 15.6.10
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: mixlib-shellout
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -174,6 +174,7 @@ 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
|
177
178
|
- lib/chef-config/exceptions.rb
|
178
179
|
- lib/chef-config/fips.rb
|
179
180
|
- lib/chef-config/logger.rb
|