r10k 2.3.1 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.mkd +40 -13
- data/Gemfile +1 -2
- data/README.mkd +25 -0
- data/Rakefile +3 -0
- data/doc/dynamic-environments/configuration.mkd +91 -14
- data/doc/dynamic-environments/workflow-guide.mkd +3 -3
- data/doc/puppetfile.mkd +89 -40
- data/integration/Gemfile +2 -0
- data/integration/Rakefile +41 -0
- data/integration/tests/purging/content_not_purged_at_root.rb +89 -0
- data/integration/tests/purging/default_purging.rb +125 -0
- data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_git_module_ref.rb +1 -1
- data/lib/r10k.rb +8 -1
- data/lib/r10k/action/deploy/deploy_helpers.rb +3 -3
- data/lib/r10k/action/deploy/environment.rb +35 -14
- data/lib/r10k/action/deploy/module.rb +4 -4
- data/lib/r10k/action/puppetfile/check.rb +1 -1
- data/lib/r10k/action/puppetfile/install.rb +1 -1
- data/lib/r10k/action/runner.rb +3 -3
- data/lib/r10k/deployment.rb +8 -4
- data/lib/r10k/deployment/config.rb +1 -1
- data/lib/r10k/environment/base.rb +32 -3
- data/lib/r10k/environment/git.rb +19 -6
- data/lib/r10k/feature.rb +6 -6
- data/lib/r10k/forge/module_release.rb +4 -6
- data/lib/r10k/git.rb +7 -7
- data/lib/r10k/git/alternates.rb +1 -1
- data/lib/r10k/git/cache.rb +2 -2
- data/lib/r10k/git/rugged/bare_repository.rb +29 -9
- data/lib/r10k/git/rugged/credentials.rb +8 -8
- data/lib/r10k/git/rugged/thin_repository.rb +17 -3
- data/lib/r10k/git/rugged/working_repository.rb +12 -5
- data/lib/r10k/git/shellgit/thin_repository.rb +5 -1
- data/lib/r10k/git/shellgit/working_repository.rb +16 -2
- data/lib/r10k/git/stateful_repository.rb +33 -23
- data/lib/r10k/initializers.rb +1 -1
- data/lib/r10k/keyed_factory.rb +2 -2
- data/lib/r10k/logging.rb +1 -1
- data/lib/r10k/module.rb +4 -3
- data/lib/r10k/module/base.rb +3 -2
- data/lib/r10k/module/forge.rb +9 -4
- data/lib/r10k/module/git.rb +39 -22
- data/lib/r10k/module/local.rb +1 -1
- data/lib/r10k/module/metadata_file.rb +1 -1
- data/lib/r10k/module/svn.rb +3 -1
- data/lib/r10k/puppetfile.rb +72 -11
- data/lib/r10k/settings.rb +20 -0
- data/lib/r10k/settings/collection.rb +2 -2
- data/lib/r10k/settings/container.rb +1 -1
- data/lib/r10k/settings/enum_definition.rb +11 -3
- data/lib/r10k/settings/helpers.rb +2 -2
- data/lib/r10k/settings/list.rb +1 -1
- data/lib/r10k/settings/loader.rb +6 -6
- data/lib/r10k/settings/uri_definition.rb +1 -1
- data/lib/r10k/source/base.rb +2 -2
- data/lib/r10k/source/git.rb +4 -4
- data/lib/r10k/svn/working_dir.rb +1 -1
- data/lib/r10k/util/basedir.rb +9 -9
- data/lib/r10k/util/license.rb +3 -3
- data/lib/r10k/util/purgeable.rb +50 -24
- data/lib/r10k/util/setopts.rb +1 -1
- data/lib/r10k/util/subprocess.rb +3 -3
- data/lib/r10k/util/symbolize_keys.rb +1 -1
- data/lib/r10k/version.rb +1 -1
- data/locales/config.yaml +21 -0
- data/r10k.gemspec +3 -0
- data/spec/fixtures/unit/puppetfile/valid-forge-with-version/Puppetfile +1 -0
- data/spec/fixtures/unit/puppetfile/valid-forge-without-version/Puppetfile +1 -0
- data/spec/fixtures/unit/util/purgeable/managed_one/expected_1 +0 -0
- data/spec/fixtures/unit/util/purgeable/managed_one/managed_subdir_1/subdir_expected_1 +0 -0
- data/spec/fixtures/unit/util/purgeable/managed_one/managed_subdir_1/subdir_unmanaged_1 +0 -0
- data/spec/fixtures/unit/util/purgeable/managed_one/unmanaged_1 +0 -0
- data/spec/fixtures/unit/util/purgeable/managed_two/expected_2 +0 -0
- data/spec/fixtures/unit/util/purgeable/managed_two/unmanaged_2 +0 -0
- data/spec/integration/git/stateful_repository_spec.rb +39 -21
- data/spec/r10k-mocks/mock_config.rb +4 -0
- data/spec/spec_helper.rb +3 -0
- data/spec/unit/action/deploy/environment_spec.rb +71 -13
- data/spec/unit/environment/base_spec.rb +71 -0
- data/spec/unit/forge/module_release_spec.rb +7 -10
- data/spec/unit/git/stateful_repository_spec.rb +6 -6
- data/spec/unit/module/git_spec.rb +156 -5
- data/spec/unit/module_spec.rb +3 -3
- data/spec/unit/puppetfile_spec.rb +115 -0
- data/spec/unit/util/purgeable_spec.rb +230 -0
- metadata +45 -18
- data/integration/test_run_scripts/README.mkd +0 -5
- data/integration/test_run_scripts/all_tests-rugged-pe-centos6.sh +0 -20
- data/integration/test_run_scripts/all_tests-rugged-pe-rhel7.sh +0 -20
- data/integration/test_run_scripts/all_tests-rugged-pe-sles11.sh +0 -20
- data/integration/test_run_scripts/all_tests-rugged-pe-ubuntu1204.sh +0 -20
- data/integration/test_run_scripts/all_tests-rugged-pe-ubuntu1404.sh +0 -20
- data/integration/test_run_scripts/all_tests-shellgit-pe-centos6.sh +0 -20
- data/integration/test_run_scripts/all_tests-shellgit-pe-rhel7.sh +0 -20
- data/integration/test_run_scripts/all_tests-shellgit-pe-sles11.sh +0 -20
- data/integration/test_run_scripts/all_tests-shellgit-pe-ubuntu1204.sh +0 -20
- data/integration/test_run_scripts/all_tests-shellgit-pe-ubuntu1404.sh +0 -20
- data/integration/test_run_scripts/basic_functionality/all_tests-pe-centos6.sh +0 -20
- data/integration/test_run_scripts/command_line/all_tests-pe-centos6.sh +0 -20
- data/integration/test_run_scripts/git_source/all_tests-pe-centos6.sh +0 -20
- data/integration/test_run_scripts/user_scenario/basic_workflow/all_tests-pe-centos6.sh +0 -20
- data/integration/test_run_scripts/user_scenario/complex_workflow/all_tests-pe-centos6.sh +0 -20
data/lib/r10k/util/setopts.rb
CHANGED
@@ -44,7 +44,7 @@ module R10K
|
|
44
44
|
instance_variable_set("@#{rhs}".to_sym, value)
|
45
45
|
end
|
46
46
|
else
|
47
|
-
raise ArgumentError, "
|
47
|
+
raise ArgumentError, _("%{class_name} cannot handle option '%{key}'") % {class_name: self.class.name, key: key}
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
data/lib/r10k/util/subprocess.rb
CHANGED
@@ -66,15 +66,15 @@ module R10K
|
|
66
66
|
subprocess = self.class.runner.new(@argv)
|
67
67
|
subprocess.cwd = @cwd if @cwd
|
68
68
|
|
69
|
-
logmsg = "Starting process:
|
69
|
+
logmsg = _("Starting process: %{args}") % {args: @argv.inspect}
|
70
70
|
logmsg << "(cwd: #{@cwd})" if @cwd
|
71
71
|
logger.debug2(logmsg)
|
72
72
|
|
73
73
|
result = subprocess.run
|
74
|
-
logger.debug2("Finished process:\n
|
74
|
+
logger.debug2(_("Finished process:\n%{result}") % {result: result.format})
|
75
75
|
|
76
76
|
if @raise_on_fail && result.failed?
|
77
|
-
raise SubprocessError.new("Command exited with non-zero exit code", :result => result)
|
77
|
+
raise SubprocessError.new(_("Command exited with non-zero exit code"), :result => result)
|
78
78
|
end
|
79
79
|
|
80
80
|
result
|
@@ -14,7 +14,7 @@ module R10K
|
|
14
14
|
hash.keys.each do |key|
|
15
15
|
if key.is_a?(String)
|
16
16
|
if hash.key?(key.to_sym)
|
17
|
-
raise TypeError, "An existing interned key for
|
17
|
+
raise TypeError, _("An existing interned key for %{key} exists, cannot overwrite") % {key: key}
|
18
18
|
end
|
19
19
|
hash[key.to_sym] = hash.delete(key)
|
20
20
|
key = key.to_sym
|
data/lib/r10k/version.rb
CHANGED
data/locales/config.yaml
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
---
|
2
|
+
# This is the project-specific configuration file for setting up
|
3
|
+
# fast_gettext for your project.
|
4
|
+
gettext:
|
5
|
+
# This is used for the name of the .pot and .po files; they will be
|
6
|
+
# called <project_name>.pot?
|
7
|
+
project_name: 'r10k'
|
8
|
+
# This is used in comments in the .pot and .po files to indicate what
|
9
|
+
# project the files belong to and should bea little more desctiptive than
|
10
|
+
# <project_name>
|
11
|
+
package_name: r10k
|
12
|
+
# The locale that the default messages in the .pot file are in
|
13
|
+
default_locale: en
|
14
|
+
# The email used for sending bug reports.
|
15
|
+
bugs_address: docs@puppetlabs.com
|
16
|
+
# The holder of the copyright.
|
17
|
+
copyright_holder: Puppet, Inc.
|
18
|
+
# Patterns for +Dir.glob+ used to find all files that might contain
|
19
|
+
# translatable content, relative to the project root directory
|
20
|
+
source_files:
|
21
|
+
- 'lib/**/*.rb'
|
data/r10k.gemspec
CHANGED
@@ -32,8 +32,11 @@ Gem::Specification.new do |s|
|
|
32
32
|
s.add_dependency 'semantic_puppet', '~> 0.1.0'
|
33
33
|
s.add_dependency 'minitar'
|
34
34
|
|
35
|
+
s.add_dependency 'gettext-setup', '~> 0.5'
|
36
|
+
|
35
37
|
s.add_development_dependency 'rspec', '~> 3.1'
|
36
38
|
|
39
|
+
s.add_development_dependency 'rake'
|
37
40
|
|
38
41
|
s.add_development_dependency 'yard', '~> 0.8.7.3'
|
39
42
|
|
@@ -0,0 +1 @@
|
|
1
|
+
mod 'puppetlabs/apt', '2.1.1'
|
@@ -0,0 +1 @@
|
|
1
|
+
mod 'puppetlabs/apt'
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -9,20 +9,21 @@ describe R10K::Git::StatefulRepository do
|
|
9
9
|
|
10
10
|
let(:cacherepo) { R10K::Git.cache.generate(remote) }
|
11
11
|
let(:thinrepo) { R10K::Git.thin_repository.new(basedir, dirname, cacherepo) }
|
12
|
+
let(:ref) { '0.9.x' }
|
12
13
|
|
13
|
-
subject { described_class.new(
|
14
|
+
subject { described_class.new(remote, basedir, dirname) }
|
14
15
|
|
15
16
|
describe 'status' do
|
16
17
|
describe "when the directory does not exist" do
|
17
18
|
it "is absent" do
|
18
|
-
expect(subject.status).to eq :absent
|
19
|
+
expect(subject.status(ref)).to eq :absent
|
19
20
|
end
|
20
21
|
end
|
21
22
|
|
22
23
|
describe "when the directory is not a git repository" do
|
23
24
|
it "is mismatched" do
|
24
25
|
thinrepo.path.mkdir
|
25
|
-
expect(subject.status).to eq :mismatched
|
26
|
+
expect(subject.status(ref)).to eq :mismatched
|
26
27
|
end
|
27
28
|
end
|
28
29
|
|
@@ -30,7 +31,7 @@ describe R10K::Git::StatefulRepository do
|
|
30
31
|
it "is mismatched" do
|
31
32
|
thinrepo.path.mkdir
|
32
33
|
File.open("#{thinrepo.path}/.git", "w") {}
|
33
|
-
expect(subject.status).to eq :mismatched
|
34
|
+
expect(subject.status(ref)).to eq :mismatched
|
34
35
|
end
|
35
36
|
end
|
36
37
|
|
@@ -38,74 +39,91 @@ describe R10K::Git::StatefulRepository do
|
|
38
39
|
it "is mismatched" do
|
39
40
|
thinrepo.clone(remote, {:ref => '1.0.0'})
|
40
41
|
allow(subject.repo).to receive(:origin).and_return('http://some.site/repo.git')
|
41
|
-
expect(subject.status).to eq :mismatched
|
42
|
+
expect(subject.status(ref)).to eq :mismatched
|
42
43
|
end
|
43
44
|
end
|
44
45
|
|
45
46
|
describe "when the wrong ref is checked out" do
|
46
47
|
it "is outdated" do
|
47
48
|
thinrepo.clone(remote, {:ref => '1.0.0'})
|
48
|
-
expect(subject.status).to eq :outdated
|
49
|
+
expect(subject.status(ref)).to eq :outdated
|
49
50
|
end
|
50
51
|
end
|
51
52
|
|
52
53
|
describe "when the ref is a branch and the cache is not synced" do
|
53
54
|
it "is outdated" do
|
54
|
-
thinrepo.clone(remote, {:ref =>
|
55
|
+
thinrepo.clone(remote, {:ref => ref})
|
55
56
|
cacherepo.reset!
|
56
|
-
expect(subject.status).to eq :outdated
|
57
|
+
expect(subject.status(ref)).to eq :outdated
|
57
58
|
end
|
58
59
|
end
|
59
60
|
|
60
61
|
describe "when the ref can't be resolved" do
|
61
|
-
|
62
|
+
let(:ref) { '1.1.x' }
|
62
63
|
|
63
64
|
it "is outdated" do
|
64
65
|
thinrepo.clone(remote, {:ref => '0.9.x'})
|
65
|
-
expect(subject.status).to eq :outdated
|
66
|
+
expect(subject.status(ref)).to eq :outdated
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe "when the workdir has local modifications" do
|
71
|
+
it "is dirty" do
|
72
|
+
thinrepo.clone(remote, {:ref => ref})
|
73
|
+
File.open(File.join(thinrepo.path, 'README.markdown'), 'a') { |f| f.write('local modifications!') }
|
74
|
+
|
75
|
+
expect(subject.status(ref)).to eq :dirty
|
66
76
|
end
|
67
77
|
end
|
68
78
|
|
69
79
|
describe "if the right ref is checked out" do
|
70
80
|
it "is insync" do
|
71
|
-
thinrepo.clone(remote, {:ref =>
|
72
|
-
expect(subject.status).to eq :insync
|
81
|
+
thinrepo.clone(remote, {:ref => ref})
|
82
|
+
expect(subject.status(ref)).to eq :insync
|
73
83
|
end
|
74
84
|
end
|
75
85
|
end
|
76
86
|
|
77
87
|
describe "syncing" do
|
78
|
-
|
79
88
|
describe "when the ref is unresolvable" do
|
80
|
-
|
89
|
+
let(:ref) { '1.1.x' }
|
81
90
|
|
82
91
|
it "raises an error" do
|
83
92
|
expect {
|
84
|
-
subject.sync
|
93
|
+
subject.sync(ref)
|
85
94
|
}.to raise_error(R10K::Git::UnresolvableRefError)
|
86
95
|
end
|
87
96
|
end
|
88
97
|
|
89
98
|
describe "when the repo is absent" do
|
90
99
|
it "creates the repo" do
|
91
|
-
subject.sync
|
92
|
-
expect(subject.status).to eq :insync
|
100
|
+
subject.sync(ref)
|
101
|
+
expect(subject.status(ref)).to eq :insync
|
93
102
|
end
|
94
103
|
end
|
95
104
|
|
96
105
|
describe "when the repo is mismatched" do
|
97
106
|
it "removes and recreates the repo" do
|
98
107
|
thinrepo.path.mkdir
|
99
|
-
subject.sync
|
100
|
-
expect(subject.status).to eq :insync
|
108
|
+
subject.sync(ref)
|
109
|
+
expect(subject.status(ref)).to eq :insync
|
101
110
|
end
|
102
111
|
end
|
103
112
|
|
104
113
|
describe "when the repo is out of date" do
|
105
114
|
it "updates the repository" do
|
106
115
|
thinrepo.clone(remote, {:ref => '1.0.0'})
|
107
|
-
subject.sync
|
108
|
-
expect(subject.status).to eq :insync
|
116
|
+
subject.sync(ref)
|
117
|
+
expect(subject.status(ref)).to eq :insync
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
describe "when the workdir is dirty" do
|
122
|
+
it "overwrites local modificatios" do
|
123
|
+
thinrepo.clone(remote, {:ref => ref})
|
124
|
+
File.open(File.join(thinrepo.path, 'README.markdown'), 'a') { |f| f.write('local modifications!') }
|
125
|
+
subject.sync(ref)
|
126
|
+
expect(subject.status(ref)).to eq :insync
|
109
127
|
end
|
110
128
|
end
|
111
129
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -23,6 +23,9 @@ require 'matchers/exit_with'
|
|
23
23
|
require 'matchers/match_realpath'
|
24
24
|
require 'r10k-mocks'
|
25
25
|
|
26
|
+
# Add a negated version of the change matcher.
|
27
|
+
RSpec::Matchers.define_negated_matcher :not_change, :change
|
28
|
+
|
26
29
|
RSpec.configure do |config|
|
27
30
|
config.before(:all) do
|
28
31
|
Log4r::Logger.global.level = Log4r::OFF
|
@@ -23,28 +23,28 @@ describe R10K::Action::Deploy::Environment do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
describe "when called" do
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
:
|
30
|
-
:
|
31
|
-
|
32
|
-
|
33
|
-
:environments => %w[first second third],
|
34
|
-
}
|
26
|
+
let(:mock_config) do
|
27
|
+
R10K::Deployment::MockConfig.new(
|
28
|
+
:sources => {
|
29
|
+
:control => {
|
30
|
+
:type => :mock,
|
31
|
+
:basedir => '/some/nonexistent/path/control',
|
32
|
+
:environments => %w[first second third],
|
35
33
|
}
|
36
|
-
|
37
|
-
|
34
|
+
}
|
35
|
+
)
|
36
|
+
end
|
38
37
|
|
38
|
+
describe "with an environment that doesn't exist" do
|
39
39
|
let(:deployment) do
|
40
|
-
R10K::Deployment.new(
|
40
|
+
R10K::Deployment.new(mock_config)
|
41
41
|
end
|
42
42
|
|
43
43
|
before do
|
44
44
|
expect(R10K::Deployment).to receive(:new).and_return(deployment)
|
45
45
|
end
|
46
46
|
|
47
|
-
subject { described_class.new({config: "/some/nonexistent/path"
|
47
|
+
subject { described_class.new({config: "/some/nonexistent/path"}, %w[not_an_environment]) }
|
48
48
|
|
49
49
|
it "logs that the environments can't be deployed and returns false" do
|
50
50
|
expect(subject.logger).to receive(:error).with("Environment(s) 'not_an_environment' cannot be found in any source and will not be deployed.")
|
@@ -52,5 +52,63 @@ describe R10K::Action::Deploy::Environment do
|
|
52
52
|
expect(subject.call).to eq false
|
53
53
|
end
|
54
54
|
end
|
55
|
+
|
56
|
+
describe "purge_levels" do
|
57
|
+
let(:settings) { { deploy: { purge_levels: purge_levels } } }
|
58
|
+
|
59
|
+
let(:deployment) do
|
60
|
+
R10K::Deployment.new(mock_config.merge(settings))
|
61
|
+
end
|
62
|
+
|
63
|
+
before do
|
64
|
+
expect(R10K::Deployment).to receive(:new).and_return(deployment)
|
65
|
+
end
|
66
|
+
|
67
|
+
subject { described_class.new({ config: "/some/nonexistent/path", puppetfile: true }, %w[first], settings) }
|
68
|
+
|
69
|
+
describe "deployment purge level" do
|
70
|
+
let(:purge_levels) { [:deployment] }
|
71
|
+
|
72
|
+
it "only logs about purging deployment" do
|
73
|
+
expect(subject.logger).to receive(:debug).with(/purging unmanaged environments for deployment/i)
|
74
|
+
expect(subject.logger).to_not receive(:debug).with(/purging unmanaged content for environment/i)
|
75
|
+
expect(subject.logger).to_not receive(:debug).with(/purging unmanaged puppetfile content/i)
|
76
|
+
|
77
|
+
subject.call
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe "environment purge level" do
|
82
|
+
let(:purge_levels) { [:environment] }
|
83
|
+
|
84
|
+
it "only logs about purging environment" do
|
85
|
+
expect(subject.logger).to receive(:debug).with(/purging unmanaged content for environment/i)
|
86
|
+
expect(subject.logger).to_not receive(:debug).with(/purging unmanaged environments for deployment/i)
|
87
|
+
expect(subject.logger).to_not receive(:debug).with(/purging unmanaged puppetfile content/i)
|
88
|
+
|
89
|
+
subject.call
|
90
|
+
end
|
91
|
+
|
92
|
+
it "logs that environment was not purged if deploy failed" do
|
93
|
+
expect(subject).to receive(:visit_puppetfile) { subject.instance_variable_set(:@visit_ok, false) }
|
94
|
+
|
95
|
+
expect(subject.logger).to receive(:debug).with(/not purging unmanaged content for environment/i)
|
96
|
+
|
97
|
+
subject.call
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
describe "puppetfile purge level" do
|
102
|
+
let(:purge_levels) { [:puppetfile] }
|
103
|
+
|
104
|
+
it "only logs about purging puppetfile" do
|
105
|
+
expect(subject.logger).to receive(:debug).with(/purging unmanaged puppetfile content/i)
|
106
|
+
expect(subject.logger).to_not receive(:debug).with(/purging unmanaged environments for deployment/i)
|
107
|
+
expect(subject.logger).to_not receive(:debug).with(/purging unmanaged content for environment/i)
|
108
|
+
|
109
|
+
subject.call
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
55
113
|
end
|
56
114
|
end
|
@@ -35,4 +35,75 @@ describe R10K::Environment::Base do
|
|
35
35
|
subject.accept(visitor)
|
36
36
|
end
|
37
37
|
end
|
38
|
+
|
39
|
+
describe "#whitelist" do
|
40
|
+
let(:whitelist) do
|
41
|
+
['**/*.xpp', 'custom', '*.tmp']
|
42
|
+
end
|
43
|
+
|
44
|
+
it "combines given patterns with full_path to env" do
|
45
|
+
expect(subject.whitelist(whitelist)).to all(start_with(subject.path.to_s))
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "#purge_exclusions" do
|
50
|
+
let(:mock_env) { instance_double("R10K::Environment::Base") }
|
51
|
+
let(:mock_puppetfile) { instance_double("R10K::Puppetfile", :environment= => true, :environment => mock_env) }
|
52
|
+
|
53
|
+
before(:each) do
|
54
|
+
allow(mock_puppetfile).to receive(:managed_directories).and_return([])
|
55
|
+
allow(mock_puppetfile).to receive(:desired_contents).and_return([])
|
56
|
+
allow(R10K::Puppetfile).to receive(:new).and_return(mock_puppetfile)
|
57
|
+
end
|
58
|
+
|
59
|
+
it "excludes .r10k-deploy.json" do
|
60
|
+
expect(subject.purge_exclusions).to include(/r10k-deploy\.json/)
|
61
|
+
end
|
62
|
+
|
63
|
+
it "excludes puppetfile managed directories" do
|
64
|
+
managed_dirs = [
|
65
|
+
'/some/imaginary/path/env_name/modules',
|
66
|
+
'/some/imaginary/path/env_name/data',
|
67
|
+
]
|
68
|
+
|
69
|
+
expect(mock_puppetfile).to receive(:managed_directories).and_return(managed_dirs)
|
70
|
+
|
71
|
+
exclusions = subject.purge_exclusions
|
72
|
+
|
73
|
+
managed_dirs.each do |dir|
|
74
|
+
expect(exclusions).to include(dir)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
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
|
+
|
87
|
+
before(:each) do
|
88
|
+
allow(File).to receive(:directory?).with(/^\/some\/imaginary\/path/).and_return(true)
|
89
|
+
|
90
|
+
expect(mock_puppetfile).to receive(:desired_contents).and_return(desired_contents)
|
91
|
+
end
|
92
|
+
|
93
|
+
it "excludes desired directory contents with glob" do
|
94
|
+
exclusions = subject.purge_exclusions
|
95
|
+
|
96
|
+
expect(exclusions).to include(/#{Regexp.escape(File.join('apache', '**', '*'))}$/)
|
97
|
+
expect(exclusions).to include(/#{Regexp.escape(File.join('site', '**', '*'))}$/)
|
98
|
+
end
|
99
|
+
|
100
|
+
it "excludes ancestors of desired directories" do
|
101
|
+
exclusions = subject.purge_exclusions
|
102
|
+
|
103
|
+
expect(exclusions).to include(/modules$/)
|
104
|
+
expect(exclusions).to include(/data\/local$/)
|
105
|
+
expect(exclusions).to include(/data$/)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
38
109
|
end
|
@@ -40,17 +40,14 @@ describe R10K::Forge::ModuleRelease do
|
|
40
40
|
subject.unpack(target_dir)
|
41
41
|
end
|
42
42
|
|
43
|
-
it "
|
44
|
-
logger_dbl = double(Log4r::Logger)
|
43
|
+
it "logs a warning if symlinks are present during the unpacking process" do
|
44
|
+
logger_dbl = double(Log4r::Logger, debug1: true, debug2: true)
|
45
45
|
allow(subject).to receive(:logger).and_return(logger_dbl)
|
46
|
-
|
47
|
-
|
48
|
-
expect(logger_dbl).to receive(:
|
49
|
-
|
50
|
-
|
51
|
-
subject.unpack(target_dir)
|
52
|
-
}.to raise_error(R10K::Error, "Symlinks are unsupported and were not unpacked from the module tarball. " +
|
53
|
-
"#{subject.forge_release.slug} contained these ignored symlinks: #{file_lists[:symlinks]}")
|
46
|
+
allow(PuppetForge::Unpacker).to receive(:unpack).and_return(file_lists)
|
47
|
+
|
48
|
+
expect(logger_dbl).to receive(:warn).with(/symlinks are unsupported.*#{Regexp.escape(subject.forge_release.slug)}/i)
|
49
|
+
|
50
|
+
subject.unpack(target_dir)
|
54
51
|
end
|
55
52
|
end
|
56
53
|
|