r10k 3.7.0 → 3.9.3

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.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/.github/pull_request_template.md +1 -1
  3. data/.github/workflows/docker.yml +4 -1
  4. data/.github/workflows/release.yml +3 -2
  5. data/.github/workflows/rspec_tests.yml +1 -1
  6. data/.github/workflows/stale.yml +19 -0
  7. data/.travis.yml +8 -1
  8. data/CHANGELOG.mkd +32 -0
  9. data/CODEOWNERS +2 -2
  10. data/doc/common-patterns.mkd +1 -0
  11. data/doc/dynamic-environments/configuration.mkd +114 -42
  12. data/doc/dynamic-environments/usage.mkd +12 -11
  13. data/doc/puppetfile.mkd +23 -3
  14. data/docker/Gemfile +1 -1
  15. data/docker/Makefile +4 -3
  16. data/docker/docker-compose.yml +18 -0
  17. data/docker/r10k/Dockerfile +1 -1
  18. data/docker/r10k/docker-entrypoint.sh +0 -1
  19. data/docker/r10k/release.Dockerfile +1 -1
  20. data/docker/spec/dockerfile_spec.rb +26 -32
  21. data/integration/tests/git_source/git_source_repeated_remote.rb +2 -2
  22. data/integration/tests/user_scenario/basic_workflow/multi_env_custom_forge_git_module.rb +2 -1
  23. data/integration/tests/user_scenario/basic_workflow/multi_env_custom_forge_git_module_static.rb +2 -1
  24. data/integration/tests/user_scenario/basic_workflow/multi_source_custom_forge_git_module.rb +1 -1
  25. data/integration/tests/user_scenario/basic_workflow/single_env_custom_forge_git_module.rb +2 -1
  26. data/lib/r10k/action/base.rb +10 -0
  27. data/lib/r10k/action/deploy/display.rb +49 -10
  28. data/lib/r10k/action/deploy/environment.rb +101 -51
  29. data/lib/r10k/action/deploy/module.rb +54 -30
  30. data/lib/r10k/action/puppetfile/check.rb +3 -1
  31. data/lib/r10k/action/puppetfile/install.rb +20 -23
  32. data/lib/r10k/action/puppetfile/purge.rb +8 -2
  33. data/lib/r10k/action/runner.rb +33 -0
  34. data/lib/r10k/cli/deploy.rb +13 -7
  35. data/lib/r10k/cli/puppetfile.rb +5 -5
  36. data/lib/r10k/content_synchronizer.rb +83 -0
  37. data/lib/r10k/deployment.rb +1 -1
  38. data/lib/r10k/environment/base.rb +29 -2
  39. data/lib/r10k/environment/git.rb +17 -5
  40. data/lib/r10k/environment/name.rb +22 -4
  41. data/lib/r10k/environment/svn.rb +11 -4
  42. data/lib/r10k/environment/with_modules.rb +46 -30
  43. data/lib/r10k/git.rb +1 -0
  44. data/lib/r10k/git/rugged/credentials.rb +39 -2
  45. data/lib/r10k/initializers.rb +1 -0
  46. data/lib/r10k/module.rb +1 -1
  47. data/lib/r10k/module/base.rb +17 -1
  48. data/lib/r10k/module/forge.rb +29 -11
  49. data/lib/r10k/module/git.rb +50 -27
  50. data/lib/r10k/module/local.rb +2 -1
  51. data/lib/r10k/module/svn.rb +24 -18
  52. data/lib/r10k/puppetfile.rb +66 -83
  53. data/lib/r10k/settings.rb +18 -2
  54. data/lib/r10k/source/base.rb +9 -0
  55. data/lib/r10k/source/git.rb +18 -7
  56. data/lib/r10k/source/hash.rb +5 -5
  57. data/lib/r10k/source/svn.rb +5 -3
  58. data/lib/r10k/util/cleaner.rb +21 -0
  59. data/lib/r10k/util/setopts.rb +33 -12
  60. data/lib/r10k/version.rb +1 -1
  61. data/locales/r10k.pot +98 -82
  62. data/r10k.gemspec +1 -1
  63. data/spec/fixtures/unit/action/r10k_creds.yaml +9 -0
  64. data/spec/r10k-mocks/mock_source.rb +1 -1
  65. data/spec/shared-examples/puppetfile-action.rb +7 -7
  66. data/spec/unit/action/deploy/display_spec.rb +35 -5
  67. data/spec/unit/action/deploy/environment_spec.rb +199 -38
  68. data/spec/unit/action/deploy/module_spec.rb +162 -28
  69. data/spec/unit/action/puppetfile/check_spec.rb +2 -2
  70. data/spec/unit/action/puppetfile/install_spec.rb +31 -10
  71. data/spec/unit/action/puppetfile/purge_spec.rb +25 -5
  72. data/spec/unit/action/runner_spec.rb +48 -1
  73. data/spec/unit/environment/git_spec.rb +19 -2
  74. data/spec/unit/environment/name_spec.rb +28 -0
  75. data/spec/unit/environment/svn_spec.rb +12 -0
  76. data/spec/unit/environment/with_modules_spec.rb +74 -0
  77. data/spec/unit/git/rugged/credentials_spec.rb +78 -1
  78. data/spec/unit/module/forge_spec.rb +21 -13
  79. data/spec/unit/module/git_spec.rb +63 -8
  80. data/spec/unit/module_spec.rb +77 -10
  81. data/spec/unit/puppetfile_spec.rb +63 -60
  82. data/spec/unit/util/purgeable_spec.rb +2 -8
  83. data/spec/unit/util/setopts_spec.rb +25 -1
  84. metadata +11 -12
  85. data/azure-pipelines.yml +0 -87
