r10k 3.9.2 → 3.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rspec_tests.yml +1 -1
  3. data/.travis.yml +0 -10
  4. data/CHANGELOG.mkd +33 -0
  5. data/README.mkd +6 -0
  6. data/doc/dynamic-environments/configuration.mkd +25 -0
  7. data/doc/dynamic-environments/usage.mkd +26 -0
  8. data/doc/puppetfile.mkd +18 -5
  9. data/integration/Rakefile +3 -1
  10. data/integration/tests/basic_functionality/basic_deployment.rb +176 -0
  11. data/integration/tests/user_scenario/basic_workflow/negative/neg_specify_deleted_forge_module.rb +3 -9
  12. data/integration/tests/user_scenario/basic_workflow/single_env_purge_unmanaged_modules.rb +21 -25
  13. data/integration/tests/user_scenario/complex_workflow/multi_env_add_change_remove.rb +3 -3
  14. data/integration/tests/user_scenario/complex_workflow/multi_env_remove_re-add.rb +3 -3
  15. data/integration/tests/user_scenario/complex_workflow/multi_env_unamanaged.rb +3 -3
  16. data/lib/r10k/action/deploy/environment.rb +17 -2
  17. data/lib/r10k/action/deploy/module.rb +38 -7
  18. data/lib/r10k/action/puppetfile/check.rb +7 -5
  19. data/lib/r10k/action/puppetfile/install.rb +22 -16
  20. data/lib/r10k/action/puppetfile/purge.rb +12 -9
  21. data/lib/r10k/action/runner.rb +45 -10
  22. data/lib/r10k/cli/deploy.rb +5 -0
  23. data/lib/r10k/cli/puppetfile.rb +0 -1
  24. data/lib/r10k/content_synchronizer.rb +16 -4
  25. data/lib/r10k/environment/base.rb +64 -11
  26. data/lib/r10k/environment/with_modules.rb +6 -10
  27. data/lib/r10k/git/cache.rb +1 -1
  28. data/lib/r10k/git/rugged/credentials.rb +77 -0
  29. data/lib/r10k/git/stateful_repository.rb +8 -0
  30. data/lib/r10k/git.rb +3 -0
  31. data/lib/r10k/initializers.rb +4 -0
  32. data/lib/r10k/module/base.rb +42 -1
  33. data/lib/r10k/module/definition.rb +64 -0
  34. data/lib/r10k/module/forge.rb +17 -4
  35. data/lib/r10k/module/git.rb +24 -2
  36. data/lib/r10k/module/local.rb +2 -3
  37. data/lib/r10k/module/svn.rb +12 -1
  38. data/lib/r10k/module.rb +20 -2
  39. data/lib/r10k/module_loader/puppetfile/dsl.rb +42 -0
  40. data/lib/r10k/module_loader/puppetfile.rb +272 -0
  41. data/lib/r10k/puppetfile.rb +82 -160
  42. data/lib/r10k/settings/definition.rb +1 -1
  43. data/lib/r10k/settings.rb +58 -2
  44. data/lib/r10k/source/base.rb +10 -0
  45. data/lib/r10k/source/git.rb +5 -0
  46. data/lib/r10k/source/svn.rb +4 -0
  47. data/lib/r10k/util/purgeable.rb +70 -8
  48. data/lib/r10k/version.rb +1 -1
  49. data/locales/r10k.pot +165 -65
  50. data/r10k.gemspec +2 -0
  51. data/spec/fixtures/unit/action/r10k_forge_auth.yaml +4 -0
  52. data/spec/fixtures/unit/action/r10k_forge_auth_no_url.yaml +3 -0
  53. data/spec/fixtures/unit/puppetfile/forge-override/Puppetfile +8 -0
  54. data/spec/fixtures/unit/puppetfile/various-modules/Puppetfile +9 -0
  55. data/spec/fixtures/unit/puppetfile/various-modules/Puppetfile.new +9 -0
  56. data/spec/fixtures/unit/util/purgeable/managed_one/managed_subdir_1/managed_subdir_2/ignored_1 +0 -0
  57. data/spec/fixtures/unit/util/purgeable/managed_two/.hidden/unmanaged_3 +0 -0
  58. data/spec/r10k-mocks/mock_env.rb +3 -0
  59. data/spec/r10k-mocks/mock_source.rb +7 -3
  60. data/spec/unit/action/deploy/environment_spec.rb +105 -30
  61. data/spec/unit/action/deploy/module_spec.rb +232 -42
  62. data/spec/unit/action/puppetfile/check_spec.rb +17 -5
  63. data/spec/unit/action/puppetfile/install_spec.rb +42 -36
  64. data/spec/unit/action/puppetfile/purge_spec.rb +15 -17
  65. data/spec/unit/action/runner_spec.rb +122 -26
  66. data/spec/unit/environment/base_spec.rb +30 -17
  67. data/spec/unit/environment/git_spec.rb +2 -2
  68. data/spec/unit/environment/svn_spec.rb +4 -3
  69. data/spec/unit/environment/with_modules_spec.rb +2 -1
  70. data/spec/unit/git/cache_spec.rb +14 -0
  71. data/spec/unit/git/rugged/credentials_spec.rb +29 -0
  72. data/spec/unit/git/stateful_repository_spec.rb +5 -0
  73. data/spec/unit/module/base_spec.rb +54 -8
  74. data/spec/unit/module/forge_spec.rb +59 -5
  75. data/spec/unit/module/git_spec.rb +67 -17
  76. data/spec/unit/module/svn_spec.rb +35 -5
  77. data/spec/unit/module_loader/puppetfile_spec.rb +403 -0
  78. data/spec/unit/module_spec.rb +28 -0
  79. data/spec/unit/puppetfile_spec.rb +125 -189
  80. data/spec/unit/settings_spec.rb +47 -2
  81. data/spec/unit/util/purgeable_spec.rb +38 -6
  82. metadata +28 -2
