r10k 3.9.3 → 3.12.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rspec_tests.yml +1 -1
- data/.travis.yml +0 -10
- data/CHANGELOG.mkd +33 -0
- data/README.mkd +6 -0
- data/doc/dynamic-environments/configuration.mkd +25 -0
- data/doc/dynamic-environments/usage.mkd +26 -0
- data/doc/puppetfile.mkd +18 -5
- data/integration/Rakefile +3 -1
- data/integration/tests/basic_functionality/basic_deployment.rb +176 -0
- data/integration/tests/user_scenario/basic_workflow/negative/neg_specify_deleted_forge_module.rb +3 -9
- data/integration/tests/user_scenario/basic_workflow/single_env_purge_unmanaged_modules.rb +21 -25
- data/integration/tests/user_scenario/complex_workflow/multi_env_add_change_remove.rb +3 -3
- data/integration/tests/user_scenario/complex_workflow/multi_env_remove_re-add.rb +3 -3
- data/integration/tests/user_scenario/complex_workflow/multi_env_unamanaged.rb +3 -3
- data/lib/r10k/action/base.rb +1 -1
- data/lib/r10k/action/deploy/deploy_helpers.rb +4 -0
- data/lib/r10k/action/deploy/display.rb +1 -1
- data/lib/r10k/action/deploy/environment.rb +22 -9
- data/lib/r10k/action/deploy/module.rb +41 -11
- data/lib/r10k/action/puppetfile/check.rb +7 -5
- data/lib/r10k/action/puppetfile/install.rb +22 -16
- data/lib/r10k/action/puppetfile/purge.rb +12 -9
- data/lib/r10k/action/runner.rb +45 -10
- data/lib/r10k/action/visitor.rb +3 -0
- data/lib/r10k/cli/deploy.rb +5 -0
- data/lib/r10k/cli/puppetfile.rb +0 -1
- data/lib/r10k/content_synchronizer.rb +16 -4
- data/lib/r10k/environment/base.rb +64 -11
- data/lib/r10k/environment/with_modules.rb +6 -10
- data/lib/r10k/git/cache.rb +1 -1
- data/lib/r10k/git/rugged/credentials.rb +77 -0
- data/lib/r10k/git/stateful_repository.rb +8 -0
- data/lib/r10k/git.rb +3 -0
- data/lib/r10k/initializers.rb +4 -0
- data/lib/r10k/module/base.rb +42 -1
- data/lib/r10k/module/definition.rb +64 -0
- data/lib/r10k/module/forge.rb +16 -3
- data/lib/r10k/module/git.rb +23 -1
- data/lib/r10k/module/local.rb +6 -3
- data/lib/r10k/module/svn.rb +11 -0
- data/lib/r10k/module.rb +20 -2
- data/lib/r10k/module_loader/puppetfile/dsl.rb +42 -0
- data/lib/r10k/module_loader/puppetfile.rb +276 -0
- data/lib/r10k/puppetfile.rb +82 -160
- data/lib/r10k/settings/definition.rb +1 -1
- data/lib/r10k/settings.rb +58 -2
- data/lib/r10k/source/base.rb +10 -0
- data/lib/r10k/source/git.rb +5 -0
- data/lib/r10k/source/svn.rb +4 -0
- data/lib/r10k/util/purgeable.rb +74 -8
- data/lib/r10k/util/setopts.rb +2 -0
- data/lib/r10k/util/subprocess.rb +1 -0
- data/lib/r10k/version.rb +1 -1
- data/locales/r10k.pot +165 -65
- data/r10k.gemspec +2 -0
- data/spec/fixtures/unit/action/r10k_forge_auth.yaml +4 -0
- data/spec/fixtures/unit/action/r10k_forge_auth_no_url.yaml +3 -0
- data/spec/fixtures/unit/puppetfile/forge-override/Puppetfile +8 -0
- data/spec/fixtures/unit/puppetfile/various-modules/Puppetfile +10 -0
- data/spec/fixtures/unit/puppetfile/various-modules/Puppetfile.new +10 -0
- data/spec/fixtures/unit/util/purgeable/managed_one/managed_subdir_1/managed_subdir_2/ignored_1 +0 -0
- data/spec/fixtures/unit/util/purgeable/managed_two/.hidden/unmanaged_3 +0 -0
- data/spec/r10k-mocks/mock_env.rb +3 -0
- data/spec/r10k-mocks/mock_source.rb +7 -3
- data/spec/unit/action/deploy/environment_spec.rb +105 -30
- data/spec/unit/action/deploy/module_spec.rb +232 -42
- data/spec/unit/action/puppetfile/check_spec.rb +17 -5
- data/spec/unit/action/puppetfile/install_spec.rb +42 -36
- data/spec/unit/action/puppetfile/purge_spec.rb +15 -17
- data/spec/unit/action/runner_spec.rb +122 -26
- data/spec/unit/environment/base_spec.rb +30 -17
- data/spec/unit/environment/git_spec.rb +2 -2
- data/spec/unit/environment/svn_spec.rb +4 -3
- data/spec/unit/environment/with_modules_spec.rb +2 -1
- data/spec/unit/git/cache_spec.rb +14 -0
- data/spec/unit/git/rugged/credentials_spec.rb +29 -0
- data/spec/unit/git/stateful_repository_spec.rb +5 -0
- data/spec/unit/module/base_spec.rb +54 -8
- data/spec/unit/module/forge_spec.rb +59 -5
- data/spec/unit/module/git_spec.rb +67 -9
- data/spec/unit/module/svn_spec.rb +35 -5
- data/spec/unit/module_loader/puppetfile_spec.rb +405 -0
- data/spec/unit/module_spec.rb +12 -1
- data/spec/unit/puppetfile_spec.rb +125 -189
- data/spec/unit/settings_spec.rb +47 -2
- data/spec/unit/util/purgeable_spec.rb +38 -6
- metadata +29 -3
@@ -10,7 +10,7 @@ describe R10K::Puppetfile do
|
|
10
10
|
)
|
11
11
|
end
|
12
12
|
|
13
|
-
describe "a custom
|
13
|
+
describe "a custom puppetfile_name" do
|
14
14
|
it "is the basedir joined with '/Puppetfile.r10k' path" do
|
15
15
|
expect(subject.puppetfile_path).to eq '/some/nonexistent/basedir/Puppetfile.r10k'
|
16
16
|
end
|
@@ -18,6 +18,25 @@ describe R10K::Puppetfile do
|
|
18
18
|
|
19
19
|
end
|
20
20
|
|
21
|
+
describe R10K::Puppetfile do
|
22
|
+
|
23
|
+
describe "a custom relative puppetfile_path" do
|
24
|
+
it "is the basedir joined with the puppetfile_path" do
|
25
|
+
relative_subject = described_class.new('/some/nonexistent/basedir',
|
26
|
+
{puppetfile_path: 'relative/Puppetfile'})
|
27
|
+
expect(relative_subject.puppetfile_path).to eq '/some/nonexistent/basedir/relative/Puppetfile'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "a custom absolute puppetfile_path" do
|
32
|
+
it "is the puppetfile_path as given" do
|
33
|
+
absolute_subject = described_class.new('/some/nonexistent/basedir',
|
34
|
+
{puppetfile_path: '/some/absolute/custom/Puppetfile'})
|
35
|
+
expect(absolute_subject.puppetfile_path).to eq '/some/absolute/custom/Puppetfile'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
21
40
|
describe R10K::Puppetfile do
|
22
41
|
|
23
42
|
subject do
|
@@ -67,230 +86,147 @@ describe R10K::Puppetfile do
|
|
67
86
|
end
|
68
87
|
end
|
69
88
|
|
70
|
-
describe "
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
expect(subject.modules.collect(&:name)).to include('test_module')
|
76
|
-
end
|
77
|
-
|
78
|
-
it "should not accept Forge modules with a version comparison" do
|
79
|
-
allow(R10K::Module).to receive(:new).with('puppet/test_module', subject.moduledir, hash_including(version: '< 1.2.0'), anything).and_call_original
|
80
|
-
|
81
|
-
expect {
|
82
|
-
subject.add_module('puppet/test_module', '< 1.2.0')
|
83
|
-
}.to raise_error(RuntimeError, /module puppet\/test_module.*doesn't have an implementation/i)
|
84
|
-
|
85
|
-
expect(subject.modules.collect(&:name)).not_to include('test_module')
|
86
|
-
end
|
87
|
-
|
88
|
-
it "should accept non-Forge modules with a hash arg" do
|
89
|
-
module_opts = { git: 'git@example.com:puppet/test_module.git' }
|
90
|
-
|
91
|
-
allow(R10K::Module).to receive(:new).with('puppet/test_module', subject.moduledir, module_opts, anything).and_call_original
|
92
|
-
|
93
|
-
expect { subject.add_module('puppet/test_module', module_opts) }.to change { subject.modules }
|
94
|
-
expect(subject.modules.collect(&:name)).to include('test_module')
|
95
|
-
end
|
96
|
-
|
97
|
-
it "should accept non-Forge modules with a valid relative :install_path option" do
|
98
|
-
module_opts = {
|
99
|
-
install_path: 'vendor',
|
100
|
-
git: 'git@example.com:puppet/test_module.git',
|
101
|
-
}
|
102
|
-
|
103
|
-
allow(R10K::Module).to receive(:new).with('puppet/test_module', File.join(subject.basedir, 'vendor'), module_opts, anything).and_call_original
|
104
|
-
|
105
|
-
expect { subject.add_module('puppet/test_module', module_opts) }.to change { subject.modules }
|
106
|
-
expect(subject.modules.collect(&:name)).to include('test_module')
|
107
|
-
end
|
108
|
-
|
109
|
-
it "should accept non-Forge modules with a valid absolute :install_path option" do
|
110
|
-
install_path = File.join(subject.basedir, 'vendor')
|
111
|
-
|
112
|
-
module_opts = {
|
113
|
-
install_path: install_path,
|
114
|
-
git: 'git@example.com:puppet/test_module.git',
|
115
|
-
}
|
116
|
-
|
117
|
-
allow(R10K::Module).to receive(:new).with('puppet/test_module', install_path, module_opts, anything).and_call_original
|
118
|
-
|
119
|
-
expect { subject.add_module('puppet/test_module', module_opts) }.to change { subject.modules }
|
120
|
-
expect(subject.modules.collect(&:name)).to include('test_module')
|
121
|
-
end
|
89
|
+
describe "loading a Puppetfile" do
|
90
|
+
context 'using load' do
|
91
|
+
it "returns the loaded content" do
|
92
|
+
path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'valid-forge-with-version')
|
93
|
+
subject = described_class.new(path, {})
|
122
94
|
|
123
|
-
|
124
|
-
|
125
|
-
install_path: '../../vendor',
|
126
|
-
git: 'git@example.com:puppet/test_module.git',
|
127
|
-
}
|
95
|
+
loaded_content = subject.load
|
96
|
+
expect(loaded_content).to be_an_instance_of(Hash)
|
128
97
|
|
129
|
-
|
98
|
+
has_some_data = loaded_content.values.none?(&:empty?)
|
99
|
+
expect(has_some_data).to be true
|
100
|
+
end
|
130
101
|
|
131
|
-
|
132
|
-
|
102
|
+
it "handles a relative basedir" do
|
103
|
+
path = File.join('spec', 'fixtures', 'unit', 'puppetfile', 'valid-forge-with-version')
|
104
|
+
subject = described_class.new(path, {})
|
133
105
|
|
134
|
-
|
135
|
-
|
136
|
-
install_path: '/tmp/mydata/vendor',
|
137
|
-
git: 'git@example.com:puppet/test_module.git',
|
138
|
-
}
|
106
|
+
loaded_content = subject.load
|
107
|
+
expect(loaded_content).to be_an_instance_of(Hash)
|
139
108
|
|
140
|
-
|
109
|
+
has_some_data = loaded_content.values.none?(&:empty?)
|
110
|
+
expect(has_some_data).to be true
|
111
|
+
end
|
141
112
|
|
142
|
-
|
143
|
-
|
113
|
+
it "is idempotent" do
|
114
|
+
path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'valid-forge-with-version')
|
115
|
+
subject = described_class.new(path, {})
|
144
116
|
|
145
|
-
|
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)
|
117
|
+
expect(subject.loader).to receive(:load!).and_call_original.once
|
151
118
|
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
end
|
119
|
+
loaded_content1 = subject.load
|
120
|
+
expect(subject.loaded?).to be true
|
121
|
+
loaded_content2 = subject.load
|
156
122
|
|
157
|
-
|
158
|
-
|
123
|
+
expect(loaded_content2).to eq(loaded_content1)
|
124
|
+
end
|
159
125
|
|
160
|
-
|
161
|
-
|
126
|
+
it "returns nil if Puppetfile doesn't exist" do
|
127
|
+
path = '/rando/path/that/wont/exist'
|
128
|
+
subject = described_class.new(path, {})
|
129
|
+
expect(subject.load).to eq nil
|
130
|
+
end
|
162
131
|
end
|
163
132
|
|
164
|
-
|
165
|
-
|
166
|
-
|
133
|
+
context 'using load!' do
|
134
|
+
it "returns the loaded content" do
|
135
|
+
path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'valid-forge-with-version')
|
136
|
+
subject = described_class.new(path, {})
|
167
137
|
|
168
|
-
|
169
|
-
|
138
|
+
loaded_content = subject.load!
|
139
|
+
expect(loaded_content).to be_an_instance_of(Hash)
|
170
140
|
|
171
|
-
|
172
|
-
|
173
|
-
allow(subject).to receive(:environment).and_return(mock_env)
|
141
|
+
has_some_data = loaded_content.values.none?(&:empty?)
|
142
|
+
expect(has_some_data).to be true
|
174
143
|
end
|
175
144
|
|
176
|
-
it "
|
177
|
-
|
145
|
+
it "raises if Puppetfile doesn't exist" do
|
146
|
+
path = '/rando/path/that/wont/exist'
|
147
|
+
subject = described_class.new(path, {})
|
148
|
+
expect {
|
149
|
+
subject.load!
|
150
|
+
}.to raise_error(/No such file or directory.*\/rando\/path\/.*/)
|
178
151
|
end
|
179
152
|
end
|
180
153
|
end
|
181
154
|
|
182
|
-
describe '
|
183
|
-
it '
|
184
|
-
|
155
|
+
describe 'default_branch_override' do
|
156
|
+
it 'is passed correctly to module loader init' do
|
157
|
+
# This path doesn't matter so long as it has a Puppetfile within it
|
158
|
+
path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'valid-forge-with-version')
|
159
|
+
subject = described_class.new(path, {overrides: {environments: {default_branch_override: 'foo'}}})
|
185
160
|
|
186
|
-
|
187
|
-
|
188
|
-
|
161
|
+
repo = instance_double('R10K::Git::StatefulRepository')
|
162
|
+
allow(repo).to receive(:resolve).with('foo').and_return(true)
|
163
|
+
allow(R10K::Git::StatefulRepository).to receive(:new).and_return(repo)
|
189
164
|
|
190
|
-
|
191
|
-
|
192
|
-
|
165
|
+
allow(subject.loader).to receive(:puppetfile_content).and_return <<-EOPF
|
166
|
+
# Track control branch and fall-back to main if no matching branch.
|
167
|
+
mod 'hieradata',
|
168
|
+
:git => 'git@git.example.com:organization/hieradata.git',
|
169
|
+
:branch => :control_branch,
|
170
|
+
:default_branch => 'main'
|
171
|
+
EOPF
|
193
172
|
|
194
|
-
|
173
|
+
expect(subject.logger).not_to receive(:warn).
|
174
|
+
with(/Mismatch between passed and initialized.*preferring passed value/)
|
195
175
|
|
196
|
-
|
197
|
-
expect(subject.managed_directories).to be_empty
|
198
|
-
end
|
199
|
-
end
|
200
|
-
end
|
176
|
+
subject.load
|
201
177
|
|
202
|
-
|
203
|
-
|
204
|
-
expect(orig).to be_a_kind_of(R10K::Error)
|
205
|
-
expect(orig.message).to eq("Failed to evaluate #{pf_path}")
|
206
|
-
expect(orig.original).to be_a_kind_of(wrapped_error)
|
178
|
+
loaded_module = subject.modules.first
|
179
|
+
expect(loaded_module.version).to eq('foo')
|
207
180
|
end
|
208
181
|
|
209
|
-
it
|
210
|
-
|
211
|
-
|
212
|
-
subject = described_class.new(path, {})
|
213
|
-
expect {
|
214
|
-
subject.load!
|
215
|
-
}.to raise_error do |e|
|
216
|
-
expect_wrapped_error(e, pf_path, SyntaxError)
|
217
|
-
end
|
218
|
-
end
|
182
|
+
it 'overrides module loader init if needed' do
|
183
|
+
# This path doesn't matter so long as it has a Puppetfile within it
|
184
|
+
path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'valid-forge-with-version')
|
185
|
+
subject = described_class.new(path, {overrides: {environments: {default_branch_override: 'foo'}}})
|
219
186
|
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
subject = described_class.new(path, {})
|
224
|
-
expect {
|
225
|
-
subject.load!
|
226
|
-
}.to raise_error do |e|
|
227
|
-
expect_wrapped_error(e, pf_path, LoadError)
|
228
|
-
end
|
229
|
-
end
|
187
|
+
repo = instance_double('R10K::Git::StatefulRepository')
|
188
|
+
allow(repo).to receive(:resolve).with('bar').and_return(true)
|
189
|
+
allow(R10K::Git::StatefulRepository).to receive(:new).and_return(repo)
|
230
190
|
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
expect_wrapped_error(e, pf_path, ArgumentError)
|
239
|
-
end
|
240
|
-
end
|
191
|
+
allow(subject.loader).to receive(:puppetfile_content).and_return <<-EOPF
|
192
|
+
# Track control branch and fall-back to main if no matching branch.
|
193
|
+
mod 'hieradata',
|
194
|
+
:git => 'git@git.example.com:organization/hieradata.git',
|
195
|
+
:branch => :control_branch,
|
196
|
+
:default_branch => 'main'
|
197
|
+
EOPF
|
241
198
|
|
242
|
-
|
243
|
-
|
244
|
-
pf_path = File.join(path, 'Puppetfile')
|
245
|
-
subject = described_class.new(path, {})
|
246
|
-
expect {
|
247
|
-
subject.load!
|
248
|
-
}.to raise_error(R10K::Error, /Puppetfiles cannot contain duplicate module names/i)
|
249
|
-
end
|
199
|
+
expect(subject.logger).to receive(:warn).
|
200
|
+
with(/Mismatch between passed and initialized.*preferring passed value/)
|
250
201
|
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
subject = described_class.new(path, {})
|
255
|
-
expect {
|
256
|
-
subject.load!
|
257
|
-
}.to raise_error do |e|
|
258
|
-
expect_wrapped_error(e, pf_path, NameError)
|
259
|
-
end
|
202
|
+
subject.load('bar')
|
203
|
+
loaded_module = subject.modules.first
|
204
|
+
expect(loaded_module.version).to eq('bar')
|
260
205
|
end
|
261
206
|
|
262
|
-
it
|
207
|
+
it 'does not warn if passed and initialized default_branch_overrides match' do
|
208
|
+
# This path doesn't matter so long as it has a Puppetfile within it
|
263
209
|
path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'valid-forge-with-version')
|
264
|
-
|
265
|
-
subject = described_class.new(path, {})
|
266
|
-
expect { subject.load! }.not_to raise_error
|
267
|
-
end
|
210
|
+
subject = described_class.new(path, {overrides: {environments: {default_branch_override: 'foo'}}})
|
268
211
|
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
subject = described_class.new(path, {})
|
273
|
-
expect { subject.load! }.not_to raise_error
|
274
|
-
end
|
212
|
+
repo = instance_double('R10K::Git::StatefulRepository')
|
213
|
+
allow(repo).to receive(:resolve).with('foo').and_return(true)
|
214
|
+
allow(R10K::Git::StatefulRepository).to receive(:new).and_return(repo)
|
275
215
|
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
216
|
+
allow(subject.loader).to receive(:puppetfile_content).and_return <<-EOPF
|
217
|
+
# Track control branch and fall-back to main if no matching branch.
|
218
|
+
mod 'hieradata',
|
219
|
+
:git => 'git@git.example.com:organization/hieradata.git',
|
220
|
+
:branch => :control_branch,
|
221
|
+
:default_branch => 'main'
|
222
|
+
EOPF
|
223
|
+
|
224
|
+
expect(subject.logger).not_to receive(:warn).
|
225
|
+
with(/Mismatch between passed and initialized.*preferring passed value/)
|
284
226
|
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
subject = described_class.new(path, {})
|
289
|
-
default_branch_override = 'default_branch_override_name'
|
290
|
-
expect { subject.load!(default_branch_override) }.not_to raise_error
|
291
|
-
git_module = subject.modules[0]
|
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"
|
227
|
+
subject.load('foo')
|
228
|
+
loaded_module = subject.modules.first
|
229
|
+
expect(loaded_module.version).to eq('foo')
|
294
230
|
end
|
295
231
|
end
|
296
232
|
|
@@ -337,7 +273,7 @@ describe R10K::Puppetfile do
|
|
337
273
|
expect(subject).to receive(:modules).and_return([mod1, mod2])
|
338
274
|
|
339
275
|
expect(Thread).to receive(:new).exactly(pool_size).and_call_original
|
340
|
-
expect(Queue).to receive(:new).and_call_original
|
276
|
+
expect(Queue).to receive(:new).and_call_original.twice
|
341
277
|
|
342
278
|
subject.accept(visitor)
|
343
279
|
end
|
data/spec/unit/settings_spec.rb
CHANGED
@@ -90,11 +90,50 @@ describe R10K::Settings do
|
|
90
90
|
end
|
91
91
|
end
|
92
92
|
end
|
93
|
+
|
94
|
+
describe "allow_puppetfile_override" do
|
95
|
+
it 'is false by default' do
|
96
|
+
expect(subject.evaluate({})[:allow_puppetfile_override]).to eq(false)
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'can be set to true' do
|
100
|
+
expect(subject.evaluate({"allow_puppetfile_override" => true})[:allow_puppetfile_override]).to eq(true)
|
101
|
+
end
|
102
|
+
|
103
|
+
it "raises an error for non-boolean values" do
|
104
|
+
expect {
|
105
|
+
subject.evaluate({"allow_puppetfile_override" => 'invalid_string'})
|
106
|
+
}.to raise_error do |err|
|
107
|
+
expect(err.message).to match(/Validation failed for 'forge' settings group/)
|
108
|
+
expect(err.errors.size).to eq 1
|
109
|
+
expect(err.errors[:allow_puppetfile_override]).to be_a_kind_of(ArgumentError)
|
110
|
+
expect(err.errors[:allow_puppetfile_override].message).to match(/`allow_puppetfile_override` can only be a boolean value, not 'invalid_string'/)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
93
114
|
end
|
94
115
|
|
95
116
|
describe "deploy settings" do
|
96
117
|
subject { described_class.deploy_settings }
|
97
118
|
|
119
|
+
describe 'exclude_spec' do
|
120
|
+
it 'is false by default' do
|
121
|
+
expect(subject.evaluate({})[:exclude_spec]).to eq(false)
|
122
|
+
end
|
123
|
+
it 'can be set to true' do
|
124
|
+
expect(subject.evaluate({"exclude_spec" => true})[:exclude_spec]).to eq(true)
|
125
|
+
end
|
126
|
+
it "raises an error for non-boolean values" do
|
127
|
+
expect {
|
128
|
+
subject.evaluate({"exclude_spec" => 'invalid_string'})
|
129
|
+
}.to raise_error do |err|
|
130
|
+
expect(err.message).to match(/Validation failed for 'deploy' settings group/)
|
131
|
+
expect(err.errors.size).to eq 1
|
132
|
+
expect(err.errors[:exclude_spec]).to be_a_kind_of(ArgumentError)
|
133
|
+
expect(err.errors[:exclude_spec].message).to match(/`exclude_spec` can only be a boolean value, not 'invalid_string'/)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
98
137
|
describe "write_lock" do
|
99
138
|
it "accepts a string with a reason for the write lock" do
|
100
139
|
output = subject.evaluate("write_lock" => "No maintenance window active, code freeze till 2038-01-19")
|
@@ -250,8 +289,14 @@ describe R10K::Settings do
|
|
250
289
|
|
251
290
|
describe "forge settings" do
|
252
291
|
it "passes settings through to the forge settings" do
|
253
|
-
output = subject.evaluate("forge" => {"baseurl" => "https://forge.tessier-ashpool.freeside",
|
254
|
-
|
292
|
+
output = subject.evaluate("forge" => {"baseurl" => "https://forge.tessier-ashpool.freeside",
|
293
|
+
"proxy" => "https://proxy.tessier-ashpool.freesize:3128",
|
294
|
+
"authorization_token" => "faketoken",
|
295
|
+
"allow_puppetfile_override" => true})
|
296
|
+
expect(output[:forge]).to eq(:baseurl => "https://forge.tessier-ashpool.freeside",
|
297
|
+
:proxy => "https://proxy.tessier-ashpool.freesize:3128",
|
298
|
+
:authorization_token => "faketoken",
|
299
|
+
:allow_puppetfile_override => true)
|
255
300
|
end
|
256
301
|
end
|
257
302
|
end
|
@@ -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)).
|
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)).
|
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
|
-
|
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
|
-
|
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)
|
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(
|
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.
|
4
|
+
version: 3.12.1
|
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-
|
11
|
+
date: 2021-09-17 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
|
@@ -576,7 +602,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
576
602
|
- !ruby/object:Gem::Version
|
577
603
|
version: '0'
|
578
604
|
requirements: []
|
579
|
-
rubygems_version: 3.0.
|
605
|
+
rubygems_version: 3.0.3
|
580
606
|
signing_key:
|
581
607
|
specification_version: 4
|
582
608
|
summary: Puppet environment and module deployment
|