@@ -3,27 +3,94 @@ require 'r10k/module'
3
3
 
4
4
  describe R10K::Module do
5
5
  describe 'delegating to R10K::Module::Git' do
6
- it "accepts args {:git => 'git url}" do
7
- obj = R10K::Module.new('foo', '/modulepath', :git => 'git url')
8
- expect(obj).to be_a_kind_of(R10K::Module::Git)
6
+ [ {git: 'git url'},
7
+ {type: 'git', source: 'git url'},
8
+ ].each do |scenario|
9
+ it "accepts a name matching 'test' and args #{scenario.inspect}" do
10
+ obj = R10K::Module.new('test', '/modulepath', scenario)
11
+ expect(obj).to be_a_kind_of(R10K::Module::Git)
12
+ expect(obj.send(:instance_variable_get, :'@remote')).to eq('git url')
13
+ end
14
+ end
15
+ end
16
+
17
+ describe 'delegating to R10K::Module::Svn' do
18
+ [ {svn: 'svn url'},
19
+ {type: 'svn', source: 'svn url'},
20
+ ].each do |scenario|
21
+ it "accepts a name matching 'test' and args #{scenario.inspect}" do
22
+ obj = R10K::Module.new('test', '/modulepath', scenario)
23
+ expect(obj).to be_a_kind_of(R10K::Module::SVN)
24
+ expect(obj.send(:instance_variable_get, :'@url')).to eq('svn url')
25
+ end
9
26
  end
10
27
  end
11
28
 
12
29
  describe 'delegating to R10K::Module::Forge' do