@@ -19,6 +19,7 @@ RSpec.describe R10K::Util::Purgeable do
19
19
  'spec/fixtures/unit/util/purgeable/managed_one/managed_subdir_1/subdir_new_1',
20
20
  'spec/fixtures/unit/util/purgeable/managed_two/expected_2',
21
21
  'spec/fixtures/unit/util/purgeable/managed_two/new_2',
22
+ 'spec/fixtures/unit/util/purgeable/managed_two/.hidden',
22
23
  ]
23
24
  end
24
25
 
@@ -98,7 +99,13 @@ RSpec.describe R10K::Util::Purgeable do
98
99
 
99
100
  describe '#current_contents' do
100
101
  it 'collects contents of all managed directories recursively' do
101
- expect(subject.current_contents(recurse)).to contain_exactly(/\/expected_1/, /\/expected_2/, /\/unmanaged_1/, /\/unmanaged_2/, /\/managed_subdir_1/, /\/subdir_expected_1/, /\/subdir_unmanaged_1/)
102
+ expect(subject.current_contents(recurse)).
103
+ to contain_exactly(/\/expected_1/, /\/expected_2/,
104
+ /\/unmanaged_1/, /\/unmanaged_2/,
105
+ /\/managed_subdir_1/,
106
+ /\/subdir_expected_1/, /\/subdir_unmanaged_1/,
107
+ /\/managed_subdir_2/, /\/ignored_1/,
108
+ /\/\.hidden/)
102
109
  end
103
110
  end
104
111
 
@@ -114,7 +121,8 @@ RSpec.describe R10K::Util::Purgeable do
114
121
  let(:whitelist) { [] }
115
122
 
116
123
  it 'collects current_contents that should not exist recursively' do
117
- expect(subject.stale_contents(recurse, exclusions, whitelist)).to contain_exactly(/\/unmanaged_1/, /\/unmanaged_2/, /\/subdir_unmanaged_1/)
124
+ expect(subject.stale_contents(recurse, exclusions, whitelist)).
125
+ to contain_exactly(/\/unmanaged_1/, /\/unmanaged_2/, /\/subdir_unmanaged_1/, /\/ignored_1/)
118
126
  end
119
127
  end
120
128
 
@@ -124,7 +132,17 @@ RSpec.describe R10K::Util::Purgeable do
124
132
 
125
133
  it 'collects current_contents that should not exist except whitelisted items' do
126
134
  expect(subject.logger).to receive(:debug).with(/unmanaged_1.*whitelist match/i)
