r10k 3.13.0 → 3.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/docker.yml +1 -1
- data/.github/workflows/rspec_tests.yml +2 -2
- data/.travis.yml +1 -1
- data/CHANGELOG.mkd +10 -0
- data/doc/dynamic-environments/configuration.mkd +24 -0
- data/doc/puppetfile.mkd +13 -0
- data/lib/r10k/environment/name.rb +14 -9
- data/lib/r10k/environment/tarball.rb +78 -0
- data/lib/r10k/environment.rb +1 -0
- data/lib/r10k/forge/module_release.rb +2 -1
- data/lib/r10k/git/cache.rb +4 -13
- data/lib/r10k/git/rugged/base_repository.rb +12 -1
- data/lib/r10k/git/rugged/cache.rb +8 -0
- data/lib/r10k/git/stateful_repository.rb +2 -0
- data/lib/r10k/initializers.rb +10 -0
- data/lib/r10k/module/tarball.rb +101 -0
- data/lib/r10k/module.rb +1 -0
- data/lib/r10k/module_loader/puppetfile.rb +10 -1
- data/lib/r10k/source/git.rb +18 -18
- data/lib/r10k/tarball.rb +183 -0
- data/lib/r10k/util/cacheable.rb +31 -0
- data/lib/r10k/util/downloader.rb +134 -0
- data/lib/r10k/version.rb +1 -1
- data/locales/r10k.pot +39 -23
- data/r10k.gemspec +2 -2
- data/spec/fixtures/tarball/tarball.tar.gz +0 -0
- data/spec/integration/git/rugged/cache_spec.rb +33 -0
- data/spec/shared-contexts/tarball.rb +32 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/unit/action/deploy/module_spec.rb +2 -2
- data/spec/unit/environment/name_spec.rb +18 -0
- data/spec/unit/environment/tarball_spec.rb +45 -0
- data/spec/unit/git/cache_spec.rb +2 -15
- data/spec/unit/git/rugged/cache_spec.rb +19 -0
- data/spec/unit/module/tarball_spec.rb +70 -0
- data/spec/unit/module_loader/puppetfile_spec.rb +4 -1
- data/spec/unit/tarball_spec.rb +57 -0
- data/spec/unit/util/cacheable_spec.rb +23 -0
- data/spec/unit/util/downloader_spec.rb +98 -0
- metadata +29 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da22a28bcd5de19a996ff2c869ba074c402e393d7a3caa2528bb342c75192234
|
4
|
+
data.tar.gz: 9bf7067d8412b9d158f2d47ad96499f90183c5dcade26b97fede2a344b06dca0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2a529ce1b781f858253f1d929e4cf521806a8f11ce9733a4f2dc92dcfd4792d4afcbad9290a814d10a14be645eb0ada9551c542def43f6acc48d28931783bc2
|
7
|
+
data.tar.gz: 31d2a9e5d85f29da1c6f62d77d7bbd83c7ed8c4687bb5035f7185c8b37042e2707e59b623d6603af5d533ee79c44380d4a3a4a1a2a28ddd06af9c723c6f1c1bb
|
@@ -59,7 +59,7 @@ jobs:
|
|
59
59
|
bundle --version
|
60
60
|
|
61
61
|
# Run tests
|
62
|
-
bundle exec rspec --color --format documentation spec
|
62
|
+
bundle exec rspec --color --format documentation spec
|
63
63
|
|
64
64
|
- name: Run tests on Linux
|
65
65
|
if: runner.os == 'Linux'
|
@@ -78,4 +78,4 @@ jobs:
|
|
78
78
|
fi
|
79
79
|
|
80
80
|
# Run tests
|
81
|
-
bundle exec rspec --color --format documentation spec
|
81
|
+
bundle exec rspec --color --format documentation spec
|
data/.travis.yml
CHANGED
data/CHANGELOG.mkd
CHANGED
@@ -4,6 +4,16 @@ CHANGELOG
|
|
4
4
|
Unreleased
|
5
5
|
----------
|
6
6
|
|
7
|
+
3.14.0
|
8
|
+
------
|
9
|
+
|
10
|
+
- Record unprocessed environment name, so that `strip_component` does not cause truncated environment names to be used as git branches, resulting in errors or incorrect deploys. [#1240](https://github.com/puppetlabs/r10k/pull/1240)
|
11
|
+
- (CODEMGMT-1294) Resync repos with unresolvable refs [#1239](https://github.com/puppetlabs/r10k/pull/1239)
|
12
|
+
- (RK-378) Restore access to the environment name from the Puppetfile [#1241](https://github.com/puppetlabs/r10k/pull/1241)
|
13
|
+
- (CODEMGMT-1300) Ensure the remote url in rugged cache directories is current [#1245](https://github.com/puppetlabs/r10k/pull/1245)
|
14
|
+
- Add support for tarball module type, allowing module content to be packaged and sourced from generic fileservers [#1244](https://github.com/puppetlabs/r10k/pull/1244)
|
15
|
+
- Add experimental support for tarball environment type, allowing whole environments to be packaged and sourced from generic fileservers [#1244](https://github.com/puppetlabs/r10k/pull/1244)
|
16
|
+
|
7
17
|
3.13.0
|
8
18
|
------
|
9
19
|
|
@@ -796,3 +796,27 @@ development:
|
|
796
796
|
source: https://github.com/reidmv/reidmv-xampl.git
|
797
797
|
version: 62d07f2
|
798
798
|
```
|
799
|
+
|
800
|
+
### Tarball Environment Type
|
801
|
+
|
802
|
+
The tarball environment type allows an environment to be deployed from a tarball archive, rather than a Git repository. When using a tarball environment type, a source location for the tarball is required. Optionally, the tarball's sha256 checksum may be specified as the version. It is highly recommended to include a version specifier. If a version specifier is not included, r10k will never invalidate a cached copy of the tarball's source.
|
803
|
+
|
804
|
+
Tarball environment sources will be unpacked directly into the environment root.
|
805
|
+
|
806
|
+
```yaml
|
807
|
+
---
|
808
|
+
production:
|
809
|
+
type: tarball
|
810
|
+
source: https://repo.example.com/projects/puppet/env-2.36.1.tar.gz
|
811
|
+
version: 99a906c99c2f144de43f2ae500509a7474ed11c583fb623efa8e5b377a3157f0 # sha256digest
|
812
|
+
|
813
|
+
development:
|
814
|
+
type: tarball
|
815
|
+
source: https://repo.example.com/projects/puppet/env-6128ada.tar.gz
|
816
|
+
version: 6128ada158622cd90f8e1360fb7c2c3830a812d1ec26ddf0db7eb16d61b7293f # sha256digest
|
817
|
+
modules:
|
818
|
+
reidmv-xampl:
|
819
|
+
type: git
|
820
|
+
source: https://github.com/reidmv/reidmv-xampl.git
|
821
|
+
version: 62d07f2
|
822
|
+
```
|
data/doc/puppetfile.mkd
CHANGED
@@ -239,6 +239,19 @@ credentials may be visible in the process table when r10k is running. If you
|
|
239
239
|
choose to supply SVN credentials make sure that the system running r10k is
|
240
240
|
appropriately secured.
|
241
241
|
|
242
|
+
### Tarball
|
243
|
+
|
244
|
+
Modules can be installed from tarball archives. A tarball module must specify a source URL to retreive the tarball content from. A tarball module may optionally specify a sha256 checksum as the module version.
|
245
|
+
|
246
|
+
mod 'puppetlabs-apache',
|
247
|
+
type: 'tarball',
|
248
|
+
source: 'https://repo.example.com/puppet/modules/puppetlabs-apache-7.0.0.tar.gz',
|
249
|
+
version: 'aedd6dc1a5136c6a1a1ec2f285df2a70b0fe4c9effb254b5a1f58116e4c1659e' # sha256 digest
|
250
|
+
|
251
|
+
If no version is specified, a tarball will be downloaded from the given source and cached. The cache will not be invalidated until the source URL is changed, or a sha256 checksum version is provided.
|
252
|
+
|
253
|
+
Tarball module content will be unpacked directly into an appropriately named module directory. For example, the puppetlabs-apache-7.0.0.tar.gz archive in the example above will be unpacked into `<environment-dir>/modules/apache/`.
|
254
|
+
|
242
255
|
### Local
|
243
256
|
|
244
257
|
In the event you want to store locally written modules in your r10k-managed
|
@@ -6,17 +6,22 @@ module R10K
|
|
6
6
|
class Name
|
7
7
|
|
8
8
|
# @!attribute [r] name
|
9
|
-
# @return [String] The
|
9
|
+
# @return [String] The functional name of the environment derived from inputs and options.
|
10
10
|
attr_reader :name
|
11
11
|
|
12
|
+
# @!attribute [r] original_name
|
13
|
+
# @return [String] The unmodified name originally given to create the object.
|
14
|
+
attr_reader :original_name
|
15
|
+
|
12
16
|
INVALID_CHARACTERS = %r[\W]
|
13
17
|
|
14
|
-
def initialize(
|
18
|
+
def initialize(original_name, opts)
|
15
19
|
@source = opts[:source]
|
16
20
|
@prefix = opts[:prefix]
|
17
21
|
@invalid = opts[:invalid]
|
18
22
|
|
19
|
-
@name = derive_name(
|
23
|
+
@name = derive_name(original_name, opts[:strip_component])
|
24
|
+
@original_name = original_name
|
20
25
|
@opts = opts
|
21
26
|
|
22
27
|
case @invalid
|
@@ -71,8 +76,8 @@ module R10K
|
|
71
76
|
|
72
77
|
private
|
73
78
|
|
74
|
-
def derive_name(
|
75
|
-
return
|
79
|
+
def derive_name(original_name, strip_component)
|
80
|
+
return original_name unless strip_component
|
76
81
|
|
77
82
|
unless strip_component.is_a?(String)
|
78
83
|
raise _('Improper configuration value given for strip_component setting in %{src} source. ' \
|
@@ -82,11 +87,11 @@ module R10K
|
|
82
87
|
|
83
88
|
if %r{^/.*/$}.match(strip_component)
|
84
89
|
regex = Regexp.new(strip_component[1..-2])
|
85
|
-
|
86
|
-
elsif
|
87
|
-
|
90
|
+
original_name.gsub(regex, '')
|
91
|
+
elsif original_name.start_with?(strip_component)
|
92
|
+
original_name[strip_component.size..-1]
|
88
93
|
else
|
89
|
-
|
94
|
+
original_name
|
90
95
|
end
|
91
96
|
end
|
92
97
|
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'r10k/util/setopts'
|
2
|
+
require 'r10k/tarball'
|
3
|
+
require 'r10k/environment'
|
4
|
+
|
5
|
+
class R10K::Environment::Tarball < R10K::Environment::WithModules
|
6
|
+
|
7
|
+
R10K::Environment.register(:tarball, self)
|
8
|
+
|
9
|
+
# @!attribute [r] tarball
|
10
|
+
# @api private
|
11
|
+
# @return [R10K::Tarball]
|
12
|
+
attr_reader :tarball
|
13
|
+
|
14
|
+
include R10K::Util::Setopts
|
15
|
+
|
16
|
+
# Initialize the given tarball environment.
|
17
|
+
#
|
18
|
+
# @param name [String] The unique name describing this environment.
|
19
|
+
# @param basedir [String] The base directory where this environment will be created.
|
20
|
+
# @param dirname [String] The directory name for this environment.
|
21
|
+
# @param options [Hash] An additional set of options for this environment.
|
22
|
+
#
|
23
|
+
# @param options [String] :source Where to get the tarball from
|
24
|
+
# @param options [String] :version The sha256 digest of the tarball
|
25
|
+
def initialize(name, basedir, dirname, options = {})
|
26
|
+
super
|
27
|
+
setopts(options, {
|
28
|
+
# Standard option interface
|
29
|
+
:type => ::R10K::Util::Setopts::Ignore,
|
30
|
+
:source => :self,
|
31
|
+
:version => :checksum,
|
32
|
+
|
33
|
+
# Type-specific options
|
34
|
+
:checksum => :self,
|
35
|
+
})
|
36
|
+
|
37
|
+
@tarball = R10K::Tarball.new(name, @source, checksum: @checksum)
|
38
|
+
end
|
39
|
+
|
40
|
+
def path
|
41
|
+
@path ||= Pathname.new(File.join(@basedir, @dirname))
|
42
|
+
end
|
43
|
+
|
44
|
+
def sync
|
45
|
+
tarball.get unless tarball.cache_valid?
|
46
|
+
case status
|
47
|
+
when :absent, :mismatched
|
48
|
+
tarball.unpack(path.to_s)
|
49
|
+
# Untracked files left behind from previous extractions are expected to
|
50
|
+
# be deleted by r10k's purge facility.
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def status
|
55
|
+
if not path.exist?
|
56
|
+
:absent
|
57
|
+
elsif not (tarball.cache_valid? && tarball.insync?(path.to_s, ignore_untracked_files: true))
|
58
|
+
:mismatched
|
59
|
+
else
|
60
|
+
:insync
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def signature
|
65
|
+
@checksum || @tarball.cache_checksum
|
66
|
+
end
|
67
|
+
|
68
|
+
include R10K::Util::Purgeable
|
69
|
+
|
70
|
+
# Returns an array of the full paths to all the content being managed.
|
71
|
+
# @note This implements a required method for the Purgeable mixin
|
72
|
+
# @return [Array<String>]
|
73
|
+
def desired_contents
|
74
|
+
desired = []
|
75
|
+
desired += @tarball.paths.map { |entry| File.join(@full_path, entry) }
|
76
|
+
desired += super
|
77
|
+
end
|
78
|
+
end
|
data/lib/r10k/environment.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'r10k/logging'
|
2
2
|
require 'r10k/settings/mixin'
|
3
|
+
require 'r10k/util/cacheable'
|
3
4
|
require 'fileutils'
|
4
5
|
require 'tmpdir'
|
5
6
|
require 'puppet_forge'
|
@@ -13,7 +14,7 @@ module R10K
|
|
13
14
|
|
14
15
|
def_setting_attr :proxy
|
15
16
|
def_setting_attr :baseurl
|
16
|
-
def_setting_attr :cache_root,
|
17
|
+
def_setting_attr :cache_root, R10K::Util::Cacheable.default_cachedir
|
17
18
|
|
18
19
|
include R10K::Logging
|
19
20
|
|
data/lib/r10k/git/cache.rb
CHANGED
@@ -3,6 +3,7 @@ require 'r10k/git'
|
|
3
3
|
require 'r10k/settings'
|
4
4
|
require 'r10k/instance_cache'
|
5
5
|
require 'forwardable'
|
6
|
+
require 'r10k/util/cacheable'
|
6
7
|
|
7
8
|
# Cache Git repository mirrors for object database reuse.
|
8
9
|
#
|
@@ -15,18 +16,9 @@ require 'forwardable'
|
|
15
16
|
class R10K::Git::Cache
|
16
17
|
|
17
18
|
include R10K::Settings::Mixin
|
19
|
+
include R10K::Util::Cacheable
|
18
20
|
|
19
|
-
|
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
|
21
|
+
def_setting_attr :cache_root, R10K::Util::Cacheable.default_cachedir('git')
|
30
22
|
|
31
23
|
@instance_cache = R10K::InstanceCache.new(self)
|
32
24
|
|
@@ -109,8 +101,7 @@ class R10K::Git::Cache
|
|
109
101
|
|
110
102
|
alias cached? exist?
|
111
103
|
|
112
|
-
# Reformat the remote name into something that can be used as a directory
|
113
104
|
def sanitized_dirname
|
114
|
-
@sanitized_dirname ||= @remote
|
105
|
+
@sanitized_dirname ||= super(@remote)
|
115
106
|
end
|
116
107
|
end
|
@@ -20,7 +20,8 @@ class R10K::Git::Rugged::BaseRepository
|
|
20
20
|
else
|
21
21
|
object.oid
|
22
22
|
end
|
23
|
-
rescue ::Rugged::ReferenceError
|
23
|
+
rescue ::Rugged::ReferenceError, ::Rugged::OdbError => e
|
24
|
+
logger.debug2(_("Unable to resolve %{pattern}: %{e} ") % {pattern: pattern, e: e })
|
24
25
|
nil
|
25
26
|
end
|
26
27
|
|
@@ -60,6 +61,16 @@ class R10K::Git::Rugged::BaseRepository
|
|
60
61
|
remotes_hash
|
61
62
|
end
|
62
63
|
|
64
|
+
# Update a remote URL
|
65
|
+
# @param [String] The remote URL of the git repository
|
66
|
+
# @param [String] An optional remote name for the git repository
|
67
|
+
def update_remote(remote, remote_name='origin')
|
68
|
+
if @_rugged_repo
|
69
|
+
logger.debug2(_("Remote URL is different from cache, updating %{orig} to %{update}") % {orig: remotes[remote_name], update: remote})
|
70
|
+
@_rugged_repo.remotes.set_url(remote_name, remote)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
63
74
|
private
|
64
75
|
|
65
76
|
def with_repo(opts={})
|
@@ -8,4 +8,12 @@ class R10K::Git::Rugged::Cache < R10K::Git::Cache
|
|
8
8
|
def self.bare_repository
|
9
9
|
R10K::Git::Rugged::BareRepository
|
10
10
|
end
|
11
|
+
|
12
|
+
# Update the remote URL if the cache differs from the current configuration
|
13
|
+
def sync!
|
14
|
+
if cached? && @repo.remotes['origin'] != @remote
|
15
|
+
@repo.update_remote(@remote)
|
16
|
+
end
|
17
|
+
super
|
18
|
+
end
|
11
19
|
end
|
data/lib/r10k/initializers.rb
CHANGED
@@ -4,6 +4,7 @@ require 'r10k/git'
|
|
4
4
|
require 'r10k/git/cache'
|
5
5
|
|
6
6
|
require 'r10k/forge/module_release'
|
7
|
+
require 'r10k/tarball'
|
7
8
|
|
8
9
|
module R10K
|
9
10
|
module Initializers
|
@@ -36,10 +37,13 @@ module R10K
|
|
36
37
|
|
37
38
|
with_setting(:cachedir) { |value| R10K::Git::Cache.settings[:cache_root] = value }
|
38
39
|
with_setting(:cachedir) { |value| R10K::Forge::ModuleRelease.settings[:cache_root] = value }
|
40
|
+
with_setting(:cachedir) { |value| R10K::Tarball.settings[:cache_root] = value }
|
39
41
|
with_setting(:pool_size) { |value| R10K::Puppetfile.settings[:pool_size] = value }
|
42
|
+
with_setting(:proxy) { |value| R10K::Tarball.settings[:proxy] = value }
|
40
43
|
|
41
44
|
with_setting(:git) { |value| GitInitializer.new(value).call }
|
42
45
|
with_setting(:forge) { |value| ForgeInitializer.new(value).call }
|
46
|
+
with_setting(:tarball) { |value| TarballInitializer.new(value).call }
|
43
47
|
end
|
44
48
|
end
|
45
49
|
|
@@ -79,5 +83,11 @@ module R10K
|
|
79
83
|
with_setting(:authorization_token) { |value| PuppetForge::Connection.authorization = value }
|
80
84
|
end
|
81
85
|
end
|
86
|
+
|
87
|
+
class TarballInitializer < BaseInitializer
|
88
|
+
def call
|
89
|
+
with_setting(:proxy) { |value| R10K::Tarball.settings[:proxy] = value }
|
90
|
+
end
|
91
|
+
end
|
82
92
|
end
|
83
93
|
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
require 'r10k/module'
|
2
|
+
require 'r10k/util/setopts'
|
3
|
+
require 'r10k/tarball'
|
4
|
+
|
5
|
+
# This class defines a tarball source module implementation
|
6
|
+
class R10K::Module::Tarball < R10K::Module::Base
|
7
|
+
|
8
|
+
R10K::Module.register(self)
|
9
|
+
|
10
|
+
def self.implement?(name, args)
|
11
|
+
args.is_a?(Hash) && args[:type].to_s == 'tarball'
|
12
|
+
rescue
|
13
|
+
false
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.statically_defined_version(name, args)
|
17
|
+
args[:version] || args[:checksum]
|
18
|
+
end
|
19
|
+
|
20
|
+
# @!attribute [r] tarball
|
21
|
+
# @api private
|
22
|
+
# @return [R10K::Tarball]
|
23
|
+
attr_reader :tarball
|
24
|
+
|
25
|
+
include R10K::Util::Setopts
|
26
|
+
|
27
|
+
def initialize(name, dirname, opts, environment=nil)
|
28
|
+
super
|
29
|
+
setopts(opts, {
|
30
|
+
# Standard option interface
|
31
|
+
:source => :self,
|
32
|
+
:version => :checksum,
|
33
|
+
:type => ::R10K::Util::Setopts::Ignore,
|
34
|
+
:overrides => :self,
|
35
|
+
|
36
|
+
# Type-specific options
|
37
|
+
:checksum => :self,
|
38
|
+
})
|
39
|
+
|
40
|
+
@tarball = R10K::Tarball.new(name, @source, checksum: @checksum)
|
41
|
+
end
|
42
|
+
|
43
|
+
# Return the status of the currently installed module.
|
44
|
+
#
|
45
|
+
# @return [Symbol]
|
46
|
+
def status
|
47
|
+
if not path.exist?
|
48
|
+
:absent
|
49
|
+
elsif not (tarball.cache_valid? && tarball.insync?(path.to_s))
|
50
|
+
:mismatched
|
51
|
+
else
|
52
|
+
:insync
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# Synchronize this module with the indicated state.
|
57
|
+
# @param [Hash] opts Deprecated
|
58
|
+
# @return [Boolean] true if the module was updated, false otherwise
|
59
|
+
def sync(opts={})
|
60
|
+
tarball.get unless tarball.cache_valid?
|
61
|
+
if should_sync?
|
62
|
+
case status
|
63
|
+
when :absent
|
64
|
+
tarball.unpack(path.to_s)
|
65
|
+
when :mismatched
|
66
|
+
path.rmtree
|
67
|
+
tarball.unpack(path.to_s)
|
68
|
+
end
|
69
|
+
maybe_delete_spec_dir
|
70
|
+
true
|
71
|
+
else
|
72
|
+
false
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
# Return the desired version of this module
|
77
|
+
def version
|
78
|
+
@checksum || '(present)'
|
79
|
+
end
|
80
|
+
|
81
|
+
# Return the properties of the module
|
82
|
+
#
|
83
|
+
# @return [Hash]
|
84
|
+
# @abstract
|
85
|
+
def properties
|
86
|
+
{
|
87
|
+
:expected => version,
|
88
|
+
:actual => ((state = status) == :insync) ? version : state,
|
89
|
+
:type => :tarball,
|
90
|
+
}
|
91
|
+
end
|
92
|
+
|
93
|
+
# Tarball caches are files, not directories. An important purpose of this
|
94
|
+
# method is to indicate where the cache "path" is, for locking/parallelism,
|
95
|
+
# so for the Tarball module type, the relevant path location is returned.
|
96
|
+
#
|
97
|
+
# @return [String] The path this module will cache its tarball source to
|
98
|
+
def cachedir
|
99
|
+
tarball.cache_path
|
100
|
+
end
|
101
|
+
end
|
data/lib/r10k/module.rb
CHANGED
@@ -16,7 +16,8 @@ module R10K
|
|
16
16
|
|
17
17
|
attr_accessor :default_branch_override, :environment
|
18
18
|
attr_reader :modules, :moduledir, :puppetfile_path,
|
19
|
-
:managed_directories, :desired_contents, :purge_exclusions
|
19
|
+
:managed_directories, :desired_contents, :purge_exclusions,
|
20
|
+
:environment_name
|
20
21
|
|
21
22
|
# @param basedir [String] The path that contains the moduledir &
|
22
23
|
# Puppetfile by default. May be an environment, project, or
|
@@ -40,6 +41,7 @@ module R10K
|
|
40
41
|
@puppetfile_path = resolve_path(@basedir, puppetfile)
|
41
42
|
@overrides = overrides
|
42
43
|
@environment = environment
|
44
|
+
@environment_name = @environment&.name
|
43
45
|
@default_branch_override = @overrides.dig(:environments, :default_branch_override)
|
44
46
|
@allow_puppetfile_forge = @overrides.dig(:forge, :allow_puppetfile_override)
|
45
47
|
|
@@ -165,6 +167,13 @@ module R10K
|
|
165
167
|
@modules << mod
|
166
168
|
end
|
167
169
|
|
170
|
+
# @deprecated
|
171
|
+
# @return [String] The base directory that contains the Puppetfile
|
172
|
+
def basedir
|
173
|
+
logger.warn _('"basedir" is deprecated. Please use "environment_name" instead. "basedir" will be removed in a future version.')
|
174
|
+
@basedir
|
175
|
+
end
|
176
|
+
|
168
177
|
private
|
169
178
|
|
170
179
|
def empty_load_output
|
data/lib/r10k/source/git.rb
CHANGED
@@ -100,26 +100,26 @@ class R10K::Source::Git < R10K::Source::Base
|
|
100
100
|
|
101
101
|
def generate_environments
|
102
102
|
envs = []
|
103
|
-
|
104
|
-
if
|
105
|
-
envs << R10K::Environment::Git.new(
|
103
|
+
environment_names.each do |en|
|
104
|
+
if en.valid?
|
105
|
+
envs << R10K::Environment::Git.new(en.name,
|
106
106
|
@basedir,
|
107
|
-
|
107
|
+
en.dirname,
|
108
108
|
{remote: remote,
|
109
|
-
ref:
|
109
|
+
ref: en.original_name,
|
110
110
|
puppetfile_name: puppetfile_name,
|
111
111
|
overrides: @options[:overrides]})
|
112
|
-
elsif
|
113
|
-
logger.warn _("Environment %{env_name} contained non-word characters, correcting name to %{corrected_env_name}") % {env_name:
|
114
|
-
envs << R10K::Environment::Git.new(
|
112
|
+
elsif en.correct?
|
113
|
+
logger.warn _("Environment %{env_name} contained non-word characters, correcting name to %{corrected_env_name}") % {env_name: en.name.inspect, corrected_env_name: en.dirname}
|
114
|
+
envs << R10K::Environment::Git.new(en.name,
|
115
115
|
@basedir,
|
116
|
-
|
116
|
+
en.dirname,
|
117
117
|
{remote: remote,
|
118
|
-
ref:
|
118
|
+
ref: en.original_name,
|
119
119
|
puppetfile_name: puppetfile_name,
|
120
120
|
overrides: @options[:overrides]})
|
121
|
-
elsif
|
122
|
-
logger.error _("Environment %{env_name} contained non-word characters, ignoring it.") % {env_name:
|
121
|
+
elsif en.validate?
|
122
|
+
logger.error _("Environment %{env_name} contained non-word characters, ignoring it.") % {env_name: en.name.inspect}
|
123
123
|
end
|
124
124
|
end
|
125
125
|
|
@@ -157,22 +157,22 @@ class R10K::Source::Git < R10K::Source::Base
|
|
157
157
|
|
158
158
|
private
|
159
159
|
|
160
|
-
def
|
160
|
+
def environment_names
|
161
161
|
opts = {prefix: @prefix,
|
162
162
|
invalid: @invalid_branches,
|
163
163
|
source: @name,
|
164
164
|
strip_component: @strip_component}
|
165
|
-
|
165
|
+
branch_names = @cache.branches
|
166
166
|
if @ignore_branch_prefixes && !@ignore_branch_prefixes.empty?
|
167
|
-
|
167
|
+
branch_names = filter_branches_by_regexp(branch_names, @ignore_branch_prefixes)
|
168
168
|
end
|
169
169
|
|
170
170
|
if @filter_command && !@filter_command.empty?
|
171
|
-
|
171
|
+
branch_names = filter_branches_by_command(branch_names, @filter_command)
|
172
172
|
end
|
173
173
|
|
174
|
-
|
175
|
-
R10K::Environment::Name.new(
|
174
|
+
branch_names.map do |branch_name|
|
175
|
+
R10K::Environment::Name.new(branch_name, opts)
|
176
176
|
end
|
177
177
|
end
|
178
178
|
end
|