13
- [
14
- ['bar/quux', nil],
15
- ['bar-quux', nil],
16
- ['bar/quux', '8.0.0'],
30
+ [ 'bar/quux',
31
+ 'bar-quux',
32
+ ].each do |scenario|
33
+ it "accepts a name matching #{scenario} and version nil" do
34
+ obj = R10K::Module.new(scenario, '/modulepath', { version: nil })
35
+ expect(obj).to be_a_kind_of(R10K::Module::Forge)
36
+ end
37
+ end
38
+ [ {version: '8.0.0'},
39
+ {type: 'forge', version: '8.0.0'},
17
40
  ].each do |scenario|
18
- it "accepts a name matching #{scenario[0]} and args #{scenario[1].inspect}" do
19
- expect(R10K::Module.new(scenario[0], '/modulepath', scenario[1])).to be_a_kind_of(R10K::Module::Forge)
41
+ it "accepts a name matching bar-quux and args #{scenario.inspect}" do
42
+ obj = R10K::Module.new('bar-quux', '/modulepath', scenario)
43
+ expect(obj).to be_a_kind_of(R10K::Module::Forge)
44
+ expect(obj.send(:instance_variable_get, :'@expected_version')).to eq('8.0.0')
45
+ end
46
+ end
47
+
48
+ describe 'when the module is ostensibly on disk' do
49
+ before do
50
+ owner = 'theowner'
51
+ module_name = 'themodulename'
52
+ @title = "#{owner}-#{module_name}"
53
+ metadata = <<~METADATA
54
+ {
55
+ "name": "#{@title}",
56
+ "version": "1.2.0"
57
+ }
58
+ METADATA
59
+ @dirname = Dir.mktmpdir
60
+ module_path = File.join(@dirname, module_name)
61
+ FileUtils.mkdir(module_path)
62
+ File.open("#{module_path}/metadata.json", 'w') do |file|
63
+ file.write(metadata)
64
+ end
65
+ end
66
+
67
+ it 'sets the expected version to what is found in the metadata' do
68
+ obj = R10K::Module.new(@title, @dirname, {version: nil})
69
+ expect(obj.send(:instance_variable_get, :'@expected_version')).to eq('1.2.0')
20
70
  end
21
71
  end
22
72
  end
23
73
 
24
74
  it "raises an error if delegation fails" do
25
75
  expect {
26
- R10K::Module.new('bar!quux', '/modulepath', ["NOPE NOPE NOPE NOPE!"])
76
+ R10K::Module.new('bar!quux', '/modulepath', {version: ["NOPE NOPE NOPE NOPE!"]})
27
77
  }.to raise_error RuntimeError, /doesn't have an implementation/
28
78
  end
79
+
80
+ describe 'when a user passes a `default_branch_override`' do
81
+ [ ['name', {git: 'git url'}],
82
+ ['name', {type: 'git', source: 'git url'}],
83
+ ['name', {svn: 'svn url'}],
84
+ ['name', {type: 'svn', source: 'svn url'}],
85
+ ['namespace-name', {version: '8.0.0'}],
86
+ ['namespace-name', {type: 'forge', version: '8.0.0'}]
87
+ ].each do |(name, options)|
88
+ it 'can handle the default_branch_override option' do
89
+ expect {
90
+ obj = R10K::Module.new(name, '/modulepath', options.merge({default_branch_override: 'foo'}))
91
+ expect(obj).to be_a_kind_of(R10K::Module::Base)
92
+ }.not_to raise_error
93
+ end
94
+ end
95
+ end
29
96
  end
@@ -6,9 +6,7 @@ describe R10K::Puppetfile do
6
6
  subject do
7
7
  described_class.new(
8
8
  '/some/nonexistent/basedir',
9
- nil,
10
- nil,
11
- 'Puppetfile.r10k'
9
+ {puppetfile_name: 'Puppetfile.r10k'}
12
10
  )
13
11
  end
14
12
 
@@ -23,9 +21,25 @@ end
23
21
  describe R10K::Puppetfile do
24
22
 
25
23
  subject do
26
- described_class.new(
27
- '/some/nonexistent/basedir'
28
- )
24
+ described_class.new( '/some/nonexistent/basedir', {})
25
+ end
26
+
27
+ describe "backwards compatibility with older calling conventions" do
28
+ it "honors all arguments correctly" do
29
+ puppetfile = described_class.new('/some/nonexistant/basedir', '/some/nonexistant/basedir/site-modules', nil, 'Pupupupetfile', true)
30
+ expect(puppetfile.force).to eq(true)
31
+ expect(puppetfile.moduledir).to eq('/some/nonexistant/basedir/site-modules')
32
+ expect(puppetfile.puppetfile_path).to eq('/some/nonexistant/basedir/Pupupupetfile')
33
+ expect(puppetfile.overrides).to eq({})
34
+ end
35
+
36
+ it "handles defaults correctly" do
37
+ puppetfile = described_class.new('/some/nonexistant/basedir', nil, nil, nil)
38
+ expect(puppetfile.force).to eq(false)
39
+ expect(puppetfile.moduledir).to eq('/some/nonexistant/basedir/modules')
40
+ expect(puppetfile.puppetfile_path).to eq('/some/nonexistant/basedir/Puppetfile')
41
+ expect(puppetfile.overrides).to eq({})
42
+ end
29
43
  end
30
44
 
31
45
  describe "the default moduledir" do
@@ -54,15 +68,15 @@ describe R10K::Puppetfile do
54
68
  end
55
69
 
56
70
  describe "adding modules" do
57
- it "should accept Forge modules with a string arg" do
58
- allow(R10K::Module).to receive(:new).with('puppet/test_module', subject.moduledir, '1.2.3', anything).and_call_original
71
+ it "should transform Forge modules with a string arg to have a version key" do
72
+ allow(R10K::Module).to receive(:new).with('puppet/test_module', subject.moduledir, hash_including(version: '1.2.3'), anything).and_call_original
59
73
 
60
74
  expect { subject.add_module('puppet/test_module', '1.2.3') }.to change { subject.modules }
61
75
  expect(subject.modules.collect(&:name)).to include('test_module')
62
76
  end
63
77
 
64
78
  it "should not accept Forge modules with a version comparison" do
65
- allow(R10K::Module).to receive(:new).with('puppet/test_module', subject.moduledir, '< 1.2.0', anything).and_call_original
79
+ allow(R10K::Module).to receive(:new).with('puppet/test_module', subject.moduledir, hash_including(version: '< 1.2.0'), anything).and_call_original
66
80
 
67
81
  expect {
68
82
  subject.add_module('puppet/test_module', '< 1.2.0')
@@ -128,23 +142,15 @@ describe R10K::Puppetfile do
128
142
  expect { subject.add_module('puppet/test_module', module_opts) }.to raise_error(R10K::Error, /cannot manage content.*is not within/i).and not_change { subject.modules }
129
143
  end
130
144
 
131
- it "groups modules by vcs cache location" do
132
- module_opts = { install_path: File.join(subject.basedir, 'vendor') }
133
- opts1 = module_opts.merge(git: 'git@example.com:puppet/test_module.git')
134
- opts2 = module_opts.merge(git: 'git@example.com:puppet/test_module_c.git')
135
- sanitized_name1 = "git@example.com-puppet-test_module.git"
136
- sanitized_name2 = "git@example.com-puppet-test_module_c.git"
137
-
138
- subject.add_module('puppet/test_module_a', opts1)
139
- subject.add_module('puppet/test_module_b', opts1)
140
- subject.add_module('puppet/test_module_c', opts2)
141
- subject.add_module('puppet/test_module_d', '1.2.3')
145
+ it "should disable and not add modules that conflict with the environment" do
146
+ env = instance_double('R10K::Environment::Base')
147
+ mod = instance_double('R10K::Module::Base', name: 'conflict', origin: :puppetfile)
148
+ allow(mod).to receive(:origin=).and_return(nil)
149
+ allow(subject).to receive(:environment).and_return(env)
150
+ allow(env).to receive(:'module_conflicts?').with(mod).and_return(true)
142
151
 
143
- mods_by_cachedir = subject.modules_by_vcs_cachedir
144
-
145
- expect(mods_by_cachedir[:none].length).to be 1
146
- expect(mods_by_cachedir[sanitized_name1].length).to be 2
147
- expect(mods_by_cachedir[sanitized_name2].length).to be 1
152
+ allow(R10K::Module).to receive(:new).with('test', anything, anything, anything).and_return(mod)
153
+ expect { subject.add_module('test', {}) }.not_to change { subject.modules }
148
154
  end
149
155
  end
150
156
 
@@ -175,7 +181,7 @@ describe R10K::Puppetfile do
175
181
 
176
182
  describe '#managed_directories' do
177
183
  it 'returns an array of paths that can be purged' do
178
- allow(R10K::Module).to receive(:new).with('puppet/test_module', subject.moduledir, '1.2.3', anything).and_call_original
184
+ allow(R10K::Module).to receive(:new).with('puppet/test_module', subject.moduledir, hash_including(version: '1.2.3'), anything).and_call_original
179
185
 
180
186
  subject.add_module('puppet/test_module', '1.2.3')
181
187
  expect(subject.managed_directories).to match_array(["/some/nonexistent/basedir/modules"])
@@ -203,7 +209,7 @@ describe R10K::Puppetfile do
203
209
  it "wraps and re-raises syntax errors" do
204
210
  path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'invalid-syntax')
205
211
  pf_path = File.join(path, 'Puppetfile')
206
- subject = described_class.new(path)
212
+ subject = described_class.new(path, {})
207
213
  expect {
208
214
  subject.load!
209
215
  }.to raise_error do |e|
@@ -214,7 +220,7 @@ describe R10K::Puppetfile do
214
220
  it "wraps and re-raises load errors" do
215
221
  path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'load-error')