127
- expect(subject.stale_contents(recurse, exclusions, whitelist)).to contain_exactly(/\/unmanaged_2/, /\/subdir_unmanaged_1/)
135
+
136
+ expect(subject.stale_contents(recurse, exclusions, whitelist)).
137
+ to contain_exactly(/\/unmanaged_2/, /\/subdir_unmanaged_1/, /\/ignored_1/)
138
+ end
139
+
140
+ it 'does not collect contents that match recursive globbed whitelist items as intermediate values' do
141
+ recursive_whitelist = ['**/managed_subdir_1/**/*']
142
+ expect(subject.logger).not_to receive(:debug).with(/ignored_1/)
143
+
144
+ expect(subject.stale_contents(recurse, exclusions, recursive_whitelist)).
145
+ to contain_exactly(/\/unmanaged_2/, /\/managed_one\/unmanaged_1/)
128
146
  end
129
147
  end
130
148
 
@@ -134,7 +152,17 @@ RSpec.describe R10K::Util::Purgeable do
134
152
 
135
153
  it 'collects current_contents that should not exist except excluded items' do
136
154
  expect(subject.logger).to receive(:debug2).with(/unmanaged_2.*internal exclusion match/i)
137
- expect(subject.stale_contents(recurse, exclusions, whitelist)).to contain_exactly(/\/unmanaged_1/, /\/subdir_unmanaged_1/)
155
+
156
+ expect(subject.stale_contents(recurse, exclusions, whitelist)).
157
+ to contain_exactly(/\/unmanaged_1/, /\/subdir_unmanaged_1/, /\/ignored_1/)
158
+ end
159
+
160
+ it 'does not collect contents that match recursive globbed exclusion items as intermediate values' do
161
+ recursive_exclusions = ['**/managed_subdir_1/**/*']
162
+ expect(subject.logger).not_to receive(:debug).with(/ignored_1/)
163
+
164
+ expect(subject.stale_contents(recurse, recursive_exclusions, whitelist)).
165
+ to contain_exactly(/\/unmanaged_2/, /\/managed_one\/unmanaged_1/)
138
166
  end
139
167
  end
140
168
  end
@@ -179,7 +207,11 @@ RSpec.describe R10K::Util::Purgeable do
179
207
  end
180
208
 
181
209
  context "recursive whitelist glob" do
182
- let(:whitelist) { managed_directories.collect { |dir| File.join(dir, "**", "*unmanaged*") } }
210
+ let(:whitelist) do
211
+ managed_directories.flat_map do |dir|
212
+ [File.join(dir, "**", "*unmanaged*"), File.join(dir, "**", "managed_subdir_2")]
213
+ end
214
+ end
183
215
  let(:purge_opts) { { recurse: true, whitelist: whitelist } }
184
216
 
185
217
  describe '#purge!' do
@@ -214,7 +246,7 @@ RSpec.describe R10K::Util::Purgeable do
214
246
  context "when class does not implement #purge_exclusions" do
215
247
  describe '#purge!' do
216
248
  it 'purges normally' do
217
- expect(FileUtils).to receive(:rm_r).at_least(3).times
249
+ expect(FileUtils).to receive(:rm_r).at_least(4).times
218
250
 
219
251
  subject.purge!(purge_opts)
220
252
  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.9.2
4
+ version: 3.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrien Thebo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-19 00:00:00.000000000 Z
11
+ date: 2021-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colored2
@@ -128,6 +128,20 @@ dependencies:
128
128
  - - "<"
129
129
  - !ruby/object:Gem::Version
130
130
  version: 3.3.0
131
+ - !ruby/object:Gem::Dependency
132
+ name: jwt
133
+ requirement: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - "~>"
136
+ - !ruby/object:Gem::Version
137
+ version: 2.2.3
138
+ type: :runtime
139
+ prerelease: false
140
+ version_requirements: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - "~>"
143
+ - !ruby/object:Gem::Version
144
+ version: 2.2.3
131
145
  - !ruby/object:Gem::Dependency
132
146
  name: rspec
133
147
  requirement: !ruby/object:Gem::Requirement
@@ -263,6 +277,7 @@ files:
263
277
  - integration/tests/Puppetfile/HTTP_PROXY_affects_forge_source.rb
264
278
  - integration/tests/Puppetfile/HTTP_PROXY_affects_git_source.rb
