r10k 3.5.0 → 3.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/.github/pull_request_template.md +4 -1
  3. data/.github/workflows/docker.yml +25 -1
  4. data/.github/workflows/rspec_tests.yml +81 -0
  5. data/.travis.yml +14 -11
  6. data/CHANGELOG.mkd +42 -6
  7. data/CODEOWNERS +1 -1
  8. data/Gemfile +1 -1
  9. data/README.mkd +13 -4
  10. data/azure-pipelines.yml +2 -1
  11. data/doc/dynamic-environments/configuration.mkd +60 -3
  12. data/doc/dynamic-environments/usage.mkd +5 -4
  13. data/doc/faq.mkd +6 -1
  14. data/doc/puppetfile.mkd +2 -0
  15. data/docker/Makefile +16 -2
  16. data/docker/r10k/Dockerfile +17 -6
  17. data/docker/r10k/release.Dockerfile +23 -4
  18. data/integration/tests/git_source/git_source_repeated_remote.rb +68 -0
  19. data/integration/tests/user_scenario/complex_workflow/multi_env_add_change_remove.rb +1 -1
  20. data/integration/tests/user_scenario/complex_workflow/multi_env_remove_re-add.rb +1 -1
  21. data/integration/tests/user_scenario/complex_workflow/multi_env_unamanaged.rb +1 -1
  22. data/lib/r10k/action/deploy/environment.rb +3 -0
  23. data/lib/r10k/action/deploy/module.rb +4 -1
  24. data/lib/r10k/action/runner.rb +34 -0
  25. data/lib/r10k/cli/deploy.rb +9 -4
  26. data/lib/r10k/cli/puppetfile.rb +5 -5
  27. data/lib/r10k/environment/base.rb +8 -1
  28. data/lib/r10k/environment/with_modules.rb +27 -19
  29. data/lib/r10k/forge/module_release.rb +2 -2
  30. data/lib/r10k/git.rb +1 -0
  31. data/lib/r10k/git/cache.rb +12 -4
  32. data/lib/r10k/git/rugged/credentials.rb +32 -2
  33. data/lib/r10k/git/stateful_repository.rb +4 -0
  34. data/lib/r10k/initializers.rb +2 -0
  35. data/lib/r10k/module/base.rb +8 -0
  36. data/lib/r10k/module/forge.rb +1 -1
  37. data/lib/r10k/module/git.rb +20 -3
  38. data/lib/r10k/puppetfile.rb +30 -12
  39. data/lib/r10k/settings.rb +24 -2
  40. data/lib/r10k/source/git.rb +22 -2
  41. data/lib/r10k/version.rb +1 -1
  42. data/locales/r10k.pot +60 -36
  43. data/spec/fixtures/unit/action/r10k_creds.yaml +9 -0
  44. data/spec/shared-examples/subprocess-runner.rb +11 -5
  45. data/spec/unit/action/deploy/environment_spec.rb +43 -2
  46. data/spec/unit/action/deploy/module_spec.rb +40 -1
  47. data/spec/unit/action/puppetfile/install_spec.rb +1 -0
  48. data/spec/unit/action/runner_spec.rb +48 -1
  49. data/spec/unit/environment/git_spec.rb +3 -2
  50. data/spec/unit/environment/with_modules_spec.rb +74 -0
  51. data/spec/unit/forge/module_release_spec.rb +14 -10
  52. data/spec/unit/git/cache_spec.rb +10 -0
  53. data/spec/unit/git/rugged/credentials_spec.rb +69 -2
  54. data/spec/unit/git_spec.rb +3 -3
  55. data/spec/unit/module/git_spec.rb +55 -0
  56. data/spec/unit/puppetfile_spec.rb +61 -7
  57. data/spec/unit/settings_spec.rb +12 -0
  58. data/spec/unit/source/git_spec.rb +49 -1
  59. metadata +6 -2
@@ -129,6 +129,18 @@ describe R10K::Settings do
129
129
  expect { subject.evaluate('puppet_path' => '/nonexistent') }.to raise_error(R10K::Settings::Collection::ValidationError)
130
130
  end
131
131
  end
132
+
133
+ describe 'puppet_conf' do
134
+ it 'when file raises no error' do
135
+ allow(File).to receive(:readable?).with('/nonexistent').and_return(true)
136
+ expect { subject.evaluate('puppet_conf' => '/nonexistent') }.not_to raise_error
137
+ end
138
+
139
+ it 'when not file raises error' do
140
+ allow(File).to receive(:readable?).with('/nonexistent').and_return(false)
141
+ expect { subject.evaluate('puppet_conf' => '/nonexistent') }.to raise_error(R10K::Settings::Collection::ValidationError)
142
+ end
143
+ end
132
144
  end
133
145
 
134
146
  describe "global settings" do
@@ -93,9 +93,57 @@ describe R10K::Source::Git do
93
93
  let(:ignore_prefixes) { ['dev', 'test'] }