216
222
  pf_path = File.join(path, 'Puppetfile')
217
- subject = described_class.new(path)
223
+ subject = described_class.new(path, {})
218
224
  expect {
219
225
  subject.load!
220
226
  }.to raise_error do |e|
@@ -225,7 +231,7 @@ describe R10K::Puppetfile do
225
231
  it "wraps and re-raises argument errors" do
226
232
  path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'argument-error')
227
233
  pf_path = File.join(path, 'Puppetfile')
228
- subject = described_class.new(path)
234
+ subject = described_class.new(path, {})
229
235
  expect {
230
236
  subject.load!
231
237
  }.to raise_error do |e|
@@ -236,7 +242,7 @@ describe R10K::Puppetfile do
236
242
  it "rejects Puppetfiles with duplicate module names" do
237
243
  path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'duplicate-module-error')
238
244
  pf_path = File.join(path, 'Puppetfile')
239
- subject = described_class.new(path)
245
+ subject = described_class.new(path, {})
240
246
  expect {
241
247
  subject.load!
242
248
  }.to raise_error(R10K::Error, /Puppetfiles cannot contain duplicate module names/i)
@@ -245,7 +251,7 @@ describe R10K::Puppetfile do
245
251
  it "wraps and re-raises name errors" do
246
252
  path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'name-error')