265
279
  - integration/tests/README.mkd
280
+ - integration/tests/basic_functionality/basic_deployment.rb
266
281
  - integration/tests/basic_functionality/install_pe_only_module_with_puppetfile.rb
267
282
  - integration/tests/basic_functionality/negative/neg_deploy_with_invalid_r10k_yaml.rb
268
283
  - integration/tests/basic_functionality/negative/neg_deploy_with_missing_r10k_yaml.rb
@@ -388,11 +403,14 @@ files:
388
403
  - lib/r10k/logging/terminaloutputter.rb
389
404
  - lib/r10k/module.rb
390
405
  - lib/r10k/module/base.rb
406
+ - lib/r10k/module/definition.rb
391
407
  - lib/r10k/module/forge.rb
392
408
  - lib/r10k/module/git.rb
393
409
  - lib/r10k/module/local.rb
394
410
  - lib/r10k/module/metadata_file.rb
395
411
  - lib/r10k/module/svn.rb
412
+ - lib/r10k/module_loader/puppetfile.rb
413
+ - lib/r10k/module_loader/puppetfile/dsl.rb
396
414
  - lib/r10k/puppetfile.rb
397
415
  - lib/r10k/settings.rb
398
416
  - lib/r10k/settings/collection.rb
@@ -446,20 +464,27 @@ files:
446
464
  - spec/fixtures/unit/action/r10k.yaml
447
465
  - spec/fixtures/unit/action/r10k_cachedir.yaml
448
466
  - spec/fixtures/unit/action/r10k_creds.yaml
467
+ - spec/fixtures/unit/action/r10k_forge_auth.yaml
468
+ - spec/fixtures/unit/action/r10k_forge_auth_no_url.yaml
449
469
  - spec/fixtures/unit/action/r10k_generate_types.yaml
450
470
  - spec/fixtures/unit/action/r10k_puppet_path.yaml
451
471
  - spec/fixtures/unit/puppetfile/argument-error/Puppetfile
452
472
  - spec/fixtures/unit/puppetfile/default-branch-override/Puppetfile
453
473
  - spec/fixtures/unit/puppetfile/duplicate-module-error/Puppetfile
474
+ - spec/fixtures/unit/puppetfile/forge-override/Puppetfile
454
475
  - spec/fixtures/unit/puppetfile/invalid-syntax/Puppetfile
455
476
  - spec/fixtures/unit/puppetfile/load-error/Puppetfile
456
477
  - spec/fixtures/unit/puppetfile/name-error/Puppetfile
457
478
  - spec/fixtures/unit/puppetfile/valid-forge-with-version/Puppetfile
458
479
  - spec/fixtures/unit/puppetfile/valid-forge-without-version/Puppetfile
480
+ - spec/fixtures/unit/puppetfile/various-modules/Puppetfile
481
+ - spec/fixtures/unit/puppetfile/various-modules/Puppetfile.new
459
482
  - spec/fixtures/unit/util/purgeable/managed_one/expected_1
483
+ - spec/fixtures/unit/util/purgeable/managed_one/managed_subdir_1/managed_subdir_2/ignored_1
460
484
  - spec/fixtures/unit/util/purgeable/managed_one/managed_subdir_1/subdir_expected_1
461
485
  - spec/fixtures/unit/util/purgeable/managed_one/managed_subdir_1/subdir_unmanaged_1
462
486
  - spec/fixtures/unit/util/purgeable/managed_one/unmanaged_1
487
+ - spec/fixtures/unit/util/purgeable/managed_two/.hidden/unmanaged_3
463
488
  - spec/fixtures/unit/util/purgeable/managed_two/expected_2
464
489
  - spec/fixtures/unit/util/purgeable/managed_two/unmanaged_2
465
490
  - spec/fixtures/unit/util/subprocess/runner/no-execute.sh
@@ -525,6 +550,7 @@ files:
525
550
  - spec/unit/module/git_spec.rb
526
551
  - spec/unit/module/metadata_file_spec.rb
527
552
  - spec/unit/module/svn_spec.rb
553
+ - spec/unit/module_loader/puppetfile_spec.rb
528
554
  - spec/unit/module_spec.rb
529
555
  - spec/unit/puppetfile_spec.rb
530
556
  - spec/unit/settings/collection_spec.rb