r10k 3.12.1 → 3.14.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/docker.yml +1 -1
- data/.github/workflows/rspec_tests.yml +5 -5
- data/.github/workflows/stale.yml +2 -0
- data/.gitignore +1 -0
- data/.travis.yml +1 -1
- data/CHANGELOG.mkd +32 -0
- data/doc/dynamic-environments/configuration.mkd +59 -10
- data/doc/dynamic-environments/usage.mkd +4 -0
- data/doc/git/providers.mkd +22 -0
- data/doc/puppetfile.mkd +13 -0
- data/docker/Makefile +1 -1
- data/docker/r10k/Dockerfile +1 -1
- data/docker/r10k/release.Dockerfile +1 -1
- data/lib/r10k/action/runner.rb +6 -0
- data/lib/r10k/environment/bare.rb +4 -7
- data/lib/r10k/environment/name.rb +14 -9
- data/lib/r10k/environment/plain.rb +16 -0
- data/lib/r10k/environment/tarball.rb +78 -0
- data/lib/r10k/environment/with_modules.rb +1 -1
- data/lib/r10k/environment.rb +2 -0
- data/lib/r10k/errors.rb +5 -0
- data/lib/r10k/forge/module_release.rb +2 -1
- data/lib/r10k/git/cache.rb +4 -13
- data/lib/r10k/git/rugged/bare_repository.rb +1 -1
- data/lib/r10k/git/rugged/base_repository.rb +12 -1
- data/lib/r10k/git/rugged/cache.rb +8 -0
- data/lib/r10k/git/rugged/credentials.rb +1 -1
- data/lib/r10k/git/rugged/working_repository.rb +1 -1
- data/lib/r10k/git/stateful_repository.rb +2 -0
- data/lib/r10k/initializers.rb +20 -0
- data/lib/r10k/logging.rb +78 -1
- data/lib/r10k/module/base.rb +6 -2
- data/lib/r10k/module/forge.rb +10 -10
- data/lib/r10k/module/git.rb +1 -3
- data/lib/r10k/module/local.rb +1 -1
- data/lib/r10k/module/tarball.rb +101 -0
- data/lib/r10k/module.rb +1 -0
- data/lib/r10k/module_loader/puppetfile/dsl.rb +1 -1
- data/lib/r10k/module_loader/puppetfile.rb +21 -7
- data/lib/r10k/settings.rb +35 -0
- data/lib/r10k/source/git.rb +18 -18
- data/lib/r10k/source/yaml.rb +1 -1
- data/lib/r10k/tarball.rb +183 -0
- data/lib/r10k/util/cacheable.rb +31 -0
- data/lib/r10k/util/downloader.rb +134 -0
- data/lib/r10k/util/purgeable.rb +2 -2
- data/lib/r10k/version.rb +1 -1
- data/locales/r10k.pot +85 -57
- data/r10k.gemspec +2 -2
- data/r10k.yaml.example +28 -0
- data/spec/fixtures/tarball/tarball.tar.gz +0 -0
- data/spec/fixtures/unit/action/r10k_logging.yaml +12 -0
- data/spec/fixtures/unit/puppetfile/various-modules/modules/apt/.gitkeep +1 -0
- data/spec/fixtures/unit/puppetfile/various-modules/modules/baz/.gitkeep +1 -0
- data/spec/fixtures/unit/puppetfile/various-modules/modules/buzz/.gitkeep +1 -0
- data/spec/fixtures/unit/puppetfile/various-modules/modules/canary/.gitkeep +1 -0
- data/spec/fixtures/unit/puppetfile/various-modules/modules/fizz/.gitkeep +1 -0
- data/spec/fixtures/unit/puppetfile/various-modules/modules/rpm/.gitkeep +1 -0
- data/spec/fixtures/unit/util/purgeable/managed_one/managed_subdir_1/managed_symlink_file +1 -0
- data/spec/fixtures/unit/util/purgeable/managed_one/managed_subdir_1/{managed_subdir_2 → subdir_allowlisted_2}/ignored_1 +0 -0
- data/spec/fixtures/unit/util/purgeable/managed_one/managed_subdir_1/unmanaged_symlink_dir +1 -0
- data/spec/fixtures/unit/util/purgeable/managed_one/managed_symlink_dir +1 -0
- data/spec/fixtures/unit/util/purgeable/managed_one/unmanaged_symlink_file +1 -0
- data/spec/integration/git/rugged/cache_spec.rb +33 -0
- data/spec/integration/util/purageable_spec.rb +41 -0
- data/spec/shared-contexts/tarball.rb +32 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/unit/action/deploy/module_spec.rb +2 -2
- data/spec/unit/action/puppetfile/install_spec.rb +2 -2
- data/spec/unit/action/runner_spec.rb +52 -1
- data/spec/unit/environment/bare_spec.rb +13 -0
- data/spec/unit/environment/name_spec.rb +18 -0
- data/spec/unit/environment/plain_spec.rb +8 -0
- data/spec/unit/environment/tarball_spec.rb +45 -0
- data/spec/unit/environment/with_modules_spec.rb +1 -1
- data/spec/unit/git/cache_spec.rb +2 -15
- data/spec/unit/git/rugged/cache_spec.rb +19 -0
- data/spec/unit/module/forge_spec.rb +9 -7
- data/spec/unit/module/tarball_spec.rb +70 -0
- data/spec/unit/module_loader/puppetfile_spec.rb +21 -5
- data/spec/unit/module_spec.rb +14 -7
- data/spec/unit/tarball_spec.rb +57 -0
- data/spec/unit/util/cacheable_spec.rb +23 -0
- data/spec/unit/util/downloader_spec.rb +98 -0
- data/spec/unit/util/purgeable_spec.rb +22 -11
- metadata +45 -17
@@ -159,10 +159,61 @@ describe R10K::Action::Runner do
|
|
159
159
|
end
|
160
160
|
|
161
161
|
describe "configuring logging" do
|
162
|
+
before(:each) do
|
163
|
+
R10K::Logging.outputters.clear
|
164
|
+
end
|
165
|
+
|
162
166
|
it "sets the log level if :loglevel is provided" do
|
163
167
|
runner = described_class.new({:opts => :yep, :loglevel => 'FATAL'}, %w[args yes], action_class)
|
164
|
-
|
168
|
+
# The settings/overrides system causes the level to be set twice
|
169
|
+
expect(R10K::Logging).to receive(:level=).with('FATAL').twice
|
170
|
+
runner.call
|
171
|
+
end
|
172
|
+
|
173
|
+
# The logging fixture tests require a platform with syslog
|
174
|
+
if !R10K::Util::Platform.windows?
|
175
|
+
it "sets the log level if the logging.level setting is provided" do
|
176
|
+
runner = described_class.new({ opts: :yep, config: 'spec/fixtures/unit/action/r10k_logging.yaml'}, %w[args yes], action_class)
|
177
|
+
expect(R10K::Logging).to receive(:level=).with('FATAL')
|
178
|
+
runner.call
|
179
|
+
end
|
180
|
+
|
181
|
+
it "sets the outputters if logging.outputs is provided" do
|
182
|
+
runner = described_class.new({ opts: :yep, config: 'spec/fixtures/unit/action/r10k_logging.yaml' }, %w[args yes], action_class)
|
183
|
+
expect(R10K::Logging).to receive(:add_outputters).with([
|
184
|
+
{ type: 'file', parameters: { filename: 'r10k.log' } },
|
185
|
+
{ type: 'syslog' }
|
186
|
+
])
|
187
|
+
runner.call
|
188
|
+
end
|
189
|
+
|
190
|
+
it "disables the default outputter if the logging.disable_default_stderr setting is provided" do
|
191
|
+
runner = described_class.new({ opts: :yep, config: 'spec/fixtures/unit/action/r10k_logging.yaml'}, %w[args yes], action_class)
|
192
|
+
expect(R10K::Logging).to receive(:disable_default_stderr=).with(true)
|
193
|
+
runner.call
|
194
|
+
end
|
195
|
+
|
196
|
+
it "adds additional log outputs if the logging.outputs setting is provided" do
|
197
|
+
runner = described_class.new({ opts: :yep, config: 'spec/fixtures/unit/action/r10k_logging.yaml'}, %w[args yes], action_class)
|
198
|
+
runner.call
|
199
|
+
expect(R10K::Logging.outputters).to_not be_empty
|
200
|
+
end
|
201
|
+
|
202
|
+
it "disables the default output if the logging.disable_default_stderr setting is provided" do
|
203
|
+
runner = described_class.new({ opts: :yep, config: 'spec/fixtures/unit/action/r10k_logging.yaml'}, %w[args yes], action_class)
|
204
|
+
runner.call
|
205
|
+
expect(runner.logger.outputters).to satisfy { |outputs| outputs.any? { |output| output.is_a?(R10K::Logging::TerminalOutputter) && output.level == Log4r::OFF } }
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
it "doesn't add additional log outputs if the logging.outputs setting is not provided" do
|
210
|
+
runner.call
|
211
|
+
expect(R10K::Logging.outputters).to be_empty
|
212
|
+
end
|
213
|
+
|
214
|
+
it "includes the default stderr outputter" do
|
165
215
|
runner.call
|
216
|
+
expect(runner.logger.outputters).to satisfy { |outputs| outputs.any? { |output| output.is_a? R10K::Logging::TerminalOutputter } }
|
166
217
|
end
|
167
218
|
|
168
219
|
it "does not modify the loglevel if :loglevel is not provided" do
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'r10k/environment'
|
3
|
+
|
4
|
+
describe R10K::Environment::Bare do
|
5
|
+
it "warns on initialization" do
|
6
|
+
logger_spy = spy('logger')
|
7
|
+
allow_any_instance_of(described_class).to receive(:logger).and_return(logger_spy)
|
8
|
+
|
9
|
+
described_class.new('envname', '/basedir', 'dirname', {})
|
10
|
+
|
11
|
+
expect(logger_spy).to have_received(:warn).with(%r{deprecated.*envname})
|
12
|
+
end
|
13
|
+
end
|
@@ -6,21 +6,29 @@ describe R10K::Environment::Name do
|
|
6
6
|
it "does not modify the given name when no strip_component is given" do
|
7
7
|
bn = described_class.new('myenv', source: 'source', prefix: false)
|
8
8
|
expect(bn.dirname).to eq 'myenv'
|
9
|
+
expect(bn.name).to eq 'myenv'
|
10
|
+
expect(bn.original_name).to eq 'myenv'
|
9
11
|
end
|
10
12
|
|
11
13
|
it "removes the first occurance of a regex match when a regex is given" do
|
12
14
|
bn = described_class.new('myenv', source: 'source', prefix: false, strip_component: '/env/')
|
13
15
|
expect(bn.dirname).to eq 'my'
|
16
|
+
expect(bn.name).to eq 'my'
|
17
|
+
expect(bn.original_name).to eq 'myenv'
|
14
18
|
end
|
15
19
|
|
16
20
|
it "does not modify the given name when there is no regex match" do
|
17
21
|
bn = described_class.new('myenv', source: 'source', prefix: false, strip_component: '/bar/')
|
18
22
|
expect(bn.dirname).to eq 'myenv'
|
23
|
+
expect(bn.name).to eq 'myenv'
|
24
|
+
expect(bn.original_name).to eq 'myenv'
|
19
25
|
end
|
20
26
|
|
21
27
|
it "removes the given name's prefix when it matches strip_component" do
|
22
28
|
bn = described_class.new('env/prod', source: 'source', prefix: false, strip_component: 'env/')
|
23
29
|
expect(bn.dirname).to eq 'prod'
|
30
|
+
expect(bn.name).to eq 'prod'
|
31
|
+
expect(bn.original_name).to eq 'env/prod'
|
24
32
|
end
|
25
33
|
|
26
34
|
it "raises an error when given an integer" do
|
@@ -34,21 +42,29 @@ describe R10K::Environment::Name do
|
|
34
42
|
it "uses the branch name as the dirname when prefixing is off" do
|
35
43
|
bn = described_class.new('mybranch', :source => 'source', :prefix => false)
|
36
44
|
expect(bn.dirname).to eq 'mybranch'
|
45
|
+
expect(bn.name).to eq 'mybranch'
|
46
|
+
expect(bn.original_name).to eq 'mybranch'
|
37
47
|
end
|
38
48
|
|
39
49
|
it "prepends the source name when prefixing is on" do
|
40
50
|
bn = described_class.new('mybranch', :source => 'source', :prefix => true)
|
41
51
|
expect(bn.dirname).to eq 'source_mybranch'
|
52
|
+
expect(bn.name).to eq 'mybranch'
|
53
|
+
expect(bn.original_name).to eq 'mybranch'
|
42
54
|
end
|
43
55
|
|
44
56
|
it "prepends the prefix name when prefixing is overridden" do
|
45
57
|
bn = described_class.new('mybranch', {:prefix => "bar", :sourcename => 'foo'})
|
46
58
|
expect(bn.dirname).to eq 'bar_mybranch'
|
59
|
+
expect(bn.name).to eq 'mybranch'
|
60
|
+
expect(bn.original_name).to eq 'mybranch'
|
47
61
|
end
|
48
62
|
|
49
63
|
it "uses the branch name as the dirname when prefixing is nil" do
|
50
64
|
bn = described_class.new('mybranch', {:prefix => nil, :sourcename => 'foo'})
|
51
65
|
expect(bn.dirname).to eq 'mybranch'
|
66
|
+
expect(bn.name).to eq 'mybranch'
|
67
|
+
expect(bn.original_name).to eq 'mybranch'
|
52
68
|
end
|
53
69
|
end
|
54
70
|
|
@@ -149,6 +165,8 @@ describe R10K::Environment::Name do
|
|
149
165
|
it "replaces invalid characters in #{branch} with underscores" do
|
150
166
|
bn = described_class.new(branch.dup, {:correct => true})
|
151
167
|
expect(bn.dirname).to eq branch.gsub(/\W/, '_')
|
168
|
+
expect(bn.name).to eq branch
|
169
|
+
expect(bn.original_name).to eq branch
|
152
170
|
end
|
153
171
|
end
|
154
172
|
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'r10k/environment'
|
3
|
+
|
4
|
+
describe R10K::Environment::Tarball do
|
5
|
+
let(:tgz_path) do
|
6
|
+
File.expand_path('spec/fixtures/tarball/tarball.tar.gz', PROJECT_ROOT)
|
7
|
+
end
|
8
|
+
|
9
|
+
let(:checksum) { '36afcfc2378b8235902d6e647fce7479da6898354d620388646c595a1155ed67' }
|
10
|
+
let(:base_params) { { source: tgz_path, version: checksum, modules: { } } }
|
11
|
+
|
12
|
+
subject { described_class.new('envname', '/some/imaginary/path', 'dirname', base_params) }
|
13
|
+
|
14
|
+
describe "initializing" do
|
15
|
+
it "accepts valid base class initialization arguments" do
|
16
|
+
expect(subject.name).to eq 'envname'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "storing attributes" do
|
21
|
+
it "can return the environment name" do
|
22
|
+
expect(subject.name).to eq 'envname'
|
23
|
+
end
|
24
|
+
|
25
|
+
it "can return the environment basedir" do
|
26
|
+
expect(subject.basedir).to eq '/some/imaginary/path'
|
27
|
+
end
|
28
|
+
|
29
|
+
it "can return the environment dirname" do
|
30
|
+
expect(subject.dirname).to eq 'dirname'
|
31
|
+
end
|
32
|
+
|
33
|
+
it "can return the environment path" do
|
34
|
+
expect(subject.path.to_s).to eq '/some/imaginary/path/dirname'
|
35
|
+
end
|
36
|
+
|
37
|
+
it "can return the environment source" do
|
38
|
+
expect(subject.tarball.source).to eq tgz_path
|
39
|
+
end
|
40
|
+
|
41
|
+
it "can return the environment version" do
|
42
|
+
expect(subject.tarball.checksum).to eq checksum
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/spec/unit/git/cache_spec.rb
CHANGED
@@ -21,7 +21,8 @@ describe R10K::Git::Cache do
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
|
24
|
+
let(:remote) { 'git://some/git/remote' }
|
25
|
+
subject { subclass.new(remote) }
|
25
26
|
|
26
27
|
describe "updating the cache" do
|
27
28
|
it "only updates the cache once" do
|
@@ -62,18 +63,4 @@ describe R10K::Git::Cache do
|
|
62
63
|
subject.cached?
|
63
64
|
end
|
64
65
|
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
|
79
66
|
end
|
@@ -26,4 +26,23 @@ describe R10K::Git::Rugged::Cache, :unless => R10K::Util::Platform.jruby? do
|
|
26
26
|
expect(described_class.settings[:cache_root]).to eq '/some/path'
|
27
27
|
end
|
28
28
|
end
|
29
|
+
|
30
|
+
describe "remote url updates" do
|
31
|
+
before do
|
32
|
+
allow(subject.repo).to receive(:exist?).and_return true
|
33
|
+
allow(subject.repo).to receive(:fetch)
|
34
|
+
allow(subject.repo).to receive(:remotes).and_return({ 'origin' => 'git://some/git/remote' })
|
35
|
+
end
|
36
|
+
|
37
|
+
it "does not update the URLs if they match" do
|
38
|
+
expect(subject.repo).to_not receive(:update_remote)
|
39
|
+
subject.sync!
|
40
|
+
end
|
41
|
+
|
42
|
+
it "updates the remote URL if they do not match" do
|
43
|
+
allow(subject.repo).to receive(:remotes).and_return({ 'origin' => 'foo'})
|
44
|
+
expect(subject.repo).to receive(:update_remote)
|
45
|
+
subject.sync!
|
46
|
+
end
|
47
|
+
end
|
29
48
|
end
|
@@ -33,21 +33,17 @@ describe R10K::Module::Forge do
|
|
33
33
|
|
34
34
|
describe "implementing the Puppetfile spec" do
|
35
35
|
it "should implement 'branan/eight_hundred', '8.0.0'" do
|
36
|
-
expect(described_class).to be_implement('branan/eight_hundred', { version: '8.0.0' })
|
36
|
+
expect(described_class).to be_implement('branan/eight_hundred', { type: 'forge', version: '8.0.0' })
|
37
37
|
end
|
38
38
|
|
39
39
|
it "should implement 'branan-eight_hundred', '8.0.0'" do
|
40
|
-
expect(described_class).to be_implement('branan-eight_hundred', { version: '8.0.0' })
|
41
|
-
end
|
42
|
-
|
43
|
-
it "should fail with an invalid title" do
|
44
|
-
expect(described_class).to_not be_implement('branan!eight_hundred', { version: '8.0.0' })
|
40
|
+
expect(described_class).to be_implement('branan-eight_hundred', { type: 'forge', version: '8.0.0' })
|
45
41
|
end
|
46
42
|
end
|
47
43
|
|
48
44
|
describe "implementing the standard options interface" do
|
49
45
|
it "should implement {type: forge}" do
|
50
|
-
expect(described_class).to be_implement('branan-eight_hundred', {type: 'forge', version: '8.0.0', source: 'not implemented'})
|
46
|
+
expect(described_class).to be_implement('branan-eight_hundred', { type: 'forge', version: '8.0.0', source: 'not implemented' })
|
51
47
|
end
|
52
48
|
end
|
53
49
|
|
@@ -71,6 +67,12 @@ describe R10K::Module::Forge do
|
|
71
67
|
end
|
72
68
|
end
|
73
69
|
|
70
|
+
describe "invalid attributes" do
|
71
|
+
it "errors on invalid versions" do
|
72
|
+
expect { described_class.new('branan/eight_hundred', '/moduledir', { version: '_8.0.0_' }) }.to raise_error ArgumentError, /version/
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
74
76
|
describe "properties" do
|
75
77
|
subject { described_class.new('branan/eight_hundred', fixture_modulepath, { version: '8.0.0' }) }
|
76
78
|
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'r10k/module'
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
describe R10K::Module::Tarball do
|
6
|
+
include_context 'Tarball'
|
7
|
+
|
8
|
+
let(:base_params) { { type: 'tarball', source: fixture_tarball, version: fixture_checksum } }
|
9
|
+
|
10
|
+
subject do
|
11
|
+
described_class.new(
|
12
|
+
'fixture-tarball',
|
13
|
+
moduledir,
|
14
|
+
base_params,
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "setting the owner and name" do
|
19
|
+
describe "with a title of 'fixture-tarball'" do
|
20
|
+
it "sets the owner to 'fixture'" do
|
21
|
+
expect(subject.owner).to eq 'fixture'
|
22
|
+
end
|
23
|
+
|
24
|
+
it "sets the name to 'tarball'" do
|
25
|
+
expect(subject.name).to eq 'tarball'
|
26
|
+
end
|
27
|
+
|
28
|
+
it "sets the path to the given moduledir + modname" do
|
29
|
+
expect(subject.path.to_s).to eq(File.join(moduledir, 'tarball'))
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "properties" do
|
35
|
+
it "sets the module type to :tarball" do
|
36
|
+
expect(subject.properties).to include(type: :tarball)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "sets the version" do
|
40
|
+
expect(subject.properties).to include(expected: fixture_checksum)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe 'syncing the module' do
|
45
|
+
it 'defaults to keeping the spec dir' do
|
46
|
+
subject.sync
|
47
|
+
expect(Dir.exist?(File.join(moduledir, 'tarball', 'spec'))).to be(true)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "determining the status" do
|
52
|
+
it "delegates to R10K::Tarball" do
|
53
|
+
expect(subject).to receive(:tarball).twice.and_return instance_double('R10K::Tarball', cache_valid?: true, insync?: true)
|
54
|
+
expect(subject).to receive(:path).twice.and_return instance_double('Pathname', exist?: true)
|
55
|
+
|
56
|
+
expect(subject.status).to eq(:insync)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "option parsing" do
|
61
|
+
describe "version" do
|
62
|
+
context "when no version is given" do
|
63
|
+
subject { described_class.new('fixture-tarball', moduledir, base_params.reject { |k| k.eql?(:version) }) }
|
64
|
+
it "does not require a version" do
|
65
|
+
expect(subject).to be_kind_of(described_class)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -80,7 +80,8 @@ describe R10K::ModuleLoader::Puppetfile do
|
|
80
80
|
describe 'adding modules' do
|
81
81
|
let(:basedir) { '/test/basedir' }
|
82
82
|
|
83
|
-
subject { R10K::ModuleLoader::Puppetfile.new(basedir: basedir
|
83
|
+
subject { R10K::ModuleLoader::Puppetfile.new(basedir: basedir,
|
84
|
+
overrides: {modules: {exclude_spec: true}}) }
|
84
85
|
|
85
86
|
it 'should transform Forge modules with a string arg to have a version key' do
|
86
87
|
expect(R10K::Module).to receive(:from_metadata).with('puppet/test_module', subject.moduledir, hash_including(version: '1.2.3'), anything).and_call_original
|
@@ -94,11 +95,23 @@ describe R10K::ModuleLoader::Puppetfile do
|
|
94
95
|
|
95
96
|
expect {
|
96
97
|
subject.add_module('puppet/test_module', '< 1.2.0')
|
97
|
-
}.to raise_error(
|
98
|
+
}.to raise_error(ArgumentError, /module version .* is not a valid forge module version/i)
|
98
99
|
|
99
100
|
expect(subject.modules.collect(&:name)).not_to include('test_module')
|
100
101
|
end
|
101
102
|
|
103
|
+
it 'should not modify the overrides when adding modules' do
|
104
|
+
module_opts = { git: 'git@example.com:puppet/test_module.git' }
|
105
|
+
subject.add_module('puppet/test_module', module_opts)
|
106
|
+
expect(subject.instance_variable_get("@overrides")[:modules]).to eq({exclude_spec: true})
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'should read the `exclude_spec` setting in the module definition and override the overrides' do
|
110
|
+
module_opts = { git: 'git@example.com:puppet/test_module.git', exclude_spec: false }
|
111
|
+
subject.add_module('puppet/test_module', module_opts)
|
112
|
+
expect(subject.modules[0].instance_variable_get("@exclude_spec")).to be false
|
113
|
+
end
|
114
|
+
|
102
115
|
it 'should set :spec_deletable to true for modules in the basedir' do
|
103
116
|
module_opts = { git: 'git@example.com:puppet/test_module.git' }
|
104
117
|
subject.add_module('puppet/test_module', module_opts)
|
@@ -167,6 +180,7 @@ describe R10K::ModuleLoader::Puppetfile do
|
|
167
180
|
it 'should disable and not add modules that conflict with the environment' do
|
168
181
|
env = instance_double('R10K::Environment::Base')
|
169
182
|
mod = instance_double('R10K::Module::Base', name: 'conflict', origin: :puppetfile, 'origin=': nil)
|
183
|
+
allow(env).to receive(:name).and_return('conflict')
|
170
184
|
loader = R10K::ModuleLoader::Puppetfile.new(basedir: basedir, environment: env)
|
171
185
|
allow(env).to receive(:'module_conflicts?').with(mod).and_return(true)
|
172
186
|
allow(mod).to receive(:spec_deletable=)
|
@@ -187,7 +201,9 @@ describe R10K::ModuleLoader::Puppetfile do
|
|
187
201
|
context 'when belonging to an environment' do
|
188
202
|
let(:env_contents) { ['env1', 'env2' ] }
|
189
203
|
let(:env) { double(:environment, desired_contents: env_contents) }
|
190
|
-
|
204
|
+
before {
|
205
|
+
allow(env).to receive(:name).and_return('env1')
|
206
|
+
}
|
191
207
|
subject { R10K::ModuleLoader::Puppetfile.new(basedir: '/test/basedir', environment: env) }
|
192
208
|
|
193
209
|
it "includes environment's desired_contents" do
|
@@ -369,7 +385,7 @@ describe R10K::ModuleLoader::Puppetfile do
|
|
369
385
|
expect(metadata['canary']).to eq('0.0.0')
|
370
386
|
end
|
371
387
|
|
372
|
-
it 'does not load module implementations for static
|
388
|
+
it 'does not load module implementations for static versions unless the module install path does not exist on disk' do
|
373
389
|
@path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'various-modules')
|
374
390
|
subject.load_metadata
|
375
391
|
modules = subject.load[:modules].map { |mod| [ mod.name, mod ] }.to_h
|
@@ -378,7 +394,7 @@ describe R10K::ModuleLoader::Puppetfile do
|
|
378
394
|
expect(modules['concat']).to be_a_kind_of(R10K::Module::Forge)
|
379
395
|
expect(modules['rpm']).to be_a_kind_of(R10K::Module::Definition)
|
380
396
|
expect(modules['foo']).to be_a_kind_of(R10K::Module::Git)
|
381
|
-
expect(modules['bar']).to be_a_kind_of(R10K::Module::
|
397
|
+
expect(modules['bar']).to be_a_kind_of(R10K::Module::Git)
|
382
398
|
expect(modules['baz']).to be_a_kind_of(R10K::Module::Definition)
|
383
399
|
expect(modules['fizz']).to be_a_kind_of(R10K::Module::Definition)
|
384
400
|
expect(modules['buzz']).to be_a_kind_of(R10K::Module::Git)
|
data/spec/unit/module_spec.rb
CHANGED
@@ -31,12 +31,11 @@ describe R10K::Module do
|
|
31
31
|
'bar-quux',
|
32
32
|
].each do |scenario|
|
33
33
|
it "accepts a name matching #{scenario} and version nil" do
|
34
|
-
obj = R10K::Module.new(scenario, '/modulepath', { version: nil })
|
34
|
+
obj = R10K::Module.new(scenario, '/modulepath', { type: 'forge', version: nil })
|
35
35
|
expect(obj).to be_a_kind_of(R10K::Module::Forge)
|
36
36
|
end
|
37
37
|
end
|
38
|
-
[ {version: '8.0.0'},
|
39
|
-
{type: 'forge', version: '8.0.0'},
|
38
|
+
[ {type: 'forge', version: '8.0.0'},
|
40
39
|
].each do |scenario|
|
41
40
|
it "accepts a name matching bar-quux and args #{scenario.inspect}" do
|
42
41
|
obj = R10K::Module.new('bar-quux', '/modulepath', scenario)
|
@@ -65,7 +64,7 @@ describe R10K::Module do
|
|
65
64
|
end
|
66
65
|
|
67
66
|
it 'sets the expected version to what is found in the metadata' do
|
68
|
-
obj = R10K::Module.new(@title, @dirname, {version: nil})
|
67
|
+
obj = R10K::Module.new(@title, @dirname, {type: 'forge', version: nil})
|
69
68
|
expect(obj.send(:instance_variable_get, :'@expected_version')).to eq('1.2.0')
|
70
69
|
end
|
71
70
|
end
|
@@ -82,7 +81,6 @@ describe R10K::Module do
|
|
82
81
|
['name', {type: 'git', source: 'git url'}],
|
83
82
|
['name', {svn: 'svn url'}],
|
84
83
|
['name', {type: 'svn', source: 'svn url'}],
|
85
|
-
['namespace-name', {version: '8.0.0'}],
|
86
84
|
['namespace-name', {type: 'forge', version: '8.0.0'}]
|
87
85
|
].each do |(name, options)|
|
88
86
|
it 'can handle the default_branch_override option' do
|
@@ -92,12 +90,21 @@ describe R10K::Module do
|
|
92
90
|
}.not_to raise_error
|
93
91
|
end
|
94
92
|
describe 'the exclude_spec setting' do
|
93
|
+
it 'sets the exclude_spec instance variable to false by default' do
|
94
|
+
obj = R10K::Module.new(name, '/modulepath', options)
|
95
|
+
expect(obj.instance_variable_get("@exclude_spec")).to eq(false)
|
96
|
+
end
|
95
97
|
it 'sets the exclude_spec instance variable' do
|
96
98
|
obj = R10K::Module.new(name, '/modulepath', options.merge({exclude_spec: true}))
|
97
99
|
expect(obj.instance_variable_get("@exclude_spec")).to eq(true)
|
98
100
|
end
|
99
|
-
it '
|
100
|
-
options = options.merge({exclude_spec:
|
101
|
+
it 'cannot be overridden by the settings from the cli, r10k.yaml, or settings default' do
|
102
|
+
options = options.merge({exclude_spec: true, overrides: {modules: {exclude_spec: false}}})
|
103
|
+
obj = R10K::Module.new(name, '/modulepath', options)
|
104
|
+
expect(obj.instance_variable_get("@exclude_spec")).to eq(true)
|
105
|
+
end
|
106
|
+
it 'reads the setting from the cli, r10k.yaml, or settings default when not provided directly' do
|
107
|
+
options = options.merge({overrides: {modules: {exclude_spec: true}}})
|
101
108
|
obj = R10K::Module.new(name, '/modulepath', options)
|
102
109
|
expect(obj.instance_variable_get("@exclude_spec")).to eq(true)
|
103
110
|
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'r10k/tarball'
|
3
|
+
|
4
|
+
describe R10K::Tarball do
|
5
|
+
include_context 'Tarball'
|
6
|
+
|
7
|
+
subject { described_class.new('fixture-tarball', fixture_tarball, checksum: fixture_checksum) }
|
8
|
+
|
9
|
+
describe 'initialization' do
|
10
|
+
it 'initializes' do
|
11
|
+
expect(subject).to be_kind_of(described_class)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe 'downloading and caching' do
|
16
|
+
it 'downloads the source to the cache' do
|
17
|
+
# No cache present initially
|
18
|
+
expect(File.exist?(subject.cache_path)).to be(false)
|
19
|
+
expect(subject.cache_valid?).to be(false)
|
20
|
+
|
21
|
+
subject.get
|
22
|
+
|
23
|
+
expect(subject.cache_valid?).to be(true)
|
24
|
+
expect(File.exist?(subject.cache_path)).to be(true)
|
25
|
+
end
|
26
|
+
|
27
|
+
let(:raw_content) {[
|
28
|
+
'./',
|
29
|
+
'./Puppetfile',
|
30
|
+
'./metadata.json',
|
31
|
+
'./spec/',
|
32
|
+
'./environment.conf',
|
33
|
+
'./spec/1',
|
34
|
+
]}
|
35
|
+
|
36
|
+
let(:clean_content) {[
|
37
|
+
'Puppetfile',
|
38
|
+
'metadata.json',
|
39
|
+
'spec',
|
40
|
+
'environment.conf',
|
41
|
+
'spec/1',
|
42
|
+
]}
|
43
|
+
|
44
|
+
it 'returns clean paths when listing cached tarball content' do
|
45
|
+
iterator = allow(subject).to receive(:each_tarball_entry)
|
46
|
+
raw_content.each { |entry| iterator.and_yield(entry) }
|
47
|
+
|
48
|
+
expect(subject.paths).to eq(clean_content)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe 'http sources'
|
53
|
+
|
54
|
+
describe 'file sources'
|
55
|
+
|
56
|
+
describe 'syncing'
|
57
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'r10k/util/cacheable'
|
3
|
+
|
4
|
+
RSpec.describe R10K::Util::Cacheable do
|
5
|
+
|
6
|
+
subject { Object.new.extend(R10K::Util::Cacheable) }
|
7
|
+
|
8
|
+
describe "dirname sanitization" do
|
9
|
+
let(:input) { 'git://some/git/remote' }
|
10
|
+
|
11
|
+
it 'sanitizes URL to directory name' do
|
12
|
+
expect(subject.sanitized_dirname(input)).to eq('git---some-git-remote')
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'with username and password' do
|
16
|
+
let(:input) { 'https://"user:pa$$w0rd:@authenticated/git/remote' }
|
17
|
+
|
18
|
+
it 'sanitizes authenticated URL to directory name' do
|
19
|
+
expect(subject.sanitized_dirname(input)).to eq('https---authenticated-git-remote')
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|