247
253
  pf_path = File.join(path, 'Puppetfile')
248
- subject = described_class.new(path)
254
+ subject = described_class.new(path, {})
249
255
  expect {
250
256
  subject.load!
251
257
  }.to raise_error do |e|
@@ -256,21 +262,21 @@ describe R10K::Puppetfile do
256
262
  it "accepts a forge module with a version" do
257
263
  path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'valid-forge-with-version')
258
264
  pf_path = File.join(path, 'Puppetfile')
259
- subject = described_class.new(path)
265
+ subject = described_class.new(path, {})
260
266
  expect { subject.load! }.not_to raise_error
261
267
  end
262
268
 
263
269
  it "accepts a forge module without a version" do
264
270
  path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'valid-forge-without-version')
265
271
  pf_path = File.join(path, 'Puppetfile')
266
- subject = described_class.new(path)
272
+ subject = described_class.new(path, {})
267
273
  expect { subject.load! }.not_to raise_error
268
274
  end
269
275
 
270
276
  it "creates a git module and applies the default branch sepcified in the Puppetfile" do
271
277
  path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'default-branch-override')
272
278
  pf_path = File.join(path, 'Puppetfile')
273
- subject = described_class.new(path)
279
+ subject = described_class.new(path, {})
274
280
  expect { subject.load! }.not_to raise_error
275
281
  git_module = subject.modules[0]
