r10k 3.5.2 → 3.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/pull_request_template.md +4 -1
- data/.github/workflows/docker.yml +4 -1
- data/.github/workflows/release.yml +3 -2
- data/.github/workflows/rspec_tests.yml +81 -0
- data/.github/workflows/stale.yml +19 -0
- data/.travis.yml +8 -1
- data/CHANGELOG.mkd +43 -1
- data/CODEOWNERS +2 -2
- data/README.mkd +13 -4
- data/doc/common-patterns.mkd +1 -0
- data/doc/dynamic-environments/configuration.mkd +149 -45
- data/doc/dynamic-environments/usage.mkd +12 -11
- data/doc/puppetfile.mkd +23 -3
- data/docker/Gemfile +1 -1
- data/docker/Makefile +7 -4
- data/docker/docker-compose.yml +18 -0
- data/docker/r10k/Dockerfile +4 -3
- data/docker/r10k/docker-entrypoint.sh +0 -1
- data/docker/r10k/release.Dockerfile +3 -2
- data/docker/spec/dockerfile_spec.rb +26 -32
- data/integration/tests/git_source/git_source_repeated_remote.rb +68 -0
- 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 +2 -1
- data/integration/tests/user_scenario/basic_workflow/multi_source_custom_forge_git_module.rb +1 -1
- data/integration/tests/user_scenario/basic_workflow/single_env_custom_forge_git_module.rb +2 -1
- data/integration/tests/user_scenario/complex_workflow/multi_env_add_change_remove.rb +1 -1
- data/integration/tests/user_scenario/complex_workflow/multi_env_remove_re-add.rb +1 -1
- data/integration/tests/user_scenario/complex_workflow/multi_env_unamanaged.rb +1 -1
- data/lib/r10k/action/base.rb +8 -1
- data/lib/r10k/action/deploy/display.rb +46 -10
- data/lib/r10k/action/deploy/environment.rb +98 -50
- data/lib/r10k/action/deploy/module.rb +51 -29
- data/lib/r10k/action/puppetfile/check.rb +3 -1
- data/lib/r10k/action/puppetfile/install.rb +20 -23
- data/lib/r10k/action/puppetfile/purge.rb +8 -2
- data/lib/r10k/action/runner.rb +34 -0
- data/lib/r10k/cli/deploy.rb +14 -7
- data/lib/r10k/cli/puppetfile.rb +5 -5
- data/lib/r10k/content_synchronizer.rb +83 -0
- data/lib/r10k/deployment.rb +1 -1
- data/lib/r10k/environment/base.rb +30 -3
- data/lib/r10k/environment/git.rb +17 -5
- data/lib/r10k/environment/name.rb +22 -4
- data/lib/r10k/environment/svn.rb +11 -4
- data/lib/r10k/environment/with_modules.rb +46 -30
- data/lib/r10k/git.rb +1 -0
- data/lib/r10k/git/cache.rb +12 -4
- data/lib/r10k/git/rugged/credentials.rb +39 -2
- data/lib/r10k/git/stateful_repository.rb +4 -0
- data/lib/r10k/initializers.rb +2 -0
- data/lib/r10k/module.rb +1 -1
- data/lib/r10k/module/base.rb +25 -1
- data/lib/r10k/module/forge.rb +29 -11
- data/lib/r10k/module/git.rb +54 -27
- data/lib/r10k/module/local.rb +2 -1
- data/lib/r10k/module/svn.rb +24 -18
- data/lib/r10k/puppetfile.rb +75 -72
- data/lib/r10k/settings.rb +30 -3
- data/lib/r10k/source/base.rb +9 -0
- data/lib/r10k/source/git.rb +40 -9
- data/lib/r10k/source/hash.rb +5 -5
- data/lib/r10k/source/svn.rb +5 -3
- data/lib/r10k/util/cleaner.rb +21 -0
- data/lib/r10k/util/setopts.rb +33 -12
- data/lib/r10k/version.rb +1 -1
- data/locales/r10k.pot +103 -83
- data/r10k.gemspec +1 -1
- data/spec/fixtures/unit/action/r10k_creds.yaml +9 -0
- data/spec/r10k-mocks/mock_source.rb +1 -1
- data/spec/shared-examples/puppetfile-action.rb +7 -7
- data/spec/shared-examples/subprocess-runner.rb +11 -5
- data/spec/unit/action/deploy/display_spec.rb +35 -5
- data/spec/unit/action/deploy/environment_spec.rb +207 -37
- data/spec/unit/action/deploy/module_spec.rb +173 -26
- data/spec/unit/action/puppetfile/check_spec.rb +2 -2
- data/spec/unit/action/puppetfile/install_spec.rb +32 -10
- data/spec/unit/action/puppetfile/purge_spec.rb +25 -5
- data/spec/unit/action/runner_spec.rb +48 -1
- data/spec/unit/environment/git_spec.rb +19 -2
- data/spec/unit/environment/name_spec.rb +28 -0
- data/spec/unit/environment/svn_spec.rb +12 -0
- data/spec/unit/environment/with_modules_spec.rb +74 -0
- data/spec/unit/git/cache_spec.rb +10 -0
- data/spec/unit/git/rugged/credentials_spec.rb +79 -2
- data/spec/unit/git_spec.rb +3 -3
- data/spec/unit/module/forge_spec.rb +21 -13
- data/spec/unit/module/git_spec.rb +64 -1
- data/spec/unit/module_spec.rb +60 -10
- data/spec/unit/puppetfile_spec.rb +98 -30
- data/spec/unit/settings_spec.rb +12 -0
- data/spec/unit/source/git_spec.rb +49 -1
- data/spec/unit/util/purgeable_spec.rb +2 -8
- data/spec/unit/util/setopts_spec.rb +25 -1
- metadata +12 -11
- data/azure-pipelines.yml +0 -86
@@ -12,13 +12,13 @@ module R10K
|
|
12
12
|
INVALID_CHARACTERS = %r[\W]
|
13
13
|
|
14
14
|
def initialize(name, opts)
|
15
|
-
@name = name
|
16
|
-
@opts = opts
|
17
|
-
|
18
15
|
@source = opts[:source]
|
19
16
|
@prefix = opts[:prefix]
|
20
17
|
@invalid = opts[:invalid]
|
21
18
|
|
19
|
+
@name = derive_name(name, opts[:strip_component])
|
20
|
+
@opts = opts
|
21
|
+
|
22
22
|
case @invalid
|
23
23
|
when 'correct_and_warn'
|
24
24
|
@validate = true
|
@@ -71,8 +71,26 @@ module R10K
|
|
71
71
|
|
72
72
|
private
|
73
73
|
|
74
|
-
def
|
74
|
+
def derive_name(name, strip_component)
|
75
|
+
return name unless strip_component
|
76
|
+
|
77
|
+
unless strip_component.is_a?(String)
|
78
|
+
raise _('Improper configuration value given for strip_component setting in %{src} source. ' \
|
79
|
+
'Value must be a string, a /regex/, false, or omitted. Got "%{val}" (%{type})' \
|
80
|
+
% {src: @source, val: strip_component, type: strip_component.class})
|
81
|
+
end
|
75
82
|
|
83
|
+
if %r{^/.*/$}.match(strip_component)
|
84
|
+
regex = Regexp.new(strip_component[1..-2])
|
85
|
+
name.gsub(regex, '')
|
86
|
+
elsif name.start_with?(strip_component)
|
87
|
+
name[strip_component.size..-1]
|
88
|
+
else
|
89
|
+
name
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def derive_prefix(source,prefix)
|
76
94
|
if prefix == true
|
77
95
|
"#{source}_"
|
78
96
|
elsif prefix.is_a? String
|
data/lib/r10k/environment/svn.rb
CHANGED
@@ -7,8 +7,6 @@ require 'r10k/util/setopts'
|
|
7
7
|
# @since 1.3.0
|
8
8
|
class R10K::Environment::SVN < R10K::Environment::Base
|
9
9
|
|
10
|
-
include R10K::Logging
|
11
|
-
|
12
10
|
R10K::Environment.register(:svn, self)
|
13
11
|
|
14
12
|
# @!attribute [r] remote
|
@@ -44,8 +42,17 @@ class R10K::Environment::SVN < R10K::Environment::Base
|
|
44
42
|
# @option options [String] :password The SVN password
|
45
43
|
def initialize(name, basedir, dirname, options = {})
|
46
44
|
super
|
45
|
+
setopts(options, {
|
46
|
+
# Standard option interface
|
47
|
+
:source => :remote,
|
48
|
+
:version => :expected_revision,
|
49
|
+
:type => ::R10K::Util::Setopts::Ignore,
|
47
50
|
|
48
|
-
|
51
|
+
# Type-specific options
|
52
|
+
:remote => :self,
|
53
|
+
:username => :self,
|
54
|
+
:password => :self,
|
55
|
+
})
|
49
56
|
|
50
57
|
@working_dir = R10K::SVN::WorkingDir.new(Pathname.new(@full_path), :username => @username, :password => @password)
|
51
58
|
end
|
@@ -61,7 +68,7 @@ class R10K::Environment::SVN < R10K::Environment::Base
|
|
61
68
|
if @working_dir.is_svn?
|
62
69
|
@working_dir.update
|
63
70
|
else
|
64
|
-
@working_dir.checkout(@remote)
|
71
|
+
@working_dir.checkout(@remote, @expected_revision)
|
65
72
|
end
|
66
73
|
@synced = true
|
67
74
|
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'r10k/logging'
|
2
1
|
require 'r10k/util/purgeable'
|
3
2
|
|
4
3
|
# This abstract base class implements an environment that can include module
|
@@ -7,8 +6,6 @@ require 'r10k/util/purgeable'
|
|
7
6
|
# @since 3.4.0
|
8
7
|
class R10K::Environment::WithModules < R10K::Environment::Base
|
9
8
|
|
10
|
-
include R10K::Logging
|
11
|
-
|
12
9
|
# @!attribute [r] moduledir
|
13
10
|
# @return [String] The directory to install environment-defined modules
|
14
11
|
# into (default: #{basedir}/modules)
|
@@ -24,7 +21,7 @@ class R10K::Environment::WithModules < R10K::Environment::Base
|
|
24
21
|
# @param options [String] :moduledir The path to install modules to
|
25
22
|
# @param options [Hash] :modules Modules to add to the environment
|
26
23
|
def initialize(name, basedir, dirname, options = {})
|
27
|
-
super
|
24
|
+
super
|
28
25
|
|
29
26
|
@managed_content = {}
|
30
27
|
@modules = []
|
@@ -46,38 +43,71 @@ class R10K::Environment::WithModules < R10K::Environment::Base
|
|
46
43
|
# - The r10k environment object
|
47
44
|
# - A Puppetfile in the environment's content
|
48
45
|
def modules
|
49
|
-
return @modules if
|
46
|
+
return @modules if puppetfile.nil?
|
47
|
+
|
48
|
+
puppetfile.load unless puppetfile.loaded?
|
49
|
+
@modules + puppetfile.modules
|
50
|
+
end
|
51
|
+
|
52
|
+
def module_conflicts?(mod_b)
|
53
|
+
conflict = @modules.any? { |mod_a| mod_a.name == mod_b.name }
|
54
|
+
return false unless conflict
|
55
|
+
|
56
|
+
msg_vars = {src: mod_b.origin, name: mod_b.name}
|
57
|
+
msg_error = _('Environment and %{src} both define the "%{name}" module' % msg_vars)
|
58
|
+
msg_continue = _("#{msg_error}. The %{src} definition will be ignored" % msg_vars)
|
59
|
+
|
60
|
+
case conflict_opt = @options[:module_conflicts]
|
61
|
+
when 'override_and_warn', nil
|
62
|
+
logger.warn msg_continue
|
63
|
+
when 'override'
|
64
|
+
logger.debug msg_continue
|
65
|
+
when 'error'
|
66
|
+
raise R10K::Error, msg_error
|
67
|
+
else
|
68
|
+
raise R10K::Error, _('Unexpected value for `module_conflicts` setting in %{env} ' \
|
69
|
+
'environment: %{val}' % {env: self.name, val: conflict_opt})
|
70
|
+
end
|
50
71
|
|
51
|
-
|
52
|
-
@modules + @puppetfile.modules
|
72
|
+
true
|
53
73
|
end
|
54
74
|
|
55
75
|
def accept(visitor)
|
56
76
|
visitor.visit(:environment, self) do
|
57
77
|
@modules.each do |mod|
|
58
|
-
mod.
|
78
|
+
mod.sync
|
59
79
|
end
|
60
80
|
|
61
81
|
puppetfile.accept(visitor)
|
62
|
-
validate_no_module_conflicts
|
63
82
|
end
|
64
83
|
end
|
65
84
|
|
85
|
+
def deploy
|
86
|
+
@modules.each do |mod|
|
87
|
+
mod.sync
|
88
|
+
end
|
89
|
+
|
90
|
+
super
|
91
|
+
end
|
92
|
+
|
66
93
|
def load_modules(module_hash)
|
67
94
|
module_hash.each do |name, args|
|
95
|
+
if !args.is_a?(Hash)
|
96
|
+
args = { version: args }
|
97
|
+
end
|
98
|
+
|
68
99
|
add_module(name, args)
|
69
100
|
end
|
70
101
|
end
|
71
102
|
|
72
103
|
# @param [String] name
|
73
|
-
# @param [
|
104
|
+
# @param [Hash] args
|
74
105
|
def add_module(name, args)
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
end
|
106
|
+
# symbolize keys in the args hash
|
107
|
+
args = args.inject({}) { |memo,(k,v)| memo[k.to_sym] = v; memo }
|
108
|
+
args[:overrides] = @overrides
|
79
109
|
|
80
|
-
if
|
110
|
+
if install_path = args.delete(:install_path)
|
81
111
|
install_path = resolve_install_path(install_path)
|
82
112
|
validate_install_path(install_path, name)
|
83
113
|
else
|
@@ -88,26 +118,12 @@ class R10K::Environment::WithModules < R10K::Environment::Base
|
|
88
118
|
@managed_content[install_path] = Array.new unless @managed_content.has_key?(install_path)
|
89
119
|
|
90
120
|
mod = R10K::Module.new(name, install_path, args, self.name)
|
91
|
-
mod.origin =
|
121
|
+
mod.origin = :environment
|
92
122
|
|
93
123
|
@managed_content[install_path] << mod.name
|
94
124
|
@modules << mod
|
95
125
|
end
|
96
126
|
|
97
|
-
def validate_no_module_conflicts
|
98
|
-
@puppetfile.load unless @puppetfile.loaded?
|
99
|
-
conflicts = (@modules + @puppetfile.modules)
|
100
|
-
.group_by { |mod| mod.name }
|
101
|
-
.select { |_, v| v.size > 1 }
|
102
|
-
.map(&:first)
|
103
|
-
unless conflicts.empty?
|
104
|
-
msg = _('Puppetfile cannot contain module names defined by environment %{name}') % {name: self.name}
|
105
|
-
msg += ' '
|
106
|
-
msg += _("Remove the conflicting definitions of the following modules: %{conflicts}" % { conflicts: conflicts.join(' ') })
|
107
|
-
raise R10K::Error.new(msg)
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
127
|
include R10K::Util::Purgeable
|
112
128
|
|
113
129
|
# Returns an array of the full paths that can be purged.
|
data/lib/r10k/git.rb
CHANGED
data/lib/r10k/git/cache.rb
CHANGED
@@ -16,7 +16,17 @@ class R10K::Git::Cache
|
|
16
16
|
|
17
17
|
include R10K::Settings::Mixin
|
18
18
|
|
19
|
-
|
19
|
+
#@api private
|
20
|
+
def self.determine_cache_root
|
21
|
+
if R10K::Util::Platform.windows?
|
22
|
+
File.join(ENV['LOCALAPPDATA'], 'r10k', 'git')
|
23
|
+
else
|
24
|
+
File.expand_path(ENV['HOME'] ? '~/.r10k/git': '/root/.r10k/git')
|
25
|
+
end
|
26
|
+
end
|
27
|
+
private_class_method :determine_cache_root
|
28
|
+
|
29
|
+
def_setting_attr :cache_root, determine_cache_root
|
20
30
|
|
21
31
|
@instance_cache = R10K::InstanceCache.new(self)
|
22
32
|
|
@@ -99,10 +109,8 @@ class R10K::Git::Cache
|
|
99
109
|
|
100
110
|
alias cached? exist?
|
101
111
|
|
102
|
-
private
|
103
|
-
|
104
112
|
# Reformat the remote name into something that can be used as a directory
|
105
113
|
def sanitized_dirname
|
106
|
-
@remote.gsub(/[^@\w\.-]/, '-')
|
114
|
+
@sanitized_dirname ||= @remote.gsub(/[^@\w\.-]/, '-')
|
107
115
|
end
|
108
116
|
end
|
@@ -61,11 +61,48 @@ class R10K::Git::Rugged::Credentials
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def get_plaintext_credentials(url, username_from_url)
|
64
|
-
|
65
|
-
|
64
|
+
per_repo_oauth_token = nil
|
65
|
+
if per_repo_settings = R10K::Git.get_repo_settings(url)
|
66
|
+
per_repo_oauth_token = per_repo_settings[:oauth_token]
|
67
|
+
end
|
68
|
+
|
69
|
+
if token_path = per_repo_oauth_token || R10K::Git.settings[:oauth_token]
|
70
|
+
@oauth_token ||= extract_token(token_path, url)
|
71
|
+
|
72
|
+
user = 'x-oauth-token'
|
73
|
+
password = @oauth_token
|
74
|
+
else
|
75
|
+
user = get_git_username(url, username_from_url)
|
76
|
+
password = URI.parse(url).password || ''
|
77
|
+
end
|
66
78
|
Rugged::Credentials::UserPassword.new(username: user, password: password)
|
67
79
|
end
|
68
80
|
|
81
|
+
def extract_token(token_path, url)
|
82
|
+
if token_path == '-'
|
83
|
+
token = $stdin.read.strip
|
84
|
+
logger.debug2 _("Using OAuth token from stdin for URL %{url}") % { url: url }
|
85
|
+
elsif File.readable?(token_path)
|
86
|
+
token = File.read(token_path).strip
|
87
|
+
logger.debug2 _("Using OAuth token from %{token_path} for URL %{url}") % { token_path: token_path, url: url }
|
88
|
+
else
|
89
|
+
raise R10K::Git::GitError, _("%{path} is missing or unreadable, cannot load OAuth token") % { path: token_path }
|
90
|
+
end
|
91
|
+
|
92
|
+
unless valid_token?(token)
|
93
|
+
raise R10K::Git::GitError, _("Supplied OAuth token contains invalid characters.")
|
94
|
+
end
|
95
|
+
|
96
|
+
token
|
97
|
+
end
|
98
|
+
|
99
|
+
# This regex is the only real requirement for OAuth token format,
|
100
|
+
# per https://www.oauth.com/oauth2-servers/access-tokens/access-token-response/
|
101
|
+
# Bitbucket's tokens also can include an underscore, so that is added here.
|
102
|
+
def valid_token?(token)
|
103
|
+
return token =~ /^[\w\-\.~_\+\/]+$/
|
104
|
+
end
|
105
|
+
|
69
106
|
def get_default_credentials(url, username_from_url)
|
70
107
|
Rugged::Credentials::Default.new
|
71
108
|
end
|
data/lib/r10k/initializers.rb
CHANGED
@@ -44,6 +44,7 @@ module R10K
|
|
44
44
|
class DeployInitializer < BaseInitializer
|
45
45
|
def call
|
46
46
|
with_setting(:puppet_path) { |value| R10K::Settings.puppet_path = value }
|
47
|
+
with_setting(:puppet_conf) { |value| R10K::Settings.puppet_conf = value }
|
47
48
|
end
|
48
49
|
end
|
49
50
|
|
@@ -54,6 +55,7 @@ module R10K
|
|
54
55
|
with_setting(:private_key) { |value| R10K::Git.settings[:private_key] = value }
|
55
56
|
with_setting(:proxy) { |value| R10K::Git.settings[:proxy] = value }
|
56
57
|
with_setting(:repositories) { |value| R10K::Git.settings[:repositories] = value }
|
58
|
+
with_setting(:oauth_token) { |value| R10K::Git.settings[:oauth_token] = value }
|
57
59
|
end
|
58
60
|
end
|
59
61
|
|
data/lib/r10k/module.rb
CHANGED
@@ -17,7 +17,7 @@ module R10K::Module
|
|
17
17
|
#
|
18
18
|
# @param [String] name The unique name of the module
|
19
19
|
# @param [String] basedir The root to install the module in
|
20
|
-
# @param [
|
20
|
+
# @param [Hash] args An arbitary Hash that specifies the implementation
|
21
21
|
# @param [R10K::Environment] environment Optional environment that this module is a part of
|
22
22
|
#
|
23
23
|
# @return [Object < R10K::Module] A member of the implementing subclass
|
data/lib/r10k/module/base.rb
CHANGED
@@ -51,7 +51,11 @@ class R10K::Module::Base
|
|
51
51
|
@owner, @name = parse_title(@title)
|
52
52
|
@path = Pathname.new(File.join(@dirname, @name))
|
53
53
|
@environment = environment
|
54
|
+
@overrides = args.delete(:overrides) || {}
|
54
55
|
@origin = 'external' # Expect Puppetfile or R10k::Environment to set this to a specific value
|
56
|
+
|
57
|
+
@requested_modules = @overrides.dig(:modules, :requested_modules) || []
|
58
|
+
@should_sync = (@requested_modules.empty? || @requested_modules.include?(@name))
|
55
59
|
end
|
56
60
|
|
57
61
|
# @deprecated
|
@@ -61,11 +65,22 @@ class R10K::Module::Base
|
|
61
65
|
end
|
62
66
|
|
63
67
|
# Synchronize this module with the indicated state.
|
64
|
-
# @
|
68
|
+
# @param [Hash] opts Deprecated
|
65
69
|
def sync(opts={})
|
66
70
|
raise NotImplementedError
|
67
71
|
end
|
68
72
|
|
73
|
+
def should_sync?
|
74
|
+
if @should_sync
|
75
|
+
logger.info _("Deploying module to %{path}") % {path: path}
|
76
|
+
true
|
77
|
+
else
|
78
|
+
logger.debug1(_("Only updating modules %{modules}, skipping module %{name}") % {modules: @requested_modules.inspect, name: name})
|
79
|
+
false
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
|
69
84
|
# Return the desired version of this module
|
70
85
|
# @abstract
|
71
86
|
def version
|
@@ -87,6 +102,7 @@ class R10K::Module::Base
|
|
87
102
|
raise NotImplementedError
|
88
103
|
end
|
89
104
|
|
105
|
+
# Deprecated
|
90
106
|
def accept(visitor)
|
91
107
|
visitor.visit(:module, self)
|
92
108
|
end
|
@@ -99,6 +115,14 @@ class R10K::Module::Base
|
|
99
115
|
raise NotImplementedError
|
100
116
|
end
|
101
117
|
|
118
|
+
# Return the module's cachedir. Subclasses that implement a cache
|
119
|
+
# will override this to return a real directory location.
|
120
|
+
#
|
121
|
+
# @return [String, :none]
|
122
|
+
def cachedir
|
123
|
+
:none
|
124
|
+
end
|
125
|
+
|
102
126
|
private
|
103
127
|
|
104
128
|
def parse_title(title)
|
data/lib/r10k/module/forge.rb
CHANGED
@@ -13,7 +13,12 @@ class R10K::Module::Forge < R10K::Module::Base
|
|
13
13
|
R10K::Module.register(self)
|
14
14
|
|
15
15
|
def self.implement?(name, args)
|
16
|
-
|
16
|
+
args[:type].to_s == 'forge' ||
|
17
|
+
(!!
|
18
|
+
((args.keys & %i{git svn type}).empty? &&
|
19
|
+
args.has_key?(:version) &&
|
20
|
+
name.match(%r[\w+[/-]\w+]) &&
|
21
|
+
valid_version?(args[:version])))
|
17
22
|
end
|
18
23
|
|
19
24
|
def self.valid_version?(expected_version)
|
@@ -32,24 +37,37 @@ class R10K::Module::Forge < R10K::Module::Base
|
|
32
37
|
|
33
38
|
include R10K::Logging
|
34
39
|
|
35
|
-
|
40
|
+
include R10K::Util::Setopts
|
41
|
+
|
42
|
+
def initialize(title, dirname, opts, environment=nil)
|
36
43
|
super
|
37
44
|
|
38
45
|
@metadata_file = R10K::Module::MetadataFile.new(path + 'metadata.json')
|
39
46
|
@metadata = @metadata_file.read
|
40
47
|
|
41
|
-
|
48
|
+
setopts(opts, {
|
49
|
+
# Standard option interface
|
50
|
+
:version => :expected_version,
|
51
|
+
:source => ::R10K::Util::Setopts::Ignore,
|
52
|
+
:type => ::R10K::Util::Setopts::Ignore,
|
53
|
+
})
|
54
|
+
|
55
|
+
@expected_version ||= current_version || :latest
|
56
|
+
|
42
57
|
@v3_module = PuppetForge::V3::Module.new(:slug => @title)
|
43
58
|
end
|
44
59
|
|
60
|
+
# @param [Hash] opts Deprecated
|
45
61
|
def sync(opts={})
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
62
|
+
if should_sync?
|
63
|
+
case status
|
64
|
+
when :absent
|
65
|
+
install
|
66
|
+
when :outdated
|
67
|
+
upgrade
|
68
|
+
when :mismatched
|
69
|
+
reinstall
|
70
|
+
end
|
53
71
|
end
|
54
72
|
end
|
55
73
|
|
@@ -171,7 +189,7 @@ class R10K::Module::Forge < R10K::Module::Base
|
|
171
189
|
if (match = title.match(/\A(\w+)[-\/](\w+)\Z/))
|
172
190
|
[match[1], match[2]]
|
173
191
|
else
|
174
|
-
raise ArgumentError, _("Forge module names must match 'owner/modulename'")
|
192
|
+
raise ArgumentError, _("Forge module names must match 'owner/modulename', instead got #{title}")
|
175
193
|
end
|
176
194
|
end
|
177
195
|
end
|