r10k 1.5.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.travis.yml +0 -1
- data/CHANGELOG.mkd +63 -0
- data/Gemfile +2 -2
- data/README.mkd +1 -10
- data/doc/dynamic-environments/configuration.mkd +24 -6
- data/doc/dynamic-environments/quickstart.mkd +1 -1
- data/integration/Gemfile +1 -1
- data/integration/configs/pe/centos-5-64mda +25 -0
- data/integration/configs/pe/centos-6-64mda +1 -1
- data/integration/configs/pe/centos-7-64mda +1 -1
- data/integration/configs/pe/debian-6-64mda +1 -1
- data/integration/configs/pe/debian-7-64mda +1 -1
- data/integration/configs/pe/redhat-6-64mda +1 -1
- data/integration/configs/pe/redhat-7-64mda +1 -1
- data/integration/configs/pe/sles-11-64mda +1 -1
- data/integration/configs/pe/sles-12-64mda +25 -0
- data/integration/configs/pe/ubuntu-1004-64mda +1 -1
- data/integration/configs/pe/ubuntu-1204-64mda +1 -1
- data/integration/configs/pe/ubuntu-1404-64mda +1 -1
- data/integration/files/pre-suite/git_config.pp.erb +19 -0
- data/integration/pre-suite/01_git_config.rb +5 -17
- data/integration/pre-suite/02_pe_r10k.rb +0 -2
- data/integration/scripts/README.mkd +86 -0
- data/integration/scripts/setup_r10k_env_centos5.sh +23 -0
- data/integration/scripts/setup_r10k_env_centos6.sh +23 -0
- data/integration/scripts/setup_r10k_env_rhel7.sh +23 -0
- data/integration/scripts/setup_r10k_env_sles11.sh +23 -0
- data/integration/scripts/setup_r10k_env_sles12.sh +23 -0
- data/integration/scripts/setup_r10k_env_ubuntu1004.sh +23 -0
- data/integration/scripts/setup_r10k_env_ubuntu1204.sh +23 -0
- data/integration/scripts/setup_r10k_env_ubuntu1404.sh +23 -0
- data/integration/tests/basic_functionality/negative/neg_invalid_git_provider.rb +44 -0
- data/integration/tests/basic_functionality/rugged_git_provider_with_ssh.rb +106 -0
- data/integration/tests/basic_functionality/rugged_git_provider_without_ssh.rb +107 -0
- data/integration/tests/git_source/git_source_git.rb +1 -1
- data/integration/tests/git_source/git_source_ssh.rb +1 -1
- data/integration/tests/git_source/negative/neg_git_unauthorized_https.rb +1 -1
- data/integration/tests/git_source/negative/neg_git_unauthorized_ssh.rb +1 -1
- data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_basedir.rb +1 -1
- data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_git_module.rb +8 -2
- data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_git_module_ref.rb +1 -1
- data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_git_remote.rb +1 -1
- data/integration/tests/user_scenario/basic_workflow/negative/neg_branch_name_collision.rb +1 -1
- data/integration/tests/user_scenario/basic_workflow/negative/neg_disk_full.rb +5 -1
- data/integration/tests/user_scenario/basic_workflow/negative/neg_duplicate_module_names.rb +3 -3
- data/integration/tests/user_scenario/basic_workflow/negative/neg_invalid_puppet_file.rb +1 -1
- data/integration/tests/user_scenario/basic_workflow/negative/neg_read_only.rb +1 -1
- data/integration/tests/user_scenario/basic_workflow/single_env_10000_files.rb +4 -0
- data/integration/tests/user_scenario/basic_workflow/single_env_large_files.rb +4 -0
- data/integration/tests/user_scenario/complex_workflow/multi_env_unamanaged.rb +77 -0
- data/integration/tests/user_scenario/complex_workflow/single_env_git_module_update.rb +99 -0
- data/lib/r10k/action/deploy/display.rb +0 -1
- data/lib/r10k/action/runner.rb +20 -0
- data/lib/r10k/cli.rb +0 -3
- data/lib/r10k/cli/deploy.rb +0 -3
- data/lib/r10k/deployment.rb +1 -7
- data/lib/r10k/deployment/config.rb +15 -1
- data/lib/r10k/deployment/config/loader.rb +0 -11
- data/lib/r10k/environment/git.rb +0 -9
- data/lib/r10k/environment/svn.rb +0 -9
- data/lib/r10k/errors.rb +0 -3
- data/lib/r10k/feature.rb +24 -3
- data/lib/r10k/forge/module_release.rb +142 -0
- data/lib/r10k/git.rb +32 -11
- data/lib/r10k/module/forge.rb +25 -54
- data/lib/r10k/module_repository/forge.rb +2 -5
- data/lib/r10k/puppetfile.rb +1 -1
- data/lib/r10k/util/license.rb +20 -0
- data/lib/r10k/version.rb +1 -1
- data/lib/shared/puppet_forge/connection.rb +62 -0
- data/lib/shared/puppet_forge/error.rb +28 -0
- data/lib/shared/puppet_forge/tar.rb +10 -0
- data/lib/shared/puppet_forge/tar/mini.rb +81 -0
- data/lib/shared/puppet_forge/unpacker.rb +68 -0
- data/lib/shared/puppet_forge/v3.rb +13 -0
- data/lib/shared/puppet_forge/v3/module.rb +66 -0
- data/lib/shared/puppet_forge/v3/module_release.rb +73 -0
- data/lib/shared/puppet_forge/version.rb +3 -0
- data/r10k.gemspec +2 -2
- data/r10k.yaml.example +80 -5
- data/spec/spec_helper.rb +0 -12
- data/spec/unit/action/runner_spec.rb +53 -0
- data/spec/unit/deployment/config/loader_spec.rb +5 -19
- data/spec/unit/deployment/config_spec.rb +8 -0
- data/spec/unit/deployment_spec.rb +1 -1
- data/spec/unit/forge/module_release_spec.rb +130 -0
- data/spec/unit/git_spec.rb +5 -5
- data/spec/unit/module/forge_spec.rb +66 -116
- data/spec/unit/module_repository/forge_spec.rb +35 -5
- data/spec/unit/module_spec.rb +10 -10
- data/spec/unit/puppet_forge/connection_spec.rb +41 -0
- data/spec/unit/puppet_forge/tar/mini_spec.rb +87 -0
- data/spec/unit/puppet_forge/tar_spec.rb +9 -0
- data/spec/unit/puppet_forge/unpacker_spec.rb +59 -0
- data/spec/unit/puppet_forge/v3/module_release_spec.rb +68 -0
- data/spec/unit/puppet_forge/v3/module_spec.rb +67 -0
- metadata +48 -112
- data/lib/r10k/cli/environment.rb +0 -28
- data/lib/r10k/cli/environment/deploy.rb +0 -26
- data/lib/r10k/cli/environment/list.rb +0 -23
- data/lib/r10k/cli/environment/stale.rb +0 -24
- data/lib/r10k/cli/module.rb +0 -29
- data/lib/r10k/cli/module/deploy.rb +0 -27
- data/lib/r10k/cli/module/list.rb +0 -24
- data/lib/r10k/cli/synchronize.rb +0 -27
- data/lib/r10k/deployment/basedir.rb +0 -4
- data/lib/r10k/deployment/environment.rb +0 -20
- data/lib/r10k/deployment/source.rb +0 -37
- data/lib/r10k/git/commit.rb +0 -22
- data/lib/r10k/git/head.rb +0 -36
- data/lib/r10k/git/ref.rb +0 -66
- data/lib/r10k/git/remote_head.rb +0 -19
- data/lib/r10k/git/repository.rb +0 -158
- data/lib/r10k/git/tag.rb +0 -29
- data/lib/r10k/git/working_dir.rb +0 -186
- data/lib/r10k/registry.rb +0 -4
- data/lib/r10k/semver.rb +0 -128
- data/lib/r10k/task.rb +0 -12
- data/lib/r10k/task/deployment.rb +0 -164
- data/lib/r10k/task/environment.rb +0 -31
- data/lib/r10k/task/module.rb +0 -19
- data/lib/r10k/task/puppetfile.rb +0 -102
- data/lib/r10k/task_runner.rb +0 -72
- data/lib/r10k/util/monkey_patches.rb +0 -11
- data/spec/fixtures/vcr/cassettes/R10K_ModuleRepository_Forge/and_the_expected_version_is_latest/can_fetch_all_versions_of_a_given_module.yml +0 -187
- data/spec/fixtures/vcr/cassettes/R10K_ModuleRepository_Forge/and_the_expected_version_is_latest/can_fetch_the_latest_version_of_a_given_module.yml +0 -187
- data/spec/fixtures/vcr/cassettes/R10K_ModuleRepository_Forge/and_the_expected_version_is_latest/ignores_deleted_releases.yml +0 -190
- data/spec/fixtures/vcr/cassettes/R10K_ModuleRepository_Forge/it_handles_errors_from_forgeapi_puppetlabs_com/raises_an_error_for_a_non-existant_module.yml +0 -34
- data/spec/fixtures/vcr/cassettes/R10K_Module_Forge/and_the_expected_version_is_latest/sets_the_expected_version_based_on_the_latest_forge_version.yml +0 -103
- data/spec/shared-examples/git-ref.rb +0 -49
- data/spec/unit/deployment/environment_spec.rb +0 -25
- data/spec/unit/git/commit_spec.rb +0 -34
- data/spec/unit/git/head_spec.rb +0 -22
- data/spec/unit/git/ref_spec.rb +0 -45
- data/spec/unit/git/repository_spec.rb +0 -34
- data/spec/unit/git/tag_spec.rb +0 -32
- data/spec/unit/git/working_dir_spec.rb +0 -122
- data/spec/unit/util/monkey_patches_spec.rb +0 -20
data/r10k.gemspec
CHANGED
@@ -18,6 +18,8 @@ Gem::Specification.new do |s|
|
|
18
18
|
dynamic environments.
|
19
19
|
DESCRIPTION
|
20
20
|
|
21
|
+
s.required_ruby_version = '>= 1.9.3'
|
22
|
+
|
21
23
|
s.license = 'Apache-2.0'
|
22
24
|
|
23
25
|
s.add_dependency 'colored', '1.2'
|
@@ -25,7 +27,6 @@ Gem::Specification.new do |s|
|
|
25
27
|
|
26
28
|
s.add_dependency 'log4r', '1.1.10'
|
27
29
|
s.add_dependency 'multi_json', '~> 1.10'
|
28
|
-
s.add_dependency 'json_pure', '~> 1.8'
|
29
30
|
|
30
31
|
s.add_dependency 'faraday', '~> 0.9.0'
|
31
32
|
s.add_dependency 'faraday_middleware', '~> 0.9.0'
|
@@ -34,7 +35,6 @@ Gem::Specification.new do |s|
|
|
34
35
|
s.add_dependency 'semantic_puppet', '~> 0.1.0'
|
35
36
|
|
36
37
|
s.add_development_dependency 'rspec', '~> 3.1'
|
37
|
-
s.add_development_dependency 'vcr', '~> 2.9'
|
38
38
|
|
39
39
|
s.add_development_dependency 'minitar'
|
40
40
|
|
data/r10k.yaml.example
CHANGED
@@ -1,5 +1,80 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
---
|
2
|
+
# This example configuration details the most commonly used configuration
|
3
|
+
# options for the `r10k deploy` command.
|
4
|
+
#
|
5
|
+
|
6
|
+
# The 'cachedir' setting controls where cached content, such as mirrored Git
|
7
|
+
# repositories, are stored on the local machine. This location should be
|
8
|
+
# persistent, as environments and modules may rely on these files in order to
|
9
|
+
# be updated.
|
10
|
+
#
|
11
|
+
# The default value is "~/.r10k"
|
12
|
+
cachedir: '/var/cache/r10k'
|
13
|
+
|
14
|
+
# The 'sources' setting determines what repositories r10k will use when creating
|
15
|
+
# Puppet environments.
|
16
|
+
sources:
|
17
|
+
# Each source should have a unique name, and preferrably should only use
|
18
|
+
# alphanumeric characters and underscores.
|
19
|
+
operations:
|
20
|
+
|
21
|
+
# The 'remote' setting determines the location of the VCS repository used
|
22
|
+
# for creating environments.
|
23
|
+
remote: 'git@github.com:my-org/org-operations-modules'
|
24
|
+
|
25
|
+
# The 'basedir' setting specifies where environments will be created for
|
26
|
+
# this source. This setting should match the Puppet 'environmentpath'
|
27
|
+
# setting in puppet.conf.
|
28
|
+
#
|
29
|
+
# See http://docs.puppetlabs.com/references/latest/configuration.html#environmentpath
|
30
|
+
# for more information about the Puppet 'environmentpath' setting.
|
31
|
+
basedir: '/etc/puppetlabs/puppet/environments'
|
32
|
+
|
33
|
+
# One or more sources can be specified; each source is simple another entry
|
34
|
+
# in the sources map.
|
35
|
+
qa:
|
36
|
+
remote: 'git@github.com:my-org/org-qa-modules'
|
37
|
+
|
38
|
+
# Multiple sources can have the same 'basedir' setting, in case there is a
|
39
|
+
# reason to push different sets of environments to the same Puppet master.
|
40
|
+
# If two different sources have the same basedir care should be exercised
|
41
|
+
# to make sure that two sources don't try create multiple environments with
|
42
|
+
# the same name. See the 'prefix' setting for more information.
|
43
|
+
basedir: '/etc/puppetlabs/puppet/environments'
|
44
|
+
|
45
|
+
# Sources can use the 'prefix' setting to avoid collisions between multiple
|
46
|
+
# sources being created in the same directory. Setting prefix to true
|
47
|
+
# prepends the source name and an underscore to each environment, so for
|
48
|
+
# the qa source the "production" branch will create the "qa_production"
|
49
|
+
# branch.
|
50
|
+
#
|
51
|
+
# The default value is 'false'.
|
52
|
+
prefix: true
|
53
|
+
|
54
|
+
# Additional configuration can be supplied to configure how r10k uses Git
|
55
|
+
# and what version of Git it uses.
|
56
|
+
git:
|
57
|
+
|
58
|
+
# As of 1.5.0 r10k can interact with Git repositories in two ways - by
|
59
|
+
# shelling out to the 'git' executable, and by using libgit2 through the
|
60
|
+
# 'rugged' library.
|
61
|
+
provider: 'shellgit' # Either 'shellgit' or 'rugged', defaults to 'shellgit'
|
62
|
+
|
63
|
+
# The 'private_key' setting sets the the SSH private key to use for remote
|
64
|
+
# Git repositories accessed over SSH.
|
65
|
+
#
|
66
|
+
# The 'private_key' setting is only used by the 'rugged' Git provider.
|
67
|
+
#private_key: '/root/.ssh/id_rsa'
|
68
|
+
|
69
|
+
# The 'username' setting sets the SSH username for remote Git repositories
|
70
|
+
# when a username is not provided in the URL. The username defaults to the
|
71
|
+
# current user.
|
72
|
+
#
|
73
|
+
# The 'username' setting is only used by the 'rugged' Git provider.
|
74
|
+
#username: 'git'
|
75
|
+
|
76
|
+
# Configuration options for downloading modules from the Puppet Forge
|
77
|
+
forge:
|
78
|
+
# The 'proxy' setting specifies an optional HTTP proxy to use when making
|
79
|
+
# requests to the Puppet Forge.
|
80
|
+
proxy: 'http://my.site.proxy:3128'
|
data/spec/spec_helper.rb
CHANGED
@@ -23,18 +23,6 @@ require 'matchers/exit_with'
|
|
23
23
|
require 'matchers/match_realpath'
|
24
24
|
require 'r10k-mocks'
|
25
25
|
|
26
|
-
|
27
|
-
require 'vcr'
|
28
|
-
VCR.configure do |vcr|
|
29
|
-
vcr.cassette_library_dir = File.expand_path('spec/fixtures/vcr/cassettes', PROJECT_ROOT)
|
30
|
-
# VCR 2.9.3 uses a Faraday constant that was deprecated in Faraday 0.9.0,
|
31
|
-
# and as such triggers a warning on the part of Faraday during the following
|
32
|
-
# hooking step. It's known and there's nothing that can be done until VCR
|
33
|
-
# 2.9.4 comes out.
|
34
|
-
vcr.hook_into :faraday
|
35
|
-
vcr.configure_rspec_metadata!
|
36
|
-
end
|
37
|
-
|
38
26
|
RSpec.configure do |config|
|
39
27
|
config.before(:all) do
|
40
28
|
Log4r::Logger.global.level = Log4r::OFF
|
@@ -44,6 +44,11 @@ describe R10K::Action::Runner do
|
|
44
44
|
runner.call
|
45
45
|
end
|
46
46
|
|
47
|
+
it "configures settings" do
|
48
|
+
expect(runner).to receive(:setup_settings)
|
49
|
+
runner.call
|
50
|
+
end
|
51
|
+
|
47
52
|
it "returns the result of the wrapped class #call method" do
|
48
53
|
expect(runner.call).to eq %w[ARGS YES]
|
49
54
|
end
|
@@ -61,4 +66,52 @@ describe R10K::Action::Runner do
|
|
61
66
|
runner.call
|
62
67
|
end
|
63
68
|
end
|
69
|
+
|
70
|
+
describe "configuring settings" do
|
71
|
+
it "configures authorization" do
|
72
|
+
expect(runner).to receive(:setup_authorization)
|
73
|
+
runner.setup_settings
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe "configuration authorization" do
|
78
|
+
context "when license is not present" do
|
79
|
+
before(:each) do
|
80
|
+
expect(R10K::Util::License).to receive(:load).and_return(nil)
|
81
|
+
end
|
82
|
+
|
83
|
+
it "does not set authorization header on connection class" do
|
84
|
+
expect(PuppetForge::Connection).not_to receive(:authorization=)
|
85
|
+
runner.setup_authorization
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
context "when license is present but invalid" do
|
90
|
+
before(:each) do
|
91
|
+
expect(R10K::Util::License).to receive(:load).and_raise(R10K::Error.new('invalid license'))
|
92
|
+
end
|
93
|
+
|
94
|
+
it "issues warning to logger" do
|
95
|
+
expect(runner.logger).to receive(:warn).with(/invalid license/)
|
96
|
+
runner.setup_authorization
|
97
|
+
end
|
98
|
+
|
99
|
+
it "does not set authorization header on connection class" do
|
100
|
+
expect(PuppetForge::Connection).not_to receive(:authorization=)
|
101
|
+
runner.setup_authorization
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
context "when license is present and valid" do
|
106
|
+
before(:each) do
|
107
|
+
mock_license = double('pe-license', :authorization_token => 'test token')
|
108
|
+
expect(R10K::Util::License).to receive(:load).and_return(mock_license)
|
109
|
+
end
|
110
|
+
|
111
|
+
it "sets authorization header on connection class" do
|
112
|
+
expect(PuppetForge::Connection).to receive(:authorization=).with('test token')
|
113
|
+
runner.setup_authorization
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
64
117
|
end
|
@@ -8,15 +8,16 @@ describe R10K::Deployment::Config::Loader do
|
|
8
8
|
expect(subject.loadpath).to include('/etc/puppetlabs/r10k/r10k.yaml')
|
9
9
|
end
|
10
10
|
|
11
|
-
it 'includes /etc/r10k.yaml in the loadpath' do
|
12
|
-
expect(subject.loadpath).to include('/etc/r10k.yaml')
|
13
|
-
end
|
14
|
-
|
15
11
|
it 'does include the current working directory in the loadpath' do
|
16
12
|
allow(Dir).to receive(:getwd).and_return '/some/random/path/westvletren'
|
17
13
|
expect(subject.loadpath).to include('/some/random/path/westvletren/r10k.yaml')
|
18
14
|
end
|
19
15
|
|
16
|
+
# This was the old default location that is no longer supported as of 2.0.0.
|
17
|
+
it 'does not include /etc/r10k.yaml in the loadpath' do
|
18
|
+
expect(subject.loadpath).not_to include('/etc/r10k.yaml')
|
19
|
+
end
|
20
|
+
|
20
21
|
it 'does not include /some/random/path/atomium/r10k.yaml in the loadpath' do
|
21
22
|
expect(subject.loadpath).not_to include('/some/random/path/atomium/r10k.yaml')
|
22
23
|
end
|
@@ -27,22 +28,7 @@ describe R10K::Deployment::Config::Loader do
|
|
27
28
|
it 'returns the correct default location' do
|
28
29
|
allow(File).to receive(:file?).and_return false
|
29
30
|
allow(File).to receive(:file?).with('/etc/puppetlabs/r10k/r10k.yaml').and_return true
|
30
|
-
allow(File).to receive(:file?).with('/etc/r10k.yaml').and_return true
|
31
31
|
expect(subject.search).to eq '/etc/puppetlabs/r10k/r10k.yaml'
|
32
32
|
end
|
33
|
-
|
34
|
-
it 'issues a warning if both default locations are present' do
|
35
|
-
allow(File).to receive(:file?).and_return false
|
36
|
-
allow(File).to receive(:file?).with('/etc/puppetlabs/r10k/r10k.yaml').and_return true
|
37
|
-
allow(File).to receive(:file?).with('/etc/r10k.yaml').and_return true
|
38
|
-
|
39
|
-
logger_dbl = double('Logging')
|
40
|
-
allow(subject).to receive(:logger).and_return logger_dbl
|
41
|
-
|
42
|
-
expect(logger_dbl).to receive(:warn).with('Both /etc/puppetlabs/r10k/r10k.yaml and /etc/r10k.yaml configuration files exist.')
|
43
|
-
expect(logger_dbl).to receive(:warn).with('/etc/puppetlabs/r10k/r10k.yaml will be used.')
|
44
|
-
|
45
|
-
subject.search
|
46
|
-
end
|
47
33
|
end
|
48
34
|
end
|
@@ -26,6 +26,14 @@ describe R10K::Deployment::Config do
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
+
describe "for the forge" do
|
30
|
+
it "sets the proxy when given" do
|
31
|
+
expect(YAML).to receive(:load_file).with('foo/bar').and_return('forge' => {'proxy' => 'https://proxy.url'})
|
32
|
+
expect(R10K::Forge::ModuleRelease.settings).to receive(:[]=).with(:proxy, 'https://proxy.url')
|
33
|
+
described_class.new('foo/bar')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
29
37
|
describe "for git" do
|
30
38
|
it "sets the git provider when given" do
|
31
39
|
expect(YAML).to receive(:load_file).with('foo/bar').and_return('git' => {'provider' => 'rugged'})
|
@@ -137,7 +137,7 @@ describe R10K::Deployment, "with environment collisions" do
|
|
137
137
|
it "raises an error when validating" do
|
138
138
|
expect {
|
139
139
|
deployment.validate!
|
140
|
-
}.to raise_error(R10K::
|
140
|
+
}.to raise_error(R10K::Error, /Environment collision at .* between s\d:third and s\d:third/)
|
141
141
|
end
|
142
142
|
end
|
143
143
|
|
@@ -0,0 +1,130 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'r10k/forge/module_release'
|
3
|
+
require 'r10k/util/exec_env'
|
4
|
+
|
5
|
+
describe R10K::Forge::ModuleRelease do
|
6
|
+
subject { described_class.new('branan-eight_hundred', '8.0.0') }
|
7
|
+
|
8
|
+
let(:download_path) { instance_double('Pathname') }
|
9
|
+
let(:unpack_path) { instance_double('Pathname') }
|
10
|
+
let(:target_dir) { instance_double('Pathname') }
|
11
|
+
let(:file_lists) { {:valid=>['valid_ex'], :invalid=>[], :symlinks=>['symlink_ex']} }
|
12
|
+
|
13
|
+
before do
|
14
|
+
subject.download_path = download_path
|
15
|
+
subject.unpack_path = unpack_path
|
16
|
+
end
|
17
|
+
|
18
|
+
describe 'setting the proxy' do
|
19
|
+
%w[HTTPS_PROXY https_proxy HTTP_PROXY http_proxy].each do |env_var|
|
20
|
+
it "respects the #{env_var} environment variable" do
|
21
|
+
R10K::Util::ExecEnv.withenv(env_var => "http://proxy.value") do
|
22
|
+
subject = described_class.new('branan-eight_hundred', '8.0.0')
|
23
|
+
proxy_uri = subject.forge_release.conn.proxy.uri
|
24
|
+
expect(proxy_uri.to_s).to eq "http://proxy.value"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'using application settings' do
|
30
|
+
before { described_class.settings[:proxy] = 'http://proxy.setting' }
|
31
|
+
after { described_class.settings.reset! }
|
32
|
+
|
33
|
+
it 'has a setting for the forge proxy' do
|
34
|
+
subject = described_class.new('branan-eight_hundred', '8.0.0')
|
35
|
+
proxy_uri = subject.forge_release.conn.proxy.uri
|
36
|
+
expect(proxy_uri.to_s).to eq "http://proxy.setting"
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'prefers the proxy setting over an environment variable' do
|
40
|
+
R10K::Util::ExecEnv.withenv('HTTPS_PROXY' => "http://proxy.from.env") do
|
41
|
+
subject = described_class.new('branan-eight_hundred', '8.0.0')
|
42
|
+
proxy_uri = subject.forge_release.conn.proxy.uri
|
43
|
+
expect(proxy_uri.to_s).to eq "http://proxy.setting"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
describe '#download' do
|
51
|
+
it "downloads the module from the forge into `download_path`" do
|
52
|
+
expect(subject.forge_release).to receive(:download).with(download_path)
|
53
|
+
subject.download
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe '#verify' do
|
58
|
+
it "verifies the module checksum based on the Forge file checksum" do
|
59
|
+
expect(subject.forge_release).to receive(:verify).with(download_path)
|
60
|
+
subject.verify
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe '#unpack' do
|
65
|
+
it "unpacks the module tarball in `download_path` into the provided target path" do
|
66
|
+
expect(PuppetForge::Unpacker).to receive(:unpack).with(download_path.to_s, target_dir.to_s, unpack_path.to_s).\
|
67
|
+
and_return({:valid=>["extractedmodule/metadata.json"], :invalid=>[], :symlinks=>[]})
|
68
|
+
subject.unpack(target_dir)
|
69
|
+
end
|
70
|
+
|
71
|
+
it "raises an error if symlinks are present during the unpacking process after unpacking" do
|
72
|
+
logger_dbl = double(Log4r::Logger)
|
73
|
+
allow(subject).to receive(:logger).and_return(logger_dbl)
|
74
|
+
expect(PuppetForge::Unpacker).to receive(:unpack).with(download_path.to_s, target_dir.to_s, unpack_path.to_s).\
|
75
|
+
and_return(file_lists)
|
76
|
+
expect(logger_dbl).to receive(:debug1)
|
77
|
+
expect(logger_dbl).to receive(:debug2)
|
78
|
+
expect {
|
79
|
+
subject.unpack(target_dir)
|
80
|
+
}.to raise_error(R10K::Error, "Symlinks are unsupported and were not unpacked from the module tarball. " +
|
81
|
+
"#{subject.forge_release.slug} contained these ignored symlinks: #{file_lists[:symlinks]}")
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe "#cleanup" do
|
86
|
+
it "cleans up the download and unpack paths" do
|
87
|
+
expect(subject).to receive(:cleanup_unpack_path)
|
88
|
+
expect(subject).to receive(:cleanup_download_path)
|
89
|
+
subject.cleanup
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe "#cleanup_unpack_path" do
|
94
|
+
it "ignores the unpack_path if it doesn't exist" do
|
95
|
+
expect(unpack_path).to receive(:exist?).and_return false
|
96
|
+
expect(unpack_path).to_not receive(:rmtree)
|
97
|
+
subject.cleanup_unpack_path
|
98
|
+
end
|
99
|
+
|
100
|
+
it "removes the unpack_path if it exists" do
|
101
|
+
expect(unpack_path).to receive(:exist?).and_return true
|
102
|
+
expect(unpack_path).to receive(:rmtree)
|
103
|
+
subject.cleanup_unpack_path
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
describe "#cleanup_download_path" do
|
108
|
+
it "ignores the download_path if it doesn't exist" do
|
109
|
+
expect(download_path).to receive(:exist?).and_return false
|
110
|
+
expect(download_path).to_not receive(:delete)
|
111
|
+
subject.cleanup_download_path
|
112
|
+
end
|
113
|
+
|
114
|
+
it "removes the download_path if it exists" do
|
115
|
+
expect(download_path).to receive(:exist?).and_return true
|
116
|
+
expect(download_path).to receive(:delete)
|
117
|
+
subject.cleanup_download_path
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
describe '#install' do
|
122
|
+
it "performs all steps needed to install the module" do
|
123
|
+
expect(subject).to receive(:download)
|
124
|
+
expect(subject).to receive(:verify)
|
125
|
+
expect(subject).to receive(:unpack).with(target_dir)
|
126
|
+
expect(subject).to receive(:cleanup)
|
127
|
+
subject.install(target_dir)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
data/spec/unit/git_spec.rb
CHANGED
@@ -8,20 +8,20 @@ describe R10K::Git do
|
|
8
8
|
describe 'selecting the default provider' do
|
9
9
|
it 'returns shellgit when the git executable is present' do
|
10
10
|
expect(R10K::Features).to receive(:available?).with(:shellgit).and_return true
|
11
|
-
expect(described_class.
|
11
|
+
expect(described_class.default_name).to eq :shellgit
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'returns rugged when the git executable is absent and the rugged library is present' do
|
15
15
|
expect(R10K::Features).to receive(:available?).with(:shellgit).and_return false
|
16
16
|
expect(R10K::Features).to receive(:available?).with(:rugged).and_return true
|
17
|
-
expect(described_class.
|
17
|
+
expect(described_class.default_name).to eq :rugged
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'raises an error when the git executable and rugged library are absent' do
|
21
21
|
expect(R10K::Features).to receive(:available?).with(:shellgit).and_return false
|
22
22
|
expect(R10K::Features).to receive(:available?).with(:rugged).and_return false
|
23
23
|
expect {
|
24
|
-
described_class.
|
24
|
+
described_class.default_name
|
25
25
|
}.to raise_error(R10K::Error, 'No Git providers are functional.')
|
26
26
|
end
|
27
27
|
|
@@ -60,8 +60,8 @@ describe R10K::Git do
|
|
60
60
|
|
61
61
|
describe "retrieving the current provider" do
|
62
62
|
it "uses the default if a provider has not been set" do
|
63
|
-
expect(described_class).to receive(:
|
64
|
-
expect(described_class.provider).to eq
|
63
|
+
expect(described_class).to receive(:default_name).and_return :rugged
|
64
|
+
expect(described_class.provider).to eq(R10K::Git::Rugged)
|
65
65
|
end
|
66
66
|
|
67
67
|
it "uses an explicitly set provider" do
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'r10k/module/forge'
|
2
|
-
require 'r10k/semver'
|
3
2
|
require 'spec_helper'
|
4
3
|
|
5
4
|
describe R10K::Module::Forge do
|
@@ -15,16 +14,12 @@ describe R10K::Module::Forge do
|
|
15
14
|
end
|
16
15
|
|
17
16
|
it "should implement 'branan-eight_hundred', '8.0.0'" do
|
18
|
-
expect(described_class).to be_implement('branan
|
17
|
+
expect(described_class).to be_implement('branan-eight_hundred', '8.0.0')
|
19
18
|
end
|
20
19
|
|
21
20
|
it "should fail with an invalid title" do
|
22
21
|
expect(described_class).to_not be_implement('branan!eight_hundred', '8.0.0')
|
23
22
|
end
|
24
|
-
|
25
|
-
it "should fail with an invalid version" do
|
26
|
-
expect(described_class).to_not be_implement('branan-eight_hundred', 'not a semantic version')
|
27
|
-
end
|
28
23
|
end
|
29
24
|
|
30
25
|
describe "setting attributes" do
|
@@ -55,117 +50,25 @@ describe R10K::Module::Forge do
|
|
55
50
|
end
|
56
51
|
|
57
52
|
it "sets the expected version" do
|
58
|
-
expect(subject.properties).to include(:expected =>
|
53
|
+
expect(subject.properties).to include(:expected => '8.0.0')
|
59
54
|
end
|
60
55
|
|
61
56
|
it "sets the actual version" do
|
62
|
-
expect(subject).to receive(:current_version).and_return(
|
63
|
-
expect(subject.properties).to include(:actual =>
|
57
|
+
expect(subject).to receive(:current_version).and_return('0.8.0')
|
58
|
+
expect(subject.properties).to include(:actual => '0.8.0')
|
64
59
|
end
|
65
60
|
end
|
66
61
|
|
67
|
-
describe
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
:author => 'branan',
|
72
|
-
:version => R10K::SemVer.new('8.0.0'))
|
62
|
+
describe '#expected_version' do
|
63
|
+
it "returns an explicitly given expected version" do
|
64
|
+
subject = described_class.new('branan/eight_hundred', fixture_modulepath, '8.0.0')
|
65
|
+
expect(subject.expected_version).to eq '8.0.0'
|
73
66
|
end
|
74
67
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
allow(subject).to receive(:status).and_return :insync
|
80
|
-
end
|
81
|
-
|
82
|
-
it "is in sync" do
|
83
|
-
expect(subject).to be_insync
|
84
|
-
end
|
85
|
-
|
86
|
-
it "doesn't act when syncing anything" do
|
87
|
-
expect(subject).to receive(:install).never
|
88
|
-
expect(subject).to receive(:upgrade).never
|
89
|
-
expect(subject).to receive(:reinstall).never
|
90
|
-
subject.sync
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
describe "and the module is mismatched" do
|
95
|
-
before do
|
96
|
-
allow(subject).to receive(:status).and_return :mismatched
|
97
|
-
end
|
98
|
-
|
99
|
-
it "is not in sync" do
|
100
|
-
expect(subject).to_not be_insync
|
101
|
-
end
|
102
|
-
|
103
|
-
it "reinstalls the module" do
|
104
|
-
expect(subject).to receive(:reinstall)
|
105
|
-
subject.sync
|
106
|
-
end
|
107
|
-
|
108
|
-
it "reinstalls by removing the existing directory and calling the module tool" do
|
109
|
-
expect(FileUtils).to receive(:rm_rf)
|
110
|
-
expect(subject).to receive(:pmt) do |args|
|
111
|
-
expect(args).to include 'install'
|
112
|
-
expect(args).to include '--version=8.0.0'
|
113
|
-
expect(args).to include 'branan/eight_hundred'
|
114
|
-
end
|
115
|
-
|
116
|
-
subject.sync
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
describe "and the module is outdated" do
|
121
|
-
before do
|
122
|
-
allow(subject).to receive(:status).and_return :outdated
|
123
|
-
end
|
124
|
-
|
125
|
-
it "is not in sync" do
|
126
|
-
expect(subject).to_not be_insync
|
127
|
-
end
|
128
|
-
|
129
|
-
it "upgrades the module" do
|
130
|
-
expect(subject).to receive(:upgrade)
|
131
|
-
subject.sync
|
132
|
-
end
|
133
|
-
|
134
|
-
it "upgrades by calling the module tool" do
|
135
|
-
expect(subject).to receive(:pmt) do |args|
|
136
|
-
expect(args).to include 'upgrade'
|
137
|
-
expect(args).to include '--version=8.0.0'
|
138
|
-
expect(args).to include 'branan/eight_hundred'
|
139
|
-
end
|
140
|
-
|
141
|
-
subject.sync
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
describe "and the module is not installed" do
|
146
|
-
before do
|
147
|
-
allow(subject).to receive(:status).and_return :absent
|
148
|
-
end
|
149
|
-
|
150
|
-
it "is not in sync" do
|
151
|
-
expect(subject).to_not be_insync
|
152
|
-
end
|
153
|
-
|
154
|
-
it "installs the module" do
|
155
|
-
expect(subject).to receive(:uninstall).never
|
156
|
-
expect(subject).to receive(:install)
|
157
|
-
subject.sync
|
158
|
-
end
|
159
|
-
|
160
|
-
it "installs by calling the module tool" do
|
161
|
-
expect(subject).to receive(:pmt) do |args|
|
162
|
-
expect(args).to include 'install'
|
163
|
-
expect(args).to include '--version=8.0.0'
|
164
|
-
expect(args).to include 'branan/eight_hundred'
|
165
|
-
end
|
166
|
-
|
167
|
-
subject.sync
|
168
|
-
end
|
68
|
+
it "uses the latest version from the forge when the version is :latest" do
|
69
|
+
subject = described_class.new('branan/eight_hundred', fixture_modulepath, :latest)
|
70
|
+
expect(subject.v3_module).to receive(:latest_version).and_return('8.8.8')
|
71
|
+
expect(subject.expected_version).to eq '8.8.8'
|
169
72
|
end
|
170
73
|
end
|
171
74
|
|
@@ -207,14 +110,61 @@ describe R10K::Module::Forge do
|
|
207
110
|
end
|
208
111
|
end
|
209
112
|
|
210
|
-
describe "
|
211
|
-
subject { described_class.new('branan/eight_hundred', fixture_modulepath,
|
113
|
+
describe "#sync" do
|
114
|
+
subject { described_class.new('branan/eight_hundred', fixture_modulepath, '8.0.0') }
|
212
115
|
|
213
|
-
it
|
214
|
-
allow(subject).to receive(:
|
215
|
-
|
216
|
-
expect(subject
|
217
|
-
expect(subject
|
116
|
+
it 'does nothing when the module is in sync' do
|
117
|
+
allow(subject).to receive(:status).and_return :insync
|
118
|
+
|
119
|
+
expect(subject).to receive(:install).never
|
120
|
+
expect(subject).to receive(:upgrade).never
|
121
|
+
expect(subject).to receive(:reinstall).never
|
122
|
+
subject.sync
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'reinstalls the module when it is mismatched' do
|
126
|
+
allow(subject).to receive(:status).and_return :mismatched
|
127
|
+
expect(subject).to receive(:reinstall)
|
128
|
+
subject.sync
|
129
|
+
end
|
130
|
+
|
131
|
+
it 'upgrades the module when it is outdated' do
|
132
|
+
allow(subject).to receive(:status).and_return :outdated
|
133
|
+
expect(subject).to receive(:upgrade)
|
134
|
+
subject.sync
|
135
|
+
end
|
136
|
+
|
137
|
+
it 'installs the module when it is absent' do
|
138
|
+
allow(subject).to receive(:status).and_return :absent
|
139
|
+
expect(subject).to receive(:install)
|
140
|
+
subject.sync
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
describe '#install' do
|
145
|
+
it 'installs the module from the forge' do
|
146
|
+
subject = described_class.new('branan/eight_hundred', fixture_modulepath, '8.0.0')
|
147
|
+
release = instance_double('R10K::Forge::ModuleRelease')
|
148
|
+
expect(R10K::Forge::ModuleRelease).to receive(:new).with('branan/eight_hundred', '8.0.0').and_return(release)
|
149
|
+
expect(release).to receive(:install).with(subject.path)
|
150
|
+
subject.install
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
describe '#uninstall' do
|
155
|
+
it 'removes the module path' do
|
156
|
+
subject = described_class.new('branan/eight_hundred', fixture_modulepath, '8.0.0')
|
157
|
+
expect(FileUtils).to receive(:rm_rf).with(subject.path.to_s)
|
158
|
+
subject.uninstall
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
describe '#reinstall' do
|
163
|
+
it 'uninstalls and then installs the module' do
|
164
|
+
subject = described_class.new('branan/eight_hundred', fixture_modulepath, '8.0.0')
|
165
|
+
expect(subject).to receive(:uninstall)
|
166
|
+
expect(subject).to receive(:install)
|
167
|
+
subject.reinstall
|
218
168
|
end
|
219
169
|
end
|
220
170
|
end
|