276
282
  expect(git_module.default_ref).to eq 'here_lies_the_default_branch'
@@ -279,11 +285,12 @@ describe R10K::Puppetfile do
279
285
  it "creates a git module and applies the provided default_branch_override" do
280
286
  path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'default-branch-override')
281
287
  pf_path = File.join(path, 'Puppetfile')
282
- subject = described_class.new(path)
288
+ subject = described_class.new(path, {})
283
289
  default_branch_override = 'default_branch_override_name'
284
290
  expect { subject.load!(default_branch_override) }.not_to raise_error
285
291
  git_module = subject.modules[0]
286
- expect(git_module.default_ref).to eq default_branch_override
292
+ expect(git_module.default_override_ref).to eq default_branch_override
293
+ expect(git_module.default_ref).to eq "here_lies_the_default_branch"
287
294
  end
288
295
  end
289
296
 
@@ -294,7 +301,7 @@ describe R10K::Puppetfile do
294
301
  subject.accept(visitor)
295
302
  end
296
303
 
297
- it "passes the visitor to each module if the visitor yields" do
304
+ it "synchronizes each module if the visitor yields" do
298
305
  visitor = spy('visitor')
299
306
  expect(visitor).to receive(:visit) do |type, other, &block|
300
307
  expect(type).to eq :puppetfile
@@ -302,12 +309,12 @@ describe R10K::Puppetfile do
302
309
  block.call
303
310
  end
304
311
 
305
- mod1 = spy('module')
306
- expect(mod1).to receive(:accept).with(visitor)
307
- mod2 = spy('module')
308
- expect(mod2).to receive(:accept).with(visitor)
312
+ mod1 = instance_double('R10K::Module::Base', :cachedir => :none)
313
+ mod2 = instance_double('R10K::Module::Base', :cachedir => :none)
314
+ expect(mod1).to receive(:sync)
315
+ expect(mod2).to receive(:sync)
316
+ expect(subject).to receive(:modules).and_return([mod1, mod2])
309
317
 
310
- expect(subject).to receive(:modules_by_vcs_cachedir).and_return({none: [mod1, mod2]})
311
318
  subject.accept(visitor)
312
319
  end
313
320
 
@@ -323,12 +330,11 @@ describe R10K::Puppetfile do
323
330
  block.call
324
331
  end
325
332
 
326
- mod1 = spy('module')
327
- expect(mod1).to receive(:accept).with(visitor)
328
- mod2 = spy('module')
329
- expect(mod2).to receive(:accept).with(visitor)
330
-
331
- expect(subject).to receive(:modules_by_vcs_cachedir).and_return({none: [mod1, mod2]})
333
+ mod1 = instance_double('R10K::Module::Base', :cachedir => :none)
334
+ mod2 = instance_double('R10K::Module::Base', :cachedir => :none)
335
+ expect(mod1).to receive(:sync)
336
+ expect(mod2).to receive(:sync)
337
+ expect(subject).to receive(:modules).and_return([mod1, mod2])
332
338
 
333
339
  expect(Thread).to receive(:new).exactly(pool_size).and_call_original
334
340
  expect(Queue).to receive(:new).and_call_original
@@ -344,22 +350,19 @@ describe R10K::Puppetfile do
344
350
  block.call
345
351
  end
346
352
 
347
- mod1 = spy('module1')
348
- mod2 = spy('module2')
349
- mod3 = spy('module3')
350
- mod4 = spy('module4')
351
- mod5 = spy('module5')
352
- mod6 = spy('module6')
353
+ m1 = instance_double('R10K::Module::Base', :cachedir => '/dev/null/A')
354
+ m2 = instance_double('R10K::Module::Base', :cachedir => '/dev/null/B')
355
+ m3 = instance_double('R10K::Module::Base', :cachedir => '/dev/null/C')
356
+ m4 = instance_double('R10K::Module::Base', :cachedir => '/dev/null/C')
357
+ m5 = instance_double('R10K::Module::Base', :cachedir => '/dev/null/D')
358
+ m6 = instance_double('R10K::Module::Base', :cachedir => '/dev/null/D')
353
359
 
