r10k 3.12.0 → 3.14.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/docker.yml +1 -1
  3. data/.github/workflows/rspec_tests.yml +5 -5
  4. data/.github/workflows/stale.yml +2 -0
  5. data/.gitignore +1 -0
  6. data/.travis.yml +1 -1
  7. data/CHANGELOG.mkd +33 -0
  8. data/doc/dynamic-environments/configuration.mkd +59 -10
  9. data/doc/git/providers.mkd +22 -0
  10. data/doc/puppetfile.mkd +13 -0
  11. data/docker/Makefile +1 -1
  12. data/docker/r10k/Dockerfile +1 -1
  13. data/docker/r10k/release.Dockerfile +1 -1
  14. data/lib/r10k/action/base.rb +1 -1
  15. data/lib/r10k/action/deploy/deploy_helpers.rb +4 -0
  16. data/lib/r10k/action/deploy/display.rb +1 -1
  17. data/lib/r10k/action/deploy/environment.rb +5 -7
  18. data/lib/r10k/action/deploy/module.rb +3 -4
  19. data/lib/r10k/action/runner.rb +6 -0
  20. data/lib/r10k/action/visitor.rb +3 -0
  21. data/lib/r10k/environment/bare.rb +4 -7
  22. data/lib/r10k/environment/name.rb +14 -9
  23. data/lib/r10k/environment/plain.rb +16 -0
  24. data/lib/r10k/environment/tarball.rb +78 -0
  25. data/lib/r10k/environment/with_modules.rb +1 -1
  26. data/lib/r10k/environment.rb +2 -0
  27. data/lib/r10k/errors.rb +5 -0
  28. data/lib/r10k/forge/module_release.rb +2 -1
  29. data/lib/r10k/git/cache.rb +4 -13
  30. data/lib/r10k/git/rugged/bare_repository.rb +1 -1
  31. data/lib/r10k/git/rugged/base_repository.rb +12 -1
  32. data/lib/r10k/git/rugged/cache.rb +8 -0
  33. data/lib/r10k/git/rugged/credentials.rb +1 -1
  34. data/lib/r10k/git/rugged/working_repository.rb +1 -1
  35. data/lib/r10k/git/stateful_repository.rb +2 -0
  36. data/lib/r10k/initializers.rb +20 -0
  37. data/lib/r10k/logging.rb +78 -1
  38. data/lib/r10k/module/base.rb +6 -2
  39. data/lib/r10k/module/forge.rb +10 -10
  40. data/lib/r10k/module/git.rb +1 -3
  41. data/lib/r10k/module/local.rb +6 -2
  42. data/lib/r10k/module/tarball.rb +101 -0
  43. data/lib/r10k/module.rb +1 -0
  44. data/lib/r10k/module_loader/puppetfile/dsl.rb +1 -1
  45. data/lib/r10k/module_loader/puppetfile.rb +17 -2
  46. data/lib/r10k/settings.rb +35 -0
  47. data/lib/r10k/source/git.rb +18 -18
  48. data/lib/r10k/source/yaml.rb +1 -1
  49. data/lib/r10k/tarball.rb +183 -0
  50. data/lib/r10k/util/cacheable.rb +31 -0
  51. data/lib/r10k/util/downloader.rb +134 -0
  52. data/lib/r10k/util/purgeable.rb +6 -2
  53. data/lib/r10k/util/setopts.rb +2 -0
  54. data/lib/r10k/util/subprocess.rb +1 -0
  55. data/lib/r10k/version.rb +1 -1
  56. data/locales/r10k.pot +85 -57
  57. data/r10k.gemspec +2 -2
  58. data/r10k.yaml.example +28 -0
  59. data/spec/fixtures/tarball/tarball.tar.gz +0 -0
  60. data/spec/fixtures/unit/action/r10k_logging.yaml +12 -0
  61. data/spec/fixtures/unit/puppetfile/various-modules/Puppetfile +1 -0
  62. data/spec/fixtures/unit/puppetfile/various-modules/Puppetfile.new +1 -0
  63. data/spec/fixtures/unit/util/purgeable/managed_one/managed_subdir_1/managed_symlink_file +1 -0
  64. data/spec/fixtures/unit/util/purgeable/managed_one/managed_subdir_1/{managed_subdir_2 → subdir_allowlisted_2}/ignored_1 +0 -0
  65. data/spec/fixtures/unit/util/purgeable/managed_one/managed_subdir_1/unmanaged_symlink_dir +1 -0
  66. data/spec/fixtures/unit/util/purgeable/managed_one/managed_symlink_dir +1 -0
  67. data/spec/fixtures/unit/util/purgeable/managed_one/unmanaged_symlink_file +1 -0
  68. data/spec/integration/git/rugged/cache_spec.rb +33 -0
  69. data/spec/integration/util/purageable_spec.rb +41 -0
  70. data/spec/shared-contexts/tarball.rb +32 -0
  71. data/spec/spec_helper.rb +1 -0
  72. data/spec/unit/action/deploy/module_spec.rb +2 -2
  73. data/spec/unit/action/puppetfile/install_spec.rb +2 -2
  74. data/spec/unit/action/runner_spec.rb +52 -1
  75. data/spec/unit/environment/bare_spec.rb +13 -0
  76. data/spec/unit/environment/name_spec.rb +18 -0
  77. data/spec/unit/environment/plain_spec.rb +8 -0
  78. data/spec/unit/environment/tarball_spec.rb +45 -0
  79. data/spec/unit/environment/with_modules_spec.rb +1 -1
  80. data/spec/unit/git/cache_spec.rb +2 -15
  81. data/spec/unit/git/rugged/cache_spec.rb +19 -0
  82. data/spec/unit/module/forge_spec.rb +9 -7
  83. data/spec/unit/module/tarball_spec.rb +70 -0
  84. data/spec/unit/module_loader/puppetfile_spec.rb +21 -3
  85. data/spec/unit/module_spec.rb +14 -7
  86. data/spec/unit/tarball_spec.rb +57 -0
  87. data/spec/unit/util/cacheable_spec.rb +23 -0
  88. data/spec/unit/util/downloader_spec.rb +98 -0
  89. data/spec/unit/util/purgeable_spec.rb +22 -11
  90. metadata +39 -17
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f378346234a9e8a8d92b3acb64735f88ca6b8e8edd60aa33adad9a09d7efd537
4
- data.tar.gz: 1b94403eb2e5cb420939d85b73ec299c709418afabb45705f70b1cfb8606a1f5
3
+ metadata.gz: 51cffcbc4e3340cf55e51da3a60e66e4c4b851d17bdd566d257213e6a4244bdc
4
+ data.tar.gz: 10c04f87924b3c5f4eb84cba797879a0a1ac09a6fbc3e0f598c53788d1d5f9b2
5
5
  SHA512:
