r10k 2.0.3 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGELOG.mkd +150 -0
- data/README.mkd +10 -1
- data/doc/dynamic-environments/configuration.mkd +31 -0
- data/doc/dynamic-environments/quickstart.mkd +33 -79
- data/doc/faq.mkd +67 -0
- data/doc/git/providers.mkd +37 -0
- data/doc/puppetfile.mkd +73 -0
- data/integration/lib/r10k_utils.rb +47 -2
- data/integration/pre-suite/01_git_config.rb +9 -8
- data/integration/pre-suite/02_pe_r10k.rb +5 -8
- data/integration/scripts/setup_r10k_env_centos5.sh +1 -1
- data/integration/scripts/setup_r10k_env_centos6.sh +1 -1
- data/integration/scripts/setup_r10k_env_rhel7.sh +1 -1
- data/integration/scripts/setup_r10k_env_sles11.sh +1 -1
- data/integration/scripts/setup_r10k_env_sles12.sh +1 -1
- data/integration/scripts/setup_r10k_env_ubuntu1004.sh +1 -1
- data/integration/scripts/setup_r10k_env_ubuntu1204.sh +1 -1
- data/integration/scripts/setup_r10k_env_ubuntu1404.sh +1 -1
- data/integration/test_run_scripts/all_tests-rugged-pe-centos6.sh +1 -1
- data/integration/test_run_scripts/all_tests-rugged-pe-rhel7.sh +1 -1
- data/integration/test_run_scripts/all_tests-rugged-pe-sles11.sh +1 -1
- data/integration/test_run_scripts/all_tests-rugged-pe-ubuntu1204.sh +1 -1
- data/integration/test_run_scripts/all_tests-rugged-pe-ubuntu1404.sh +1 -1
- data/integration/test_run_scripts/all_tests-shellgit-pe-centos6.sh +1 -1
- data/integration/test_run_scripts/all_tests-shellgit-pe-rhel7.sh +1 -1
- data/integration/test_run_scripts/all_tests-shellgit-pe-sles11.sh +1 -1
- data/integration/test_run_scripts/all_tests-shellgit-pe-ubuntu1204.sh +1 -1
- data/integration/test_run_scripts/all_tests-shellgit-pe-ubuntu1404.sh +1 -1
- data/integration/test_run_scripts/basic_functionality/all_tests-pe-centos6.sh +1 -1
- data/integration/test_run_scripts/command_line/all_tests-pe-centos6.sh +1 -1
- data/integration/test_run_scripts/git_source/all_tests-pe-centos6.sh +1 -1
- data/integration/test_run_scripts/user_scenario/basic_workflow/all_tests-pe-centos6.sh +1 -1
- data/integration/test_run_scripts/user_scenario/complex_workflow/all_tests-pe-centos6.sh +1 -1
- data/integration/tests/basic_functionality/install_pe_only_module_with_puppetfile.rb +83 -0
- data/integration/tests/basic_functionality/negative/attempt_to_install_peonly_module_without_license.rb +71 -0
- data/integration/tests/basic_functionality/negative/neg_deploy_with_invalid_r10k_yaml.rb +7 -2
- data/integration/tests/basic_functionality/negative/neg_deploy_with_missing_r10k_yaml.rb +3 -2
- data/integration/tests/basic_functionality/negative/neg_invalid_git_provider.rb +3 -2
- data/integration/tests/basic_functionality/negative/negative_bad_proxy.rb +56 -0
- data/integration/tests/basic_functionality/proxy_specified_in_configuration.rb +103 -0
- data/integration/tests/basic_functionality/proxy_with_puppetfile.rb +61 -0
- data/integration/tests/basic_functionality/rugged_git_provider_with_ssh.rb +2 -1
- data/integration/tests/basic_functionality/rugged_git_provider_without_ssh.rb +2 -1
- data/integration/tests/command_line/deploy_env_without_mod_update.rb +3 -2
- data/integration/tests/command_line/negative/neg_deploy_env_with_module_update.rb +3 -2
- data/integration/tests/command_line/negative/neg_invalid_cli_dep_flag.rb +2 -1
- data/integration/tests/command_line/negative/neg_invalid_cli_env_flag.rb +2 -1
- data/integration/tests/command_line/negative/neg_invalid_cmd_line_arg.rb +3 -4
- data/integration/tests/git_source/git_source_git.rb +7 -2
- data/integration/tests/git_source/git_source_ssh.rb +3 -2
- data/integration/tests/git_source/git_source_submodule.rb +2 -1
- data/integration/tests/git_source/negative/neg_git_broken_remote.rb +2 -1
- data/integration/tests/git_source/negative/neg_git_unauthorized_https.rb +2 -1
- data/integration/tests/git_source/negative/neg_git_unauthorized_ssh.rb +2 -1
- data/integration/tests/git_source/negative/neg_git_unicode_branch.rb +2 -1
- data/integration/tests/user_scenario/basic_workflow/multi_env_1000_branches.rb +3 -3
- data/integration/tests/user_scenario/basic_workflow/multi_env_custom_forge_git_module.rb +2 -1
- data/integration/tests/user_scenario/basic_workflow/multi_env_custom_forge_git_module_static.rb +9 -5
- data/integration/tests/user_scenario/basic_workflow/multi_env_hiera.rb +9 -2
- data/integration/tests/user_scenario/basic_workflow/multi_env_multi_source.rb +2 -1
- data/integration/tests/user_scenario/basic_workflow/multi_source_custom_forge_git_module.rb +2 -1
- data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_basedir.rb +2 -1
- data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_forge_module.rb +7 -2
- data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_git_module.rb +3 -4
- data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_git_module_ref.rb +2 -1
- data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_git_remote.rb +2 -1
- data/integration/tests/user_scenario/basic_workflow/negative/neg_branch_name_collision.rb +2 -1
- data/integration/tests/user_scenario/basic_workflow/negative/neg_disk_full.rb +2 -1
- data/integration/tests/user_scenario/basic_workflow/negative/neg_duplicate_module_names.rb +10 -4
- data/integration/tests/user_scenario/basic_workflow/negative/neg_inaccessible_forge.rb +9 -2
- data/integration/tests/user_scenario/basic_workflow/negative/neg_invalid_env_name.rb +2 -1
- data/integration/tests/user_scenario/basic_workflow/negative/neg_invalid_puppet_file.rb +2 -1
- data/integration/tests/user_scenario/basic_workflow/negative/neg_module_specified_at_deleted_release.rb +7 -2
- data/integration/tests/user_scenario/basic_workflow/negative/neg_read_only.rb +2 -1
- data/integration/tests/user_scenario/basic_workflow/negative/neg_specify_deleted_forge_module.rb +9 -2
- data/integration/tests/user_scenario/basic_workflow/single_env_10000_files.rb +2 -1
- data/integration/tests/user_scenario/basic_workflow/single_env_custom_forge_git_module.rb +2 -1
- data/integration/tests/user_scenario/basic_workflow/single_env_custom_forge_module.rb +2 -1
- data/integration/tests/user_scenario/basic_workflow/single_env_custom_module.rb +2 -1
- data/integration/tests/user_scenario/basic_workflow/single_env_large_files.rb +2 -1
- data/integration/tests/user_scenario/basic_workflow/single_env_module_already_installed.rb +2 -1
- data/integration/tests/user_scenario/basic_workflow/single_env_module_last_release_deleted.rb +2 -1
- data/integration/tests/user_scenario/basic_workflow/single_env_non-existent_base_dir.rb +2 -1
- data/integration/tests/user_scenario/basic_workflow/single_env_purge_unmanaged_modules.rb +3 -2
- data/integration/tests/user_scenario/basic_workflow/single_env_switch_forge_git_module.rb +3 -2
- data/integration/tests/user_scenario/basic_workflow/single_env_unicode_paths.rb +2 -1
- data/integration/tests/user_scenario/basic_workflow/single_env_upgrade_forge_mod_revert_change.rb +4 -3
- data/integration/tests/user_scenario/complex_workflow/multi_env_add_change_remove.rb +3 -2
- data/integration/tests/user_scenario/complex_workflow/multi_env_remove_re-add.rb +4 -3
- data/integration/tests/user_scenario/complex_workflow/multi_env_unamanaged.rb +3 -2
- data/integration/tests/user_scenario/complex_workflow/single_env_git_module_update.rb +3 -2
- data/lib/r10k/action/base.rb +31 -0
- data/lib/r10k/action/deploy/deploy_helpers.rb +34 -0
- data/lib/r10k/action/deploy/display.rb +57 -75
- data/lib/r10k/action/deploy/environment.rb +52 -15
- data/lib/r10k/action/deploy/module.rb +13 -18
- data/lib/r10k/action/puppetfile/check.rb +8 -18
- data/lib/r10k/action/puppetfile/install.rb +13 -27
- data/lib/r10k/action/puppetfile/purge.rb +8 -17
- data/lib/r10k/action/runner.rb +39 -3
- data/lib/r10k/cli.rb +1 -3
- data/lib/r10k/cli/deploy.rb +3 -1
- data/lib/r10k/cli/puppetfile.rb +2 -2
- data/lib/r10k/deployment.rb +8 -6
- data/lib/r10k/deployment/config.rb +18 -65
- data/lib/r10k/environment/base.rb +19 -0
- data/lib/r10k/environment/git.rb +9 -0
- data/lib/r10k/environment/svn.rb +9 -0
- data/lib/r10k/forge/module_release.rb +21 -14
- data/lib/r10k/git.rb +6 -0
- data/lib/r10k/git/alternates.rb +20 -6
- data/lib/r10k/git/cache.rb +1 -1
- data/lib/r10k/git/rugged/bare_repository.rb +5 -0
- data/lib/r10k/git/rugged/base_repository.rb +6 -20
- data/lib/r10k/git/rugged/credentials.rb +66 -0
- data/lib/r10k/git/rugged/thin_repository.rb +16 -11
- data/lib/r10k/git/rugged/working_repository.rb +15 -7
- data/lib/r10k/git/shellgit/bare_repository.rb +9 -4
- data/lib/r10k/git/shellgit/thin_repository.rb +8 -10
- data/lib/r10k/git/stateful_repository.rb +1 -1
- data/lib/r10k/initializers.rb +55 -0
- data/lib/r10k/module.rb +1 -0
- data/lib/r10k/module/base.rb +3 -2
- data/lib/r10k/module/forge.rb +14 -6
- data/lib/r10k/module/local.rb +36 -0
- data/lib/r10k/module/metadata_file.rb +2 -2
- data/lib/r10k/puppetfile.rb +1 -1
- data/lib/r10k/settings.rb +86 -0
- data/lib/r10k/settings/collection.rb +118 -0
- data/lib/r10k/settings/definition.rb +112 -0
- data/lib/r10k/settings/enum_definition.rb +22 -0
- data/lib/r10k/settings/loader.rb +96 -0
- data/lib/r10k/settings/uri_definition.rb +19 -0
- data/lib/r10k/util/subprocess/runner/windows.rb +4 -4
- data/lib/r10k/version.rb +1 -1
- data/r10k.gemspec +2 -3
- data/spec/fixtures/unit/puppetfile/argument-error/Puppetfile +1 -0
- data/spec/fixtures/unit/util/subprocess/{posix/runner → runner}/no-execute.sh +0 -0
- data/spec/integration/git/rugged/thin_repository_spec.rb +2 -2
- data/spec/integration/git/rugged/working_repository_spec.rb +9 -0
- data/spec/integration/git/shellgit/thin_repository_spec.rb +2 -2
- data/spec/integration/git/stateful_repository_spec.rb +1 -1
- data/spec/r10k-mocks/mock_config.rb +10 -13
- data/spec/r10k-mocks/mock_env.rb +8 -0
- data/spec/shared-examples/deploy-actions.rb +69 -0
- data/spec/shared-examples/puppetfile-action.rb +17 -0
- data/spec/unit/action/cri_runner_spec.rb +3 -1
- data/spec/unit/action/deploy/deploy_helpers_spec.rb +38 -0
- data/spec/unit/action/deploy/display_spec.rb +31 -0
- data/spec/unit/action/deploy/environment_spec.rb +56 -0
- data/spec/unit/action/deploy/module_spec.rb +17 -0
- data/spec/unit/action/puppetfile/check_spec.rb +26 -0
- data/spec/unit/action/puppetfile/install_spec.rb +68 -0
- data/spec/unit/action/puppetfile/purge_spec.rb +19 -0
- data/spec/unit/action/runner_spec.rb +10 -9
- data/spec/unit/deployment/config_spec.rb +20 -44
- data/spec/unit/deployment_spec.rb +1 -1
- data/spec/unit/environment/git_spec.rb +20 -0
- data/spec/unit/environment/svn_spec.rb +20 -0
- data/spec/unit/forge/module_release_spec.rb +6 -3
- data/spec/unit/git/alternates_spec.rb +38 -12
- data/spec/unit/git/cache_spec.rb +4 -0
- data/spec/unit/git/rugged/credentials_spec.rb +74 -0
- data/spec/unit/initializers_spec.rb +68 -0
- data/spec/unit/module/base_spec.rb +2 -2
- data/spec/unit/module/forge_spec.rb +11 -3
- data/spec/unit/module/metadata_file_spec.rb +0 -1
- data/spec/unit/puppetfile_spec.rb +11 -0
- data/spec/unit/settings/collection_spec.rb +122 -0
- data/spec/unit/settings/definition_spec.rb +78 -0
- data/spec/unit/settings/enum_definition_spec.rb +20 -0
- data/spec/unit/{deployment/config → settings}/loader_spec.rb +50 -2
- data/spec/unit/settings/uri_definition_spec.rb +23 -0
- data/spec/unit/settings_spec.rb +151 -0
- data/spec/unit/util/subprocess/runner/posix_spec.rb +1 -1
- data/spec/unit/util/subprocess/runner/windows_spec.rb +7 -0
- metadata +53 -90
- data/lib/r10k/deployment/config/loader.rb +0 -59
- data/lib/shared/puppet/module_tool/metadata.rb +0 -197
- data/lib/shared/puppet_forge/connection.rb +0 -64
- data/lib/shared/puppet_forge/connection/connection_failure.rb +0 -26
- data/lib/shared/puppet_forge/error.rb +0 -41
- data/lib/shared/puppet_forge/tar.rb +0 -10
- data/lib/shared/puppet_forge/tar/mini.rb +0 -81
- data/lib/shared/puppet_forge/unpacker.rb +0 -68
- data/lib/shared/puppet_forge/v3.rb +0 -13
- data/lib/shared/puppet_forge/v3/module.rb +0 -69
- data/lib/shared/puppet_forge/v3/module_release.rb +0 -85
- data/lib/shared/puppet_forge/version.rb +0 -3
- data/spec/unit/puppet/module_tool/metadata_spec.rb +0 -301
- data/spec/unit/puppet_forge/connection/connection_failure_spec.rb +0 -28
- data/spec/unit/puppet_forge/connection_spec.rb +0 -41
- data/spec/unit/puppet_forge/tar/mini_spec.rb +0 -87
- data/spec/unit/puppet_forge/tar_spec.rb +0 -9
- data/spec/unit/puppet_forge/unpacker_spec.rb +0 -59
- data/spec/unit/puppet_forge/v3/module_release_spec.rb +0 -83
- data/spec/unit/puppet_forge/v3/module_spec.rb +0 -75
@@ -0,0 +1,112 @@
|
|
1
|
+
require 'r10k/util/setopts'
|
2
|
+
|
3
|
+
module R10K
|
4
|
+
module Settings
|
5
|
+
|
6
|
+
# Define a single setting and additional attributes like descriptions,
|
7
|
+
# default values, and validation.
|
8
|
+
class Definition
|
9
|
+
|
10
|
+
require 'r10k/settings/uri_definition'
|
11
|
+
require 'r10k/settings/enum_definition'
|
12
|
+
|
13
|
+
include R10K::Util::Setopts
|
14
|
+
|
15
|
+
# @!attribute [r] name
|
16
|
+
# @return [String] The name of this setting
|
17
|
+
attr_reader :name
|
18
|
+
|
19
|
+
# @!attribute [r] value
|
20
|
+
# @return [Object] An explicitly set value. This should only be used if
|
21
|
+
# an optional default value should not be used; otherwise use {#resolve}.
|
22
|
+
attr_reader :value
|
23
|
+
|
24
|
+
# @!attribute [r] desc
|
25
|
+
# @return [String] An optional documentation string for this setting.
|
26
|
+
attr_reader :desc
|
27
|
+
|
28
|
+
# @param name [Symbol] The name of the setting for this definition.
|
29
|
+
# @param opts [Hash] Additional options for this definition to control
|
30
|
+
# validation, normalization, and the like.
|
31
|
+
#
|
32
|
+
# @option opts [Proc, Object] :default An optional proc or object for
|
33
|
+
# this setting. If no value has been set and the default is a Proc then
|
34
|
+
# it will be called and the result will be returned, otherwise if the
|
35
|
+
# value is not set the default value itself is returned.
|
36
|
+
#
|
37
|
+
# @options opts [Proc] :validate An optional proc that can be used to
|
38
|
+
# validate an assigned value. Default values are not assigned.
|
39
|
+
#
|
40
|
+
# @options opts [Proc] :normalize An optional proc that can be used to
|
41
|
+
# normalize an explicitly assigned value.
|
42
|
+
def initialize(name, opts = {})
|
43
|
+
@name = name
|
44
|
+
setopts(opts, allowed_initialize_opts)
|
45
|
+
end
|
46
|
+
|
47
|
+
# Assign new values, perform validation checks, and return the final
|
48
|
+
# values for this collection
|
49
|
+
def evaluate(newvalue)
|
50
|
+
assign(newvalue)
|
51
|
+
validate
|
52
|
+
resolve
|
53
|
+
end
|
54
|
+
|
55
|
+
# Store an explicit value for this definition
|
56
|
+
#
|
57
|
+
# If a :normalize hook has been given then it will be called with the
|
58
|
+
# new value and the returned value will be stored.
|
59
|
+
#
|
60
|
+
# @param newvalue [Object] The value to store for this setting
|
61
|
+
# @return [void]
|
62
|
+
def assign(newvalue)
|
63
|
+
if @normalize
|
64
|
+
@value = @normalize.call(newvalue)
|
65
|
+
else
|
66
|
+
@value = newvalue
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# Call any validation hooks for this definition.
|
71
|
+
#
|
72
|
+
# The :validate hook will be called if the hook has been set and an
|
73
|
+
# explicit value has been assigned to this definition. Validation
|
74
|
+
# failures should be indicated by the :validate hook raising an exception.
|
75
|
+
#
|
76
|
+
# @raise [Exception] An exception class indicating that validation failed.
|
77
|
+
# @return [nil]
|
78
|
+
def validate
|
79
|
+
if @value && @validate
|
80
|
+
@validate.call(@value)
|
81
|
+
end
|
82
|
+
nil
|
83
|
+
end
|
84
|
+
|
85
|
+
# Compute the final value of this setting. If a value has not been
|
86
|
+
# assigned the default value will be used.
|
87
|
+
#
|
88
|
+
# @return [Object] The final value of this definition.
|
89
|
+
def resolve
|
90
|
+
if !@value.nil?
|
91
|
+
@value
|
92
|
+
elsif @default
|
93
|
+
@default.is_a?(Proc) ? @default.call : @default
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
private
|
98
|
+
|
99
|
+
# Subclasses may define additional params that are accepted at
|
100
|
+
# initialization; they should override this method to add any
|
101
|
+
# additional fields that should be respected.
|
102
|
+
def allowed_initialize_opts
|
103
|
+
{
|
104
|
+
:desc => true,
|
105
|
+
:default => true,
|
106
|
+
:validate => true,
|
107
|
+
:normalize => true,
|
108
|
+
}
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'r10k/settings/definition'
|
2
|
+
|
3
|
+
module R10K
|
4
|
+
module Settings
|
5
|
+
class EnumDefinition < R10K::Settings::Definition
|
6
|
+
|
7
|
+
def validate
|
8
|
+
if @value
|
9
|
+
if !@enum.include?(@value)
|
10
|
+
raise ArgumentError, "Setting #{@name} should be one of #{@enum.inspect}, not '#{@value}'"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def allowed_initialize_opts
|
18
|
+
super.merge({:enum => true})
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
require 'r10k/logging'
|
2
|
+
require 'r10k/errors'
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
module R10K
|
6
|
+
module Settings
|
7
|
+
# Look for the r10k configuration file in standard locations.
|
8
|
+
#
|
9
|
+
# r10k.yaml is checked for in the following locations:
|
10
|
+
# - $PWD/r10k.yaml
|
11
|
+
# - /etc/puppetlabs/r10k/r10k.yaml
|
12
|
+
# - /etc/r10k.yaml
|
13
|
+
class Loader
|
14
|
+
|
15
|
+
def self.search(override = nil)
|
16
|
+
new.search(override)
|
17
|
+
end
|
18
|
+
|
19
|
+
include R10K::Logging
|
20
|
+
|
21
|
+
attr_reader :loadpath
|
22
|
+
|
23
|
+
CONFIG_FILE = 'r10k.yaml'
|
24
|
+
DEFAULT_LOCATION = File.join('/etc/puppetlabs/r10k', CONFIG_FILE)
|
25
|
+
OLD_DEFAULT_LOCATION = File.join('/etc', CONFIG_FILE)
|
26
|
+
|
27
|
+
def initialize
|
28
|
+
@loadpath = []
|
29
|
+
populate_loadpath
|
30
|
+
end
|
31
|
+
|
32
|
+
# Find the first valid config file.
|
33
|
+
#
|
34
|
+
# @param override [String, nil] An optional path that when is truthy
|
35
|
+
# will be preferred over all other files, to make it easy to
|
36
|
+
# optionally supply an explicit configuration file that will always
|
37
|
+
# be used when set.
|
38
|
+
# @return [String, nil] The path to the first valid configfile, or nil
|
39
|
+
# if no file was found.
|
40
|
+
def search(override = nil)
|
41
|
+
return override if override
|
42
|
+
|
43
|
+
# If both default files are present, issue a warning.
|
44
|
+
if (File.file? DEFAULT_LOCATION) && (File.file? OLD_DEFAULT_LOCATION)
|
45
|
+
logger.warn "Both #{DEFAULT_LOCATION} and #{OLD_DEFAULT_LOCATION} configuration files exist."
|
46
|
+
logger.warn "#{DEFAULT_LOCATION} will be used."
|
47
|
+
end
|
48
|
+
|
49
|
+
path = @loadpath.find {|filename| File.file? filename}
|
50
|
+
|
51
|
+
if path == OLD_DEFAULT_LOCATION
|
52
|
+
logger.warn "The r10k configuration file at #{OLD_DEFAULT_LOCATION} is deprecated."
|
53
|
+
logger.warn "Please move your r10k configuration to #{DEFAULT_LOCATION}."
|
54
|
+
end
|
55
|
+
|
56
|
+
path
|
57
|
+
end
|
58
|
+
|
59
|
+
def read(override = nil)
|
60
|
+
path = search(override)
|
61
|
+
|
62
|
+
if path.nil?
|
63
|
+
raise ConfigError, "No configuration file given, no config file found in current directory, and no global config present"
|
64
|
+
end
|
65
|
+
|
66
|
+
begin
|
67
|
+
contents = ::YAML.load_file(path)
|
68
|
+
rescue => e
|
69
|
+
raise ConfigError, "Couldn't load config file: #{e.message}"
|
70
|
+
end
|
71
|
+
|
72
|
+
R10K::Util::SymbolizeKeys.symbolize_keys!(contents, true)
|
73
|
+
contents
|
74
|
+
end
|
75
|
+
|
76
|
+
private
|
77
|
+
|
78
|
+
def populate_loadpath
|
79
|
+
|
80
|
+
# Add the current directory for r10k.yaml
|
81
|
+
@loadpath << File.join(Dir.getwd, CONFIG_FILE)
|
82
|
+
|
83
|
+
# Add the AIO location for of r10k.yaml
|
84
|
+
@loadpath << DEFAULT_LOCATION
|
85
|
+
|
86
|
+
# Add the old default location last.
|
87
|
+
@loadpath << OLD_DEFAULT_LOCATION
|
88
|
+
|
89
|
+
@loadpath
|
90
|
+
end
|
91
|
+
|
92
|
+
class ConfigError < R10K::Error
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'r10k/settings/definition'
|
2
|
+
require 'uri'
|
3
|
+
|
4
|
+
module R10K
|
5
|
+
module Settings
|
6
|
+
class URIDefinition < R10K::Settings::Definition
|
7
|
+
def validate
|
8
|
+
if @value
|
9
|
+
begin
|
10
|
+
URI.parse(@value)
|
11
|
+
rescue URI::Error
|
12
|
+
raise ArgumentError, "Setting #{@name} requires a URL but '#{@value}' could not be parsed as a URL"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
super
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -14,10 +14,10 @@ class R10K::Util::Subprocess::Runner::Windows < R10K::Util::Subprocess::Runner
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def run
|
17
|
-
|
18
|
-
|
19
|
-
stdout, stderr, status = Open3.capture3(cmd)
|
20
|
-
|
17
|
+
spawn_opts = @cwd ? {:chdir => @cwd} : {}
|
18
|
+
stdout, stderr, status = Open3.capture3(*@argv, spawn_opts)
|
21
19
|
@result = R10K::Util::Subprocess::Result.new(@argv, stdout, stderr, status.exitstatus)
|
20
|
+
rescue Errno::ENOENT, Errno::EACCES => e
|
21
|
+
@result = R10K::Util::Subprocess::Result.new(@argv, '', e.message, 255)
|
22
22
|
end
|
23
23
|
end
|
data/lib/r10k/version.rb
CHANGED
data/r10k.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
|
|
10
10
|
|
11
11
|
s.authors = "Adrien Thebo"
|
12
12
|
s.email = "adrien@somethingsinistral.net"
|
13
|
-
s.homepage = "
|
13
|
+
s.homepage = "https://github.com/puppetlabs/r10k"
|
14
14
|
s.summary = "Puppet environment and module deployment"
|
15
15
|
s.description = <<-DESCRIPTION
|
16
16
|
R10K provides a general purpose toolset for deploying Puppet environments and modules.
|
@@ -28,6 +28,7 @@ Gem::Specification.new do |s|
|
|
28
28
|
s.add_dependency 'log4r', '1.1.10'
|
29
29
|
s.add_dependency 'multi_json', '~> 1.10'
|
30
30
|
|
31
|
+
s.add_dependency 'puppet_forge', '~> 2.1.1'
|
31
32
|
s.add_dependency 'faraday', '~> 0.9.0'
|
32
33
|
s.add_dependency 'faraday_middleware', '~> 0.9.0'
|
33
34
|
s.add_dependency 'faraday_middleware-multi_json', '~> 0.0.6'
|
@@ -44,6 +45,4 @@ Gem::Specification.new do |s|
|
|
44
45
|
s.require_path = 'lib'
|
45
46
|
s.bindir = 'bin'
|
46
47
|
s.executables = 'r10k'
|
47
|
-
|
48
|
-
s.test_files = Dir.glob("spec/**/*_spec.rb")
|
49
48
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
mod 'branan/eight_hundred', '1.0.0', :git => 'https://github.com/branan/eight_hundred', :ref => 'master'
|
File without changes
|
@@ -6,9 +6,9 @@ describe R10K::Git::Rugged::ThinRepository, :if => R10K::Features.available?(:ru
|
|
6
6
|
|
7
7
|
let(:dirname) { 'working-repo' }
|
8
8
|
|
9
|
-
subject { described_class.new(basedir, dirname) }
|
10
|
-
|
11
9
|
let(:cacherepo) { R10K::Git::Rugged::Cache.generate(remote) }
|
12
10
|
|
11
|
+
subject { described_class.new(basedir, dirname, cacherepo) }
|
12
|
+
|
13
13
|
it_behaves_like "a git thin repository"
|
14
14
|
end
|
@@ -10,4 +10,13 @@ describe R10K::Git::Rugged::WorkingRepository, :if => R10K::Features.available?(
|
|
10
10
|
|
11
11
|
it_behaves_like 'a git repository'
|
12
12
|
it_behaves_like 'a git working repository'
|
13
|
+
|
14
|
+
describe "checking out an unresolvable ref" do
|
15
|
+
it "raises an error indicating that the ref was unresolvable" do
|
16
|
+
expect(subject).to receive(:resolve).with("unresolvable")
|
17
|
+
expect {
|
18
|
+
subject.checkout("unresolvable")
|
19
|
+
}.to raise_error(R10K::Git::GitError, /Unable to check out unresolvable ref 'unresolvable'/)
|
20
|
+
end
|
21
|
+
end
|
13
22
|
end
|
@@ -6,9 +6,9 @@ describe R10K::Git::ShellGit::ThinRepository do
|
|
6
6
|
|
7
7
|
let(:dirname) { 'working-repo' }
|
8
8
|
|
9
|
-
subject { described_class.new(basedir, dirname) }
|
10
|
-
|
11
9
|
let(:cacherepo) { R10K::Git::ShellGit::Cache.generate(remote) }
|
12
10
|
|
11
|
+
subject { described_class.new(basedir, dirname, cacherepo) }
|
12
|
+
|
13
13
|
it_behaves_like "a git thin repository"
|
14
14
|
end
|
@@ -7,8 +7,8 @@ describe R10K::Git::StatefulRepository do
|
|
7
7
|
|
8
8
|
let(:dirname) { 'working-repo' }
|
9
9
|
|
10
|
-
let(:thinrepo) { R10K::Git.thin_repository.new(basedir, dirname) }
|
11
10
|
let(:cacherepo) { R10K::Git.cache.generate(remote) }
|
11
|
+
let(:thinrepo) { R10K::Git.thin_repository.new(basedir, dirname, cacherepo) }
|
12
12
|
|
13
13
|
subject { described_class.new('0.9.x', remote, basedir, dirname) }
|
14
14
|
|
@@ -3,8 +3,11 @@ require 'r10k/deployment/config'
|
|
3
3
|
module R10K
|
4
4
|
class Deployment
|
5
5
|
class MockConfig
|
6
|
+
|
7
|
+
attr_accessor :hash
|
8
|
+
|
6
9
|
def initialize(hash)
|
7
|
-
@hash = hash
|
10
|
+
@hash = hash.merge(deploy: {})
|
8
11
|
end
|
9
12
|
|
10
13
|
def configfile
|
@@ -13,19 +16,13 @@ module R10K
|
|
13
16
|
|
14
17
|
# Perform a scan for key and check for both string and symbol keys
|
15
18
|
def setting(key)
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
when Symbol
|
21
|
-
keys << key.to_s
|
22
|
-
end
|
19
|
+
@hash[key]
|
20
|
+
end
|
21
|
+
|
22
|
+
alias [] setting
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
v = @hash[k]
|
27
|
-
break v unless v.nil?
|
28
|
-
end
|
24
|
+
def settings
|
25
|
+
@hash
|
29
26
|
end
|
30
27
|
end
|
31
28
|
end
|
data/spec/r10k-mocks/mock_env.rb
CHANGED
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'r10k/deployment'
|
4
|
+
|
5
|
+
shared_examples_for "a deploy action that requires a config file" do
|
6
|
+
let(:config) do
|
7
|
+
R10K::Deployment::MockConfig.new(
|
8
|
+
:sources => {
|
9
|
+
:control => {
|
10
|
+
:type => :mock,
|
11
|
+
:basedir => '/some/nonexistent/path/control',
|
12
|
+
:environments => %w[first second third],
|
13
|
+
},
|
14
|
+
:hiera => {
|
15
|
+
:type => :mock,
|
16
|
+
:basedir => '/some/nonexistent/path/hiera',
|
17
|
+
:environments => %w[fourth fifth sixth],
|
18
|
+
}
|
19
|
+
}
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
let(:deployment) { R10K::Deployment.new(config) }
|
24
|
+
|
25
|
+
before do
|
26
|
+
allow(R10K::Deployment).to receive(:new).and_return(deployment)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "exits when no config file was provided or found" do
|
30
|
+
subject.instance_variable_set(:@config, nil)
|
31
|
+
expect {
|
32
|
+
subject.call
|
33
|
+
}.to exit_with(8)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
shared_examples_for "a deploy action that can be write locked" do
|
38
|
+
|
39
|
+
let(:config) do
|
40
|
+
R10K::Deployment::MockConfig.new(
|
41
|
+
:sources => {
|
42
|
+
:control => {
|
43
|
+
:type => :mock,
|
44
|
+
:basedir => '/some/nonexistent/path/control',
|
45
|
+
:environments => %w[first second third],
|
46
|
+
},
|
47
|
+
:hiera => {
|
48
|
+
:type => :mock,
|
49
|
+
:basedir => '/some/nonexistent/path/hiera',
|
50
|
+
:environments => %w[fourth fifth sixth],
|
51
|
+
}
|
52
|
+
}
|
53
|
+
)
|
54
|
+
end
|
55
|
+
|
56
|
+
let(:deployment) { R10K::Deployment.new(config) }
|
57
|
+
|
58
|
+
before do
|
59
|
+
allow(R10K::Deployment).to receive(:new).and_return(deployment)
|
60
|
+
subject.settings = {deploy: {write_lock: "Disabled, yo"}}
|
61
|
+
end
|
62
|
+
|
63
|
+
it "exits without running when the write lock is set" do
|
64
|
+
expect(subject).to_not receive(:visit_deployment)
|
65
|
+
expect {
|
66
|
+
subject.call
|
67
|
+
}.to exit_with(16)
|
68
|
+
end
|
69
|
+
end
|