354
- expect(subject).to receive(:modules_by_vcs_cachedir)
355
- .and_return({:none => [mod1, mod2],
356
- "foo-cachedir" => [mod3, mod4],
357
- "bar-cachedir" => [mod5, mod6]})
360
+ modules = [m1, m2, m3, m4, m5, m6]
358
361
 
359
- queue = subject.modules_queue(visitor)
362
+ queue = R10K::ContentSynchronizer.modules_visit_queue(modules, visitor, subject)
360
363
  expect(queue.length).to be 4
361
364
  queue_array = 4.times.map { queue.pop }
362
- expect(queue_array).to match_array([[mod1], [mod2], [mod3, mod4], [mod5, mod6]])
365
+ expect(queue_array).to match_array([[m1], [m2], [m3, m4], [m5, m6]])
363
366
  end
364
367
  end
365
368
  end
@@ -1,5 +1,6 @@
1
1
  require 'spec_helper'
2
2
  require 'r10k/util/purgeable'
3
+ require 'r10k/util/cleaner'
3
4
 
4
5
  RSpec.describe R10K::Util::Purgeable do
5
6
  let(:managed_directories) do
@@ -21,14 +22,7 @@ RSpec.describe R10K::Util::Purgeable do
21
22
  ]
22
23
  end
23
24
 
24
- let(:test_class) do
25
- Struct.new(:managed_directories, :desired_contents) do
26
- include R10K::Util::Purgeable
27
- include R10K::Logging
28
- end
29
- end
30
-
31
- subject { test_class.new(managed_directories, desired_contents) }
25
+ subject { R10K::Util::Cleaner.new(managed_directories, desired_contents) }
32
26
 
33
27
  context 'without recurse option' do
34
28
  let(:recurse) { false }
@@ -10,7 +10,10 @@ describe R10K::Util::Setopts do
10
10
 
11
11
  def initialize(opts = {})
12
12
  setopts(opts, {
13
- :valid => :self, :alsovalid => :self, :truthyvalid => true,
13
+ :valid => :self,
14
+ :duplicate => :valid,
15
+ :alsovalid => :self,
16
+ :truthyvalid => true,
14
17
  :validalias => :valid,
15
18
  :ignoreme => nil
16
19
  })
@@ -53,7 +56,28 @@ describe R10K::Util::Setopts do
53
56
  }.to raise_error(ArgumentError, /cannot handle option 'notvalid'/)
54
57
  end
55
58
 
59
+ it "warns when given an unhandled option and raise_on_unhandled=false" do
60
+ test = Class.new { include R10K::Util::Setopts }.new
61
+ allow(test).to receive(:logger).and_return(spy)
62
+
63
+ test.send(:setopts, {valid: :value, invalid: :value},
64
+ {valid: :self},
65
+ raise_on_unhandled: false)
66
+
67
+ expect(test.logger).to have_received(:warn).with(%r{cannot handle option 'invalid'})
68
+ end
69
+
56
70
  it "ignores values that are marked as unhandled" do
57
71
  klass.new(:ignoreme => "IGNORE ME!")
58
72
  end
73
+
74
+ it "warns when given conflicting options" do
75
+ test = Class.new { include R10K::Util::Setopts }.new
76
+ allow(test).to receive(:logger).and_return(spy)
77
+
78
+ test.send(:setopts, {valid: :one, duplicate: :two},
79
+ {valid: :arg, duplicate: :arg})
80
+
81
+ expect(test.logger).to have_received(:warn).with(%r{valid.*duplicate.*conflict.*not both})
82
+ end
59
83
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: r10k
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.7.0
4
+ version: 3.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrien Thebo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-13 00:00:00.000000000 Z
11
+ date: 2021-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colored2
@@ -28,22 +28,16 @@ dependencies:
28
28
  name: cri
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - '='
32
32
  - !ruby/object:Gem::Version
