r10k 3.7.0 → 3.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.mkd +7 -0
- data/CODEOWNERS +1 -1
- data/doc/dynamic-environments/configuration.mkd +25 -0
- data/doc/dynamic-environments/usage.mkd +5 -4
- data/lib/r10k/action/deploy/environment.rb +2 -0
- data/lib/r10k/action/deploy/module.rb +3 -1
- data/lib/r10k/action/runner.rb +33 -0
- data/lib/r10k/cli/deploy.rb +8 -4
- data/lib/r10k/cli/puppetfile.rb +5 -5
- data/lib/r10k/environment/base.rb +7 -0
- data/lib/r10k/environment/with_modules.rb +27 -19
- data/lib/r10k/git.rb +1 -0
- data/lib/r10k/git/rugged/credentials.rb +32 -2
- data/lib/r10k/initializers.rb +1 -0
- data/lib/r10k/module/forge.rb +1 -1
- data/lib/r10k/module/git.rb +16 -3
- data/lib/r10k/puppetfile.rb +14 -16
- data/lib/r10k/settings.rb +12 -1
- data/lib/r10k/version.rb +1 -1
- data/locales/r10k.pot +51 -31
- data/spec/fixtures/unit/action/r10k_creds.yaml +9 -0
- data/spec/unit/action/deploy/environment_spec.rb +34 -2
- data/spec/unit/action/deploy/module_spec.rb +29 -3
- data/spec/unit/action/runner_spec.rb +48 -1
- data/spec/unit/environment/git_spec.rb +3 -2
- data/spec/unit/environment/with_modules_spec.rb +74 -0
- data/spec/unit/git/rugged/credentials_spec.rb +68 -1
- data/spec/unit/module/git_spec.rb +55 -0
- data/spec/unit/puppetfile_spec.rb +24 -35
- metadata +4 -2
data/lib/r10k/puppetfile.rb
CHANGED
@@ -42,11 +42,6 @@ class Puppetfile
|
|
42
42
|
# @return [Boolean] Overwrite any locally made changes
|
43
43
|
attr_accessor :force
|
44
44
|
|
45
|
-
# @!attribute [r] modules_by_vcs_cachedir
|
46
|
-
# @api private Only exposed for testing purposes
|
47
|
-
# @return [Hash{:none, String => Array<R10K::Module>}]
|
48
|
-
attr_reader :modules_by_vcs_cachedir
|
49
|
-
|
50
45
|
# @param [String] basedir
|
51
46
|
# @param [String] moduledir The directory to install the modules, default to #{basedir}/modules
|
52
47
|
# @param [String] puppetfile_path The path to the Puppetfile, default to #{basedir}/Puppetfile
|
@@ -63,7 +58,6 @@ class Puppetfile
|
|
63
58
|
|
64
59
|
@modules = []
|
65
60
|
@managed_content = {}
|
66
|
-
@modules_by_vcs_cachedir = {}
|
67
61
|
@forge = 'forgeapi.puppetlabs.com'
|
68
62
|
|
69
63
|
@loaded = false
|
@@ -83,7 +77,7 @@ class Puppetfile
|
|
83
77
|
|
84
78
|
dsl = R10K::Puppetfile::DSL.new(self)
|
85
79
|
dsl.instance_eval(puppetfile_contents, @puppetfile_path)
|
86
|
-
|
80
|
+
|
87
81
|
validate_no_duplicate_names(@modules)
|
88
82
|
@loaded = true
|
89
83
|
rescue SyntaxError, LoadError, ArgumentError, NameError => e
|
@@ -133,19 +127,23 @@ class Puppetfile
|
|
133
127
|
end
|
134
128
|
|
135
129
|
if args.is_a?(Hash) && @default_branch_override != nil
|
136
|
-
args[:
|
130
|
+
args[:default_branch_override] = @default_branch_override
|
137
131
|
end
|
138
132
|
|
139
|
-
# Keep track of all the content this Puppetfile is managing to enable purging.
|
140
|
-
@managed_content[install_path] = Array.new unless @managed_content.has_key?(install_path)
|
141
|
-
|
142
133
|
mod = R10K::Module.new(name, install_path, args, @environment)
|
143
|
-
mod.origin =
|
134
|
+
mod.origin = :puppetfile
|
144
135
|
|
136
|
+
# Do not load modules if they would conflict with the attached
|
137
|
+
# environment
|
138
|
+
if environment && environment.module_conflicts?(mod)
|
139
|
+
mod = nil
|
140
|
+
return @modules
|
141
|
+
end
|
142
|
+
|
143
|
+
# Keep track of all the content this Puppetfile is managing to enable purging.
|
144
|
+
@managed_content[install_path] = Array.new unless @managed_content.has_key?(install_path)
|
145
145
|
@managed_content[install_path] << mod.name
|
146
|
-
|
147
|
-
@modules_by_vcs_cachedir[cachedir] ||= []
|
148
|
-
@modules_by_vcs_cachedir[cachedir] << mod
|
146
|
+
|
149
147
|
@modules << mod
|
150
148
|
end
|
151
149
|
|
@@ -223,7 +221,7 @@ class Puppetfile
|
|
223
221
|
def modules_queue(visitor)
|
224
222
|
Queue.new.tap do |queue|
|
225
223
|
visitor.visit(:puppetfile, self) do
|
226
|
-
modules_by_cachedir =
|
224
|
+
modules_by_cachedir = modules.group_by { |mod| mod.cachedir }
|
227
225
|
modules_without_vcs_cachedir = modules_by_cachedir.delete(:none) || []
|
228
226
|
|
229
227
|
modules_without_vcs_cachedir.each {|mod| queue << Array(mod) }
|
data/lib/r10k/settings.rb
CHANGED
@@ -37,6 +37,11 @@ module R10K
|
|
37
37
|
Only used by the 'rugged' Git provider.",
|
38
38
|
}),
|
39
39
|
|
40
|
+
Definition.new(:oauth_token, {
|
41
|
+
:desc => "The path to a token file for Git OAuth remotes.
|
42
|
+
Only used by the 'rugged' Git provider."
|
43
|
+
}),
|
44
|
+
|
40
45
|
URIDefinition.new(:proxy, {
|
41
46
|
:desc => "An optional proxy server to use when interacting with Git sources via HTTP(S).",
|
42
47
|
:default => :inherit,
|
@@ -54,11 +59,17 @@ module R10K
|
|
54
59
|
:default => :inherit,
|
55
60
|
}),
|
56
61
|
|
62
|
+
Definition.new(:oauth_token, {
|
63
|
+
:desc => "The path to a token file for Git OAuth remotes.
|
64
|
+
Only used by the 'rugged' Git provider.",
|
65
|
+
:default => :inherit
|
66
|
+
}),
|
67
|
+
|
57
68
|
URIDefinition.new(:proxy, {
|
58
69
|
:desc => "An optional proxy server to use when interacting with Git sources via HTTP(S).",
|
59
70
|
:default => :inherit,
|
60
71
|
}),
|
61
|
-
|
72
|
+
|
62
73
|
Definition.new(:ignore_branch_prefixes, {
|
63
74
|
:desc => "Array of strings used to prefix branch names that will not be deployed as environments.",
|
64
75
|
}),
|
data/lib/r10k/version.rb
CHANGED
@@ -2,5 +2,5 @@ module R10K
|
|
2
2
|
# When updating to a new major (X) or minor (Y) version, include `#major` or
|
3
3
|
# `#minor` (respectively) in your commit message to trigger the appropriate
|
4
4
|
# release. Otherwise, a new patch (Z) version will be released.
|
5
|
-
VERSION = '3.
|
5
|
+
VERSION = '3.8.0'
|
6
6
|
end
|
data/locales/r10k.pot
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
# SOME DESCRIPTIVE TITLE.
|
2
|
-
# Copyright (C)
|
2
|
+
# Copyright (C) 2021 Puppet, Inc.
|
3
3
|
# This file is distributed under the same license as the r10k package.
|
4
|
-
# FIRST AUTHOR <EMAIL@ADDRESS>,
|
4
|
+
# FIRST AUTHOR <EMAIL@ADDRESS>, 2021.
|
5
5
|
#
|
6
6
|
#, fuzzy
|
7
7
|
msgid ""
|
8
8
|
msgstr ""
|
9
|
-
"Project-Id-Version: r10k 3.4.1-
|
9
|
+
"Project-Id-Version: r10k 3.4.1-133-g2007a86\n"
|
10
10
|
"\n"
|
11
11
|
"Report-Msgid-Bugs-To: docs@puppetlabs.com\n"
|
12
|
-
"POT-Creation-Date:
|
13
|
-
"PO-Revision-Date:
|
12
|
+
"POT-Creation-Date: 2021-02-12 02:00+0000\n"
|
13
|
+
"PO-Revision-Date: 2021-02-12 02:00+0000\n"
|
14
14
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
15
15
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
16
16
|
"Language: \n"
|
@@ -83,15 +83,15 @@ msgstr ""
|
|
83
83
|
msgid "Cannot track control repo branch for content '%{name}' when not part of a 'deploy' action, will use default if available."
|
84
84
|
msgstr ""
|
85
85
|
|
86
|
-
#: ../lib/r10k/action/runner.rb:
|
86
|
+
#: ../lib/r10k/action/runner.rb:54 ../lib/r10k/deployment/config.rb:42
|
87
87
|
msgid "Overriding config file setting '%{key}': '%{old_val}' -> '%{new_val}'"
|
88
88
|
msgstr ""
|
89
89
|
|
90
|
-
#: ../lib/r10k/action/runner.rb:
|
90
|
+
#: ../lib/r10k/action/runner.rb:91
|
91
91
|
msgid "Reading configuration from %{config_path}"
|
92
92
|
msgstr ""
|
93
93
|
|
94
|
-
#: ../lib/r10k/action/runner.rb:
|
94
|
+
#: ../lib/r10k/action/runner.rb:94
|
95
95
|
msgid "No config file explicitly given and no default config file could be found, default settings will be used."
|
96
96
|
msgstr ""
|
97
97
|
|
@@ -107,12 +107,16 @@ msgstr ""
|
|
107
107
|
msgid "%{class} has not implemented method %{method}"
|
108
108
|
msgstr ""
|
109
109
|
|
110
|
-
#: ../lib/r10k/environment/with_modules.rb:
|
111
|
-
msgid "
|
110
|
+
#: ../lib/r10k/environment/with_modules.rb:60
|
111
|
+
msgid "Environment and %{src} both define the \"%{name}\" module"
|
112
112
|
msgstr ""
|
113
113
|
|
114
|
-
#: ../lib/r10k/environment/with_modules.rb:
|
115
|
-
msgid "
|
114
|
+
#: ../lib/r10k/environment/with_modules.rb:61
|
115
|
+
msgid "#{msg_error}. The %{src} definition will be ignored"
|
116
|
+
msgstr ""
|
117
|
+
|
118
|
+
#: ../lib/r10k/environment/with_modules.rb:71
|
119
|
+
msgid "Unexpected value for `module_conflicts` setting in %{env} environment: %{val}"
|
116
120
|
msgstr ""
|
117
121
|
|
118
122
|
#: ../lib/r10k/feature.rb:27
|
@@ -187,11 +191,11 @@ msgstr ""
|
|
187
191
|
msgid "Cannot write %{file}; parent directory does not exist"
|
188
192
|
msgstr ""
|
189
193
|
|
190
|
-
#: ../lib/r10k/git/cache.rb:
|
194
|
+
#: ../lib/r10k/git/cache.rb:65
|
191
195
|
msgid "%{class}#path is deprecated; use #git_dir"
|
192
196
|
msgstr ""
|
193
197
|
|
194
|
-
#: ../lib/r10k/git/cache.rb:
|
198
|
+
#: ../lib/r10k/git/cache.rb:94
|
195
199
|
msgid "Creating new git cache for %{remote}"
|
196
200
|
msgstr ""
|
197
201
|
|
@@ -227,15 +231,31 @@ msgstr ""
|
|
227
231
|
msgid "Unable to use SSH key auth for %{url}: private key %{private_key} is missing or unreadable"
|
228
232
|
msgstr ""
|
229
233
|
|
230
|
-
#: ../lib/r10k/git/rugged/credentials.rb:
|
234
|
+
#: ../lib/r10k/git/rugged/credentials.rb:72
|
235
|
+
msgid "Using OAuth token from stdin for URL %{url}"
|
236
|
+
msgstr ""
|
237
|
+
|
238
|
+
#: ../lib/r10k/git/rugged/credentials.rb:75
|
239
|
+
msgid "Using OAuth token from %{token_path} for URL %{url}"
|
240
|
+
msgstr ""
|
241
|
+
|
242
|
+
#: ../lib/r10k/git/rugged/credentials.rb:77
|
243
|
+
msgid "%{path} is missing or unreadable, cannot load OAuth token"
|
244
|
+
msgstr ""
|
245
|
+
|
246
|
+
#: ../lib/r10k/git/rugged/credentials.rb:81
|
247
|
+
msgid "Supplied OAuth token contains invalid characters."
|
248
|
+
msgstr ""
|
249
|
+
|
250
|
+
#: ../lib/r10k/git/rugged/credentials.rb:110
|
231
251
|
msgid "URL %{url} includes the username %{username}, using that user for authentication."
|
232
252
|
msgstr ""
|
233
253
|
|
234
|
-
#: ../lib/r10k/git/rugged/credentials.rb:
|
254
|
+
#: ../lib/r10k/git/rugged/credentials.rb:113
|
235
255
|
msgid "URL %{url} did not specify a user, using %{user} from configuration"
|
236
256
|
msgstr ""
|
237
257
|
|
238
|
-
#: ../lib/r10k/git/rugged/credentials.rb:
|
258
|
+
#: ../lib/r10k/git/rugged/credentials.rb:116
|
239
259
|
msgid "URL %{url} did not specify a user, using current user %{user}"
|
240
260
|
msgstr ""
|
241
261
|
|
@@ -255,31 +275,31 @@ msgstr ""
|
|
255
275
|
msgid "Found local modifications in %{file_path}"
|
256
276
|
msgstr ""
|
257
277
|
|
258
|
-
#: ../lib/r10k/git/stateful_repository.rb:
|
278
|
+
#: ../lib/r10k/git/stateful_repository.rb:44
|
259
279
|
msgid "Unable to sync repo to unresolvable ref '%{ref}'"
|
260
280
|
msgstr ""
|
261
281
|
|
262
|
-
#: ../lib/r10k/git/stateful_repository.rb:
|
282
|
+
#: ../lib/r10k/git/stateful_repository.rb:51
|
263
283
|
msgid "Cloning %{repo_path} and checking out %{ref}"
|
264
284
|
msgstr ""
|
265
285
|
|
266
|
-
#: ../lib/r10k/git/stateful_repository.rb:
|
286
|
+
#: ../lib/r10k/git/stateful_repository.rb:54
|
267
287
|
msgid "Replacing %{repo_path} and checking out %{ref}"
|
268
288
|
msgstr ""
|
269
289
|
|
270
|
-
#: ../lib/r10k/git/stateful_repository.rb:
|
290
|
+
#: ../lib/r10k/git/stateful_repository.rb:58 ../lib/r10k/git/stateful_repository.rb:63
|
271
291
|
msgid "Updating %{repo_path} to %{ref}"
|
272
292
|
msgstr ""
|
273
293
|
|
274
|
-
#: ../lib/r10k/git/stateful_repository.rb:
|
294
|
+
#: ../lib/r10k/git/stateful_repository.rb:62
|
275
295
|
msgid "Overwriting local modifications to %{repo_path}"
|
276
296
|
msgstr ""
|
277
297
|
|
278
|
-
#: ../lib/r10k/git/stateful_repository.rb:
|
298
|
+
#: ../lib/r10k/git/stateful_repository.rb:66
|
279
299
|
msgid "Skipping %{repo_path} due to local modifications"
|
280
300
|
msgstr ""
|
281
301
|
|
282
|
-
#: ../lib/r10k/git/stateful_repository.rb:
|
302
|
+
#: ../lib/r10k/git/stateful_repository.rb:69
|
283
303
|
msgid "%{repo_path} is already at Git ref %{ref}"
|
284
304
|
msgstr ""
|
285
305
|
|
@@ -303,7 +323,7 @@ msgstr ""
|
|
303
323
|
msgid "Module %{name} with args %{args} doesn't have an implementation. (Are you using the right arguments?)"
|
304
324
|
msgstr ""
|
305
325
|
|
306
|
-
#: ../lib/r10k/module/base.rb:
|
326
|
+
#: ../lib/r10k/module/base.rb:118
|
307
327
|
msgid "Module name (%{title}) must match either 'modulename' or 'owner/modulename'"
|
308
328
|
msgstr ""
|
309
329
|
|
@@ -312,10 +332,10 @@ msgid "The module %{title} does not exist on %{url}."
|
|
312
332
|
msgstr ""
|
313
333
|
|
314
334
|
#: ../lib/r10k/module/forge.rb:174
|
315
|
-
msgid "Forge module names must match 'owner/modulename'"
|
335
|
+
msgid "Forge module names must match 'owner/modulename', instead got #{title}"
|
316
336
|
msgstr ""
|
317
337
|
|
318
|
-
#: ../lib/r10k/module/git.rb:
|
338
|
+
#: ../lib/r10k/module/git.rb:113
|
319
339
|
msgid "Unhandled options %{unhandled} specified for %{class}"
|
320
340
|
msgstr ""
|
321
341
|
|
@@ -347,19 +367,19 @@ msgstr ""
|
|
347
367
|
msgid "Remove the duplicates of the following modules: %{dupes}"
|
348
368
|
msgstr ""
|
349
369
|
|
350
|
-
#: ../lib/r10k/puppetfile.rb:
|
370
|
+
#: ../lib/r10k/puppetfile.rb:201
|
351
371
|
msgid "Updating modules with %{pool_size} threads"
|
352
372
|
msgstr ""
|
353
373
|
|
354
|
-
#: ../lib/r10k/puppetfile.rb:
|
374
|
+
#: ../lib/r10k/puppetfile.rb:212
|
355
375
|
msgid "Error during concurrent deploy of a module: %{message}"
|
356
376
|
msgstr ""
|
357
377
|
|
358
|
-
#: ../lib/r10k/puppetfile.rb:
|
378
|
+
#: ../lib/r10k/puppetfile.rb:241
|
359
379
|
msgid "Module thread %{id} exiting: %{message}"
|
360
380
|
msgstr ""
|
361
381
|
|
362
|
-
#: ../lib/r10k/puppetfile.rb:
|
382
|
+
#: ../lib/r10k/puppetfile.rb:300
|
363
383
|
msgid "unrecognized declaration '%{method}'"
|
364
384
|
msgstr ""
|
365
385
|
|
@@ -0,0 +1,9 @@
|
|
1
|
+
---
|
2
|
+
git:
|
3
|
+
private_key: '/global/config/private/key'
|
4
|
+
oauth_token: '/global/config/oauth/token'
|
5
|
+
repositories:
|
6
|
+
- remote: 'git@myfakegitserver.com:user/repo.git'
|
7
|
+
private_key: '/config/private/key'
|
8
|
+
- remote: 'https://myfakegitserver.com/user/repo.git'
|
9
|
+
oauth_token: '/config/oauth/token'
|
@@ -27,8 +27,6 @@ describe R10K::Action::Deploy::Environment do
|
|
27
27
|
described_class.new({:'no-force' => true}, [])
|
28
28
|
end
|
29
29
|
|
30
|
-
it "normalizes environment names in the arg vector"
|
31
|
-
|
32
30
|
it 'can accept a generate-types option' do
|
33
31
|
described_class.new({ 'generate-types': true }, [])
|
34
32
|
end
|
@@ -36,6 +34,14 @@ describe R10K::Action::Deploy::Environment do
|
|
36
34
|
it 'can accept a puppet-path option' do
|
37
35
|
described_class.new({ 'puppet-path': '/nonexistent' }, [])
|
38
36
|
end
|
37
|
+
|
38
|
+
it 'can accept a private-key option' do
|
39
|
+
described_class.new({ 'private-key': '/nonexistent' }, [])
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'can accept a token option' do
|
43
|
+
described_class.new({ 'oauth-token': '/nonexistent' }, [])
|
44
|
+
end
|
39
45
|
end
|
40
46
|
|
41
47
|
describe "when called" do
|
@@ -162,6 +168,13 @@ describe R10K::Action::Deploy::Environment do
|
|
162
168
|
end
|
163
169
|
end
|
164
170
|
|
171
|
+
describe 'extracting credentials' do
|
172
|
+
let(:deployment) do
|
173
|
+
R10K::Deployment.new(mock_config)
|
174
|
+
end
|
175
|
+
|
176
|
+
end
|
177
|
+
|
165
178
|
describe "purge_levels" do
|
166
179
|
let(:settings) { { deploy: { purge_levels: purge_levels } } }
|
167
180
|
|
@@ -219,6 +232,7 @@ describe R10K::Action::Deploy::Environment do
|
|
219
232
|
end
|
220
233
|
end
|
221
234
|
end
|
235
|
+
|
222
236
|
describe "generate-types" do
|
223
237
|
let(:deployment) do
|
224
238
|
R10K::Deployment.new(
|
@@ -340,6 +354,24 @@ describe R10K::Action::Deploy::Environment do
|
|
340
354
|
expect(subject.instance_variable_get(:@puppet_conf)).to eq('/nonexistent')
|
341
355
|
end
|
342
356
|
end
|
357
|
+
|
358
|
+
describe 'with private-key' do
|
359
|
+
|
360
|
+
subject { described_class.new({ config: '/some/nonexistent/path', 'private-key': '/nonexistent' }, []) }
|
361
|
+
|
362
|
+
it 'sets private_key' do
|
363
|
+
expect(subject.instance_variable_get(:@private_key)).to eq('/nonexistent')
|
364
|
+
end
|
365
|
+
end
|
366
|
+
|
367
|
+
describe 'with oauth-token' do
|
368
|
+
|
369
|
+
subject { described_class.new({ config: '/some/nonexistent/path', 'oauth-token': '/nonexistent' }, []) }
|
370
|
+
|
371
|
+
it 'sets oauth_token' do
|
372
|
+
expect(subject.instance_variable_get(:@oauth_token)).to eq('/nonexistent')
|
373
|
+
end
|
374
|
+
end
|
343
375
|
end
|
344
376
|
|
345
377
|
describe "write_environment_info!" do
|
@@ -33,6 +33,14 @@ describe R10K::Action::Deploy::Module do
|
|
33
33
|
it 'can accept a cachedir option' do
|
34
34
|
described_class.new({ cachedir: '/nonexistent' }, [])
|
35
35
|
end
|
36
|
+
|
37
|
+
it 'can accept a private-key option' do
|
38
|
+
described_class.new({ 'private-key': '/nonexistent' }, [])
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'can accept a token option' do
|
42
|
+
described_class.new({ 'oauth-token': '/nonexistent' }, [])
|
43
|
+
end
|
36
44
|
end
|
37
45
|
|
38
46
|
describe "with no-force" do
|
@@ -74,8 +82,8 @@ describe R10K::Action::Deploy::Module do
|
|
74
82
|
|
75
83
|
before do
|
76
84
|
allow(subject).to receive(:visit_environment).and_wrap_original do |original, environment, &block|
|
77
|
-
expect(environment.puppetfile).to receive(:
|
78
|
-
|
85
|
+
expect(environment.puppetfile).to receive(:modules).and_return(
|
86
|
+
[R10K::Module::Local.new(environment.name, '/fakedir', [], environment)]
|
79
87
|
)
|
80
88
|
original.call(environment, &block)
|
81
89
|
end
|
@@ -145,8 +153,26 @@ describe R10K::Action::Deploy::Module do
|
|
145
153
|
|
146
154
|
subject { described_class.new({ config: '/some/nonexistent/path', cachedir: '/nonexistent' }, []) }
|
147
155
|
|
148
|
-
it 'sets
|
156
|
+
it 'sets cachedir' do
|
149
157
|
expect(subject.instance_variable_get(:@cachedir)).to eq('/nonexistent')
|
150
158
|
end
|
151
159
|
end
|
160
|
+
|
161
|
+
describe 'with private-key' do
|
162
|
+
|
163
|
+
subject { described_class.new({ config: '/some/nonexistent/path', 'private-key': '/nonexistent' }, []) }
|
164
|
+
|
165
|
+
it 'sets private_key' do
|
166
|
+
expect(subject.instance_variable_get(:@private_key)).to eq('/nonexistent')
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
describe 'with oauth-token' do
|
171
|
+
|
172
|
+
subject { described_class.new({ config: '/some/nonexistent/path', 'oauth-token': '/nonexistent' }, []) }
|
173
|
+
|
174
|
+
it 'sets token_path' do
|
175
|
+
expect(subject.instance_variable_get(:@oauth_token)).to eq('/nonexistent')
|
176
|
+
end
|
177
|
+
end
|
152
178
|
end
|
@@ -10,11 +10,12 @@ describe R10K::Action::Runner do
|
|
10
10
|
Class.new do
|
11
11
|
attr_reader :opts
|
12
12
|
attr_reader :argv
|
13
|
+
attr_reader :settings
|
13
14
|
|
14
15
|
def initialize(opts, argv, settings = {})
|
15
16
|
@opts = opts
|
16
17
|
@argv = argv
|
17
|
-
@settings =
|
18
|
+
@settings = settings
|
18
19
|
end
|
19
20
|
|
20
21
|
def call
|
@@ -170,6 +171,52 @@ describe R10K::Action::Runner do
|
|
170
171
|
end
|
171
172
|
end
|
172
173
|
|
174
|
+
describe "configuring git credentials" do
|
175
|
+
it 'errors if both token and key paths are passed' do
|
176
|
+
runner = described_class.new({ 'oauth-token': '/nonexistent',
|
177
|
+
'private-key': '/also/fake' }, %w[args yes], action_class)
|
178
|
+
expect{ runner.call }.to raise_error(R10K::Error, /Cannot specify both/)
|
179
|
+
end
|
180
|
+
|
181
|
+
it 'saves the sshkey path in settings hash' do
|
182
|
+
runner = described_class.new({ 'private-key': '/my/ssh/key' }, %w[args yes], action_class)
|
183
|
+
runner.call
|
184
|
+
expect(runner.instance.settings[:git][:private_key]).to eq('/my/ssh/key')
|
185
|
+
end
|
186
|
+
|
187
|
+
it 'overrides per-repo sshkey in settings hash' do
|
188
|
+
runner = described_class.new({ config: "spec/fixtures/unit/action/r10k_creds.yaml",
|
189
|
+
'private-key': '/my/ssh/key' },
|
190
|
+
%w[args yes],
|
191
|
+
action_class)
|
192
|
+
runner.call
|
193
|
+
expect(runner.instance.settings[:git][:private_key]).to eq('/my/ssh/key')
|
194
|
+
expect(runner.instance.settings[:git][:repositories].count).to eq(2)
|
195
|
+
runner.instance.settings[:git][:repositories].each do |repo_settings|
|
196
|
+
expect(repo_settings[:private_key]).to eq('/my/ssh/key')
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
it 'saves the token path in settings hash' do
|
201
|
+
runner = described_class.new({ 'oauth-token': '/my/token/path' }, %w[args yes], action_class)
|
202
|
+
runner.call
|
203
|
+
expect(runner.instance.settings[:git][:oauth_token]).to eq('/my/token/path')
|
204
|
+
end
|
205
|
+
|
206
|
+
it 'overrides per-repo oauth token in settings hash' do
|
207
|
+
runner = described_class.new({ config: "spec/fixtures/unit/action/r10k_creds.yaml",
|
208
|
+
'oauth-token': '/my/token' },
|
209
|
+
%w[args yes],
|
210
|
+
action_class)
|
211
|
+
runner.call
|
212
|
+
expect(runner.instance.settings[:git][:oauth_token]).to eq('/my/token')
|
213
|
+
expect(runner.instance.settings[:git][:repositories].count).to eq(2)
|
214
|
+
runner.instance.settings[:git][:repositories].each do |repo_settings|
|
215
|
+
expect(repo_settings[:oauth_token]).to eq('/my/token')
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
173
220
|
describe "configuration authorization" do
|
174
221
|
context "when license is not present" do
|
175
222
|
before(:each) do
|