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
data/lib/r10k/execution.rb
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
require 'r10k/errors'
|
2
|
-
|
3
|
-
require 'systemu'
|
4
|
-
|
5
|
-
module R10K
|
6
|
-
# :nocov:
|
7
|
-
module Execution
|
8
|
-
include R10K::Logging
|
9
|
-
|
10
|
-
# Execute a command and return stdout
|
11
|
-
#
|
12
|
-
# @params [String] cmd
|
13
|
-
# @params [Hash] opts
|
14
|
-
#
|
15
|
-
# @option opts [String] :event An optional log event name. Defaults to cmd.
|
16
|
-
# @option opts [String] :cwd The working directory to use when executing the command
|
17
|
-
#
|
18
|
-
# @raise [R10K::ExecutionFailure] If the executed command exited with a
|
19
|
-
# nonzero exit code.
|
20
|
-
#
|
21
|
-
# @return [String] the stdout from the command
|
22
|
-
def execute(cmd, opts = {})
|
23
|
-
|
24
|
-
logger.warn "R10K::Execution#execute is deprecated, use R10K::Util::Subprocess"
|
25
|
-
|
26
|
-
event = (opts.delete(:event) || cmd)
|
27
|
-
|
28
|
-
logger.debug1 "Execute: #{event.inspect}"
|
29
|
-
|
30
|
-
status, stdout, stderr = systemu(cmd, opts)
|
31
|
-
|
32
|
-
logger.debug2 "[#{event}] STDOUT: #{stdout.chomp}" unless stdout.empty?
|
33
|
-
logger.debug2 "[#{event}] STDERR: #{stderr.chomp}" unless stderr.empty?
|
34
|
-
|
35
|
-
unless status == 0
|
36
|
-
msg = "#{cmd.inspect} returned with non-zero exit value #{status.exitstatus}"
|
37
|
-
e = R10K::ExecutionFailure.new(msg)
|
38
|
-
e.exit_code = status
|
39
|
-
e.stdout = stdout
|
40
|
-
e.stderr = stderr
|
41
|
-
raise e
|
42
|
-
end
|
43
|
-
stdout
|
44
|
-
end
|
45
|
-
end
|
46
|
-
# :nocov:
|
47
|
-
end
|
data/lib/r10k/module/metadata.rb
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
require 'r10k/module'
|
2
|
-
require 'r10k/semver'
|
3
|
-
require 'json'
|
4
|
-
|
5
|
-
class R10K::Module::Metadata
|
6
|
-
|
7
|
-
# @!attribute [r] name
|
8
|
-
# @return [String] The module name
|
9
|
-
attr_reader :name
|
10
|
-
|
11
|
-
# @!attribute [r] author
|
12
|
-
# @return [String] The module author username
|
13
|
-
attr_reader :author
|
14
|
-
|
15
|
-
# @!attribute [r] version
|
16
|
-
# @return [R10K::SemVer] The module version
|
17
|
-
attr_reader :version
|
18
|
-
|
19
|
-
# @param metadata_path [Pathname] The file path to the metadata
|
20
|
-
def initialize(metadata_path)
|
21
|
-
@metadata_path = metadata_path
|
22
|
-
|
23
|
-
@version = R10K::SemVer::MIN
|
24
|
-
end
|
25
|
-
|
26
|
-
# Does the metadata file itself exist?
|
27
|
-
def exist?
|
28
|
-
@metadata_path.file? and @metadata_path.readable?
|
29
|
-
end
|
30
|
-
|
31
|
-
# Attempt to read the metadata file
|
32
|
-
def read
|
33
|
-
if self.exist?
|
34
|
-
hash = JSON.parse(@metadata_path.read)
|
35
|
-
attributes_from_hash(hash)
|
36
|
-
end
|
37
|
-
rescue JSON::ParserError
|
38
|
-
false
|
39
|
-
end
|
40
|
-
|
41
|
-
private
|
42
|
-
|
43
|
-
def attributes_from_hash(json)
|
44
|
-
@author, _, @name = json['name'].partition('-')
|
45
|
-
@version = R10K::SemVer.new(json['version'])
|
46
|
-
end
|
47
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module R10K
|
2
|
-
module Util
|
3
|
-
module CoreExt
|
4
|
-
module HashExt
|
5
|
-
module SymbolizeKeys
|
6
|
-
def symbolize_keys!
|
7
|
-
self.keys.each do |key|
|
8
|
-
next unless key.is_a? String
|
9
|
-
if self[key.to_sym]
|
10
|
-
raise TypeError, "An existing interned key for #{key} exists, cannot overwrite"
|
11
|
-
end
|
12
|
-
self[key.to_sym] = self.delete(key)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,140 +0,0 @@
|
|
1
|
-
require 'fcntl'
|
2
|
-
|
3
|
-
# Implement a POSIX command runner by using fork/exec.
|
4
|
-
#
|
5
|
-
# This implementation is optimized to run commands in the background, and has
|
6
|
-
# a few noteworthy implementation details.
|
7
|
-
#
|
8
|
-
# First off, when the child process is forked, it calls setsid() to detach from
|
9
|
-
# the controlling TTY. This has two main ramifications: sending signals will
|
10
|
-
# never be send to the forked process, and the forked process does not have
|
11
|
-
# access to stdin.
|
12
|
-
#
|
13
|
-
# @api private
|
14
|
-
class R10K::Util::Subprocess::POSIX::Runner < R10K::Util::Subprocess::Runner
|
15
|
-
|
16
|
-
def initialize(argv)
|
17
|
-
@argv = argv
|
18
|
-
@io = R10K::Util::Subprocess::POSIX::IO.new
|
19
|
-
|
20
|
-
attach_pipes
|
21
|
-
end
|
22
|
-
|
23
|
-
def start
|
24
|
-
exec_r, exec_w = status_pipe()
|
25
|
-
|
26
|
-
|
27
|
-
@pid = fork do
|
28
|
-
exec_r.close
|
29
|
-
execute_child(exec_w)
|
30
|
-
end
|
31
|
-
|
32
|
-
exec_w.close
|
33
|
-
execute_parent(exec_r)
|
34
|
-
end
|
35
|
-
|
36
|
-
def wait
|
37
|
-
if @pid
|
38
|
-
_, @status = Process.waitpid2(@pid)
|
39
|
-
end
|
40
|
-
|
41
|
-
stdout = @stdout_r.read
|
42
|
-
# Use non-blocking read for stderr_r to work around an issue with OpenSSH
|
43
|
-
# ControlPersist: https://bugzilla.mindrot.org/show_bug.cgi?id=1988
|
44
|
-
# Blocking should not occur in any other case since the process that was
|
45
|
-
# attached to the pipe has already terminated.
|
46
|
-
stderr = read_nonblock(@stderr_r)
|
47
|
-
|
48
|
-
@stdout_r.close
|
49
|
-
@stderr_r.close
|
50
|
-
@result = R10K::Util::Subprocess::Result.new(@argv, stdout, stderr, @status.exitstatus)
|
51
|
-
end
|
52
|
-
|
53
|
-
def run
|
54
|
-
start
|
55
|
-
wait
|
56
|
-
@result
|
57
|
-
end
|
58
|
-
|
59
|
-
def crashed?
|
60
|
-
exit_code != 0
|
61
|
-
end
|
62
|
-
|
63
|
-
def exit_code
|
64
|
-
@status.exitstatus
|
65
|
-
end
|
66
|
-
|
67
|
-
private
|
68
|
-
|
69
|
-
def execute_child(exec_w)
|
70
|
-
if @cwd
|
71
|
-
Dir.chdir @cwd
|
72
|
-
end
|
73
|
-
|
74
|
-
# Create a new session for the forked child. This prevents children from
|
75
|
-
# ever being the foreground process on a TTY, which is almost always what
|
76
|
-
# we want in r10k.
|
77
|
-
Process.setsid
|
78
|
-
|
79
|
-
# Reopen file descriptors
|
80
|
-
STDOUT.reopen(io.stdout)
|
81
|
-
STDERR.reopen(io.stderr)
|
82
|
-
|
83
|
-
executable = @argv.shift
|
84
|
-
exec([executable, executable], *@argv)
|
85
|
-
rescue SystemCallError => e
|
86
|
-
exec_w.write(e.message)
|
87
|
-
end
|
88
|
-
|
89
|
-
def execute_parent(exec_r)
|
90
|
-
@stdout_w.close
|
91
|
-
@stderr_w.close
|
92
|
-
|
93
|
-
if not exec_r.eof?
|
94
|
-
msg = exec_r.read || "exec() failed"
|
95
|
-
raise "Could not execute #{@argv.join(' ')}: #{msg}"
|
96
|
-
end
|
97
|
-
exec_r.close
|
98
|
-
end
|
99
|
-
|
100
|
-
# Create a pipe so that the parent can verify that the child process
|
101
|
-
# successfully executed. The pipe will be closed on a successful exec(),
|
102
|
-
# and will contain an error message on failure.
|
103
|
-
#
|
104
|
-
# @return [IO, IO] The reader and writer for this pipe
|
105
|
-
def status_pipe
|
106
|
-
r_pipe, w_pipe = ::IO.pipe
|
107
|
-
|
108
|
-
w_pipe.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
|
109
|
-
|
110
|
-
[r_pipe, w_pipe]
|
111
|
-
end
|
112
|
-
|
113
|
-
def attach_pipes
|
114
|
-
@stdout_r, @stdout_w = ::IO.pipe
|
115
|
-
@stderr_r, @stderr_w = ::IO.pipe
|
116
|
-
|
117
|
-
@stdout_r.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
|
118
|
-
@stdout_w.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
|
119
|
-
@stderr_r.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
|
120
|
-
@stderr_w.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
|
121
|
-
|
122
|
-
@io.stdout = @stdout_w
|
123
|
-
@io.stderr = @stderr_w
|
124
|
-
end
|
125
|
-
|
126
|
-
# Perform non-blocking reads on a pipe that could still be open
|
127
|
-
# Give up on reaching EOF or blocking and return what was read
|
128
|
-
def read_nonblock(rd_io)
|
129
|
-
data = ''
|
130
|
-
begin
|
131
|
-
# Loop until EOF or blocking
|
132
|
-
loop do
|
133
|
-
# do an 8k non-blocking read and append the result
|
134
|
-
data << rd_io.read_nonblock(8192)
|
135
|
-
end
|
136
|
-
rescue EOFError, Errno::EAGAIN, Errno::EWOULDBLOCK
|
137
|
-
end
|
138
|
-
data
|
139
|
-
end
|
140
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
---
|
2
|
-
http_interactions:
|
3
|
-
- request:
|
4
|
-
method: get
|
5
|
-
uri: https://forge.puppetlabs.com/api/v1/releases.json?module=adrien%2Fboolean
|
6
|
-
body:
|
7
|
-
encoding: US-ASCII
|
8
|
-
string: ''
|
9
|
-
headers:
|
10
|
-
User-Agent:
|
11
|
-
- Faraday v0.8.8
|
12
|
-
response:
|
13
|
-
status:
|
14
|
-
code: 200
|
15
|
-
message:
|
16
|
-
headers:
|
17
|
-
server:
|
18
|
-
- nginx
|
19
|
-
date:
|
20
|
-
- Wed, 25 Dec 2013 23:40:52 GMT
|
21
|
-
content-type:
|
22
|
-
- application/json
|
23
|
-
content-length:
|
24
|
-
- '432'
|
25
|
-
connection:
|
26
|
-
- close
|
27
|
-
status:
|
28
|
-
- 200 OK
|
29
|
-
x-frame-options:
|
30
|
-
- sameorigin
|
31
|
-
x-xss-protection:
|
32
|
-
- 1; mode=block
|
33
|
-
x-node:
|
34
|
-
- forgeweb02
|
35
|
-
x-revision:
|
36
|
-
- b288c1e7e86f82eef7692085670c78693062c84d
|
37
|
-
body:
|
38
|
-
encoding: US-ASCII
|
39
|
-
string: ! '{"adrien/boolean":[{"file":"/system/releases/a/adrien/adrien-boolean-0.9.0-rc1.tar.gz","version":"0.9.0-rc1","dependencies":[]},{"file":"/system/releases/a/adrien/adrien-boolean-0.9.0.tar.gz","version":"0.9.0","dependencies":[]},{"file":"/system/releases/a/adrien/adrien-boolean-1.0.0.tar.gz","version":"1.0.0","dependencies":[]},{"file":"/system/releases/a/adrien/adrien-boolean-1.0.1.tar.gz","version":"1.0.1","dependencies":[]}]}'
|
40
|
-
http_version:
|
41
|
-
recorded_at: Wed, 25 Dec 2013 23:42:06 GMT
|
42
|
-
recorded_with: VCR 2.8.0
|
@@ -1,42 +0,0 @@
|
|
1
|
-
---
|
2
|
-
http_interactions:
|
3
|
-
- request:
|
4
|
-
method: get
|
5
|
-
uri: https://forge.puppetlabs.com/api/v1/releases.json?module=adrien%2Fboolean
|
6
|
-
body:
|
7
|
-
encoding: US-ASCII
|
8
|
-
string: ''
|
9
|
-
headers:
|
10
|
-
User-Agent:
|
11
|
-
- Faraday v0.8.8
|
12
|
-
response:
|
13
|
-
status:
|
14
|
-
code: 200
|
15
|
-
message:
|
16
|
-
headers:
|
17
|
-
server:
|
18
|
-
- nginx
|
19
|
-
date:
|
20
|
-
- Wed, 25 Dec 2013 23:48:29 GMT
|
21
|
-
content-type:
|
22
|
-
- application/json
|
23
|
-
content-length:
|
24
|
-
- '432'
|
25
|
-
connection:
|
26
|
-
- close
|
27
|
-
status:
|
28
|
-
- 200 OK
|
29
|
-
x-frame-options:
|
30
|
-
- sameorigin
|
31
|
-
x-xss-protection:
|
32
|
-
- 1; mode=block
|
33
|
-
x-node:
|
34
|
-
- forgeweb03
|
35
|
-
x-revision:
|
36
|
-
- b288c1e7e86f82eef7692085670c78693062c84d
|
37
|
-
body:
|
38
|
-
encoding: US-ASCII
|
39
|
-
string: ! '{"adrien/boolean":[{"file":"/system/releases/a/adrien/adrien-boolean-0.9.0-rc1.tar.gz","version":"0.9.0-rc1","dependencies":[]},{"file":"/system/releases/a/adrien/adrien-boolean-0.9.0.tar.gz","version":"0.9.0","dependencies":[]},{"file":"/system/releases/a/adrien/adrien-boolean-1.0.0.tar.gz","version":"1.0.0","dependencies":[]},{"file":"/system/releases/a/adrien/adrien-boolean-1.0.1.tar.gz","version":"1.0.1","dependencies":[]}]}'
|
40
|
-
http_version:
|
41
|
-
recorded_at: Wed, 25 Dec 2013 23:49:42 GMT
|
42
|
-
recorded_with: VCR 2.8.0
|
@@ -1,42 +0,0 @@
|
|
1
|
-
---
|
2
|
-
http_interactions:
|
3
|
-
- request:
|
4
|
-
method: get
|
5
|
-
uri: https://forge.puppetlabs.com/api/v1/releases.json?module=adrien%2Fboolean
|
6
|
-
body:
|
7
|
-
encoding: US-ASCII
|
8
|
-
string: ''
|
9
|
-
headers:
|
10
|
-
User-Agent:
|
11
|
-
- Faraday v0.8.8
|
12
|
-
response:
|
13
|
-
status:
|
14
|
-
code: 200
|
15
|
-
message:
|
16
|
-
headers:
|
17
|
-
server:
|
18
|
-
- nginx
|
19
|
-
date:
|
20
|
-
- Wed, 25 Dec 2013 23:48:29 GMT
|
21
|
-
content-type:
|
22
|
-
- application/json
|
23
|
-
content-length:
|
24
|
-
- '432'
|
25
|
-
connection:
|
26
|
-
- close
|
27
|
-
status:
|
28
|
-
- 200 OK
|
29
|
-
x-frame-options:
|
30
|
-
- sameorigin
|
31
|
-
x-xss-protection:
|
32
|
-
- 1; mode=block
|
33
|
-
x-node:
|
34
|
-
- forgeweb01
|
35
|
-
x-revision:
|
36
|
-
- b288c1e7e86f82eef7692085670c78693062c84d
|
37
|
-
body:
|
38
|
-
encoding: US-ASCII
|
39
|
-
string: ! '{"adrien/boolean":[{"file":"/system/releases/a/adrien/adrien-boolean-0.9.0-rc1.tar.gz","version":"0.9.0-rc1","dependencies":[]},{"file":"/system/releases/a/adrien/adrien-boolean-0.9.0.tar.gz","version":"0.9.0","dependencies":[]},{"file":"/system/releases/a/adrien/adrien-boolean-1.0.0.tar.gz","version":"1.0.0","dependencies":[]},{"file":"/system/releases/a/adrien/adrien-boolean-1.0.1.tar.gz","version":"1.0.1","dependencies":[]}]}'
|
40
|
-
http_version:
|
41
|
-
recorded_at: Wed, 25 Dec 2013 23:49:43 GMT
|
42
|
-
recorded_with: VCR 2.8.0
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'r10k/deployment/source'
|
3
|
-
|
4
|
-
describe R10K::Deployment::Source do
|
5
|
-
let(:name) { 'do_not_name_a_branch_this' }
|
6
|
-
let(:remote) { 'git://github.com/adrienthebo/r10k-fixture-repo' }
|
7
|
-
let(:basedir) { '/tmp' }
|
8
|
-
|
9
|
-
describe 'environments', :integration => true do
|
10
|
-
it 'uses the name as a prefix when told' do
|
11
|
-
subject = described_class.new(name, remote, basedir, true)
|
12
|
-
subject.fetch_remote()
|
13
|
-
subject.environments.length.should > 0
|
14
|
-
subject.environments.first.dirname.should start_with name
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'avoids using the name as a prefix when told' do
|
18
|
-
subject = described_class.new(name, remote, basedir, false)
|
19
|
-
subject.fetch_remote()
|
20
|
-
subject.environments.length.should > 0
|
21
|
-
subject.environments.first.dirname.should_not start_with name
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|