33
33
  version: 2.15.10
34
- - - "<"
35
- - !ruby/object:Gem::Version
36
- version: 3.0.0
37
34
  type: :runtime
38
35
  prerelease: false
39
36
  version_requirements: !ruby/object:Gem::Requirement
40
37
  requirements:
41
- - - ">="
38
+ - - '='
42
39
  - !ruby/object:Gem::Version
43
40
  version: 2.15.10
44
- - - "<"
45
- - !ruby/object:Gem::Version
46
- version: 3.0.0
47
41
  - !ruby/object:Gem::Dependency
48
42
  name: log4r
49
43
  requirement: !ruby/object:Gem::Requirement
@@ -205,6 +199,7 @@ files:
205
199
  - ".github/workflows/docker.yml"
206
200
  - ".github/workflows/release.yml"
207
201
  - ".github/workflows/rspec_tests.yml"
202
+ - ".github/workflows/stale.yml"
208
203
  - ".gitignore"
209
204
  - ".travis.yml"
210
205
  - CHANGELOG.mkd
@@ -214,7 +209,6 @@ files:
214
209
  - LICENSE
215
210
  - README.mkd
216
211
  - Rakefile
217
- - azure-pipelines.yml
218
212
  - bin/r10k
219
213
  - doc/common-patterns.mkd
220
214
  - doc/dynamic-environments.mkd
@@ -236,6 +230,7 @@ files:
236
230
  - docker/Gemfile
237
231
  - docker/Makefile
238
232
  - docker/README.md
233
+ - docker/docker-compose.yml
239
234
  - docker/r10k/Dockerfile
240
235
  - docker/r10k/adduser.sh
241
236
  - docker/r10k/docker-entrypoint.d/10-analytics.sh
@@ -352,6 +347,7 @@ files:
352
347
  - lib/r10k/cli/help.rb
353
348
  - lib/r10k/cli/puppetfile.rb
354
349
  - lib/r10k/cli/version.rb
350
+ - lib/r10k/content_synchronizer.rb
355
351
  - lib/r10k/deployment.rb
356
352
  - lib/r10k/deployment/config.rb
357
353
  - lib/r10k/environment.rb
@@ -421,6 +417,7 @@ files:
421
417
  - lib/r10k/svn/working_dir.rb
422
418
  - lib/r10k/util/attempt.rb
423
419
  - lib/r10k/util/basedir.rb
420
+ - lib/r10k/util/cleaner.rb
424
421
  - lib/r10k/util/commands.rb
425
422
  - lib/r10k/util/exec_env.rb
426
423
  - lib/r10k/util/license.rb
@@ -448,6 +445,7 @@ files:
448
445
  - spec/fixtures/module/forge/eight_hundred/metadata.json
449
446
  - spec/fixtures/unit/action/r10k.yaml
450
447
  - spec/fixtures/unit/action/r10k_cachedir.yaml
448
+ - spec/fixtures/unit/action/r10k_creds.yaml
451
449
  - spec/fixtures/unit/action/r10k_generate_types.yaml
452
450
  - spec/fixtures/unit/action/r10k_puppet_path.yaml
453
451
  - spec/fixtures/unit/puppetfile/argument-error/Puppetfile
@@ -506,6 +504,7 @@ files:
506
504
  - spec/unit/environment/git_spec.rb
507
505
  - spec/unit/environment/name_spec.rb
508
506
  - spec/unit/environment/svn_spec.rb
507
+ - spec/unit/environment/with_modules_spec.rb
509
508
  - spec/unit/errors/formatting_spec.rb
510
509
  - spec/unit/feature_spec.rb
511
510
  - spec/unit/forge/module_release_spec.rb
@@ -577,7 +576,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
577
576
  - !ruby/object:Gem::Version
578
577
  version: '0'
579
578
  requirements: []
580
- rubygems_version: 3.0.3
579
+ rubygems_version: 3.0.8
581
580
  signing_key:
582
581
  specification_version: 4
583
582
  summary: Puppet environment and module deployment