r10k 3.11.0 → 3.14.0
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 +2 -2
- data/.travis.yml +1 -1
- data/CHANGELOG.mkd +34 -0
- data/doc/dynamic-environments/configuration.mkd +35 -7
- data/doc/dynamic-environments/usage.mkd +26 -0
- data/doc/puppetfile.mkd +16 -4
- data/integration/tests/basic_functionality/basic_deployment.rb +176 -0
- 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 +13 -8
- data/lib/r10k/action/deploy/module.rb +14 -10
- 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 +6 -0
- data/lib/r10k/action/visitor.rb +3 -0
- data/lib/r10k/cli/deploy.rb +1 -0
- data/lib/r10k/cli/puppetfile.rb +0 -1
- data/lib/r10k/content_synchronizer.rb +16 -4
- data/lib/r10k/environment/bare.rb +4 -7
- data/lib/r10k/environment/base.rb +64 -11
- 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 +6 -10
- 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/base_repository.rb +12 -1
- data/lib/r10k/git/rugged/cache.rb +8 -0
- data/lib/r10k/git/stateful_repository.rb +9 -0
- data/lib/r10k/initializers.rb +21 -7
- data/lib/r10k/logging.rb +78 -1
- data/lib/r10k/module/base.rb +5 -1
- data/lib/r10k/module/definition.rb +64 -0
- data/lib/r10k/module/forge.rb +10 -2
- data/lib/r10k/module/git.rb +22 -1
- data/lib/r10k/module/local.rb +6 -3
- data/lib/r10k/module/svn.rb +10 -0
- data/lib/r10k/module/tarball.rb +101 -0
- data/lib/r10k/module.rb +21 -2
- data/lib/r10k/module_loader/puppetfile/dsl.rb +8 -3
- data/lib/r10k/module_loader/puppetfile.rb +109 -30
- data/lib/r10k/puppetfile.rb +1 -2
- data/lib/r10k/settings.rb +46 -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 +6 -2
- 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 +119 -71
- 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/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_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/r10k-mocks/mock_env.rb +3 -0
- data/spec/r10k-mocks/mock_source.rb +7 -3
- data/spec/shared-contexts/tarball.rb +32 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/unit/action/deploy/environment_spec.rb +80 -30
- data/spec/unit/action/deploy/module_spec.rb +52 -64
- 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 +52 -9
- data/spec/unit/environment/bare_spec.rb +13 -0
- data/spec/unit/environment/base_spec.rb +30 -17
- data/spec/unit/environment/git_spec.rb +2 -2
- data/spec/unit/environment/name_spec.rb +18 -0
- data/spec/unit/environment/plain_spec.rb +8 -0
- data/spec/unit/environment/svn_spec.rb +4 -3
- data/spec/unit/environment/tarball_spec.rb +45 -0
- data/spec/unit/environment/with_modules_spec.rb +3 -2
- data/spec/unit/git/cache_spec.rb +2 -15
- data/spec/unit/git/rugged/cache_spec.rb +19 -0
- data/spec/unit/module/base_spec.rb +8 -8
- data/spec/unit/module/forge_spec.rb +32 -4
- data/spec/unit/module/git_spec.rb +51 -10
- data/spec/unit/module/svn_spec.rb +18 -6
- data/spec/unit/module/tarball_spec.rb +70 -0
- data/spec/unit/module_loader/puppetfile_spec.rb +96 -31
- data/spec/unit/puppetfile_spec.rb +2 -2
- data/spec/unit/settings_spec.rb +25 -2
- 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 +44 -17
data/r10k.yaml.example
CHANGED
@@ -110,3 +110,31 @@ forge:
|
|
110
110
|
# The 'baseurl' setting indicates where Forge modules should be installed
|
111
111
|
# from. This defaults to 'https://forgeapi.puppetlabs.com'
|
112
112
|
#baseurl: 'https://forgemirror.example.com'
|
113
|
+
|
114
|
+
# Configuration options on how R10k should log its actions
|
115
|
+
logging:
|
116
|
+
# The 'level' setting sets the default log level to run R10k actions at.
|
117
|
+
# This value will be overridden by any value set through the command line.
|
118
|
+
#level: warn
|
119
|
+
|
120
|
+
# Specify additional log outputs here, any log4r outputter can be used.
|
121
|
+
# If no log level is specified then the output will use the global level.
|
122
|
+
#outputs:
|
123
|
+
# - type: file
|
124
|
+
# level: debug
|
125
|
+
# parameters:
|
126
|
+
# filename: /var/log/r10k.log
|
127
|
+
# trunc: true
|
128
|
+
# - type: syslog
|
129
|
+
# - type: email
|
130
|
+
# only_at: [fatal]
|
131
|
+
# parameters:
|
132
|
+
# from: r10k@example.com
|
133
|
+
# to: sysadmins@example.com
|
134
|
+
# server: smtp.example.com
|
135
|
+
# subject: Fatal R10k error occurred
|
136
|
+
|
137
|
+
# The 'disable_default_stderr' setting specifies if the default output on
|
138
|
+
# stderr should be active or not, in case R10k is to be run entirely
|
139
|
+
# through scripts or cronjobs where console output is unwelcome.
|
140
|
+
#disable_default_stderr: false
|
Binary file
|
@@ -0,0 +1,10 @@
|
|
1
|
+
mod 'puppetlabs/apt', '2.1.1'
|
2
|
+
mod 'puppetlabs/stdlib', :latest
|
3
|
+
mod 'puppetlabs/concat'
|
4
|
+
mod 'puppetlabs/rpm', '2.1.1-pre1'
|
5
|
+
mod 'foo', git: 'this/remote', branch: 'main'
|
6
|
+
mod 'bar', git: 'this/remote', tag: 'v1.2.3'
|
7
|
+
mod 'baz', git: 'this/remote', commit: '123abc456'
|
8
|
+
mod 'fizz', git: 'this/remote', ref: '1234567890abcdef1234567890abcdef12345678'
|
9
|
+
mod 'buzz', git: 'this/remote', ref: 'refs/heads/main'
|
10
|
+
mod 'canary', local: true
|
@@ -0,0 +1,10 @@
|
|
1
|
+
mod 'puppetlabs/apt', '3.0.0'
|
2
|
+
mod 'puppetlabs/stdlib', :latest
|
3
|
+
mod 'puppetlabs/concat'
|
4
|
+
mod 'puppetlabs/rpm', '2.1.1-pre1'
|
5
|
+
mod 'foo', git: 'this/remote', branch: 'main'
|
6
|
+
mod 'bar', git: 'this/remote', tag: 'v1.2.3'
|
7
|
+
mod 'baz', git: 'this/remote', commit: '123abc456'
|
8
|
+
mod 'fizz', git: 'this/remote', ref: '1234567890abcdef1234567890abcdef12345678'
|
9
|
+
mod 'buzz', git: 'this/remote', ref: 'refs/heads/main'
|
10
|
+
mod 'canary', local: true
|
@@ -0,0 +1 @@
|
|
1
|
+
../expected_1
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
../../managed_two
|
@@ -0,0 +1 @@
|
|
1
|
+
spec/fixtures/unit/util/purgeable/managed_one/managed_subdir_1
|
@@ -0,0 +1 @@
|
|
1
|
+
spec/fixtures/unit/util/purgeable/managed_one/expected_1
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'r10k/git/rugged/cache'
|
3
|
+
|
4
|
+
describe R10K::Git::Rugged::Cache, :if => R10K::Features.available?(:rugged) do
|
5
|
+
include_context 'Git integration'
|
6
|
+
|
7
|
+
let(:dirname) { 'working-repo' }
|
8
|
+
let(:remote_name) { 'origin' }
|
9
|
+
|
10
|
+
subject { described_class.new(remote) }
|
11
|
+
|
12
|
+
context "syncing with the remote" do
|
13
|
+
before(:each) do
|
14
|
+
subject.reset!
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "with the correct configuration" do
|
18
|
+
it "is able to sync with the remote" do
|
19
|
+
subject.sync
|
20
|
+
expect(subject.synced?).to eq(true)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "with a out of date cached remote" do
|
25
|
+
it "updates the cached remote configuration" do
|
26
|
+
subject.repo.update_remote('foo', remote_name)
|
27
|
+
expect(subject.repo.remotes[remote_name]).to eq('foo')
|
28
|
+
subject.sync
|
29
|
+
expect(subject.repo.remotes[remote_name]).to eq(remote)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'r10k/util/purgeable'
|
3
|
+
require 'r10k/util/cleaner'
|
4
|
+
|
5
|
+
require 'tmpdir'
|
6
|
+
|
7
|
+
RSpec.describe R10K::Util::Purgeable do
|
8
|
+
it 'purges only unmanaged files' do
|
9
|
+
Dir.mktmpdir do |envdir|
|
10
|
+
managed_directory = "#{envdir}/managed_one"
|
11
|
+
desired_contents = [
|
12
|
+
"#{managed_directory}/expected_1",
|
13
|
+
"#{managed_directory}/managed_subdir_1",
|
14
|
+
"#{managed_directory}/managed_symlink_dir",
|
15
|
+
"#{managed_directory}/managed_subdir_1/subdir_expected_1",
|
16
|
+
"#{managed_directory}/managed_subdir_1/managed_symlink_file",
|
17
|
+
]
|
18
|
+
|
19
|
+
FileUtils.cp_r('spec/fixtures/unit/util/purgeable/managed_one/',
|
20
|
+
managed_directory)
|
21
|
+
|
22
|
+
cleaner = R10K::Util::Cleaner.new([managed_directory], desired_contents)
|
23
|
+
|
24
|
+
cleaner.purge!({ recurse: true, whitelist: ["**/subdir_allowlisted_2"] })
|
25
|
+
|
26
|
+
# Files present after purge
|
27
|
+
expect(File.exist?("#{managed_directory}/expected_1")).to be true
|
28
|
+
expect(File.exist?("#{managed_directory}/managed_subdir_1")).to be true
|
29
|
+
expect(File.exist?("#{managed_directory}/managed_symlink_dir")).to be true
|
30
|
+
expect(File.exist?("#{managed_directory}/managed_subdir_1/subdir_expected_1")).to be true
|
31
|
+
expect(File.exist?("#{managed_directory}/managed_subdir_1/managed_symlink_file")).to be true
|
32
|
+
expect(File.exist?("#{managed_directory}/managed_subdir_1/subdir_allowlisted_2")).to be true
|
33
|
+
|
34
|
+
# Purged files
|
35
|
+
expect(File.exist?("#{managed_directory}/unmanaged_1")).to be false
|
36
|
+
expect(File.exist?("#{managed_directory}/managed_subdir_1/unmanaged_symlink_dir")).to be false
|
37
|
+
expect(File.exist?("#{managed_directory}/unmanaged_symlink_file")).to be false
|
38
|
+
expect(File.exist?("#{managed_directory}/managed_subdir_1/subdir_unmanaged_1")).to be false
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/spec/r10k-mocks/mock_env.rb
CHANGED
@@ -5,9 +5,13 @@ class R10K::Source::Mock < R10K::Source::Base
|
|
5
5
|
R10K::Source.register(:mock, self)
|
6
6
|
|
7
7
|
def environments
|
8
|
-
|
9
|
-
|
8
|
+
if @_environments.nil?
|
9
|
+
corrected_environment_names = @options[:environments].map do |env|
|
10
|
+
R10K::Environment::Name.new(env, :prefix => @prefix, :invalid => 'correct_and_warn')
|
11
|
+
end
|
12
|
+
@_environments = corrected_environment_names.map { |env| R10K::Environment::Mock.new(env.name, @basedir, env.dirname, { overrides: @options[:overrides] }) }
|
10
13
|
end
|
11
|
-
|
14
|
+
|
15
|
+
@_environments
|
12
16
|
end
|
13
17
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'tmpdir'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
shared_context "Tarball" do
|
5
|
+
# Suggested subject:
|
6
|
+
#
|
7
|
+
# subject { described_class.new('fixture-tarball', fixture_tarball, checksum: fixture_checksum) }
|
8
|
+
#
|
9
|
+
let(:fixture_tarball) do
|
10
|
+
File.expand_path('spec/fixtures/tarball/tarball.tar.gz', PROJECT_ROOT)
|
11
|
+
end
|
12
|
+
|
13
|
+
let(:fixture_checksum) { '292e692ad18faabd4f9b21037d51f0185e04b69f82c522a54af91fb5b88c2d3b' }
|
14
|
+
|
15
|
+
# Use tmpdir for cached tarballs
|
16
|
+
let(:tmpdir) { Dir.mktmpdir }
|
17
|
+
|
18
|
+
# `moduledir` and `cache_root` are available for examples to use in creating
|
19
|
+
# their subjects
|
20
|
+
let(:moduledir) { File.join(tmpdir, 'modules').tap { |path| Dir.mkdir(path) } }
|
21
|
+
let(:cache_root) { File.join(tmpdir, 'cache').tap { |path| Dir.mkdir(path) } }
|
22
|
+
|
23
|
+
around(:each) do |example|
|
24
|
+
if subject.is_a?(R10K::Tarball)
|
25
|
+
subject.settings[:cache_root] = cache_root
|
26
|
+
elsif subject.respond_to?(:tarball) && subject.tarball.is_a?(R10K::Tarball)
|
27
|
+
subject.tarball.settings[:cache_root] = cache_root
|
28
|
+
end
|
29
|
+
example.run
|
30
|
+
FileUtils.remove_entry_secure(tmpdir)
|
31
|
+
end
|
32
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -19,6 +19,7 @@ require 'r10k'
|
|
19
19
|
Dir.glob(File.expand_path('spec/shared-examples/**/*.rb', PROJECT_ROOT)).each { |file| require file }
|
20
20
|
|
21
21
|
require 'shared-contexts/git-fixtures'
|
22
|
+
require 'shared-contexts/tarball'
|
22
23
|
require 'matchers/exit_with'
|
23
24
|
require 'matchers/match_realpath'
|
24
25
|
require 'r10k-mocks'
|
@@ -63,6 +63,10 @@ describe R10K::Action::Deploy::Environment do
|
|
63
63
|
described_class.new({ :'exclude-spec' => true }, [], {})
|
64
64
|
end
|
65
65
|
|
66
|
+
it 'can accept an incremental option' do
|
67
|
+
described_class.new({ :incremental => true }, [], {})
|
68
|
+
end
|
69
|
+
|
66
70
|
describe "initializing errors" do
|
67
71
|
let (:settings) { { deploy: { purge_levels: [:environment],
|
68
72
|
purge_whitelist: ['coolfile', 'coolfile2'],
|
@@ -91,27 +95,70 @@ describe R10K::Action::Deploy::Environment do
|
|
91
95
|
|
92
96
|
describe "with puppetfile or modules flag" do
|
93
97
|
let(:deployment) { R10K::Deployment.new(mock_config) }
|
94
|
-
let(:
|
98
|
+
let(:loader) do
|
99
|
+
instance_double("R10K::ModuleLoader::Puppetfile",
|
100
|
+
:load => {
|
101
|
+
:modules => ['foo'],
|
102
|
+
:purge_exclusions => [],
|
103
|
+
:managed_directories => [],
|
104
|
+
:desired_contents => []
|
105
|
+
}
|
106
|
+
).as_null_object
|
107
|
+
end
|
95
108
|
|
96
109
|
before do
|
97
110
|
expect(R10K::Deployment).to receive(:new).and_return(deployment)
|
98
|
-
expect(R10K::Puppetfile).to receive(:new).
|
111
|
+
expect(R10K::ModuleLoader::Puppetfile).to receive(:new).
|
112
|
+
and_return(loader).at_least(:once)
|
99
113
|
end
|
100
114
|
|
101
|
-
it "syncs the puppetfile when given the puppetfile flag" do
|
102
|
-
expect(
|
115
|
+
it "syncs the puppetfile content when given the puppetfile flag" do
|
116
|
+
expect(loader).to receive(:load).exactly(4).times
|
117
|
+
expect(R10K::ContentSynchronizer).to receive(:concurrent_sync).exactly(4).times
|
103
118
|
action = described_class.new({config: "/some/nonexistent/path", puppetfile: true}, [], {})
|
104
119
|
action.call
|
105
120
|
end
|
106
121
|
|
107
122
|
it "syncs the puppetfile when given the modules flag" do
|
108
|
-
expect(
|
123
|
+
expect(loader).to receive(:load).exactly(4).times
|
124
|
+
expect(R10K::ContentSynchronizer).to receive(:concurrent_sync).exactly(4).times
|
109
125
|
action = described_class.new({config: "/some/nonexistent/path", modules: true}, [], {})
|
110
126
|
action.call
|
111
127
|
end
|
128
|
+
end
|
129
|
+
|
130
|
+
describe "with incremental flag" do
|
131
|
+
let(:loader) do
|
132
|
+
instance_double("R10K::ModuleLoader::Puppetfile",
|
133
|
+
:load => {
|
134
|
+
:modules => ['foo'],
|
135
|
+
:purge_exclusions => [],
|
136
|
+
:managed_directories => [],
|
137
|
+
:desired_contents => []
|
138
|
+
}
|
139
|
+
).as_null_object
|
140
|
+
end
|
141
|
+
|
142
|
+
before do
|
143
|
+
expect(R10K::Deployment).to receive(:new).and_wrap_original do |original, settings|
|
144
|
+
original.call(mock_config.merge(settings))
|
145
|
+
end
|
146
|
+
expect(R10K::ModuleLoader::Puppetfile).to receive(:new).
|
147
|
+
and_return(loader).at_least(:once)
|
148
|
+
end
|
112
149
|
|
150
|
+
it "incremental flag causes the module definitons to be preloaded by the loader" do
|
151
|
+
expect(loader).to receive(:load_metadata).exactly(4).times
|
152
|
+
action = described_class.new({:config => "/some/nonexistent/path",
|
153
|
+
:modules => true,
|
154
|
+
:incremental => true},
|
155
|
+
[],
|
156
|
+
{})
|
157
|
+
action.call
|
158
|
+
end
|
113
159
|
end
|
114
160
|
|
161
|
+
|
115
162
|
describe "with an environment that doesn't exist" do
|
116
163
|
let(:deployment) do
|
117
164
|
R10K::Deployment.new(mock_config)
|
@@ -224,19 +271,20 @@ describe R10K::Action::Deploy::Environment do
|
|
224
271
|
|
225
272
|
describe "Purging white/allowlist" do
|
226
273
|
|
227
|
-
let(:settings) { { deploy: { purge_levels: [:environment], purge_allowlist: ['coolfile', 'coolfile2'] } } }
|
228
|
-
let(:overrides) { { environments: {}, modules: {}, purging: { purge_levels: [:environment], purge_allowlist: ['coolfile', 'coolfile2'] } } }
|
274
|
+
let(:settings) { { pool_size: 4, deploy: { purge_levels: [:environment], purge_allowlist: ['coolfile', 'coolfile2'] } } }
|
275
|
+
let(:overrides) { { environments: {}, modules: { pool_size: 4 }, purging: { purge_levels: [:environment], purge_allowlist: ['coolfile', 'coolfile2'] } } }
|
229
276
|
let(:deployment) do
|
230
|
-
R10K::Deployment.new(mock_config.merge(overrides))
|
277
|
+
R10K::Deployment.new(mock_config.merge({overrides: overrides}))
|
231
278
|
end
|
232
279
|
before do
|
233
280
|
expect(R10K::Deployment).to receive(:new).and_return(deployment)
|
281
|
+
allow_any_instance_of(R10K::Environment::Base).to receive(:purge!)
|
234
282
|
end
|
235
283
|
|
236
284
|
subject { described_class.new({ config: "/some/nonexistent/path", modules: true }, %w[PREFIX_first], settings) }
|
237
285
|
|
238
286
|
it "reads in the purge_allowlist setting and purges accordingly" do
|
239
|
-
expect(subject.logger).to receive(:debug).with(/
|
287
|
+
expect(subject.logger).to receive(:debug).with(/Purging unmanaged content for environment/)
|
240
288
|
expect(subject.settings[:overrides][:purging][:purge_allowlist]).to eq(['coolfile', 'coolfile2'])
|
241
289
|
subject.call
|
242
290
|
end
|
@@ -245,7 +293,7 @@ describe R10K::Action::Deploy::Environment do
|
|
245
293
|
let (:settings) { { deploy: { purge_levels: [:environment], purge_whitelist: ['coolfile', 'coolfile2'] } } }
|
246
294
|
|
247
295
|
it "reads in the purge_whitelist setting and still sets it to purge_allowlist and purges accordingly" do
|
248
|
-
expect(subject.logger).to receive(:debug).with(/
|
296
|
+
expect(subject.logger).to receive(:debug).with(/Purging unmanaged content for environment/)
|
249
297
|
expect(subject.settings[:overrides][:purging][:purge_allowlist]).to eq(['coolfile', 'coolfile2'])
|
250
298
|
subject.call
|
251
299
|
end
|
@@ -260,7 +308,8 @@ describe R10K::Action::Deploy::Environment do
|
|
260
308
|
requested_environments: ['PREFIX_first']
|
261
309
|
},
|
262
310
|
modules: {
|
263
|
-
deploy_modules: true
|
311
|
+
deploy_modules: true,
|
312
|
+
pool_size: 4
|
264
313
|
},
|
265
314
|
purging: {
|
266
315
|
purge_levels: purge_levels
|
@@ -274,6 +323,7 @@ describe R10K::Action::Deploy::Environment do
|
|
274
323
|
|
275
324
|
before do
|
276
325
|
expect(R10K::Deployment).to receive(:new).and_return(deployment)
|
326
|
+
allow_any_instance_of(R10K::Environment::Base).to receive(:purge!)
|
277
327
|
end
|
278
328
|
|
279
329
|
subject { described_class.new({ config: "/some/nonexistent/path", modules: true }, %w[PREFIX_first], settings) }
|
@@ -292,12 +342,12 @@ describe R10K::Action::Deploy::Environment do
|
|
292
342
|
|
293
343
|
it "only logs about purging deployment" do
|
294
344
|
expect(subject).to receive(:visit_environment).and_wrap_original do |original, env, &block|
|
295
|
-
expect(env.logger).to_not receive(:debug).with(/
|
345
|
+
expect(env.logger).to_not receive(:debug).with(/Purging unmanaged puppetfile content/)
|
296
346
|
original.call(env)
|
297
347
|
end.at_least(:once)
|
298
348
|
|
299
|
-
expect(subject.logger).to receive(:debug).with(/
|
300
|
-
expect(subject.logger).to_not receive(:debug).with(/
|
349
|
+
expect(subject.logger).to receive(:debug).with(/Purging unmanaged environments for deployment/)
|
350
|
+
expect(subject.logger).to_not receive(:debug).with(/Purging unmanaged content for environment/)
|
301
351
|
|
302
352
|
subject.call
|
303
353
|
end
|
@@ -308,11 +358,11 @@ describe R10K::Action::Deploy::Environment do
|
|
308
358
|
|
309
359
|
it "only logs about purging environment" do
|
310
360
|
expect(subject).to receive(:visit_environment).and_wrap_original do |original, env, &block|
|
311
|
-
expect(env.logger).to_not receive(:debug).with(/
|
361
|
+
expect(env.logger).to_not receive(:debug).with(/Purging unmanaged puppetfile content/)
|
312
362
|
original.call(env)
|
313
363
|
end.at_least(:once)
|
314
|
-
expect(subject.logger).to receive(:debug).with(/
|
315
|
-
expect(subject.logger).to_not receive(:debug).with(/
|
364
|
+
expect(subject.logger).to receive(:debug).with(/Purging unmanaged content for environment/)
|
365
|
+
expect(subject.logger).to_not receive(:debug).with(/Purging unmanaged environments for deployment/)
|
316
366
|
|
317
367
|
subject.call
|
318
368
|
end
|
@@ -325,7 +375,7 @@ describe R10K::Action::Deploy::Environment do
|
|
325
375
|
original.call(env)
|
326
376
|
end.at_least(:once)
|
327
377
|
|
328
|
-
expect(subject.logger).to receive(:debug).with(/
|
378
|
+
expect(subject.logger).to receive(:debug).with(/Not purging unmanaged content for environment/)
|
329
379
|
|
330
380
|
subject.call
|
331
381
|
end
|
@@ -335,15 +385,16 @@ describe R10K::Action::Deploy::Environment do
|
|
335
385
|
let(:purge_levels) { [:puppetfile] }
|
336
386
|
|
337
387
|
it "only logs about purging puppetfile" do
|
388
|
+
allow(R10K::ContentSynchronizer).to receive(:concurrent_sync)
|
338
389
|
expect(subject).to receive(:visit_environment).and_wrap_original do |original, env, &block|
|
339
390
|
if env.name =~ /first/
|
340
|
-
expect(env.logger).to receive(:debug).with(/
|
391
|
+
expect(env.logger).to receive(:debug).with(/Purging unmanaged Puppetfile content/)
|
341
392
|
end
|
342
393
|
original.call(env)
|
343
394
|
end.at_least(:once)
|
344
395
|
|
345
|
-
expect(subject.logger).to_not receive(:debug).with(/
|
346
|
-
expect(subject.logger).to_not receive(:debug).with(/
|
396
|
+
expect(subject.logger).to_not receive(:debug).with(/Purging unmanaged environments for deployment/)
|
397
|
+
expect(subject.logger).to_not receive(:debug).with(/Purging unmanaged content for environment/)
|
347
398
|
|
348
399
|
subject.call
|
349
400
|
end
|
@@ -360,6 +411,11 @@ describe R10K::Action::Deploy::Environment do
|
|
360
411
|
basedir: '/some/nonexistent/path/control',
|
361
412
|
environments: %w[first second]
|
362
413
|
}
|
414
|
+
},
|
415
|
+
overrides: {
|
416
|
+
modules: {
|
417
|
+
pool_size: 4
|
418
|
+
}
|
363
419
|
}
|
364
420
|
)
|
365
421
|
)
|
@@ -367,9 +423,8 @@ describe R10K::Action::Deploy::Environment do
|
|
367
423
|
|
368
424
|
before do
|
369
425
|
allow(R10K::Deployment).to receive(:new).and_return(deployment)
|
370
|
-
|
426
|
+
allow_any_instance_of(R10K::Environment::Base).to receive(:purge!)
|
371
427
|
|
372
|
-
before(:each) do
|
373
428
|
allow(subject).to receive(:write_environment_info!)
|
374
429
|
expect(subject.logger).not_to receive(:error)
|
375
430
|
end
|
@@ -531,7 +586,6 @@ describe R10K::Action::Deploy::Environment do
|
|
531
586
|
})
|
532
587
|
end
|
533
588
|
let(:mock_forge_module_1) { double(:name => "their_shiny_module", :properties => { :expected => "2.0.0" }) }
|
534
|
-
let(:mock_puppetfile) { instance_double("R10K::Puppetfile", :modules => [mock_git_module_1, mock_git_module_2, mock_forge_module_1]) }
|
535
589
|
|
536
590
|
before(:all) do
|
537
591
|
@tmp_path = "./tmp-r10k-test-dir/"
|
@@ -544,10 +598,8 @@ describe R10K::Action::Deploy::Environment do
|
|
544
598
|
end
|
545
599
|
|
546
600
|
it "writes the .r10k-deploy file correctly if all goes well" do
|
547
|
-
allow(R10K::Puppetfile).to receive(:new).and_return(mock_puppetfile)
|
548
|
-
|
549
601
|
fake_env = Fake_Environment.new(@tmp_path, {:name => "my_cool_environment", :signature => "pablo picasso"})
|
550
|
-
allow(fake_env).to receive(:modules).and_return(
|
602
|
+
allow(fake_env).to receive(:modules).and_return([mock_git_module_1, mock_git_module_2, mock_forge_module_1])
|
551
603
|
subject.send(:write_environment_info!, fake_env, "2019-01-01 23:23:22 +0000", true)
|
552
604
|
|
553
605
|
file_contents = File.read("#{@tmp_path}/.r10k-deploy.json")
|
@@ -570,10 +622,8 @@ describe R10K::Action::Deploy::Environment do
|
|
570
622
|
end
|
571
623
|
|
572
624
|
it "writes the .r10k-deploy file correctly if there's a failure" do
|
573
|
-
allow(R10K::Puppetfile).to receive(:new).and_return(mock_puppetfile)
|
574
|
-
|
575
625
|
fake_env = Fake_Environment.new(@tmp_path, {:name => "my_cool_environment", :signature => "pablo picasso"})
|
576
|
-
allow(fake_env).to receive(:modules).and_return(
|
626
|
+
allow(fake_env).to receive(:modules).and_return([mock_git_module_1, mock_git_module_2, mock_forge_module_1])
|
577
627
|
allow(mock_forge_module_1).to receive(:properties).and_raise(StandardError)
|
578
628
|
subject.send(:write_environment_info!, fake_env, "2019-01-01 23:23:22 +0000", true)
|
579
629
|
|