94
94
 
95
95
  it "filters branches" do
96
- expect(subject.filter_branches(branches, ignore_prefixes)).to eq(['master', 'production', 'not_dev_test_me'])
96
+ expect(subject.filter_branches_by_regexp(branches, ignore_prefixes)).to eq(['master', 'production', 'not_dev_test_me'])
97
97
  end
98
98
  end
99
+
100
+ describe "filtering branches with command" do
101
+ let(:branches) { ['master', 'development', 'production'] }
102
+ if R10K::Util::Platform.windows?
103
+ let(:filter_command) { 'powershell.exe if ($env:R10K_BRANCH.equals(\"development\")) {exit 1} else {exit 0}' }
104
+ else
105
+ let(:filter_command) { 'sh -c "[ $R10K_BRANCH != development ]"' }
106
+ end
107
+
108
+ it "filters branches" do
109
+ expect(subject.filter_branches_by_command(branches, filter_command)).to eq(['master', 'production'])
110
+ end
111
+ end
112
+
113
+ describe "generate_environments respects filter_command setting" do
114
+ before do
115
+ allow(subject.cache).to receive(:branches).and_return ['master', 'development', 'production']
116
+ if R10K::Util::Platform.windows?
117
+ subject.instance_variable_set(:@filter_command, 'powershell.exe if ($env:R10K_BRANCH.equals(\"master\")) {exit 1} else {exit 0}')
118
+ else
119
+ subject.instance_variable_set(:@filter_command, '[ $R10K_BRANCH != master ]')
120
+ end
121
+ end
122
+
123
+ let(:environments) { subject.generate_environments }
124
+
125
+ it "creates an environment for each branch not filtered by filter_command" do
126
+ expect(subject.generate_environments.size).to eq(2)
127
+ end
128
+ end
129
+
130
+ describe "generate_environments respects filter_command setting and name" do
131
+ before do
132
+ allow(subject.cache).to receive(:branches).and_return ['master', 'development', 'production']
133
+ if R10K::Util::Platform.windows?
134
+ subject.instance_variable_set(:@filter_command, 'powershell.exe if ($env:R10K_NAME.equals(\"mysource\")) {exit 0} else {exit 1}')
135
+ else
136
+ subject.instance_variable_set(:@filter_command, '[ $R10K_NAME = mysource ]')
137
+ end
138
+ end
139
+
140
+ let(:environments) { subject.generate_environments }
141
+
142
+ it "creates an environment for each branch not filtered by filter_command" do
143
+ expect(subject.generate_environments.size).to eq(3)
144
+ end
145
+ end
146
+
99
147
  end
100
148
 
101
149
  describe R10K::Source::Git, "handling invalid branch names" do
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.5.0
4
+ version: 3.8.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: 2020-05-06 00:00:00.000000000 Z
11
+ date: 2021-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colored2
@@ -204,6 +204,7 @@ files:
204
204
  - ".github/pull_request_template.md"
205
205
  - ".github/workflows/docker.yml"
206
206
  - ".github/workflows/release.yml"
207
+ - ".github/workflows/rspec_tests.yml"
207
208
  - ".gitignore"
208
209
  - ".travis.yml"
209
210
  - CHANGELOG.mkd
@@ -282,6 +283,7 @@ files:
282
283
  - integration/tests/command_line/negative/neg_invalid_cmd_line_arg.rb
283
284
  - integration/tests/git_source/HTTP_proxy_and_git_source.rb
284
285
  - integration/tests/git_source/git_source_git.rb
286
+ - integration/tests/git_source/git_source_repeated_remote.rb
285
287
  - integration/tests/git_source/git_source_ssh.rb
286
288
  - integration/tests/git_source/git_source_submodule.rb
287
289
  - integration/tests/git_source/negative/neg_git_broken_remote.rb
@@ -446,6 +448,7 @@ files:
446
448
  - spec/fixtures/module/forge/eight_hundred/metadata.json
447
449
  - spec/fixtures/unit/action/r10k.yaml
448
450
  - spec/fixtures/unit/action/r10k_cachedir.yaml
451
+ - spec/fixtures/unit/action/r10k_creds.yaml
449
452
  - spec/fixtures/unit/action/r10k_generate_types.yaml
450
453
  - spec/fixtures/unit/action/r10k_puppet_path.yaml
451
454
  - spec/fixtures/unit/puppetfile/argument-error/Puppetfile
@@ -504,6 +507,7 @@ files:
504
507
  - spec/unit/environment/git_spec.rb
505
508
  - spec/unit/environment/name_spec.rb
506
509
  - spec/unit/environment/svn_spec.rb
510
+ - spec/unit/environment/with_modules_spec.rb
507
511
  - spec/unit/errors/formatting_spec.rb
508
512
  - spec/unit/feature_spec.rb
509
513
  - spec/unit/forge/module_release_spec.rb