r10k 2.2.2 → 2.3.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 +25 -0
- data/Gemfile +1 -1
- data/doc/dynamic-environments/configuration.mkd +36 -11
- data/integration/tests/basic_functionality/proxy_with_pe_only_module.rb +128 -0
- data/lib/r10k/errors.rb +18 -0
- data/lib/r10k/forge/module_release.rb +3 -3
- data/lib/r10k/git.rb +53 -0
- data/lib/r10k/git/rugged/bare_repository.rb +16 -7
- data/lib/r10k/git/rugged/base_repository.rb +16 -2
- data/lib/r10k/git/rugged/credentials.rb +9 -0
- data/lib/r10k/git/rugged/working_repository.rb +18 -5
- data/lib/r10k/git/shellgit/bare_repository.rb +12 -3
- data/lib/r10k/git/shellgit/base_repository.rb +19 -3
- data/lib/r10k/git/shellgit/working_repository.rb +13 -3
- data/lib/r10k/initializers.rb +1 -0
- data/lib/r10k/settings.rb +41 -22
- data/lib/r10k/settings/collection.rb +25 -21
- data/lib/r10k/settings/definition.rb +14 -2
- data/lib/r10k/settings/helpers.rb +38 -0
- data/lib/r10k/settings/list.rb +107 -0
- data/lib/r10k/util/symbolize_keys.rb +6 -2
- data/lib/r10k/version.rb +1 -1
- data/r10k.gemspec +1 -1
- data/r10k.yaml.example +38 -12
- data/spec/shared-examples/git/bare_repository.rb +62 -0
- data/spec/shared-examples/git/working_repository.rb +57 -11
- data/spec/shared-examples/settings/ancestry.rb +44 -0
- data/spec/unit/forge/module_release_spec.rb +1 -1
- data/spec/unit/git/rugged/credentials_spec.rb +6 -0
- data/spec/unit/settings/collection_spec.rb +2 -1
- data/spec/unit/settings/definition_spec.rb +6 -5
- data/spec/unit/settings/inheritance_spec.rb +38 -0
- data/spec/unit/settings/list_spec.rb +88 -0
- data/spec/unit/settings_spec.rb +52 -23
- data/spec/unit/util/attempt_spec.rb +1 -1
- data/spec/unit/util/symbolize_keys_spec.rb +25 -9
- metadata +11 -4
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'r10k/settings/list'
|
3
|
+
require 'r10k/settings/collection'
|
4
|
+
require 'r10k/settings/definition'
|
5
|
+
require 'r10k/settings/uri_definition'
|
6
|
+
|
7
|
+
describe R10K::Settings::List do
|
8
|
+
let(:item_proc) do
|
9
|
+
lambda { R10K::Settings::URIDefinition.new(nil, { :desc => "A URI in a list" }) }
|
10
|
+
end
|
11
|
+
|
12
|
+
subject do
|
13
|
+
described_class.new(:test_list, item_proc, { :desc => "A test setting list" })
|
14
|
+
end
|
15
|
+
|
16
|
+
it_behaves_like "a setting with ancestors"
|
17
|
+
|
18
|
+
describe '#assign' do
|
19
|
+
it "calls item_proc for each item assigned" do
|
20
|
+
expect(R10K::Settings::URIDefinition).to receive(:new).and_call_original.exactly(3).times
|
21
|
+
|
22
|
+
subject.assign([ "uri_1", "uri_2", "uri_3"])
|
23
|
+
end
|
24
|
+
|
25
|
+
it "claims ownership of newly added items" do
|
26
|
+
subject.assign([ "uri_1", "uri_2", "uri_3"])
|
27
|
+
|
28
|
+
item_parents = subject.instance_variable_get(:@items).collect { |i| i.parent }
|
29
|
+
expect(item_parents).to all(eq subject)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "assigns value to each item" do
|
33
|
+
new_values = [ "uri_1", "uri_2", "uri_3"]
|
34
|
+
subject.assign(new_values)
|
35
|
+
|
36
|
+
item_values = subject.instance_variable_get(:@items).collect { |i| i.value }
|
37
|
+
expect(item_values).to eq new_values
|
38
|
+
end
|
39
|
+
|
40
|
+
it "silently ignores attempts to assign nil" do
|
41
|
+
subject.assign(nil)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '#validate' do
|
46
|
+
it "raises an error containing a list of every item with validation errors" do
|
47
|
+
subject.assign([ "uri 1", "uri 2", "http://www.example.com"])
|
48
|
+
|
49
|
+
expect { subject.validate }.to raise_error do |error|
|
50
|
+
expect(error).to be_a_kind_of(R10K::Settings::List::ValidationError)
|
51
|
+
errors = error.errors.collect { |key, val| val }
|
52
|
+
expect(errors.size).to eq 2
|
53
|
+
expect(errors).to all(be_a_kind_of(ArgumentError))
|
54
|
+
expect(errors.collect { |e| e.message }).to all(match /requires a URL.*could not be parsed/i)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
it "it does not raise an error if no errors were found" do
|
59
|
+
subject.assign([ "http://www.example.com" ])
|
60
|
+
expect(subject.validate).to be_nil
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe '#resolve' do
|
65
|
+
it "returns a frozen list of all items" do
|
66
|
+
subject.assign([ "uri_1", "uri_2" ])
|
67
|
+
|
68
|
+
rv = subject.resolve
|
69
|
+
|
70
|
+
expect(rv).to be_frozen
|
71
|
+
expect(rv).to eq([ "uri_1", "uri_2" ])
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe R10K::Settings::List::ValidationError do
|
77
|
+
subject do
|
78
|
+
described_class.new("Sample List Validation Errors", errors: {
|
79
|
+
2 => ArgumentError.new("Sample List Item Error"),
|
80
|
+
})
|
81
|
+
end
|
82
|
+
|
83
|
+
it "generates a human readable error message for the invalid item" do
|
84
|
+
message = subject.format
|
85
|
+
|
86
|
+
expect(message).to match /sample list validation errors.*item 2.*sample list item error/im
|
87
|
+
end
|
88
|
+
end
|
data/spec/unit/settings_spec.rb
CHANGED
@@ -32,6 +32,24 @@ describe R10K::Settings do
|
|
32
32
|
expect(output[:private_key]).to eq("/etc/puppetlabs/r10k/id_rsa")
|
33
33
|
end
|
34
34
|
end
|
35
|
+
|
36
|
+
describe "proxy" do
|
37
|
+
it "accepts valid URIs" do
|
38
|
+
output = subject.evaluate("proxy" => "http://proxy.tessier-ashpool.freeside:3128")
|
39
|
+
expect(output[:proxy]).to eq "http://proxy.tessier-ashpool.freeside:3128"
|
40
|
+
end
|
41
|
+
|
42
|
+
it "rejects invalid URIs" do
|
43
|
+
expect {
|
44
|
+
subject.evaluate("proxy" => "that's no proxy!")
|
45
|
+
}.to raise_error do |err|
|
46
|
+
expect(err.message).to match(/Validation failed for 'git' settings group/)
|
47
|
+
expect(err.errors.size).to eq 1
|
48
|
+
expect(err.errors[:proxy]).to be_a_kind_of(ArgumentError)
|
49
|
+
expect(err.errors[:proxy].message).to match(/could not be parsed as a URL/)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
35
53
|
end
|
36
54
|
|
37
55
|
describe "forge settings" do
|
@@ -47,23 +65,12 @@ describe R10K::Settings do
|
|
47
65
|
expect {
|
48
66
|
subject.evaluate("proxy" => "that's no proxy!")
|
49
67
|
}.to raise_error do |err|
|
50
|
-
expect(err.message).to match(/Validation failed for forge settings group/)
|
68
|
+
expect(err.message).to match(/Validation failed for 'forge' settings group/)
|
51
69
|
expect(err.errors.size).to eq 1
|
52
70
|
expect(err.errors[:proxy]).to be_a_kind_of(ArgumentError)
|
53
71
|
expect(err.errors[:proxy].message).to match(/could not be parsed as a URL/)
|
54
72
|
end
|
55
73
|
end
|
56
|
-
|
57
|
-
describe "setting a default value" do
|
58
|
-
%w[HTTPS_PROXY https_proxy HTTP_PROXY http_proxy].each do |env_var|
|
59
|
-
it "respects the #{env_var} environment variable" do
|
60
|
-
R10K::Util::ExecEnv.withenv(env_var => "http://proxy.value/#{env_var}") do
|
61
|
-
output = subject.evaluate({})
|
62
|
-
expect(output[:proxy]).to eq("http://proxy.value/#{env_var}")
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
74
|
end
|
68
75
|
|
69
76
|
describe "baseurl" do
|
@@ -76,7 +83,7 @@ describe R10K::Settings do
|
|
76
83
|
expect {
|
77
84
|
subject.evaluate("baseurl" => "that's no forge!")
|
78
85
|
}.to raise_error do |err|
|
79
|
-
expect(err.message).to match(/Validation failed for forge settings group/)
|
86
|
+
expect(err.message).to match(/Validation failed for 'forge' settings group/)
|
80
87
|
expect(err.errors.size).to eq 1
|
81
88
|
expect(err.errors[:baseurl]).to be_a_kind_of(ArgumentError)
|
82
89
|
expect(err.errors[:baseurl].message).to match(/could not be parsed as a URL/)
|
@@ -103,7 +110,7 @@ describe R10K::Settings do
|
|
103
110
|
expect {
|
104
111
|
subject.evaluate("write_lock" => %w[list of reasons why deploys are locked])
|
105
112
|
}.to raise_error do |err|
|
106
|
-
expect(err.message).to match(/Validation failed for deploy settings group/)
|
113
|
+
expect(err.message).to match(/Validation failed for 'deploy' settings group/)
|
107
114
|
expect(err.errors.size).to eq 1
|
108
115
|
expect(err.errors[:write_lock]).to be_a_kind_of(ArgumentError)
|
109
116
|
expect(err.errors[:write_lock].message).to match(/should be a string containing the reason/)
|
@@ -138,7 +145,7 @@ describe R10K::Settings do
|
|
138
145
|
expect {
|
139
146
|
subject.evaluate("postrun" => "curl -F 'deploy=done' https://reporting.tessier-ashpool.freeside/r10k")
|
140
147
|
}.to raise_error do |err|
|
141
|
-
expect(err.message).to match(/Validation failed for global settings group/)
|
148
|
+
expect(err.message).to match(/Validation failed for 'global' settings group/)
|
142
149
|
expect(err.errors.size).to eq 1
|
143
150
|
expect(err.errors[:postrun]).to be_a_kind_of(ArgumentError)
|
144
151
|
expect(err.errors[:postrun].message).to eq("The postrun setting should be an array of strings, not a String")
|
@@ -146,17 +153,39 @@ describe R10K::Settings do
|
|
146
153
|
end
|
147
154
|
end
|
148
155
|
|
156
|
+
describe "proxy" do
|
157
|
+
it "accepts valid URIs" do
|
158
|
+
output = subject.evaluate("proxy" => "http://proxy.tessier-ashpool.freeside:3128")
|
159
|
+
expect(output[:proxy]).to eq "http://proxy.tessier-ashpool.freeside:3128"
|
160
|
+
end
|
161
|
+
|
162
|
+
it "rejects invalid URIs" do
|
163
|
+
expect {
|
164
|
+
subject.evaluate("proxy" => "that's no proxy!")
|
165
|
+
}.to raise_error do |err|
|
166
|
+
expect(err.message).to match(/Validation failed for 'global' settings group/)
|
167
|
+
expect(err.errors.size).to eq 1
|
168
|
+
expect(err.errors[:proxy]).to be_a_kind_of(ArgumentError)
|
169
|
+
expect(err.errors[:proxy].message).to match(/could not be parsed as a URL/)
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
describe "setting a default value" do
|
174
|
+
%w[HTTPS_PROXY https_proxy HTTP_PROXY http_proxy].each do |env_var|
|
175
|
+
it "respects the #{env_var} environment variable" do
|
176
|
+
R10K::Util::ExecEnv.withenv(env_var => "http://proxy.value/#{env_var}") do
|
177
|
+
output = subject.evaluate({})
|
178
|
+
expect(output[:proxy]).to eq("http://proxy.value/#{env_var}")
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
149
185
|
describe "git settings" do
|
150
186
|
it "passes settings through to the git settings" do
|
151
187
|
output = subject.evaluate("git" => {"provider" => "shellgit", "username" => "git"})
|
152
|
-
expect(output[:git]).to
|
153
|
-
end
|
154
|
-
|
155
|
-
it "handles keywords in repository settings" do
|
156
|
-
output = subject.evaluate("git" => {"provider" => "shellgit",
|
157
|
-
"username" => "git",
|
158
|
-
"repositories" => [ {"remote" => "foo"} ]})
|
159
|
-
expect(output[:git]).to eq(:provider => :shellgit, :username => "git", :private_key => nil, :repositories => [{remote: "foo"}])
|
188
|
+
expect(output[:git]).to include(:provider => :shellgit, :username => "git")
|
160
189
|
end
|
161
190
|
end
|
162
191
|
|
@@ -37,15 +37,31 @@ describe R10K::Util::SymbolizeKeys do
|
|
37
37
|
expect(hash[key]).to eq 'bar'
|
38
38
|
end
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
40
|
+
context "when symbolizing recursively" do
|
41
|
+
it "can recursively symbolize keys in nested hash values" do
|
42
|
+
hash = {'foo' => {'bar' => 'baz'}}
|
43
|
+
described_class.symbolize_keys!(hash, true)
|
44
|
+
expect(hash).to eq({:foo => {:bar => 'baz'}})
|
45
|
+
end
|
46
|
+
|
47
|
+
it "recurses into hash values that had symbol keys" do
|
48
|
+
hash = {:foo => {'bar' => {'baz' => 'quux'}}}
|
49
|
+
described_class.symbolize_keys!(hash, true)
|
50
|
+
expect(hash).to eq({:foo => {:bar => {:baz => 'quux'}}})
|
51
|
+
end
|
52
|
+
|
53
|
+
it "recurses into array values whose items are hashes" do
|
54
|
+
hash = {'foo' => [ {'item1_key' => 'val'}, {'item2_key' => 'val'} ]}
|
55
|
+
|
56
|
+
described_class.symbolize_keys!(hash, true)
|
57
|
+
expect(hash).to eq({:foo => [ {:item1_key => 'val'}, {:item2_key => 'val'} ]})
|
58
|
+
end
|
59
|
+
|
60
|
+
it "ignores nested array items that are not hashes" do
|
61
|
+
hash = {'foo' => [ {'item1_key' => 'val'}, 'banana' ]}
|
45
62
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
expect(hash).to eq({:foo => {:bar => {:baz => 'quux'}}})
|
63
|
+
described_class.symbolize_keys!(hash, true)
|
64
|
+
expect(hash).to eq({:foo => [ {:item1_key => 'val'}, 'banana' ]})
|
65
|
+
end
|
50
66
|
end
|
51
67
|
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: 2.
|
4
|
+
version: 2.3.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: 2016-
|
11
|
+
date: 2016-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colored
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 2.
|
75
|
+
version: '2.2'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 2.
|
82
|
+
version: '2.2'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: semantic_puppet
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -236,6 +236,7 @@ files:
|
|
236
236
|
- integration/tests/basic_functionality/negative/neg_invalid_git_provider.rb
|
237
237
|
- integration/tests/basic_functionality/negative/negative_bad_proxy.rb
|
238
238
|
- integration/tests/basic_functionality/proxy_specified_in_configuration.rb
|
239
|
+
- integration/tests/basic_functionality/proxy_with_pe_only_module.rb
|
239
240
|
- integration/tests/basic_functionality/proxy_with_puppetfile.rb
|
240
241
|
- integration/tests/basic_functionality/rugged_git_provider_with_ssh.rb
|
241
242
|
- integration/tests/basic_functionality/rugged_git_provider_without_ssh.rb
|
@@ -357,6 +358,8 @@ files:
|
|
357
358
|
- lib/r10k/settings/container.rb
|
358
359
|
- lib/r10k/settings/definition.rb
|
359
360
|
- lib/r10k/settings/enum_definition.rb
|
361
|
+
- lib/r10k/settings/helpers.rb
|
362
|
+
- lib/r10k/settings/list.rb
|
360
363
|
- lib/r10k/settings/loader.rb
|
361
364
|
- lib/r10k/settings/mixin.rb
|
362
365
|
- lib/r10k/settings/uri_definition.rb
|
@@ -416,6 +419,7 @@ files:
|
|
416
419
|
- spec/shared-examples/git/thin_repository.rb
|
417
420
|
- spec/shared-examples/git/working_repository.rb
|
418
421
|
- spec/shared-examples/puppetfile-action.rb
|
422
|
+
- spec/shared-examples/settings/ancestry.rb
|
419
423
|
- spec/shared-examples/subprocess-runner.rb
|
420
424
|
- spec/spec_helper.rb
|
421
425
|
- spec/unit/action/cri_runner_spec.rb
|
@@ -461,6 +465,8 @@ files:
|
|
461
465
|
- spec/unit/settings/container_spec.rb
|
462
466
|
- spec/unit/settings/definition_spec.rb
|
463
467
|
- spec/unit/settings/enum_definition_spec.rb
|
468
|
+
- spec/unit/settings/inheritance_spec.rb
|
469
|
+
- spec/unit/settings/list_spec.rb
|
464
470
|
- spec/unit/settings/loader_spec.rb
|
465
471
|
- spec/unit/settings/uri_definition_spec.rb
|
466
472
|
- spec/unit/settings_spec.rb
|
@@ -506,3 +512,4 @@ signing_key:
|
|
506
512
|
specification_version: 4
|
507
513
|
summary: Puppet environment and module deployment
|
508
514
|
test_files: []
|
515
|
+
has_rdoc:
|