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,110 @@
|
|
1
|
+
require 'git_utils'
|
2
|
+
require 'r10k_utils'
|
3
|
+
require 'master_manipulator'
|
4
|
+
test_name 'CODEMGMT-48 - C59263 - Multiple Environments with Adding, Removing and Re-adding Same Branch Name'
|
5
|
+
|
6
|
+
#Init
|
7
|
+
master_certname = on(master, puppet('config', 'print', 'certname')).stdout.rstrip
|
8
|
+
git_environments_path = '/root/environments'
|
9
|
+
last_commit = git_last_commit(master, git_environments_path)
|
10
|
+
local_files_root_path = ENV['FILES'] || 'files'
|
11
|
+
helloworld_module_path = File.join(local_files_root_path, 'modules', 'helloworld')
|
12
|
+
|
13
|
+
initial_env_names = ['production', 'stage']
|
14
|
+
|
15
|
+
#Verification
|
16
|
+
notify_message_regex = /I am in the production environment/
|
17
|
+
stage_env_error_message_regex = /Error:.*Could not find environment 'stage'/
|
18
|
+
|
19
|
+
#Manifest
|
20
|
+
site_pp_path = File.join(git_environments_path, 'manifests', 'site.pp')
|
21
|
+
site_pp = create_site_pp(master_certname, ' include helloworld')
|
22
|
+
|
23
|
+
#Teardown
|
24
|
+
teardown do
|
25
|
+
clean_up_r10k(master, last_commit, git_environments_path)
|
26
|
+
end
|
27
|
+
|
28
|
+
#Setup
|
29
|
+
initial_env_names.each do |env|
|
30
|
+
if env == 'production'
|
31
|
+
step "Checkout \"#{env}\" Branch"
|
32
|
+
git_on(master, "checkout #{env}", git_environments_path)
|
33
|
+
|
34
|
+
step "Copy \"helloworld\" Module to \"#{env}\" Environment Git Repo"
|
35
|
+
scp_to(master, helloworld_module_path, File.join(git_environments_path, "site", 'helloworld'))
|
36
|
+
|
37
|
+
step "Inject New \"site.pp\" to the \"#{env}\" Environment"
|
38
|
+
inject_site_pp(master, site_pp_path, site_pp)
|
39
|
+
|
40
|
+
step "Push Changes to \"#{env}\" Environment"
|
41
|
+
git_add_commit_push(master, env, 'Update site.pp and add module.', git_environments_path)
|
42
|
+
else
|
43
|
+
step "Create \"#{env}\" Branch from \"production\""
|
44
|
+
git_on(master, 'checkout production', git_environments_path)
|
45
|
+
git_on(master, "checkout -b #{env}", git_environments_path)
|
46
|
+
|
47
|
+
step "Push Changes to \"#{env}\" Environment"
|
48
|
+
git_push(master, env, git_environments_path)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
#Tests
|
53
|
+
step 'Deploy Environments via r10k'
|
54
|
+
on(master, 'r10k deploy environment -v')
|
55
|
+
|
56
|
+
#Initial Verification
|
57
|
+
initial_env_names.each do |env|
|
58
|
+
agents.each do |agent|
|
59
|
+
step "Run Puppet Agent Against \"#{env}\" Environment"
|
60
|
+
on(agent, puppet('agent', '--test', "--environment #{env}"), :acceptable_exit_codes => 2) do |result|
|
61
|
+
assert_no_match(/Error:/, result.stderr, 'Unexpected error was detected!')
|
62
|
+
assert_match(/I am in the #{env} environment/, result.stdout, 'Expected message not found!')
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
#Remove "stage" Environment
|
68
|
+
step 'Delete the "stage" Environment'
|
69
|
+
git_on(master, 'checkout production', git_environments_path)
|
70
|
+
git_on(master, 'branch -D stage', git_environments_path)
|
71
|
+
git_on(master, 'push origin --delete stage', git_environments_path)
|
72
|
+
|
73
|
+
step 'Re-deploy Environments via r10k'
|
74
|
+
on(master, 'r10k deploy environment -v')
|
75
|
+
|
76
|
+
#Second Pass Verification
|
77
|
+
agents.each do |agent|
|
78
|
+
step 'Run Puppet Agent Against "production" Environment'
|
79
|
+
on(agent, puppet('agent', '--test', '--environment production'), :acceptable_exit_codes => 2) do |result|
|
80
|
+
assert_no_match(/Error:/, result.stderr, 'Unexpected error was detected!')
|
81
|
+
assert_match(notify_message_regex, result.stdout, 'Expected message not found!')
|
82
|
+
end
|
83
|
+
|
84
|
+
step 'Attempt to Run Puppet Agent Against "stage" Environment'
|
85
|
+
on(agent, puppet('agent', '--test', '--environment stage'), :acceptable_exit_codes => 1) do |result|
|
86
|
+
assert_match(stage_env_error_message_regex, result.stderr, 'Expected error was not detected!')
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
#Create the "stage" Environment Again
|
91
|
+
step 'Create "stage" Branch from "production"'
|
92
|
+
git_on(master, 'checkout production', git_environments_path)
|
93
|
+
git_on(master, 'checkout -b stage', git_environments_path)
|
94
|
+
|
95
|
+
step 'Push Changes to "stage" Environment'
|
96
|
+
git_push(master, 'stage', git_environments_path)
|
97
|
+
|
98
|
+
step 'Re-deploy Environments via r10k'
|
99
|
+
on(master, 'r10k deploy environment -v')
|
100
|
+
|
101
|
+
#Final Verification
|
102
|
+
initial_env_names.each do |env|
|
103
|
+
agents.each do |agent|
|
104
|
+
step "Run Puppet Agent Against \"#{env}\" Environment"
|
105
|
+
on(agent, puppet('agent', '--test', "--environment #{env}"), :acceptable_exit_codes => 2) do |result|
|
106
|
+
assert_no_match(/Error:/, result.stderr, 'Unexpected error was detected!')
|
107
|
+
assert_match(/I am in the #{env} environment/, result.stdout, 'Expected message not found!')
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
@@ -41,19 +41,16 @@ module R10K
|
|
41
41
|
|
42
42
|
# @return [Hash] The adapted options for the runner
|
43
43
|
def handle_opts(opts)
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
# When the type is unsure just pass it in as-is and let the internals
|
55
|
-
# raise the appropriate errors.
|
56
|
-
opts[:loglevel] = loglevel
|
44
|
+
if opts[:verbose]
|
45
|
+
# Translate from the Cri verbose logging option to the internal logging setting.
|
46
|
+
opts[:loglevel] = opts.delete(:verbose)
|
47
|
+
end
|
48
|
+
|
49
|
+
# Colored logging is only appropriate for CLI interactions, so we
|
50
|
+
# handle this while we're still in CLI specific code.
|
51
|
+
use_color = opts.delete(:color)
|
52
|
+
if use_color
|
53
|
+
R10K::Logging.use_color = use_color
|
57
54
|
end
|
58
55
|
|
59
56
|
@opts = opts
|
data/lib/r10k/cli.rb
CHANGED
@@ -31,14 +31,9 @@ module R10K::CLI
|
|
31
31
|
flag :t, :trace, 'Display stack traces on application crash'
|
32
32
|
|
33
33
|
loglevels = R10K::Logging::LOG_LEVELS.reverse.map(&:downcase).join(", ")
|
34
|
-
optional :v, :verbose, "Set log verbosity. Valid values: #{loglevels}"
|
35
|
-
|
36
|
-
|
37
|
-
R10K::Logging.level = 'INFO'
|
38
|
-
when String
|
39
|
-
R10K::Logging.level = value
|
40
|
-
end
|
41
|
-
end
|
34
|
+
optional :v, :verbose, "Set log verbosity. Valid values: #{loglevels}"
|
35
|
+
|
36
|
+
flag nil, :color, 'Enable colored log messages'
|
42
37
|
|
43
38
|
required :c, :config, 'Specify a global configuration file (deprecated, use `r10k deploy -c`)' do |value, cmd|
|
44
39
|
logger.warn "Calling `r10k --config <action>` as a global option is deprecated; use r10k <action> --config"
|
data/lib/r10k/cli/version.rb
CHANGED
@@ -12,7 +12,16 @@ module R10K::CLI
|
|
12
12
|
summary 'Print the version of r10k'
|
13
13
|
|
14
14
|
run do |opts, args, cmd|
|
15
|
-
puts R10K::VERSION
|
15
|
+
puts "r10k #{R10K::VERSION}"
|
16
|
+
if opts[:verbose]
|
17
|
+
puts RUBY_DESCRIPTION
|
18
|
+
cmdpath = caller.last.slice(/\A.*#{$PROGRAM_NAME}/)
|
19
|
+
puts "Command path: #{cmdpath}"
|
20
|
+
puts "Interpreter path: #{Gem.ruby}"
|
21
|
+
if RUBY_VERSION >= '1.9'
|
22
|
+
puts "Default encoding: #{Encoding.default_external.name}"
|
23
|
+
end
|
24
|
+
end
|
16
25
|
exit 0
|
17
26
|
end
|
18
27
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'r10k/deployment'
|
2
2
|
require 'r10k/deployment/config/loader'
|
3
|
+
require 'r10k/util/symbolize_keys'
|
4
|
+
require 'r10k/errors'
|
3
5
|
require 'yaml'
|
4
6
|
|
5
7
|
module R10K
|
@@ -52,17 +54,35 @@ class Config
|
|
52
54
|
|
53
55
|
private
|
54
56
|
|
55
|
-
|
56
|
-
|
57
|
-
|
57
|
+
def with_setting(key, &block)
|
58
|
+
value = setting(key)
|
59
|
+
block.call(value) unless value.nil?
|
60
|
+
end
|
61
|
+
|
62
|
+
# Apply global configuration settings.
|
58
63
|
def apply_config_settings
|
59
|
-
cachedir
|
60
|
-
if cachedir
|
64
|
+
with_setting(:cachedir) do |cachedir|
|
61
65
|
R10K::Git::Cache.settings[:cache_root] = cachedir
|
62
66
|
end
|
67
|
+
|
68
|
+
with_setting(:git) do |git_settings|
|
69
|
+
R10K::Util::SymbolizeKeys.symbolize_keys!(git_settings)
|
70
|
+
provider = git_settings[:provider]
|
71
|
+
if provider
|
72
|
+
R10K::Git.provider = provider.to_sym
|
73
|
+
end
|
74
|
+
|
75
|
+
if git_settings[:private_key]
|
76
|
+
R10K::Git.settings[:private_key] = git_settings[:private_key]
|
77
|
+
end
|
78
|
+
|
79
|
+
if git_settings[:username]
|
80
|
+
R10K::Git.settings[:username] = git_settings[:username]
|
81
|
+
end
|
82
|
+
end
|
63
83
|
end
|
64
84
|
|
65
|
-
class ConfigError <
|
85
|
+
class ConfigError < R10K::Error
|
66
86
|
end
|
67
87
|
end
|
68
88
|
end
|
@@ -1,43 +1,52 @@
|
|
1
|
+
require 'r10k/logging'
|
1
2
|
|
2
3
|
module R10K
|
3
|
-
class Deployment
|
4
|
-
class Config
|
5
|
-
class Loader
|
6
|
-
# Search for a deployment configuration file (r10k.yaml) in all parent
|
7
|
-
# directories and in /etc/r10k.yaml
|
4
|
+
class Deployment
|
5
|
+
class Config
|
6
|
+
class Loader
|
8
7
|
|
9
|
-
|
10
|
-
@loadpath = []
|
8
|
+
include R10K::Logging
|
11
9
|
|
12
|
-
|
13
|
-
end
|
10
|
+
attr_reader :loadpath
|
14
11
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
end
|
12
|
+
CONFIG_FILE = 'r10k.yaml'
|
13
|
+
DEFAULT_LOCATION = File.join('/etc/puppetlabs/r10k', CONFIG_FILE)
|
14
|
+
OLD_DEFAULT_LOCATION = File.join('/etc', CONFIG_FILE)
|
19
15
|
|
20
|
-
|
16
|
+
# Search for a deployment configuration file (r10k.yaml) in several locations
|
17
|
+
def initialize
|
18
|
+
@loadpath = []
|
19
|
+
populate_loadpath
|
20
|
+
end
|
21
21
|
|
22
|
-
|
22
|
+
# @return [String] The path to the first valid configfile
|
23
|
+
def search
|
23
24
|
|
24
|
-
|
25
|
-
|
25
|
+
# If both default files are present, issue a warning.
|
26
|
+
if (File.file? DEFAULT_LOCATION) && (File.file? OLD_DEFAULT_LOCATION)
|
27
|
+
logger.warn "Both #{DEFAULT_LOCATION} and #{OLD_DEFAULT_LOCATION} configuration files exist."
|
28
|
+
logger.warn "#{DEFAULT_LOCATION} will be used."
|
29
|
+
end
|
26
30
|
|
27
|
-
|
28
|
-
|
29
|
-
full_path << dir_components[0...index]
|
30
|
-
full_path << dirname << 'r10k.yaml'
|
31
|
+
first = @loadpath.find {|filename| File.file? filename}
|
32
|
+
end
|
31
33
|
|
32
|
-
|
33
|
-
|
34
|
+
private
|
35
|
+
|
36
|
+
def populate_loadpath
|
37
|
+
|
38
|
+
# Add the current directory for r10k.yaml
|
39
|
+
@loadpath << File.join(Dir.getwd, CONFIG_FILE)
|
34
40
|
|
35
|
-
|
36
|
-
|
41
|
+
# Add the AIO location for of r10k.yaml
|
42
|
+
@loadpath << DEFAULT_LOCATION
|
37
43
|
|
38
|
-
|
44
|
+
# Add the old default location last.
|
45
|
+
@loadpath << OLD_DEFAULT_LOCATION
|
46
|
+
|
47
|
+
@loadpath
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
39
51
|
end
|
40
52
|
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'r10k/source'
|
2
|
-
require 'r10k/util/
|
2
|
+
require 'r10k/util/symbolize_keys'
|
3
3
|
|
4
4
|
module R10K
|
5
5
|
class Deployment
|
@@ -18,9 +18,7 @@ class Source
|
|
18
18
|
# @deprecated
|
19
19
|
# @return [R10K::Source::Base]
|
20
20
|
def self.vivify(name, attrs)
|
21
|
-
|
22
|
-
attrs.extend R10K::Util::CoreExt::HashExt::SymbolizeKeys
|
23
|
-
attrs.symbolize_keys!
|
21
|
+
R10K::Util::SymbolizeKeys.symbolize_keys!(attrs)
|
24
22
|
|
25
23
|
remote = attrs.delete(:remote)
|
26
24
|
basedir = attrs.delete(:basedir)
|
data/lib/r10k/environment/git.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'r10k/logging'
|
2
2
|
require 'r10k/puppetfile'
|
3
|
-
require 'r10k/git/
|
3
|
+
require 'r10k/git/stateful_repository'
|
4
|
+
require 'forwardable'
|
4
5
|
|
5
6
|
# This class implements an environment based on a Git branch.
|
6
7
|
#
|
@@ -17,10 +18,10 @@ class R10K::Environment::Git < R10K::Environment::Base
|
|
17
18
|
# @return [String] The git reference to use for this environment
|
18
19
|
attr_reader :ref
|
19
20
|
|
20
|
-
# @!attribute [r]
|
21
|
+
# @!attribute [r] repo
|
21
22
|
# @api private
|
22
|
-
# @return [R10K::Git::
|
23
|
-
attr_reader :
|
23
|
+
# @return [R10K::Git::StatefulRepository] The git repo backing this environment
|
24
|
+
attr_reader :repo
|
24
25
|
|
25
26
|
# Initialize the given SVN environment.
|
26
27
|
#
|
@@ -36,7 +37,7 @@ class R10K::Environment::Git < R10K::Environment::Base
|
|
36
37
|
@remote = options[:remote]
|
37
38
|
@ref = options[:ref]
|
38
39
|
|
39
|
-
@
|
40
|
+
@repo = R10K::Git::StatefulRepository.new(@ref, @remote, @basedir, @dirname)
|
40
41
|
end
|
41
42
|
|
42
43
|
# Clone or update the given Git environment.
|
@@ -47,23 +48,13 @@ class R10K::Environment::Git < R10K::Environment::Base
|
|
47
48
|
# @api public
|
48
49
|
# @return [void]
|
49
50
|
def sync
|
50
|
-
@
|
51
|
+
@repo.sync
|
51
52
|
@synced = true
|
52
53
|
end
|
53
54
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
elsif !@working_dir.git?
|
58
|
-
:mismatched
|
59
|
-
elsif !(@remote == @working_dir.remote)
|
60
|
-
:mismatched
|
61
|
-
elsif !@synced
|
62
|
-
:outdated
|
63
|
-
else
|
64
|
-
:insync
|
65
|
-
end
|
66
|
-
end
|
55
|
+
extend Forwardable
|
56
|
+
|
57
|
+
def_delegators :@repo, :status
|
67
58
|
|
68
59
|
# @deprecated
|
69
60
|
# @api private
|
@@ -0,0 +1,86 @@
|
|
1
|
+
module R10K
|
2
|
+
module Environment
|
3
|
+
# Handle environment name validation and modification.
|
4
|
+
#
|
5
|
+
# @api private
|
6
|
+
class Name
|
7
|
+
|
8
|
+
# @!attribute [r] name
|
9
|
+
# @return [String] The unmodified name of the environment
|
10
|
+
attr_reader :name
|
11
|
+
|
12
|
+
INVALID_CHARACTERS = %r[\W]
|
13
|
+
|
14
|
+
def initialize(name, opts)
|
15
|
+
@name = name
|
16
|
+
@opts = opts
|
17
|
+
|
18
|
+
@source = opts[:source]
|
19
|
+
@prefix = opts[:prefix]
|
20
|
+
@invalid = opts[:invalid]
|
21
|
+
|
22
|
+
case @invalid
|
23
|
+
when 'correct_and_warn'
|
24
|
+
@validate = true
|
25
|
+
@correct = true
|
26
|
+
when 'correct'
|
27
|
+
@validate = false
|
28
|
+
@correct = true
|
29
|
+
when 'error'
|
30
|
+
@validate = true
|
31
|
+
@correct = false
|
32
|
+
when NilClass
|
33
|
+
@validate = opts[:validate]
|
34
|
+
@correct = opts[:correct]
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# Should the environment name have invalid characters removed?
|
39
|
+
def correct?
|
40
|
+
@correct
|
41
|
+
end
|
42
|
+
|
43
|
+
def validate?
|
44
|
+
@validate
|
45
|
+
end
|
46
|
+
|
47
|
+
def valid?
|
48
|
+
if @validate
|
49
|
+
! @name.match(INVALID_CHARACTERS)
|
50
|
+
else
|
51
|
+
true
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# The directory name for the environment, modified as necessary to remove
|
56
|
+
# invalid characters.
|
57
|
+
#
|
58
|
+
# @return [String]
|
59
|
+
def dirname
|
60
|
+
dir = @name.dup
|
61
|
+
|
62
|
+
prefix = derive_prefix(@source,@prefix)
|
63
|
+
|
64
|
+
if @correct
|
65
|
+
dir.gsub!(INVALID_CHARACTERS, '_')
|
66
|
+
end
|
67
|
+
|
68
|
+
"#{prefix}#{dir}"
|
69
|
+
end
|
70
|
+
|
71
|
+
|
72
|
+
private
|
73
|
+
|
74
|
+
def derive_prefix(source,prefix)
|
75
|
+
|
76
|
+
if prefix == true
|
77
|
+
"#{source}_"
|
78
|
+
elsif prefix.is_a? String
|
79
|
+
"#{prefix}_"
|
80
|
+
else
|
81
|
+
nil
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|