r10k 1.4.2 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +2 -0
- data/CHANGELOG.mkd +192 -0
- data/CONTRIBUTING.mkd +3 -3
- data/Gemfile +4 -0
- data/README.mkd +13 -6
- data/doc/dynamic-environments/configuration.mkd +77 -8
- data/doc/dynamic-environments/git-environments.mkd +12 -2
- data/doc/dynamic-environments/quickstart.mkd +6 -0
- data/doc/faq.mkd +6 -6
- data/doc/git/cloning-and-mirroring.mkd +60 -0
- data/doc/git/providers.mkd +68 -0
- data/integration/Gemfile +3 -0
- data/integration/README.mkd +29 -0
- data/integration/configs/README.mkd +7 -0
- data/integration/configs/pe/centos-6-64mda +25 -0
- data/integration/configs/pe/centos-7-64mda +25 -0
- data/integration/configs/pe/debian-6-64mda +25 -0
- data/integration/configs/pe/debian-7-64mda +25 -0
- data/integration/configs/pe/redhat-6-64mda +25 -0
- data/integration/configs/pe/redhat-7-64mda +25 -0
- data/integration/configs/pe/sles-11-64mda +25 -0
- data/integration/configs/pe/ubuntu-1004-64mda +25 -0
- data/integration/configs/pe/ubuntu-1204-64mda +25 -0
- data/integration/configs/pe/ubuntu-1404-64mda +25 -0
- data/integration/files/README.mkd +4 -0
- data/integration/files/hiera.yaml +8 -0
- data/integration/files/modules/helloworld/manifests/init.pp +3 -0
- data/integration/files/modules/hieratest/manifests/init.pp +3 -0
- data/integration/files/modules/unicode/files/pretend_unicode +1 -0
- data/integration/files/modules/unicode/manifests/init.pp +6 -0
- data/integration/files/pre-suite/prod_env.config +3 -0
- data/integration/files/r10k_conf.yaml.erb +9 -0
- data/integration/lib/README.mkd +4 -0
- data/integration/lib/git_utils.rb +205 -0
- data/integration/lib/master_manipulator.rb +205 -0
- data/integration/lib/r10k_utils.rb +166 -0
- data/integration/manifests/README.mkd +4 -0
- data/integration/pre-suite/00_pe_install.rb +4 -0
- data/integration/pre-suite/01_git_config.rb +59 -0
- data/integration/pre-suite/02_pe_r10k.rb +60 -0
- data/integration/pre-suite/03_test_utils.rb +17 -0
- data/integration/pre-suite/README.mkd +5 -0
- data/integration/test_run_scripts/README.mkd +5 -0
- data/integration/test_run_scripts/all_tests-rugged-pe-centos6.sh +20 -0
- data/integration/test_run_scripts/all_tests-rugged-pe-rhel7.sh +20 -0
- data/integration/test_run_scripts/all_tests-rugged-pe-sles11.sh +20 -0
- data/integration/test_run_scripts/all_tests-rugged-pe-ubuntu1204.sh +20 -0
- data/integration/test_run_scripts/all_tests-rugged-pe-ubuntu1404.sh +20 -0
- data/integration/test_run_scripts/all_tests-shellgit-pe-centos6.sh +20 -0
- data/integration/test_run_scripts/all_tests-shellgit-pe-rhel7.sh +20 -0
- data/integration/test_run_scripts/all_tests-shellgit-pe-sles11.sh +20 -0
- data/integration/test_run_scripts/all_tests-shellgit-pe-ubuntu1204.sh +20 -0
- data/integration/test_run_scripts/all_tests-shellgit-pe-ubuntu1404.sh +20 -0
- data/integration/test_run_scripts/basic_functionality/all_tests-pe-centos6.sh +20 -0
- data/integration/test_run_scripts/command_line/all_tests-pe-centos6.sh +20 -0
- data/integration/test_run_scripts/git_source/all_tests-pe-centos6.sh +20 -0
- data/integration/test_run_scripts/user_scenario/basic_workflow/all_tests-pe-centos6.sh +20 -0
- data/integration/test_run_scripts/user_scenario/complex_workflow/all_tests-pe-centos6.sh +20 -0
- data/integration/tests/README.mkd +4 -0
- data/integration/tests/basic_functionality/negative/neg_deploy_with_invalid_r10k_yaml.rb +46 -0
- data/integration/tests/basic_functionality/negative/neg_deploy_with_missing_r10k_yaml.rb +27 -0
- data/integration/tests/command_line/deploy_env_without_mod_update.rb +75 -0
- data/integration/tests/command_line/negative/neg_deploy_env_with_module_update.rb +76 -0
- data/integration/tests/command_line/negative/neg_invalid_cli_dep_flag.rb +22 -0
- data/integration/tests/command_line/negative/neg_invalid_cli_env_flag.rb +22 -0
- data/integration/tests/command_line/negative/neg_invalid_cmd_line_arg.rb +24 -0
- data/integration/tests/git_source/git_source_git.rb +123 -0
- data/integration/tests/git_source/git_source_ssh.rb +84 -0
- data/integration/tests/git_source/git_source_submodule.rb +69 -0
- data/integration/tests/git_source/negative/neg_git_broken_remote.rb +37 -0
- data/integration/tests/git_source/negative/neg_git_unauthorized_https.rb +45 -0
- data/integration/tests/git_source/negative/neg_git_unauthorized_ssh.rb +72 -0
- data/integration/tests/git_source/negative/neg_git_unicode_branch.rb +34 -0
- data/integration/tests/user_scenario/basic_workflow/multi_env_1000_branches.rb +66 -0
- data/integration/tests/user_scenario/basic_workflow/multi_env_custom_forge_git_module.rb +110 -0
- data/integration/tests/user_scenario/basic_workflow/multi_env_custom_forge_git_module_static.rb +113 -0
- data/integration/tests/user_scenario/basic_workflow/multi_env_hiera.rb +93 -0
- data/integration/tests/user_scenario/basic_workflow/multi_env_multi_source.rb +132 -0
- data/integration/tests/user_scenario/basic_workflow/multi_source_custom_forge_git_module.rb +160 -0
- data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_basedir.rb +45 -0
- data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_forge_module.rb +43 -0
- data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_git_module.rb +40 -0
- data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_git_module_ref.rb +42 -0
- data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_git_remote.rb +44 -0
- data/integration/tests/user_scenario/basic_workflow/negative/neg_branch_name_collision.rb +63 -0
- data/integration/tests/user_scenario/basic_workflow/negative/neg_disk_full.rb +73 -0
- data/integration/tests/user_scenario/basic_workflow/negative/neg_duplicate_module_names.rb +45 -0
- data/integration/tests/user_scenario/basic_workflow/negative/neg_inaccessible_forge.rb +51 -0
- data/integration/tests/user_scenario/basic_workflow/negative/neg_invalid_env_name.rb +33 -0
- data/integration/tests/user_scenario/basic_workflow/negative/neg_invalid_puppet_file.rb +35 -0
- data/integration/tests/user_scenario/basic_workflow/negative/neg_module_specified_at_deleted_release.rb +44 -0
- data/integration/tests/user_scenario/basic_workflow/negative/neg_read_only.rb +57 -0
- data/integration/tests/user_scenario/basic_workflow/negative/neg_specify_deleted_forge_module.rb +44 -0
- data/integration/tests/user_scenario/basic_workflow/single_env_10000_files.rb +73 -0
- data/integration/tests/user_scenario/basic_workflow/single_env_custom_forge_git_module.rb +103 -0
- data/integration/tests/user_scenario/basic_workflow/single_env_custom_forge_module.rb +80 -0
- data/integration/tests/user_scenario/basic_workflow/single_env_custom_module.rb +48 -0
- data/integration/tests/user_scenario/basic_workflow/single_env_large_files.rb +73 -0
- data/integration/tests/user_scenario/basic_workflow/single_env_module_already_installed.rb +81 -0
- data/integration/tests/user_scenario/basic_workflow/single_env_module_last_release_deleted.rb +67 -0
- data/integration/tests/user_scenario/basic_workflow/single_env_non-existent_base_dir.rb +93 -0
- data/integration/tests/user_scenario/basic_workflow/single_env_purge_unmanaged_modules.rb +92 -0
- data/integration/tests/user_scenario/basic_workflow/single_env_switch_forge_git_module.rb +116 -0
- data/integration/tests/user_scenario/basic_workflow/single_env_unicode_paths.rb +59 -0
- data/integration/tests/user_scenario/basic_workflow/single_env_upgrade_forge_mod_revert_change.rb +165 -0
- data/integration/tests/user_scenario/complex_workflow/multi_env_add_change_remove.rb +162 -0
- data/integration/tests/user_scenario/complex_workflow/multi_env_remove_re-add.rb +110 -0
- data/lib/r10k/action/cri_runner.rb +10 -13
- data/lib/r10k/cli.rb +3 -8
- data/lib/r10k/cli/version.rb +10 -1
- data/lib/r10k/deployment/config.rb +26 -6
- data/lib/r10k/deployment/config/loader.rb +38 -29
- data/lib/r10k/deployment/source.rb +2 -4
- data/lib/r10k/environment/git.rb +10 -19
- data/lib/r10k/environment/name.rb +86 -0
- data/lib/r10k/errors.rb +8 -5
- data/lib/r10k/feature.rb +35 -0
- data/lib/r10k/feature/collection.rb +23 -0
- data/lib/r10k/features.rb +18 -0
- data/lib/r10k/git.rb +106 -12
- data/lib/r10k/git/alternates.rb +2 -2
- data/lib/r10k/git/cache.rb +43 -26
- data/lib/r10k/git/errors.rb +12 -6
- data/lib/r10k/git/head.rb +3 -0
- data/lib/r10k/git/ref.rb +3 -0
- data/lib/r10k/git/remote_head.rb +6 -0
- data/lib/r10k/git/repository.rb +6 -0
- data/lib/r10k/git/rugged.rb +17 -0
- data/lib/r10k/git/rugged/bare_repository.rb +86 -0
- data/lib/r10k/git/rugged/base_repository.rb +90 -0
- data/lib/r10k/git/rugged/cache.rb +11 -0
- data/lib/r10k/git/rugged/thin_repository.rb +72 -0
- data/lib/r10k/git/rugged/working_repository.rb +99 -0
- data/lib/r10k/git/shellgit.rb +9 -0
- data/lib/r10k/git/shellgit/bare_repository.rb +29 -0
- data/lib/r10k/git/shellgit/base_repository.rb +102 -0
- data/lib/r10k/git/shellgit/cache.rb +11 -0
- data/lib/r10k/git/shellgit/thin_repository.rb +56 -0
- data/lib/r10k/git/shellgit/working_repository.rb +73 -0
- data/lib/r10k/git/stateful_repository.rb +80 -0
- data/lib/r10k/git/tag.rb +3 -0
- data/lib/r10k/git/working_dir.rb +15 -2
- data/lib/r10k/logging.rb +73 -36
- data/lib/r10k/logging/terminaloutputter.rb +36 -0
- data/lib/r10k/module/forge.rb +10 -9
- data/lib/r10k/module/git.rb +14 -44
- data/lib/r10k/module/metadata_file.rb +31 -0
- data/lib/r10k/module/svn.rb +0 -1
- data/lib/r10k/module_repository/forge.rb +20 -7
- data/lib/r10k/puppetfile.rb +1 -1
- data/lib/r10k/settings/container.rb +6 -0
- data/lib/r10k/settings/mixin.rb +9 -0
- data/lib/r10k/source.rb +2 -3
- data/lib/r10k/source/base.rb +5 -5
- data/lib/r10k/source/git.rb +11 -86
- data/lib/r10k/source/svn.rb +8 -52
- data/lib/r10k/util/basedir.rb +4 -4
- data/lib/r10k/util/commands.rb +31 -0
- data/lib/r10k/util/exec_env.rb +36 -0
- data/lib/r10k/util/platform.rb +4 -0
- data/lib/r10k/util/purgeable.rb +2 -2
- data/lib/r10k/util/subprocess.rb +3 -7
- data/lib/r10k/util/subprocess/runner.rb +3 -28
- data/lib/r10k/util/subprocess/runner/posix.rb +103 -0
- data/lib/r10k/util/subprocess/runner/pump.rb +59 -0
- data/lib/r10k/util/subprocess/{windows/runner.rb → runner/windows.rb} +2 -11
- data/lib/r10k/util/symbolize_keys.rb +31 -0
- data/lib/r10k/version.rb +1 -1
- data/lib/shared/puppet/module_tool/metadata.rb +197 -0
- data/r10k.gemspec +7 -5
- data/spec/fixtures/integration/git/puppet-boolean-bare.tar +0 -0
- data/spec/fixtures/module/forge/bad_module/metadata.json +1 -0
- data/spec/fixtures/unit/util/subprocess/posix/runner/no-execute.sh +3 -0
- data/spec/fixtures/vcr/cassettes/R10K_ModuleRepository_Forge/and_the_expected_version_is_latest/can_fetch_all_versions_of_a_given_module.yml +171 -26
- data/spec/fixtures/vcr/cassettes/R10K_ModuleRepository_Forge/and_the_expected_version_is_latest/can_fetch_the_latest_version_of_a_given_module.yml +171 -26
- data/spec/fixtures/vcr/cassettes/R10K_ModuleRepository_Forge/and_the_expected_version_is_latest/ignores_deleted_releases.yml +190 -0
- data/spec/fixtures/vcr/cassettes/R10K_ModuleRepository_Forge/it_handles_errors_from_forgeapi_puppetlabs_com/raises_an_error_for_a_non-existant_module.yml +34 -0
- 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 +87 -26
- data/spec/integration/git/rugged/bare_repository_spec.rb +13 -0
- data/spec/integration/git/rugged/thin_repository_spec.rb +14 -0
- data/spec/integration/git/rugged/working_repository_spec.rb +13 -0
- data/spec/integration/git/shellgit/bare_repository_spec.rb +13 -0
- data/spec/integration/git/shellgit/thin_repository_spec.rb +14 -0
- data/spec/integration/git/shellgit/working_repository_spec.rb +13 -0
- data/spec/integration/git/stateful_repository_spec.rb +104 -0
- data/spec/matchers/match_realpath.rb +18 -0
- data/spec/shared-contexts/git-fixtures.rb +55 -0
- data/spec/shared-examples/git-repository.rb +38 -0
- data/spec/shared-examples/git/bare_repository.rb +70 -0
- data/spec/shared-examples/git/thin_repository.rb +26 -0
- data/spec/shared-examples/git/working_repository.rb +115 -0
- data/spec/shared-examples/subprocess-runner.rb +83 -0
- data/spec/spec_helper.rb +13 -9
- data/spec/unit/action/cri_runner_spec.rb +0 -6
- data/spec/unit/action/puppetfile/{cri_action_spec.rb → cri_runner_spec.rb} +0 -0
- data/spec/unit/deployment/config/loader_spec.rb +48 -0
- data/spec/unit/deployment/config_spec.rb +49 -0
- data/spec/unit/environment/git_spec.rb +5 -39
- data/spec/unit/environment/name_spec.rb +135 -0
- data/spec/unit/feature_spec.rb +50 -0
- data/spec/unit/git/alternates_spec.rb +1 -1
- data/spec/unit/git/cache_spec.rb +32 -19
- data/spec/unit/git/commit_spec.rb +1 -0
- data/spec/unit/git/head_spec.rb +1 -6
- data/spec/unit/git/ref_spec.rb +0 -23
- data/spec/unit/git/rugged/cache_spec.rb +26 -0
- data/spec/unit/git/shellgit/cache_spec.rb +27 -0
- data/spec/unit/git/stateful_repository_spec.rb +43 -0
- data/spec/unit/git/tag_spec.rb +1 -0
- data/spec/unit/git/working_dir_spec.rb +1 -0
- data/spec/unit/git_spec.rb +74 -0
- data/spec/unit/logging/terminaloutputter_spec.rb +53 -0
- data/spec/unit/logging_spec.rb +68 -0
- data/spec/unit/module/forge_spec.rb +7 -38
- data/spec/unit/module/git_spec.rb +7 -38
- data/spec/unit/module/metadata_file_spec.rb +69 -0
- data/spec/unit/module/svn_spec.rb +0 -4
- data/spec/unit/module_repository/forge_spec.rb +22 -1
- data/spec/unit/puppet/module_tool/metadata_spec.rb +301 -0
- data/spec/unit/settings/container_spec.rb +17 -0
- data/spec/unit/source/git_spec.rb +0 -123
- data/spec/unit/source/svn_spec.rb +66 -0
- data/spec/unit/util/commands_spec.rb +61 -0
- data/spec/unit/util/exec_env_spec.rb +56 -0
- data/spec/unit/util/subprocess/runner/posix_spec.rb +7 -0
- data/spec/unit/util/subprocess/runner/pump_spec.rb +79 -0
- data/spec/unit/util/subprocess_spec.rb +3 -2
- data/spec/unit/util/symbolize_keys_spec.rb +51 -0
- metadata +226 -45
- data/lib/r10k/execution.rb +0 -47
- data/lib/r10k/module/metadata.rb +0 -47
- data/lib/r10k/util/core_ext/hash_ext.rb +0 -19
- data/lib/r10k/util/subprocess/io.rb +0 -7
- data/lib/r10k/util/subprocess/posix.rb +0 -4
- data/lib/r10k/util/subprocess/posix/io.rb +0 -7
- data/lib/r10k/util/subprocess/posix/runner.rb +0 -140
- data/lib/r10k/util/subprocess/windows.rb +0 -4
- data/lib/r10k/util/subprocess/windows/io.rb +0 -6
- data/spec/fixtures/vcr/cassettes/R10K_ModuleRepository_Forge/looking_up_versions.yml +0 -42
- data/spec/fixtures/vcr/cassettes/R10K_ModuleRepository_Forge/looking_up_versions/can_fetch_all_versions_of_a_given_module.yml +0 -42
- data/spec/fixtures/vcr/cassettes/R10K_ModuleRepository_Forge/looking_up_versions/can_fetch_the_latest_version_of_a_given_module.yml +0 -42
- data/spec/unit/deployment/source_spec.rb +0 -24
- data/spec/unit/module/metadata_spec.rb +0 -68
- data/spec/unit/util/core_ext/hash_ext_spec.rb +0 -63
@@ -0,0 +1,83 @@
|
|
1
|
+
shared_examples_for "a subprocess runner" do |fixture_root|
|
2
|
+
|
3
|
+
describe "running 'echo test'" do
|
4
|
+
subject { described_class.new(%w[echo test]) }
|
5
|
+
|
6
|
+
it "sets the exit code to 0" do
|
7
|
+
result = subject.run
|
8
|
+
expect(result.exit_code).to eq 0
|
9
|
+
end
|
10
|
+
|
11
|
+
it "returns the contents of stdout" do
|
12
|
+
result = subject.run
|
13
|
+
expect(result.stdout).to eq 'test'
|
14
|
+
end
|
15
|
+
|
16
|
+
it "indicates the command succeeded" do
|
17
|
+
result = subject.run
|
18
|
+
expect(result).to be_success
|
19
|
+
expect(result).to_not be_failed
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "running a command with a large amount of output" do
|
24
|
+
subject do
|
25
|
+
described_class.new(['ruby', '-e', 'blob = "buffalo!" * (2 << 16); puts blob'])
|
26
|
+
end
|
27
|
+
|
28
|
+
it "does not hang" do
|
29
|
+
Timeout.timeout(5) do
|
30
|
+
subject.run
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "running 'ls' with a different working directory" do
|
36
|
+
subject do
|
37
|
+
described_class.new(%w[ls]).tap do |o|
|
38
|
+
o.cwd = fixture_root
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
it "returns the contents of the given working directory" do
|
43
|
+
result = subject.run
|
44
|
+
expect(result.stdout).to eq 'no-execute.sh'
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "running 'false'" do
|
49
|
+
subject { described_class.new(%w[false]) }
|
50
|
+
|
51
|
+
it "sets the exit code to 1" do
|
52
|
+
result = subject.run
|
53
|
+
expect(result.exit_code).to eq 1
|
54
|
+
end
|
55
|
+
|
56
|
+
it "indicates the command failed" do
|
57
|
+
result = subject.run
|
58
|
+
expect(result).to_not be_success
|
59
|
+
expect(result).to be_failed
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "running '/this/command/will/not/exist'" do
|
64
|
+
subject { described_class.new(%w[/this/command/will/not/exist]) }
|
65
|
+
|
66
|
+
it "indicates the command failed" do
|
67
|
+
result = subject.run
|
68
|
+
expect(result).to_not be_success
|
69
|
+
expect(result).to be_failed
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe "running a non-executable file", :unless => R10K::Util::Platform.windows? do
|
74
|
+
let(:fixture_file) { File.join(fixture_root, 'no-execute.sh') }
|
75
|
+
subject { described_class.new([fixture_file]) }
|
76
|
+
|
77
|
+
it "indicates the command failed" do
|
78
|
+
result = subject.run
|
79
|
+
expect(result).to_not be_success
|
80
|
+
expect(result).to be_failed
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,8 +1,11 @@
|
|
1
|
+
PROJECT_ROOT = File.expand_path('..', File.dirname(__FILE__))
|
2
|
+
|
1
3
|
if ENV['COVERAGE']
|
2
4
|
require 'simplecov'
|
3
5
|
SimpleCov.start do
|
6
|
+
libdir = File.join(PROJECT_ROOT, 'lib')
|
4
7
|
add_filter do |src|
|
5
|
-
!src.filename.match(%r[
|
8
|
+
!src.filename.match(%r[\A#{libdir}])
|
6
9
|
end
|
7
10
|
|
8
11
|
%w[Deployment Source Environment Module Git SVN Action Util].each do |group|
|
@@ -13,27 +16,28 @@ end
|
|
13
16
|
|
14
17
|
require 'r10k'
|
15
18
|
|
16
|
-
|
19
|
+
Dir.glob(File.expand_path('spec/shared-examples/**/*.rb', PROJECT_ROOT)).each { |file| require file }
|
20
|
+
|
21
|
+
require 'shared-contexts/git-fixtures'
|
17
22
|
require 'matchers/exit_with'
|
23
|
+
require 'matchers/match_realpath'
|
18
24
|
require 'r10k-mocks'
|
19
25
|
|
20
|
-
PROJECT_ROOT = File.expand_path('..', File.dirname(__FILE__))
|
21
26
|
|
22
27
|
require 'vcr'
|
23
28
|
VCR.configure do |vcr|
|
24
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.
|
25
34
|
vcr.hook_into :faraday
|
26
35
|
vcr.configure_rspec_metadata!
|
27
36
|
end
|
28
37
|
|
29
38
|
RSpec.configure do |config|
|
30
|
-
# Filter out integration tests by default
|
31
|
-
#
|
32
|
-
# To run integration tests, run `rspec --tag integration`
|
33
|
-
config.filter_run_excluding :integration => true
|
34
|
-
|
35
39
|
config.before(:all) do
|
36
|
-
Log4r::Logger.global.level =
|
40
|
+
Log4r::Logger.global.level = Log4r::OFF
|
37
41
|
end
|
38
42
|
end
|
39
43
|
|
@@ -30,12 +30,6 @@ describe R10K::Action::CriRunner do
|
|
30
30
|
output = {:value => :yep, :loglevel => 'DEBUG'}
|
31
31
|
expect(cri_runner.handle_opts(input)).to eq(output)
|
32
32
|
end
|
33
|
-
|
34
|
-
it "sets the non-argument form of :verbose to :loglevel => 'INFO'" do
|
35
|
-
input = {:value => :yep, :verbose => true}
|
36
|
-
output = {:value => :yep, :loglevel => 'INFO'}
|
37
|
-
expect(cri_runner.handle_opts(input)).to eq(output)
|
38
|
-
end
|
39
33
|
end
|
40
34
|
|
41
35
|
describe "handling arguments" do
|
File without changes
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'r10k/deployment/config/loader'
|
3
|
+
|
4
|
+
describe R10K::Deployment::Config::Loader do
|
5
|
+
|
6
|
+
context 'populate_loadpath' do
|
7
|
+
it 'includes /etc/puppetlabs/r10k/r10k.yaml in the loadpath' do
|
8
|
+
expect(subject.loadpath).to include('/etc/puppetlabs/r10k/r10k.yaml')
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'includes /etc/r10k.yaml in the loadpath' do
|
12
|
+
expect(subject.loadpath).to include('/etc/r10k.yaml')
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'does include the current working directory in the loadpath' do
|
16
|
+
allow(Dir).to receive(:getwd).and_return '/some/random/path/westvletren'
|
17
|
+
expect(subject.loadpath).to include('/some/random/path/westvletren/r10k.yaml')
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'does not include /some/random/path/atomium/r10k.yaml in the loadpath' do
|
21
|
+
expect(subject.loadpath).not_to include('/some/random/path/atomium/r10k.yaml')
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'search' do
|
27
|
+
it 'returns the correct default location' do
|
28
|
+
allow(File).to receive(:file?).and_return false
|
29
|
+
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
|
+
expect(subject.search).to eq '/etc/puppetlabs/r10k/r10k.yaml'
|
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
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe R10K::Deployment::Config do
|
4
|
+
|
5
|
+
describe "reading settings" do
|
6
|
+
# Try all permutations of string/symbol values as arguments to #setting and
|
7
|
+
# values in the config file
|
8
|
+
x = [:key, "key"]
|
9
|
+
matrix = x.product(x)
|
10
|
+
|
11
|
+
matrix.each do |(searchvalue, configvalue)|
|
12
|
+
it "treats #{searchvalue.inspect}:#{searchvalue.class} and #{configvalue.inspect}:#{configvalue.class} as equivalent" do
|
13
|
+
expect(YAML).to receive(:load_file).with('foo/bar').and_return(configvalue => 'some/cache')
|
14
|
+
subject = described_class.new('foo/bar')
|
15
|
+
expect(subject.setting(searchvalue)).to eq 'some/cache'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "applying global settings" do
|
21
|
+
describe "for the cachedir" do
|
22
|
+
it "sets the git cache root when given" do
|
23
|
+
expect(YAML).to receive(:load_file).with('foo/bar').and_return('cachedir' => 'some/cache')
|
24
|
+
expect(R10K::Git::Cache.settings).to receive(:[]=).with(:cache_root, 'some/cache')
|
25
|
+
described_class.new('foo/bar')
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "for git" do
|
30
|
+
it "sets the git provider when given" do
|
31
|
+
expect(YAML).to receive(:load_file).with('foo/bar').and_return('git' => {'provider' => 'rugged'})
|
32
|
+
expect(R10K::Git).to receive(:provider=).with(:rugged)
|
33
|
+
described_class.new('foo/bar')
|
34
|
+
end
|
35
|
+
|
36
|
+
it "sets the git ssh username when given" do
|
37
|
+
expect(YAML).to receive(:load_file).with('foo/bar').and_return('git' => {'username' => 'grit'})
|
38
|
+
expect(R10K::Git.settings).to receive(:[]=).with(:username, 'grit')
|
39
|
+
described_class.new('foo/bar')
|
40
|
+
end
|
41
|
+
|
42
|
+
it "sets the git private key when given" do
|
43
|
+
expect(YAML).to receive(:load_file).with('foo/bar').and_return('git' => {'private_key' => '/home/user/.ssh/id_rsa'})
|
44
|
+
expect(R10K::Git.settings).to receive(:[]=).with(:private_key, '/home/user/.ssh/id_rsa')
|
45
|
+
described_class.new('foo/bar')
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -15,8 +15,6 @@ describe R10K::Environment::Git do
|
|
15
15
|
)
|
16
16
|
end
|
17
17
|
|
18
|
-
let(:working_dir) { subject.working_dir }
|
19
|
-
|
20
18
|
describe "storing attributes" do
|
21
19
|
it "can return the environment name" do
|
22
20
|
expect(subject.name).to eq 'myenv'
|
@@ -40,8 +38,8 @@ describe R10K::Environment::Git do
|
|
40
38
|
end
|
41
39
|
|
42
40
|
describe "synchronizing the environment" do
|
43
|
-
it "syncs the
|
44
|
-
expect(
|
41
|
+
it "syncs the git repository" do
|
42
|
+
expect(subject.repo).to receive(:sync)
|
45
43
|
subject.sync
|
46
44
|
end
|
47
45
|
end
|
@@ -71,41 +69,9 @@ describe R10K::Environment::Git do
|
|
71
69
|
end
|
72
70
|
|
73
71
|
describe "determining the status" do
|
74
|
-
it "
|
75
|
-
expect(
|
76
|
-
expect(subject.status).to eq :
|
77
|
-
end
|
78
|
-
|
79
|
-
it "is mismatched when the working directory is not git" do
|
80
|
-
expect(working_dir).to receive(:exist?).and_return true
|
81
|
-
expect(working_dir).to receive(:git?).and_return false
|
82
|
-
expect(subject.status).to eq :mismatched
|
83
|
-
end
|
84
|
-
|
85
|
-
it "is mismatched when the working directory remote doesn't match the desired remote" do
|
86
|
-
expect(working_dir).to receive(:exist?).and_return true
|
87
|
-
expect(working_dir).to receive(:git?).and_return true
|
88
|
-
expect(working_dir).to receive(:remote).and_return 'git://git-server.site/my-other-repo.git'
|
89
|
-
expect(subject.status).to eq :mismatched
|
90
|
-
end
|
91
|
-
|
92
|
-
it "is is outdated when the working directory has not been synced" do
|
93
|
-
expect(working_dir).to receive(:exist?).and_return true
|
94
|
-
expect(working_dir).to receive(:git?).and_return true
|
95
|
-
expect(working_dir).to receive(:remote).and_return 'git://git-server.site/my-repo.git'
|
96
|
-
expect(subject.status).to eq :outdated
|
97
|
-
end
|
98
|
-
|
99
|
-
it "is is insync when the working directory has been synced" do
|
100
|
-
expect(working_dir).to receive(:exist?).and_return true
|
101
|
-
expect(working_dir).to receive(:git?).and_return true
|
102
|
-
expect(working_dir).to receive(:remote).and_return 'git://git-server.site/my-repo.git'
|
103
|
-
|
104
|
-
expect(working_dir).to receive(:sync)
|
105
|
-
|
106
|
-
subject.sync
|
107
|
-
|
108
|
-
expect(subject.status).to eq :insync
|
72
|
+
it "delegates to the repo" do
|
73
|
+
expect(subject.repo).to receive(:status).and_return :some_status
|
74
|
+
expect(subject.status).to eq :some_status
|
109
75
|
end
|
110
76
|
end
|
111
77
|
end
|
@@ -0,0 +1,135 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'r10k/environment/name'
|
3
|
+
|
4
|
+
describe R10K::Environment::Name do
|
5
|
+
describe "prefixing" do
|
6
|
+
it "uses the branch name as the dirname when prefixing is off" do
|
7
|
+
bn = described_class.new('mybranch', :source => 'source', :prefix => false)
|
8
|
+
expect(bn.dirname).to eq 'mybranch'
|
9
|
+
end
|
10
|
+
|
11
|
+
it "prepends the source name when prefixing is on" do
|
12
|
+
bn = described_class.new('mybranch', :source => 'source', :prefix => true)
|
13
|
+
expect(bn.dirname).to eq 'source_mybranch'
|
14
|
+
end
|
15
|
+
|
16
|
+
it "prepends the prefix name when prefixing is overridden" do
|
17
|
+
bn = described_class.new('mybranch', {:prefix => "bar", :sourcename => 'foo'})
|
18
|
+
expect(bn.dirname).to eq 'bar_mybranch'
|
19
|
+
end
|
20
|
+
|
21
|
+
it "uses the branch name as the dirname when prefixing is nil" do
|
22
|
+
bn = described_class.new('mybranch', {:prefix => nil, :sourcename => 'foo'})
|
23
|
+
expect(bn.dirname).to eq 'mybranch'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "determining the validate behavior with :invalid" do
|
28
|
+
[
|
29
|
+
['correct_and_warn', {:validate => true, :correct => true}],
|
30
|
+
['correct', {:validate => false, :correct => true}],
|
31
|
+
['error', {:validate => true, :correct => false}],
|
32
|
+
].each do |(setting, outcome)|
|
33
|
+
it "treats #{setting} as #{outcome.inspect}" do
|
34
|
+
bn = described_class.new('mybranch', :source => 'source', :invalid => setting)
|
35
|
+
expect(bn.validate?).to eq outcome[:validate]
|
36
|
+
expect(bn.correct?).to eq outcome[:correct]
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "determining if a branch is a valid environment name" do
|
42
|
+
invalid_cases = [
|
43
|
+
'hyphenated-branch',
|
44
|
+
'dotted.branch',
|
45
|
+
'slashed/branch',
|
46
|
+
'at@branch',
|
47
|
+
'http://branch'
|
48
|
+
]
|
49
|
+
|
50
|
+
valid_cases = [
|
51
|
+
'my_branchname',
|
52
|
+
'my_issue_346',
|
53
|
+
]
|
54
|
+
|
55
|
+
describe "and validate is false" do
|
56
|
+
invalid_cases.each do |branch|
|
57
|
+
it "is valid if the branch is #{branch}" do
|
58
|
+
bn = described_class.new(branch, {:validate => false})
|
59
|
+
expect(bn).to be_valid
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
valid_cases.each do |branch|
|
64
|
+
it "is valid if the branch is #{branch}" do
|
65
|
+
bn = described_class.new(branch, {:validate => false})
|
66
|
+
expect(bn).to be_valid
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe "and validate is true" do
|
72
|
+
invalid_cases.each do |branch|
|
73
|
+
it "is invalid if the branch is #{branch}" do
|
74
|
+
bn = described_class.new(branch, {:validate => true})
|
75
|
+
expect(bn).to_not be_valid
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
valid_cases.each do |branch|
|
80
|
+
it "is valid if the branch is #{branch}" do
|
81
|
+
bn = described_class.new(branch, {:validate => true})
|
82
|
+
expect(bn).to be_valid
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe "correcting branch names" do
|
90
|
+
invalid_cases = [
|
91
|
+
'hyphenated-branch',
|
92
|
+
'dotted.branch',
|
93
|
+
'slashed/branch',
|
94
|
+
'at@branch',
|
95
|
+
'http://branch'
|
96
|
+
]
|
97
|
+
|
98
|
+
valid_cases = [
|
99
|
+
'my_branchname',
|
100
|
+
'my_issue_346',
|
101
|
+
]
|
102
|
+
|
103
|
+
describe "and correct is false" do
|
104
|
+
invalid_cases.each do |branch|
|
105
|
+
it "doesn't modify #{branch}" do
|
106
|
+
bn = described_class.new(branch.dup, {:correct => false})
|
107
|
+
expect(bn.dirname).to eq branch
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
valid_cases.each do |branch|
|
112
|
+
it "doesn't modify #{branch}" do
|
113
|
+
bn = described_class.new(branch.dup, {:correct => false})
|
114
|
+
expect(bn.dirname).to eq branch
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
describe "and correct is true" do
|
120
|
+
invalid_cases.each do |branch|
|
121
|
+
it "replaces invalid characters in #{branch} with underscores" do
|
122
|
+
bn = described_class.new(branch.dup, {:correct => true})
|
123
|
+
expect(bn.dirname).to eq branch.gsub(/\W/, '_')
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
valid_cases.each do |branch|
|
128
|
+
it "doesn't modify #{branch}" do
|
129
|
+
bn = described_class.new(branch.dup, {:correct => true})
|
130
|
+
expect(bn.dirname).to eq branch
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|