r10k 3.12.1 → 3.14.2
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 +5 -5
- data/.github/workflows/stale.yml +2 -0
- data/.gitignore +1 -0
- data/.travis.yml +1 -1
- data/CHANGELOG.mkd +32 -0
- data/doc/dynamic-environments/configuration.mkd +59 -10
- data/doc/dynamic-environments/usage.mkd +4 -0
- data/doc/git/providers.mkd +22 -0
- data/doc/puppetfile.mkd +13 -0
- data/docker/Makefile +1 -1
- data/docker/r10k/Dockerfile +1 -1
- data/docker/r10k/release.Dockerfile +1 -1
- data/lib/r10k/action/runner.rb +6 -0
- data/lib/r10k/environment/bare.rb +4 -7
- data/lib/r10k/environment/name.rb +14 -9
- data/lib/r10k/environment/plain.rb +16 -0
- data/lib/r10k/environment/tarball.rb +78 -0
- data/lib/r10k/environment/with_modules.rb +1 -1
- data/lib/r10k/environment.rb +2 -0
- data/lib/r10k/errors.rb +5 -0
- data/lib/r10k/forge/module_release.rb +2 -1
- data/lib/r10k/git/cache.rb +4 -13
- data/lib/r10k/git/rugged/bare_repository.rb +1 -1
- data/lib/r10k/git/rugged/base_repository.rb +12 -1
- data/lib/r10k/git/rugged/cache.rb +8 -0
- data/lib/r10k/git/rugged/credentials.rb +1 -1
- data/lib/r10k/git/rugged/working_repository.rb +1 -1
- data/lib/r10k/git/stateful_repository.rb +2 -0
- data/lib/r10k/initializers.rb +20 -0
- data/lib/r10k/logging.rb +78 -1
- data/lib/r10k/module/base.rb +6 -2
- data/lib/r10k/module/forge.rb +10 -10
- data/lib/r10k/module/git.rb +1 -3
- data/lib/r10k/module/local.rb +1 -1
- data/lib/r10k/module/tarball.rb +101 -0
- data/lib/r10k/module.rb +1 -0
- data/lib/r10k/module_loader/puppetfile/dsl.rb +1 -1
- data/lib/r10k/module_loader/puppetfile.rb +21 -7
- data/lib/r10k/settings.rb +35 -0
- data/lib/r10k/source/git.rb +18 -18
- data/lib/r10k/source/yaml.rb +1 -1
- 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/util/purgeable.rb +2 -2
- data/lib/r10k/version.rb +1 -1
- data/locales/r10k.pot +85 -57
- data/r10k.gemspec +2 -2
- data/r10k.yaml.example +28 -0
- data/spec/fixtures/tarball/tarball.tar.gz +0 -0
- data/spec/fixtures/unit/action/r10k_logging.yaml +12 -0
- data/spec/fixtures/unit/puppetfile/various-modules/modules/apt/.gitkeep +1 -0
- data/spec/fixtures/unit/puppetfile/various-modules/modules/baz/.gitkeep +1 -0
- data/spec/fixtures/unit/puppetfile/various-modules/modules/buzz/.gitkeep +1 -0
- data/spec/fixtures/unit/puppetfile/various-modules/modules/canary/.gitkeep +1 -0
- data/spec/fixtures/unit/puppetfile/various-modules/modules/fizz/.gitkeep +1 -0
- data/spec/fixtures/unit/puppetfile/various-modules/modules/rpm/.gitkeep +1 -0
- data/spec/fixtures/unit/util/purgeable/managed_one/managed_subdir_1/managed_symlink_file +1 -0
- data/spec/fixtures/unit/util/purgeable/managed_one/managed_subdir_1/{managed_subdir_2 → subdir_allowlisted_2}/ignored_1 +0 -0
- data/spec/fixtures/unit/util/purgeable/managed_one/managed_subdir_1/unmanaged_symlink_dir +1 -0
- data/spec/fixtures/unit/util/purgeable/managed_one/managed_symlink_dir +1 -0
- data/spec/fixtures/unit/util/purgeable/managed_one/unmanaged_symlink_file +1 -0
- data/spec/integration/git/rugged/cache_spec.rb +33 -0
- data/spec/integration/util/purageable_spec.rb +41 -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/action/puppetfile/install_spec.rb +2 -2
- data/spec/unit/action/runner_spec.rb +52 -1
- data/spec/unit/environment/bare_spec.rb +13 -0
- data/spec/unit/environment/name_spec.rb +18 -0
- data/spec/unit/environment/plain_spec.rb +8 -0
- data/spec/unit/environment/tarball_spec.rb +45 -0
- data/spec/unit/environment/with_modules_spec.rb +1 -1
- data/spec/unit/git/cache_spec.rb +2 -15
- data/spec/unit/git/rugged/cache_spec.rb +19 -0
- data/spec/unit/module/forge_spec.rb +9 -7
- data/spec/unit/module/tarball_spec.rb +70 -0
- data/spec/unit/module_loader/puppetfile_spec.rb +21 -5
- data/spec/unit/module_spec.rb +14 -7
- 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
- data/spec/unit/util/purgeable_spec.rb +22 -11
- metadata +45 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d1dda7446b3f3ee95e7833edf157b7ef8632e0c1404bcfdd7c981078dd0ebf0
|
4
|
+
data.tar.gz: fe4af9146645978078592086e1896fb1fc6a26082b86deef9072db6d45cb9d16
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84a6ab98f760f8de79be0ff4a1f6185c23431ccee3c1d481df7a91441130f225cc318744b2fb57e8b8504f27cb86694d6ecdda086e728c703ac8278cc5c8989b
|
7
|
+
data.tar.gz: df7654c91652b281d87f9a8352a361466107c2e98cfabaddbeba1e9b75344523e0151f8353523d990ced52b8994d83a05556d1f9ecb41b8c49cb016d7bc3d166
|
@@ -16,9 +16,9 @@ jobs:
|
|
16
16
|
- {os: ubuntu-18.04, ruby: 2.6}
|
17
17
|
- {os: ubuntu-18.04, ruby: 2.7}
|
18
18
|
- {os: ubuntu-18.04, ruby: jruby-9.2.10.0}
|
19
|
-
- {os: windows-
|
20
|
-
- {os: windows-
|
21
|
-
- {os: windows-
|
19
|
+
- {os: windows-2019, ruby: 2.5}
|
20
|
+
- {os: windows-2019, ruby: 2.6}
|
21
|
+
- {os: windows-2019, ruby: 2.7}
|
22
22
|
|
23
23
|
runs-on: ${{ matrix.cfg.os }}
|
24
24
|
steps:
|
@@ -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/.github/workflows/stale.yml
CHANGED
@@ -15,5 +15,7 @@ jobs:
|
|
15
15
|
days-before-close: 7
|
16
16
|
stale-issue-message: 'This issue has been marked stale because it has had no activity for 60 days. The Puppet Team is actively prioritizing existing bugs and new features, if this issue is still important to you please comment and we will add this to our backlog to complete. Otherwise, it will be closed in 7 days.'
|
17
17
|
stale-issue-label: 'stale'
|
18
|
+
exempt-issue-labels: 'community interest'
|
18
19
|
stale-pr-message: "This PR has been marked stale because it has had no activity for 60 days. If you are still interested in getting this merged, please comment and we'll try to move it forward. Otherwise, it will be closed in 7 days."
|
19
20
|
stale-pr-label: 'stale'
|
21
|
+
exempt-pr-labels: 'community interest'
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.mkd
CHANGED
@@ -4,6 +4,38 @@ CHANGELOG
|
|
4
4
|
Unreleased
|
5
5
|
----------
|
6
6
|
|
7
|
+
3.14.2
|
8
|
+
------
|
9
|
+
|
10
|
+
- (RK-397) Ensure `--incremental` does not skip undeployed modules [#1278](https://github.com/puppetlabs/r10k/pull/1278)
|
11
|
+
|
12
|
+
3.14.1
|
13
|
+
------
|
14
|
+
|
15
|
+
- (RK-395) Make `exclude_spec` from a Puppetfile the priority override [#1271](https://github.com/puppetlabs/r10k/issues/1271)
|
16
|
+
- (RK-394) Fix `force` always resolving to true for `puppetfile install` [#1269](https://github.com/puppetlabs/r10k/issues/1265)
|
17
|
+
- (RK-393) Bug fix: not all spec directories are deleted when :exclude_spec is true [#1267](https://github.com/puppetlabs/r10k/pull/1267)
|
18
|
+
- Refactor internal module creation to always expect a hash, even for Forge modules, which can be specified in the Puppetfile with just a version string. [#1170](https://github.com/puppetlabs/r10k/pull/1170)
|
19
|
+
|
20
|
+
3.14.0
|
21
|
+
------
|
22
|
+
|
23
|
+
- 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)
|
24
|
+
- (CODEMGMT-1294) Resync repos with unresolvable refs [#1239](https://github.com/puppetlabs/r10k/pull/1239)
|
25
|
+
- (RK-378) Restore access to the environment name from the Puppetfile [#1241](https://github.com/puppetlabs/r10k/pull/1241)
|
26
|
+
- (CODEMGMT-1300) Ensure the remote url in rugged cache directories is current [#1245](https://github.com/puppetlabs/r10k/pull/1245)
|
27
|
+
- 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)
|
28
|
+
- 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)
|
29
|
+
|
30
|
+
3.13.0
|
31
|
+
------
|
32
|
+
|
33
|
+
- Restore Ruby 3 compatibility [#1234](https://github.com/puppetlabs/r10k/pull/1234)
|
34
|
+
- (RK-381) Do not recurse into symlinked dirs when finding files to purge. [#1233](https://github.com/puppetlabs/r10k/pull/1233)
|
35
|
+
- Purge should remove unmanaged directories, in addition to unmanaged files. [#1222](https://github.com/puppetlabs/r10k/pull/1222)
|
36
|
+
- Rename experimental environment type "bare" to "plain". [#1228](https://github.com/puppetlabs/r10k/pull/1228)
|
37
|
+
- Add support for specifying additional logging ouputs. [#1230](https://github.com/puppetlabs/r10k/issues/1230)
|
38
|
+
|
7
39
|
3.12.1
|
8
40
|
------
|
9
41
|
|
@@ -128,6 +128,18 @@ git:
|
|
128
128
|
private_key: "/etc/puppetlabs/r10k/ssh/id_rsa"
|
129
129
|
```
|
130
130
|
|
131
|
+
#### oauth_token
|
132
|
+
|
133
|
+
The oauth_token setting is only used by the Rugged git provider.
|
134
|
+
|
135
|
+
The oauth_token option specifies the path to the default access token for Git HTTPS remotes.
|
136
|
+
Public git repositories can be accessed via HTTPS without authentication, but the oauth_token setting may be set if any non-public HTTPS remotes are used.
|
137
|
+
|
138
|
+
```yaml
|
139
|
+
git:
|
140
|
+
oauth_token: "/etc/puppetlabs/r10k/token"
|
141
|
+
```
|
142
|
+
|
131
143
|
#### repositories
|
132
144
|
|
133
145
|
The repositories option allows configuration to be set on a per-remote basis. Each entry is a map of
|
@@ -145,6 +157,18 @@ git:
|
|
145
157
|
private_key: "/etc/puppetlabs/r10k/ssh/id_rsa-protected-repo-deploy-key"
|
146
158
|
```
|
147
159
|
|
160
|
+
##### oauth_token
|
161
|
+
|
162
|
+
A repository specific access token to use for HTTPS connections for the given repository URL. This
|
163
|
+
overrides the global oauth_token setting.
|
164
|
+
|
165
|
+
```yaml
|
166
|
+
git:
|
167
|
+
repositories:
|
168
|
+
- remote: "https://tessier-ashpool.freeside/protected-repo.git"
|
169
|
+
oauth_token: "/etc/puppetlabs/r10k/protected-repo-deploy-token"
|
170
|
+
```
|
171
|
+
|
148
172
|
##### proxy
|
149
173
|
|
150
174
|
The 'proxy' setting allows you to set or override the global proxy setting for a single, specific
|
@@ -349,12 +373,13 @@ deploy:
|
|
349
373
|
|
350
374
|
#### exclude_spec
|
351
375
|
|
352
|
-
During module deployment, r10k's default behavior is to deploy the spec directory.
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
376
|
+
During module deployment, r10k's default behavior is to deploy the spec directory. Setting
|
377
|
+
`exclude_spec` to true will deploy modules without their spec directory. This behavior
|
378
|
+
can be configured for all modules using the `exclude_spec` setting in the r10k config.
|
379
|
+
It can also be passed as a CLI argument for `deploy environment/module`, overriding the
|
380
|
+
r10k config. Setting this per module in a `Puppetfile` will override the default, r10k config,
|
381
|
+
and cli flag for that module. The following example sets all modules to not deploy the spec
|
382
|
+
dir via the r10k config.
|
358
383
|
|
359
384
|
```yaml
|
360
385
|
deploy:
|
@@ -760,16 +785,16 @@ modules:
|
|
760
785
|
version: 62d07f2
|
761
786
|
```
|
762
787
|
|
763
|
-
###
|
788
|
+
### Plain Environment Type
|
764
789
|
|
765
790
|
A "control repository" typically contains a hiera.yaml, an environment.conf, a manifests/site.pp file, and a few other things. However, none of these are strictly necessary for an environment to be functional if modules can be deployed to it.
|
766
791
|
|
767
|
-
The
|
792
|
+
The plain environment type allows sources that support environment modules to operate without a control repo being required. Modules can be deployed directly.
|
768
793
|
|
769
794
|
```yaml
|
770
795
|
---
|
771
796
|
production:
|
772
|
-
type:
|
797
|
+
type: plain
|
773
798
|
modules:
|
774
799
|
puppetlabs-stdlib:
|
775
800
|
type: forge
|
@@ -783,7 +808,7 @@ production:
|
|
783
808
|
version: 62d07f2
|
784
809
|
|
785
810
|
development:
|
786
|
-
type:
|
811
|
+
type: plain
|
787
812
|
modules:
|
788
813
|
puppetlabs-stdlib:
|
789
814
|
type: forge
|
@@ -796,3 +821,27 @@ development:
|
|
796
821
|
source: https://github.com/reidmv/reidmv-xampl.git
|
797
822
|
version: 62d07f2
|
798
823
|
```
|
824
|
+
|
825
|
+
### Tarball Environment Type
|
826
|
+
|
827
|
+
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.
|
828
|
+
|
829
|
+
Tarball environment sources will be unpacked directly into the environment root.
|
830
|
+
|
831
|
+
```yaml
|
832
|
+
---
|
833
|
+
production:
|
834
|
+
type: tarball
|
835
|
+
source: https://repo.example.com/projects/puppet/env-2.36.1.tar.gz
|
836
|
+
version: 99a906c99c2f144de43f2ae500509a7474ed11c583fb623efa8e5b377a3157f0 # sha256digest
|
837
|
+
|
838
|
+
development:
|
839
|
+
type: tarball
|
840
|
+
source: https://repo.example.com/projects/puppet/env-6128ada.tar.gz
|
841
|
+
version: 6128ada158622cd90f8e1360fb7c2c3830a812d1ec26ddf0db7eb16d61b7293f # sha256digest
|
842
|
+
modules:
|
843
|
+
reidmv-xampl:
|
844
|
+
type: git
|
845
|
+
source: https://github.com/reidmv/reidmv-xampl.git
|
846
|
+
version: 62d07f2
|
847
|
+
```
|
@@ -84,6 +84,10 @@ explicit, static version. These are released Forge versions, or Git modules usin
|
|
84
84
|
the `:tag`, or `:commit` keys. Git `:ref`s containing only the full 40 character
|
85
85
|
commit SHA will also be treated as static versions. Then invoke a deploy with:
|
86
86
|
|
87
|
+
There may be issues with deployments apparently successful after an initial errored
|
88
|
+
deployment. If this is happening, try running without the `--incremental` flag
|
89
|
+
to run a full deployment.
|
90
|
+
|
87
91
|
r10k deploy environment production --modules --incremental
|
88
92
|
|
89
93
|
- - -
|
data/doc/git/providers.mkd
CHANGED
@@ -56,6 +56,28 @@ git:
|
|
56
56
|
private_key: '/root/.ssh/private_repo_id'
|
57
57
|
```
|
58
58
|
|
59
|
+
### HTTPS Configuration
|
60
|
+
|
61
|
+
Public HTTPS based Git repositories can be accessed with no additional settings.
|
62
|
+
For repos that do require authentication, the 'oauth_token' option may be provided.
|
63
|
+
|
64
|
+
```yaml
|
65
|
+
git:
|
66
|
+
oauth_token: '/etc/puppetlabs/r10k/token'
|
67
|
+
```
|
68
|
+
|
69
|
+
If you have per repository access tokens you can add them with the repositories list.
|
70
|
+
|
71
|
+
```yaml
|
72
|
+
git:
|
73
|
+
# default access token
|
74
|
+
oauth_token: '/etc/puppetlabs/r10k/token'
|
75
|
+
repositories:
|
76
|
+
- remote: "https://github.com/my_org/private_repo.git"
|
77
|
+
# access token for this repo only
|
78
|
+
oauth_token: '/etc/puppetlabs/r10k/private_repo_token'
|
79
|
+
```
|
80
|
+
|
59
81
|
#### Supported transports with Rugged
|
60
82
|
|
61
83
|
Rugged compiles libgit2 and and the Ruby bindings when the gem is installed. You
|
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
|
data/docker/Makefile
CHANGED
@@ -6,7 +6,7 @@ build_date := $(shell date -u +%FT%T)
|
|
6
6
|
hadolint_available := $(shell hadolint --help > /dev/null 2>&1; echo $$?)
|
7
7
|
hadolint_command := hadolint
|
8
8
|
hadolint_container := ghcr.io/hadolint/hadolint:latest
|
9
|
-
alpine_version := 3.
|
9
|
+
alpine_version := 3.14
|
10
10
|
export BUNDLE_PATH = $(PWD)/.bundle/gems
|
11
11
|
export BUNDLE_BIN = $(PWD)/.bundle/bin
|
12
12
|
export GEMFILE = $(PWD)/Gemfile
|
data/docker/r10k/Dockerfile
CHANGED
data/lib/r10k/action/runner.rb
CHANGED
@@ -51,6 +51,12 @@ module R10K
|
|
51
51
|
overrides[:deploy][:generate_types] = @opts[:'generate-types'] if @opts.key?(:'generate-types')
|
52
52
|
overrides[:deploy][:exclude_spec] = @opts[:'exclude-spec'] if @opts.key?(:'exclude-spec')
|
53
53
|
end
|
54
|
+
# If the log level has been given as an argument, ensure that output happens on stderr
|
55
|
+
if @opts.key?(:loglevel)
|
56
|
+
overrides[:logging] = {}
|
57
|
+
overrides[:logging][:level] = @opts[:loglevel]
|
58
|
+
overrides[:logging][:disable_default_stderr] = false
|
59
|
+
end
|
54
60
|
|
55
61
|
with_overrides = config_settings.merge(overrides) do |key, oldval, newval|
|
56
62
|
newval = oldval.merge(newval) if oldval.is_a? Hash
|
@@ -1,13 +1,10 @@
|
|
1
|
-
class R10K::Environment::Bare < R10K::Environment::
|
1
|
+
class R10K::Environment::Bare < R10K::Environment::Plain
|
2
2
|
|
3
3
|
R10K::Environment.register(:bare, self)
|
4
4
|
|
5
|
-
def
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
def status
|
10
|
-
:not_applicable
|
5
|
+
def initialize(name, basedir, dirname, options = {})
|
6
|
+
logger.warn _('"bare" environment type is deprecated; please use "plain" instead (environment: %{name})') % {name: name}
|
7
|
+
super
|
11
8
|
end
|
12
9
|
|
13
10
|
def signature
|
@@ -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
|
@@ -96,7 +96,7 @@ class R10K::Environment::WithModules < R10K::Environment::Base
|
|
96
96
|
def load_modules(module_hash)
|
97
97
|
module_hash.each do |name, args|
|
98
98
|
if !args.is_a?(Hash)
|
99
|
-
args = { version: args }
|
99
|
+
args = { type: 'forge', version: args }
|
100
100
|
end
|
101
101
|
|
102
102
|
add_module(name, args)
|
data/lib/r10k/environment.rb
CHANGED
@@ -30,8 +30,10 @@ module R10K
|
|
30
30
|
|
31
31
|
require 'r10k/environment/base'
|
32
32
|
require 'r10k/environment/with_modules'
|
33
|
+
require 'r10k/environment/plain'
|
33
34
|
require 'r10k/environment/bare'
|
34
35
|
require 'r10k/environment/git'
|
35
36
|
require 'r10k/environment/svn'
|
37
|
+
require 'r10k/environment/tarball'
|
36
38
|
end
|
37
39
|
end
|
data/lib/r10k/errors.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
|
@@ -64,7 +64,7 @@ class R10K::Git::Rugged::BareRepository < R10K::Git::Rugged::BaseRepository
|
|
64
64
|
results = nil
|
65
65
|
|
66
66
|
R10K::Git.with_proxy(proxy) do
|
67
|
-
results = with_repo { |repo| repo.fetch(remote_name, refspecs, options) }
|
67
|
+
results = with_repo { |repo| repo.fetch(remote_name, refspecs, **options) }
|
68
68
|
end
|
69
69
|
|
70
70
|
report_transfer(results, remote_name)
|
@@ -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
|
@@ -130,7 +130,7 @@ class R10K::Git::Rugged::Credentials
|
|
130
130
|
|
131
131
|
user = nil
|
132
132
|
|
133
|
-
if !username_from_url.nil?
|
133
|
+
if !username_from_url.nil? && !username_from_url.empty?
|
134
134
|
user = username_from_url
|
135
135
|
logger.debug2 _("URL %{url} includes the username %{username}, using that user for authentication.") % {url: url.inspect, username: username_from_url}
|
136
136
|
elsif git_user
|
@@ -93,7 +93,7 @@ class R10K::Git::Rugged::WorkingRepository < R10K::Git::Rugged::BaseRepository
|
|
93
93
|
results = nil
|
94
94
|
|
95
95
|
R10K::Git.with_proxy(proxy) do
|
96
|
-
results = with_repo { |repo| repo.fetch(remote_name, refspecs, options) }
|
96
|
+
results = with_repo { |repo| repo.fetch(remote_name, refspecs, **options) }
|
97
97
|
end
|
98
98
|
|
99
99
|
report_transfer(results, remote)
|