6
- metadata.gz: a3eda38f3fc6e79ea62082c7c71bd65383089dce82e87dc6473c1f278f1560239f3e2189df28ef23a9ce8e47f3446cdd63e8794344ee62895914353bdcdec6ee
7
- data.tar.gz: 0dc89955ede8226bf59c7cd4f8e03d9a89688700f5767d0578884fce97643c937f3363dd0d965404fd2b900128b181874dfb129952d64891a3700516239a2af6
6
+ metadata.gz: 8684fc987a031207807de406810ec0529ef00ab8cad321923451a51d5d869ec2aee3cbca411ca37dbe1bbc7ec3c4a0e7daa58df099b0bc1c74005e5c914e0ba2
7
+ data.tar.gz: b8515912cdc5099dfd5c238da01663f7352185bd8454363cdce4bf562138302002fd563fe7783c212071fee2a8855f5abc78dd7d66c1dc006595613b697cd8eb
@@ -3,7 +3,7 @@ name: Docker test and publish
3
3
  on:
4
4
  push:
5
5
  branches:
6
- - master
6
+ - main
7
7
 
8
8
  jobs:
9
9
  build-and-publish:
@@ -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-2016, ruby: 2.5}
20
- - {os: windows-2016, ruby: 2.6}
21
- - {os: windows-2016, ruby: 2.7}
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/unit
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/unit
81
+ bundle exec rspec --color --format documentation spec
@@ -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
@@ -7,3 +7,4 @@ coverage
7
7
  integration/log
8
8
  integration/junit
9
9
  integration/configs
10
+ r10k.log
data/.travis.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  language: ruby
3
3
  bundler_args: "--without system"
4
- script: "bundle exec rspec --color --format documentation spec/unit"
4
+ script: "bundle exec rspec --color --format documentation spec"
5
5
  notifications:
6
6
  email: false
7
7
  sudo: false
