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
@@ -3,9 +3,10 @@ require 'r10k/action/puppetfile/install'
|
|
3
3
|
|
4
4
|
describe R10K::Action::Puppetfile::Install do
|
5
5
|
let(:default_opts) { { root: "/some/nonexistent/path" } }
|
6
|
-
let(:
|
7
|
-
R10K::Puppetfile.new(
|
8
|
-
|
6
|
+
let(:loader) {
|
7
|
+
R10K::ModuleLoader::Puppetfile.new({
|
8
|
+
basedir: '/some/nonexistent/path',
|
9
|
+
overrides: {force: false}})
|
9
10
|
}
|
10
11
|
|
11
12
|
def installer(opts = {}, argv = [], settings = {})
|
@@ -14,11 +15,11 @@ describe R10K::Action::Puppetfile::Install do
|
|
14
15
|
end
|
15
16
|
|
16
17
|
before(:each) do
|
17
|
-
allow(
|
18
|
-
allow(R10K::Puppetfile).to receive(:new).
|
19
|
-
with("/some/nonexistent/path",
|
20
|
-
|
21
|
-
and_return(
|
18
|
+
allow(loader).to receive(:load!).and_return({})
|
19
|
+
allow(R10K::ModuleLoader::Puppetfile).to receive(:new).
|
20
|
+
with({basedir: "/some/nonexistent/path",
|
21
|
+
overrides: {force: false}}).
|
22
|
+
and_return(loader)
|
22
23
|
end
|
23
24
|
|
24
25
|
it_behaves_like "a puppetfile install action"
|
@@ -26,13 +27,19 @@ describe R10K::Action::Puppetfile::Install do
|
|
26
27
|
describe "installing modules" do
|
27
28
|
let(:modules) do
|
28
29
|
(1..4).map do |idx|
|
29
|
-
R10K::Module::Base.new("author/modname#{idx}",
|
30
|
+
R10K::Module::Base.new("author/modname#{idx}",
|
31
|
+
"/some/nonexistent/path/modname#{idx}",
|
32
|
+
{})
|
30
33
|
end
|
31
34
|
end
|
32
35
|
|
33
36
|
before do
|
34
|
-
allow(
|
35
|
-
|
37
|
+
allow(loader).to receive(:load!).and_return({
|
38
|
+
modules: modules,
|
39
|
+
managed_directories: [],
|
40
|
+
desired_contents: [],
|
41
|
+
purge_exclusions: []
|
42
|
+
})
|
36
43
|
end
|
37
44
|
|
38
45
|
it "syncs each module in the Puppetfile" do
|
@@ -50,15 +57,15 @@ describe R10K::Action::Puppetfile::Install do
|
|
50
57
|
end
|
51
58
|
|
52
59
|
describe "purging" do
|
53
|
-
before do
|
54
|
-
allow(puppetfile).to receive(:modules).and_return([])
|
55
|
-
end
|
56
|
-
|
57
60
|
it "purges the moduledir after installation" do
|
61
|
+
allow(loader).to receive(:load!).and_return({
|
62
|
+
modules: [],
|
63
|
+
desired_contents: [ 'root/foo' ],
|
64
|
+
managed_directories: [ 'root' ],
|
65
|
+
purge_exclusions: [ 'root/**/**.rb' ]
|
66
|
+
})
|
67
|
+
|
58
68
|
mock_cleaner = double("cleaner")
|
59
|
-
allow(puppetfile).to receive(:desired_contents).and_return(["root/foo"])
|
60
|
-
allow(puppetfile).to receive(:managed_directories).and_return(["root"])
|
61
|
-
allow(puppetfile).to receive(:purge_exclusions).and_return(["root/**/**.rb"])
|
62
69
|
|
63
70
|
expect(R10K::Util::Cleaner).to receive(:new).
|
64
71
|
with(["root"], ["root/foo"], ["root/**/**.rb"]).
|
@@ -70,35 +77,34 @@ describe R10K::Action::Puppetfile::Install do
|
|
70
77
|
end
|
71
78
|
|
72
79
|
describe "using custom paths" do
|
73
|
-
it "can use a custom
|
74
|
-
expect(R10K::Puppetfile).to receive(:new).
|
75
|
-
with("/some/nonexistent/path",
|
76
|
-
|
77
|
-
|
80
|
+
it "can use a custom moduledir path" do
|
81
|
+
expect(R10K::ModuleLoader::Puppetfile).to receive(:new).
|
82
|
+
with({basedir: "/some/nonexistent/path",
|
83
|
+
overrides: { force: false },
|
84
|
+
puppetfile: "/some/other/path/Puppetfile"}).
|
85
|
+
and_return(loader)
|
78
86
|
|
79
87
|
installer({puppetfile: "/some/other/path/Puppetfile"}).call
|
80
|
-
end
|
81
88
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
and_return(
|
89
|
+
expect(R10K::ModuleLoader::Puppetfile).to receive(:new).
|
90
|
+
with({basedir: "/some/nonexistent/path",
|
91
|
+
overrides: { force: false },
|
92
|
+
moduledir: "/some/other/path/site-modules"}).
|
93
|
+
and_return(loader)
|
87
94
|
|
88
95
|
installer({moduledir: "/some/other/path/site-modules"}).call
|
89
96
|
end
|
90
97
|
end
|
91
98
|
|
92
99
|
describe "forcing to overwrite local changes" do
|
93
|
-
before do
|
94
|
-
allow(puppetfile).to receive(:modules).and_return([])
|
95
|
-
end
|
96
|
-
|
97
100
|
it "can use the force overwrite option" do
|
101
|
+
allow(loader).to receive(:load!).and_return({ modules: [] })
|
102
|
+
|
98
103
|
subject = described_class.new({root: "/some/nonexistent/path", force: true}, [], {})
|
99
|
-
expect(R10K::Puppetfile).to receive(:new).
|
100
|
-
with("/some/nonexistent/path",
|
101
|
-
|
104
|
+
expect(R10K::ModuleLoader::Puppetfile).to receive(:new).
|
105
|
+
with({basedir: "/some/nonexistent/path",
|
106
|
+
overrides: { force: true }}).
|
107
|
+
and_return(loader)
|
102
108
|
subject.call
|
103
109
|
end
|
104
110
|
|
@@ -4,11 +4,13 @@ require 'r10k/action/puppetfile/purge'
|
|
4
4
|
describe R10K::Action::Puppetfile::Purge do
|
5
5
|
let(:default_opts) { {root: "/some/nonexistent/path"} }
|
6
6
|
let(:puppetfile) do
|
7
|
-
instance_double('R10K::Puppetfile',
|
8
|
-
:load!
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
instance_double('R10K::ModuleLoader::Puppetfile',
|
8
|
+
:load! => {
|
9
|
+
:modules => %w{mod},
|
10
|
+
:managed_directories => %w{foo},
|
11
|
+
:desired_contents => %w{bar},
|
12
|
+
:purge_exclusions => %w{baz}
|
13
|
+
})
|
12
14
|
end
|
13
15
|
|
14
16
|
def purger(opts = {}, argv = [], settings = {})
|
@@ -17,8 +19,8 @@ describe R10K::Action::Puppetfile::Purge do
|
|
17
19
|
end
|
18
20
|
|
19
21
|
before(:each) do
|
20
|
-
allow(R10K::Puppetfile).to receive(:new).
|
21
|
-
with("/some/nonexistent/path"
|
22
|
+
allow(R10K::ModuleLoader::Puppetfile).to receive(:new).
|
23
|
+
with({basedir: "/some/nonexistent/path"}).
|
22
24
|
and_return(puppetfile)
|
23
25
|
end
|
24
26
|
|
@@ -37,23 +39,19 @@ describe R10K::Action::Puppetfile::Purge do
|
|
37
39
|
end
|
38
40
|
|
39
41
|
describe "using custom paths" do
|
40
|
-
before(:each) do
|
41
|
-
allow(puppetfile).to receive(:purge!)
|
42
|
-
end
|
43
|
-
|
44
42
|
it "can use a custom puppetfile path" do
|
45
|
-
expect(R10K::Puppetfile).to receive(:new).
|
46
|
-
with("/some/nonexistent/path",
|
47
|
-
|
43
|
+
expect(R10K::ModuleLoader::Puppetfile).to receive(:new).
|
44
|
+
with({basedir: "/some/nonexistent/path",
|
45
|
+
puppetfile: "/some/other/path/Puppetfile"}).
|
48
46
|
and_return(puppetfile)
|
49
47
|
|
50
48
|
purger({puppetfile: "/some/other/path/Puppetfile"}).call
|
51
49
|
end
|
52
50
|
|
53
51
|
it "can use a custom moduledir path" do
|
54
|
-
expect(R10K::Puppetfile).to receive(:new).
|
55
|
-
with("/some/nonexistent/path",
|
56
|
-
|
52
|
+
expect(R10K::ModuleLoader::Puppetfile).to receive(:new).
|
53
|
+
with({basedir: "/some/nonexistent/path",
|
54
|
+
moduledir: "/some/other/path/site-modules"}).
|
57
55
|
and_return(puppetfile)
|
58
56
|
|
59
57
|
purger({moduledir: "/some/other/path/site-modules"}).call
|
@@ -171,6 +171,86 @@ describe R10K::Action::Runner do
|
|
171
171
|
end
|
172
172
|
end
|
173
173
|
|
174
|
+
describe "configuring github app credentials" do
|
175
|
+
it 'errors if app id is passed without ssl key' do
|
176
|
+
runner = described_class.new(
|
177
|
+
{ 'github-app-id': '/nonexistent', },
|
178
|
+
%w[args yes],
|
179
|
+
action_class
|
180
|
+
)
|
181
|
+
expect{ runner.call }.to raise_error(R10K::Error, /Must specify both id and SSL private key/)
|
182
|
+
end
|
183
|
+
|
184
|
+
it 'errors if ssl key is passed without app id' do
|
185
|
+
runner = described_class.new(
|
186
|
+
{ 'github-app-key': '/nonexistent', },
|
187
|
+
%w[args yes],
|
188
|
+
action_class
|
189
|
+
)
|
190
|
+
expect{ runner.call }.to raise_error(R10K::Error, /Must specify both id and SSL private key/)
|
191
|
+
end
|
192
|
+
|
193
|
+
it 'errors if both app id and token paths are passed' do
|
194
|
+
runner = described_class.new(
|
195
|
+
{ 'github-app-id': '/nonexistent', 'oauth-token': '/also/fake' },
|
196
|
+
%w[args yes],
|
197
|
+
action_class
|
198
|
+
)
|
199
|
+
expect{ runner.call }.to raise_error(R10K::Error, /Cannot specify both/)
|
200
|
+
end
|
201
|
+
|
202
|
+
it 'errors if both ssl key and token paths are passed' do
|
203
|
+
runner = described_class.new(
|
204
|
+
{ 'github-app-key': '/nonexistent', 'oauth-token': '/also/fake' },
|
205
|
+
%w[args yes],
|
206
|
+
action_class
|
207
|
+
)
|
208
|
+
expect{ runner.call }.to raise_error(R10K::Error, /Cannot specify both/)
|
209
|
+
end
|
210
|
+
|
211
|
+
it 'errors if both ssl key and ssh key paths are passed' do
|
212
|
+
runner = described_class.new(
|
213
|
+
{ 'github-app-key': '/nonexistent', 'private-key': '/also/fake' },
|
214
|
+
%w[args yes],
|
215
|
+
action_class
|
216
|
+
)
|
217
|
+
expect{ runner.call }.to raise_error(R10K::Error, /Cannot specify both/)
|
218
|
+
end
|
219
|
+
|
220
|
+
it 'errors if both app id and ssh key are passed' do
|
221
|
+
runner = described_class.new(
|
222
|
+
{ 'github-app-id': '/nonexistent', 'private-key': '/also/fake' },
|
223
|
+
%w[args yes],
|
224
|
+
action_class
|
225
|
+
)
|
226
|
+
expect{ runner.call }.to raise_error(R10K::Error, /Cannot specify both/)
|
227
|
+
end
|
228
|
+
|
229
|
+
it 'saves the parameters in settings hash' do
|
230
|
+
runner = described_class.new(
|
231
|
+
{ 'github-app-id': '123456', 'github-app-key': '/my/ssl/key', 'github-app-ttl': '600' },
|
232
|
+
%w[args yes],
|
233
|
+
action_class
|
234
|
+
)
|
235
|
+
runner.call
|
236
|
+
expect(runner.instance.settings[:git][:github_app_id]).to eq('123456')
|
237
|
+
expect(runner.instance.settings[:git][:github_app_key]).to eq('/my/ssl/key')
|
238
|
+
expect(runner.instance.settings[:git][:github_app_ttl]).to eq('600')
|
239
|
+
end
|
240
|
+
|
241
|
+
it 'saves the parameters in settings hash without ttl and uses its default value' do
|
242
|
+
runner = described_class.new(
|
243
|
+
{ 'github-app-id': '123456', 'github-app-key': '/my/ssl/key', },
|
244
|
+
%w[args yes],
|
245
|
+
action_class
|
246
|
+
)
|
247
|
+
runner.call
|
248
|
+
expect(runner.instance.settings[:git][:github_app_id]).to eq('123456')
|
249
|
+
expect(runner.instance.settings[:git][:github_app_key]).to eq('/my/ssl/key')
|
250
|
+
expect(runner.instance.settings[:git][:github_app_ttl]).to eq('120')
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
174
254
|
describe "configuring git credentials" do
|
175
255
|
it 'errors if both token and key paths are passed' do
|
176
256
|
runner = described_class.new({ 'oauth-token': '/nonexistent',
|
@@ -218,42 +298,58 @@ describe R10K::Action::Runner do
|
|
218
298
|
end
|
219
299
|
|
220
300
|
describe "configuration authorization" do
|
221
|
-
context "
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
expect(PuppetForge::Connection).
|
301
|
+
context "settings auth" do
|
302
|
+
it "sets the configured token as the forge authorization header" do
|
303
|
+
options = { config: "spec/fixtures/unit/action/r10k_forge_auth.yaml" }
|
304
|
+
runner = described_class.new(options, %w[args yes], action_class)
|
305
|
+
|
306
|
+
expect(PuppetForge).to receive(:host=).with('http://private-forge.com')
|
307
|
+
expect(PuppetForge::Connection).to receive(:authorization=).with('faketoken')
|
308
|
+
expect(PuppetForge::Connection).to receive(:authorization).and_return('faketoken')
|
309
|
+
expect(R10K::Util::License).not_to receive(:load)
|
310
|
+
runner.setup_settings
|
228
311
|
runner.setup_authorization
|
229
312
|
end
|
230
313
|
end
|
231
314
|
|
232
|
-
context "
|
233
|
-
|
234
|
-
|
235
|
-
|
315
|
+
context "license auth" do
|
316
|
+
context "when license is not present" do
|
317
|
+
before(:each) do
|
318
|
+
expect(R10K::Util::License).to receive(:load).and_return(nil)
|
319
|
+
end
|
236
320
|
|
237
|
-
|
238
|
-
|
239
|
-
|
321
|
+
it "does not set authorization header on connection class" do
|
322
|
+
expect(PuppetForge::Connection).not_to receive(:authorization=)
|
323
|
+
runner.setup_authorization
|
324
|
+
end
|
240
325
|
end
|
241
326
|
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
327
|
+
context "when license is present but invalid" do
|
328
|
+
before(:each) do
|
329
|
+
expect(R10K::Util::License).to receive(:load).and_raise(R10K::Error.new('invalid license'))
|
330
|
+
end
|
331
|
+
|
332
|
+
it "issues warning to logger" do
|
333
|
+
expect(runner.logger).to receive(:warn).with(/invalid license/)
|
334
|
+
runner.setup_authorization
|
335
|
+
end
|
247
336
|
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
337
|
+
it "does not set authorization header on connection class" do
|
338
|
+
expect(PuppetForge::Connection).not_to receive(:authorization=)
|
339
|
+
runner.setup_authorization
|
340
|
+
end
|
252
341
|
end
|
253
342
|
|
254
|
-
|
255
|
-
|
256
|
-
|
343
|
+
context "when license is present and valid" do
|
344
|
+
before(:each) do
|
345
|
+
mock_license = double('pe-license', :authorization_token => 'test token')
|
346
|
+
expect(R10K::Util::License).to receive(:load).and_return(mock_license)
|
347
|
+
end
|
348
|
+
|
349
|
+
it "sets authorization header on connection class" do
|
350
|
+
expect(PuppetForge::Connection).to receive(:authorization=).with('test token')
|
351
|
+
runner.setup_authorization
|
352
|
+
end
|
257
353
|
end
|
258
354
|
end
|
259
355
|
end
|
@@ -3,10 +3,13 @@ require 'r10k/environment'
|
|
3
3
|
|
4
4
|
describe R10K::Environment::Base do
|
5
5
|
|
6
|
-
|
6
|
+
let(:basepath) { '/some/imaginary/path' }
|
7
|
+
let(:envname) { 'env_name' }
|
8
|
+
let(:path) { File.join(basepath, envname) }
|
9
|
+
subject(:environment) { described_class.new('envname', basepath, envname, {}) }
|
7
10
|
|
8
11
|
it "can return the fully qualified path" do
|
9
|
-
expect(environment.path).to eq(Pathname.new(
|
12
|
+
expect(environment.path).to eq(Pathname.new(path))
|
10
13
|
end
|
11
14
|
|
12
15
|
it "raises an exception when #sync is called" do
|
@@ -49,45 +52,55 @@ describe R10K::Environment::Base do
|
|
49
52
|
describe "#purge_exclusions" do
|
50
53
|
let(:mock_env) { instance_double("R10K::Environment::Base") }
|
51
54
|
let(:mock_puppetfile) { instance_double("R10K::Puppetfile", :environment= => true, :environment => mock_env) }
|
55
|
+
let(:loader) do
|
56
|
+
instance_double("R10K::ModuleLoader::Puppetfile",
|
57
|
+
:environment= => nil,
|
58
|
+
:load => { :modules => @modules,
|
59
|
+
:managed_directories => @managed_dirs,
|
60
|
+
:desired_contents => @desired_contents,
|
61
|
+
:purge_exclusions => @purge_ex })
|
62
|
+
end
|
52
63
|
|
53
64
|
before(:each) do
|
54
|
-
|
55
|
-
|
56
|
-
|
65
|
+
@modules = []
|
66
|
+
@managed_dirs = []
|
67
|
+
@desired_contents = []
|
68
|
+
@purge_exclusions = []
|
57
69
|
end
|
58
70
|
|
59
71
|
it "excludes .r10k-deploy.json" do
|
72
|
+
allow(R10K::ModuleLoader::Puppetfile).to receive(:new).and_return(loader)
|
73
|
+
subject.deploy
|
74
|
+
|
60
75
|
expect(subject.purge_exclusions).to include(/r10k-deploy\.json/)
|
61
76
|
end
|
62
77
|
|
63
78
|
it "excludes puppetfile managed directories" do
|
64
|
-
managed_dirs = [
|
79
|
+
@managed_dirs = [
|
65
80
|
'/some/imaginary/path/env_name/modules',
|
66
81
|
'/some/imaginary/path/env_name/data',
|
67
82
|
]
|
68
83
|
|
69
|
-
|
84
|
+
allow(R10K::ModuleLoader::Puppetfile).to receive(:new).and_return(loader)
|
85
|
+
subject.deploy
|
70
86
|
|
71
87
|
exclusions = subject.purge_exclusions
|
72
88
|
|
73
|
-
managed_dirs.each do |dir|
|
89
|
+
@managed_dirs.each do |dir|
|
74
90
|
expect(exclusions).to include(dir)
|
75
91
|
end
|
76
92
|
end
|
77
93
|
|
78
94
|
describe "puppetfile desired contents" do
|
79
|
-
let(:desired_contents) do
|
80
|
-
basedir = subject.path.to_s
|
81
|
-
|
82
|
-
[ 'modules/apache', 'data/local/site' ].collect do |c|
|
83
|
-
File.join(basedir, c)
|
84
|
-
end
|
85
|
-
end
|
86
95
|
|
87
96
|
before(:each) do
|
88
|
-
|
97
|
+
@desired_contents = [ 'modules/apache', 'data/local/site' ].collect do |c|
|
98
|
+
File.join(path, c)
|
99
|
+
end
|
89
100
|
|
90
|
-
|
101
|
+
allow(File).to receive(:directory?).and_return true
|
102
|
+
allow(R10K::ModuleLoader::Puppetfile).to receive(:new).and_return(loader)
|
103
|
+
subject.deploy
|
91
104
|
end
|
92
105
|
|
93
106
|
it "excludes desired directory contents with glob" do
|
@@ -78,9 +78,9 @@ describe R10K::Environment::Git do
|
|
78
78
|
|
79
79
|
describe "enumerating modules" do
|
80
80
|
it "loads the Puppetfile and returns modules in that puppetfile" do
|
81
|
+
loaded = { desired_contents: [], managed_directories: [], purge_exclusions: [] }
|
81
82
|
mod = double('A module', :name => 'dbl')
|
82
|
-
expect(subject.
|
83
|
-
expect(subject.puppetfile).to receive(:modules).and_return [mod]
|
83
|
+
expect(subject.loader).to receive(:load).and_return(loaded.merge(modules: [mod]))
|
84
84
|
expect(subject.modules).to eq([mod])
|
85
85
|
end
|
86
86
|
end
|
@@ -78,9 +78,10 @@ describe R10K::Environment::SVN do
|
|
78
78
|
|
79
79
|
describe "enumerating modules" do
|
80
80
|
it "loads the Puppetfile and returns modules in that puppetfile" do
|
81
|
-
|
82
|
-
|
83
|
-
expect(subject.
|
81
|
+
loaded = { managed_directories: [], desired_contents: [], purge_exclusions: [] }
|
82
|
+
mod = double('A module', :name => 'dbl')
|
83
|
+
expect(subject.loader).to receive(:load).and_return(loaded.merge(modules: [mod]))
|
84
|
+
expect(subject.modules).to eq([mod])
|
84
85
|
end
|
85
86
|
end
|
86
87
|
|
@@ -65,8 +65,9 @@ describe R10K::Environment::WithModules do
|
|
65
65
|
|
66
66
|
describe "modules method" do
|
67
67
|
it "returns the configured modules, and Puppetfile modules" do
|
68
|
+
loaded = { managed_directories: [], desired_contents: [], purge_exclusions: [] }
|
68
69
|
puppetfile_mod = instance_double('R10K::Module::Base', name: 'zebra')
|
69
|
-
expect(subject.
|
70
|
+
expect(subject.loader).to receive(:load).and_return(loaded.merge(modules: [puppetfile_mod]))
|
70
71
|
returned_modules = subject.modules
|
71
72
|
expect(returned_modules.map(&:name).sort).to eq(%w[concat exec stdlib zebra])
|
72
73
|
end
|
data/spec/unit/git/cache_spec.rb
CHANGED
@@ -62,4 +62,18 @@ describe R10K::Git::Cache do
|
|
62
62
|
subject.cached?
|
63
63
|
end
|
64
64
|
end
|
65
|
+
|
66
|
+
describe "dirname sanitization" do
|
67
|
+
it 'sanitizes cache directory name' do
|
68
|
+
expect(subject.sanitized_dirname).to eq('git---some-git-remote')
|
69
|
+
end
|
70
|
+
|
71
|
+
context 'with username and password' do
|
72
|
+
subject { subclass.new('https://"user:pa$$w0rd:@some/git/remote') }
|
73
|
+
|
74
|
+
it 'sanitizes cache directory name' do
|
75
|
+
expect(subject.sanitized_dirname).to eq('https---some-git-remote')
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
65
79
|
end
|
@@ -79,6 +79,35 @@ describe R10K::Git::Rugged::Credentials, :unless => R10K::Util::Platform.jruby?
|
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
|
+
describe "generating github app tokens" do
|
83
|
+
it 'errors if app id has invalid characters' do
|
84
|
+
expect { subject.github_app_token("123A567890", "fake", "300")
|
85
|
+
}.to raise_error(R10K::Git::GitError, /App id contains invalid characters/)
|
86
|
+
end
|
87
|
+
it 'errors if app ttl has invalid characters' do
|
88
|
+
expect { subject.github_app_token("123456", "fake", "abc")
|
89
|
+
}.to raise_error(R10K::Git::GitError, /Github App token ttl contains/)
|
90
|
+
end
|
91
|
+
it 'errors if private file does not exist' do
|
92
|
+
R10K::Git.settings[:github_app_key] = "/missing/token/file"
|
93
|
+
expect(File).to receive(:readable?).with(R10K::Git.settings[:github_app_key]).and_return false
|
94
|
+
expect {
|
95
|
+
subject.github_app_token("123456", R10K::Git.settings[:github_app_key], "300")
|
96
|
+
}.to raise_error(R10K::Git::GitError, /App key is missing or unreadable/)
|
97
|
+
end
|
98
|
+
it 'errors if file is not a valid SSL key' do
|
99
|
+
token_file = Tempfile.new('token')
|
100
|
+
token_file.write('my_token')
|
101
|
+
token_file.close
|
102
|
+
R10K::Git.settings[:github_app_key] = token_file.path
|
103
|
+
expect(File).to receive(:readable?).with(token_file.path).and_return true
|
104
|
+
expect {
|
105
|
+
subject.github_app_token("123456", R10K::Git.settings[:github_app_key], "300")
|
106
|
+
}.to raise_error(R10K::Git::GitError, /App key is not a valid SSL key/)
|
107
|
+
token_file.unlink
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
82
111
|
describe "generating token credentials" do
|
83
112
|
it 'errors if token file does not exist' do
|
84
113
|
R10K::Git.settings[:oauth_token] = "/missing/token/file"
|
@@ -19,6 +19,11 @@ describe R10K::Git::StatefulRepository do
|
|
19
19
|
expect(subject.sync_cache?(ref)).to eq true
|
20
20
|
end
|
21
21
|
|
22
|
+
it "is true if the ref is HEAD" do
|
23
|
+
expect(cache).to receive(:exist?).and_return true
|
24
|
+
expect(subject.sync_cache?('HEAD')).to eq true
|
25
|
+
end
|
26
|
+
|
22
27
|
it "is true if the ref is unresolvable" do
|
23
28
|
expect(cache).to receive(:exist?).and_return true
|
24
29
|
expect(cache).to receive(:ref_type).with('0.9.x').and_return(:unknown)
|