data/CHANGELOG.mkd CHANGED
@@ -4,6 +4,39 @@ CHANGELOG
4
4
  Unreleased
5
5
  ----------
6
6
 
7
+ 3.14.1
8
+ ------
9
+
10
+ - (RK-395) Make `exclude_spec` from a Puppetfile the priority override [#1271](https://github.com/puppetlabs/r10k/issues/1271)
11
+ - (RK-394) Fix `force` always resolving to true for `puppetfile install` [#1269](https://github.com/puppetlabs/r10k/issues/1265)
12
+ - (RK-393) Bug fix: not all spec directories are deleted when :exclude_spec is true [#1267](https://github.com/puppetlabs/r10k/pull/1267)
13
+ - 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)
14
+
15
+ 3.14.0
16
+ ------
17
+
18
+ - 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)
19
+ - (CODEMGMT-1294) Resync repos with unresolvable refs [#1239](https://github.com/puppetlabs/r10k/pull/1239)
20
+ - (RK-378) Restore access to the environment name from the Puppetfile [#1241](https://github.com/puppetlabs/r10k/pull/1241)
21
+ - (CODEMGMT-1300) Ensure the remote url in rugged cache directories is current [#1245](https://github.com/puppetlabs/r10k/pull/1245)
22
+ - 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)
23
+ - 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)
24
+
25
+ 3.13.0
26
+ ------
27
+
28
+ - Restore Ruby 3 compatibility [#1234](https://github.com/puppetlabs/r10k/pull/1234)
29
+ - (RK-381) Do not recurse into symlinked dirs when finding files to purge. [#1233](https://github.com/puppetlabs/r10k/pull/1233)
30
+ - Purge should remove unmanaged directories, in addition to unmanaged files. [#1222](https://github.com/puppetlabs/r10k/pull/1222)
31
+ - Rename experimental environment type "bare" to "plain". [#1228](https://github.com/puppetlabs/r10k/pull/1228)
32
+ - Add support for specifying additional logging ouputs. [#1230](https://github.com/puppetlabs/r10k/issues/1230)
33
+
34
+ 3.12.1
35
+ ------
36
+
37
+ - Fix requiring individual R10K::Actions without having already required 'r10k'. [#1223](https://github.com/puppetlabs/r10k/issues/1223)
38
+ - Fix evaluation of Puppetfiles that include local modules. [#1224](https://github.com/puppetlabs/r10k/pull/1224)
39
+
7
40
  3.12.0
8
41
  ------
9
42
 
@@ -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
- This behavior can be configured for all modules using the `exclude_spec` setting in the r10k config.
354
- This config setting can be overridden in each module definition in the Puppetfile
355
- or more globally via the CLI for deploys. The following example sets all modules to
356
- not deploy the spec dir.
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
- ### Bare Environment Type
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 bare environment type allows sources that support environment modules to operate without a control repo being required. Modules can be deployed directly.
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: bare
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: bare
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
+ ```
@@ -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
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
@@ -1,4 +1,4 @@
1
- ARG alpine_version=3.9
1
+ ARG alpine_version=3.14
2
2
  FROM alpine:${alpine_version} as build
3
3
 
4
4
  # hadolint ignore=DL3018
@@ -1,4 +1,4 @@
1
- ARG alpine_version=3.9
1
+ ARG alpine_version=3.14
2
2
  FROM alpine:${alpine_version}
3
3
 
4
4
  ARG vcs_ref
@@ -1,5 +1,5 @@
1
- require 'r10k/util/setopts'
2
1
  require 'r10k/logging'
2
+ require 'r10k/util/setopts'
3
3
 
4
4
  module R10K
5
5
  module Action
@@ -1,8 +1,12 @@
1
+ require 'r10k/logging'
2
+
1
3
  module R10K
2
4
  module Action
3
5
  module Deploy
4
6
  module DeployHelpers
5
7
 
8
+ include R10K::Logging
9
+
6
10
  # Ensure that a config file has been found (and presumably loaded) and exit
7
11
  # with a helpful error if it hasn't.
8
12
  #
@@ -1,6 +1,6 @@
1
- require 'r10k/deployment'
2
1
  require 'r10k/action/base'
3
2
  require 'r10k/action/deploy/deploy_helpers'
3
+ require 'r10k/deployment'
4
4
 
5
5
  module R10K
6
6
  module Action
@@ -1,10 +1,9 @@
1
- require 'r10k/util/setopts'
2
- require 'r10k/util/cleaner'
3
- require 'r10k/deployment'
4
- require 'r10k/logging'
5
- require 'r10k/action/visitor'
6
1
  require 'r10k/action/base'
7
2
  require 'r10k/action/deploy/deploy_helpers'
3
+ require 'r10k/action/visitor'
4
+ require 'r10k/deployment'
5
+ require 'r10k/util/setopts'
6
+
8
7
  require 'json'
9
8
 
10
9
  module R10K
@@ -13,6 +12,7 @@ module R10K
13
12
  class Environment < R10K::Action::Base
14
13
 
15
14
  include R10K::Action::Deploy::DeployHelpers
15
+ include R10K::Action::Visitor
16
16
 
17
17
  # Deprecated
18
18
  attr_reader :force
@@ -81,8 +81,6 @@ module R10K
81
81
  @visit_ok
82
82
  end
83
83
 
84
- include R10K::Action::Visitor
85
-
86
84
  private
87
85
 
88
86
  def read_purge_allowlist (whitelist, allowlist)
@@ -1,7 +1,7 @@
1
- require 'r10k/deployment'
2
- require 'r10k/action/visitor'
3
1
  require 'r10k/action/base'
4
2
  require 'r10k/action/deploy/deploy_helpers'
3
+ require 'r10k/action/visitor'
4
+ require 'r10k/deployment'
5
5
 
6
6
  module R10K
7
7
  module Action
@@ -9,6 +9,7 @@ module R10K
9
9
  class Module < R10K::Action::Base
10
10
 
11
11
  include R10K::Action::Deploy::DeployHelpers
12
+ include R10K::Action::Visitor
12
13
 
13
14
  # Deprecated
14
15
  attr_reader :force
@@ -69,8 +70,6 @@ module R10K
69
70
  @visit_ok
70
71
  end
71
72
 
72
- include R10K::Action::Visitor
73
-
74
73
  private
75
74
 
76
75
  def visit_deployment(deployment)
@@ -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,4 +1,5 @@
1
1
  require 'r10k/errors/formatting'
2
+ require 'r10k/logging'
2
3
 
3
4
  module R10K
4
5
  module Action
@@ -13,6 +14,8 @@ module R10K
13
14
  # @api private
14
15
  module Visitor
15
16
 
17
+ include R10K::Logging
18
+
16
19
  # Dispatch to the type specific visitor method
17
20
  #
18
21
  # @param type [Symbol] The object type to dispatch for
@@ -1,13 +1,10 @@
1
- class R10K::Environment::Bare < R10K::Environment::WithModules
1
+ class R10K::Environment::Bare < R10K::Environment::Plain
2
2
 
3
3
  R10K::Environment.register(:bare, self)
4
4
 
5
- def sync
6
- path.mkpath
7
- end
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 unmodified name of the environment
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(name, opts)
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(name, opts[:strip_component])
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(name, strip_component)
75
- return name unless strip_component
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
- name.gsub(regex, '')
86
- elsif name.start_with?(strip_component)
87
- name[strip_component.size..-1]
90
+ original_name.gsub(regex, '')
91
+ elsif original_name.start_with?(strip_component)
92
+ original_name[strip_component.size..-1]
88
93
  else
89
- name
94
+ original_name
90
95
  end
91
96
  end
92
97
 
@@ -0,0 +1,16 @@
1
+ class R10K::Environment::Plain < R10K::Environment::WithModules
2
+
3
+ R10K::Environment.register(:plain, self)
4
+
5
+ def sync
6
+ path.mkpath
7
+ end
8
+
9
+ def status
10
+ :not_applicable
11
+ end
12
+
13
+ def signature
14
+ 'plain-default'
15
+ end
16
+ end
@@ -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)
@@ -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
@@ -58,4 +58,9 @@ module R10K
58
58
  str.gsub(/^/, prefix)
59
59
  end
60
60
  end
61
+
62
+ # An error class for configuration errors
63
+ #
64
+ class ConfigError < Error
65
+ end
61
66
  end
@@ -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, File.expand_path(ENV['HOME'] ? '~/.r10k/cache': '/root/.r10k/cache')
17
+ def_setting_attr :cache_root, R10K::Util::Cacheable.default_cachedir
17
18
 
18
19
  include R10K::Logging
19
20