r10k 3.16.0 → 4.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/docker.yml +1 -1
  3. data/.github/workflows/rspec_tests.yml +6 -8
  4. data/CHANGELOG.mkd +15 -0
  5. data/Gemfile +1 -1
  6. data/README.mkd +4 -4
  7. data/doc/common-patterns.mkd +1 -2
  8. data/doc/dynamic-environments/configuration.mkd +13 -1
  9. data/doc/puppetfile.mkd +9 -3
  10. data/integration/tests/basic_functionality/negative/negative_bad_proxy.rb +1 -1
  11. data/integration/tests/basic_functionality/proxy_specified_in_configuration.rb +1 -1
  12. data/integration/tests/basic_functionality/proxy_with_puppetfile.rb +1 -1
  13. data/integration/tests/basic_functionality/rugged_git_provider_with_ssh.rb +3 -3
  14. data/integration/tests/basic_functionality/rugged_git_provider_without_ssh.rb +3 -3
  15. data/integration/tests/git_source/git_source_git.rb +1 -1
  16. data/integration/tests/purging/{does_not_purge_files_on_white_list.rb → does_not_purge_files_on_allowlist.rb} +2 -2
  17. data/integration/tests/user_scenario/basic_workflow/negative/neg_disk_full.rb +1 -1
  18. data/integration/tests/user_scenario/basic_workflow/single_env_10000_files.rb +1 -1
  19. data/integration/tests/user_scenario/basic_workflow/single_env_large_files.rb +1 -1
  20. data/lib/r10k/action/deploy/environment.rb +2 -19
  21. data/lib/r10k/action/deploy/module.rb +1 -0
  22. data/lib/r10k/action/puppetfile/check.rb +7 -0
  23. data/lib/r10k/action/puppetfile/install.rb +1 -0
  24. data/lib/r10k/cli/deploy.rb +15 -1
  25. data/lib/r10k/environment.rb +0 -1
  26. data/lib/r10k/git/rugged/working_repository.rb +1 -1
  27. data/lib/r10k/git/shellgit/working_repository.rb +2 -2
  28. data/lib/r10k/git/stateful_repository.rb +2 -2
  29. data/lib/r10k/module/base.rb +3 -3
  30. data/lib/r10k/module/git.rb +13 -4
  31. data/lib/r10k/module_loader/puppetfile.rb +0 -7
  32. data/lib/r10k/settings.rb +6 -7
  33. data/lib/r10k/version.rb +1 -1
  34. data/locales/r10k.pot +19 -27
  35. data/r10k.gemspec +3 -5
  36. metadata +10 -51
  37. data/lib/r10k/environment/bare.rb +0 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 13267460bb0dfdd1adb733c146be3b61db8505fdf33f35eab7f6ab4e719b9643
4
- data.tar.gz: 2fffbce0bc5b07fe8dfe3809c4e7d57ff0c3acafcaa7ad8fdec74bcf03634744
3
+ metadata.gz: 05d094f24e1da891308bda6d4589351f1c2e1ba16b1efd8c97c5611414df0ee8
4
+ data.tar.gz: eaa7e2f7843cbb445a4619fdd30c923a289838a5884c07a19c4da4f2f5912293
5
5
  SHA512:
6
- metadata.gz: 36d4032b4fce66c180bbe1ae4ccf2cc323aa7236337e869b8bcb23fe557202948a91c8a8a4dcd40fd7cb8c67002ca4b2a01c1dd5d742a41f0470b5574489dd7f
7
- data.tar.gz: 297399b426133749fec9b4b2e89c5bde44c9c507af47ed52c083e890eae5880edd7619ba324c031342f7ecc0f31b5052a2ed8f00ee1b497550953f0910e0cec4
6
+ metadata.gz: afa0f4daefb75c0b8c954b27b94a53f634616d7339e18d55f96ad19b26b3e486feee0b8bf41ee2801b516451412b0d5ea8d7a81444adb03909b364b243cca121
7
+ data.tar.gz: b49551e056b22522ffc8c7778559059830aec6278cec7b37e7f4fc990be57f547a2922306e79a3b24f9bf5d8b887d8cb6c75bafcd357bb632a04ca6d8683ea14
@@ -29,7 +29,7 @@ jobs:
29
29
  - run: gem install bundler
30
30
  - uses: actions/checkout@v3
31
31
  - name: Set up QEMU
32
- uses: docker/setup-qemu-action@v2
32
+ uses: docker/setup-qemu-action@v3
33
33
  - name: Set up Docker Buildx
34
34
  uses: docker/setup-buildx-action@v2
35
35
  - name: Build container
@@ -4,6 +4,7 @@ on:
4
4
  pull_request:
5
5
  branches:
6
6
  - main
7
+ - 3.x
7
8
 
8
9
  jobs:
9
10
  rspec_tests:
@@ -11,15 +12,14 @@ jobs:
11
12
  strategy:
12
13
  matrix:
13
14
  cfg:
14
- - {os: ubuntu-latest, ruby: 2.4}
15
- - {os: ubuntu-latest, ruby: 2.5}
16
15
  - {os: ubuntu-latest, ruby: 2.6}
17
16
  - {os: ubuntu-latest, ruby: 2.7}
17
+ - {os: ubuntu-latest, ruby: 3.1}
18
18
  - {os: ubuntu-latest, ruby: 3.2}
19
- - {os: ubuntu-latest, ruby: jruby-9.2.10.0}
20
- - {os: windows-2019, ruby: 2.5}
21
- - {os: windows-2019, ruby: 2.6}
22
- - {os: windows-2019, ruby: 2.7}
19
+ - {os: ubuntu-latest, ruby: jruby-9.3}
20
+ - {os: ubuntu-latest, ruby: jruby-9.4}
21
+ - {os: windows-latest, ruby: 2.6}
22
+ - {os: windows-latest, ruby: 3.2}
23
23
 
24
24
  runs-on: ${{ matrix.cfg.os }}
25
25
  steps:
@@ -33,8 +33,6 @@ jobs:
33
33
 
34
34
  - name: Install bundler and gems
35
35
  run: |
36
- # Pin bundler to maintain support for Ruby 2.4 and 2.5
37
- gem install bundler -v 2.3.26
38
36
  bundle config set without packaging documentation
39
37
  bundle install --jobs 4 --retry 3
40
38
 
data/CHANGELOG.mkd CHANGED
@@ -4,6 +4,21 @@ CHANGELOG
4
4
  Unreleased
5
5
  ----------
6
6
 
7
+ 4.0.1
8
+ -----
9
+
10
+ - shellgit: Ensure the passed filepath to diff-index is interpreted as filepath [#1367](https://github.com/puppetlabs/r10k/pull/1367)
11
+
12
+ 4.0.0
13
+ -----
14
+ - Drop Ruby 2.3/2.4/2.5 support; use puppet_forge 4.1 or newer [#1336](https://github.com/puppetlabs/r10k/pull/1336)
15
+ - (maint) Add Ruby 3.0 to rspec CI matrix [#1261](https://github.com/puppetlabs/r10k/pull/1261)
16
+ - (RK-368) remove `purge_whitelist` setting [#1277](https://github.com/puppetlabs/r10k/pull/1277)
17
+ - (RK-390) Remove default ref for deploying git modules [#1275](http://github.com/puppetlabs/r10k/pull/1275)
18
+ - (RK-391) Change `exclude_spec` default to true for module spec dir deletion [#1264](https://github.com/puppetlabs/r10k/pull/1261)
19
+ - (RK-383) Remove deprecated `basedir` method from Puppetfile DSL. Users should use `environment_name` instead. [#1254](https://github.com/puppetlabs/r10k/pull/1254)
20
+ - (RK-386) Remove deprecated `bare` environment type. [#1235](https://github.com/puppetlabs/r10k/issues/1235)
21
+
7
22
 
8
23
  3.16.0
9
24
  ------
data/Gemfile CHANGED
@@ -6,7 +6,7 @@ group :extra do
6
6
  end
7
7
 
8
8
  group :development do
9
- gem 'simplecov', '~> 0.17.1'
9
+ gem 'simplecov', '~> 0.22.0'
10
10
  gem 'ruby-prof', :platforms => :ruby
11
11
  end
12
12
 
data/README.mkd CHANGED
@@ -27,14 +27,14 @@ based alternative.
27
27
  Requirements
28
28
  ------------
29
29
 
30
- R10k supports the Ruby versions `>= 2.4.0`. It's tested on Ruby 2.4.0 up to
30
+ R10k supports the Ruby versions `>= 2.6.0`. It's tested on Ruby 2.6.0 up to
31
31
  Ruby 3.1.0 + Jruby.
32
32
 
33
33
  R10k requires additional components, depending on how you plan on managing
34
34
  environments and modules.
35
35
 
36
- - Installing modules from the Puppet Forge requires Puppet 5.0.0+ or later.
37
- Puppet 3 or 4 may work, but is generally not recommended.
36
+ - Installing modules from the Puppet Forge requires Puppet 7.0.0+ or later.
37
+ Puppet 5 and 6 may work, but is generally not recommended.
38
38
  - Git is required for creating environments and modules from Git
39
39
  - SVN is required for creating environments and modules from SVN
40
40
 
@@ -78,7 +78,7 @@ a git repository using Bundler for dependencies:
78
78
 
79
79
  ### Arch Linux
80
80
 
81
- Arch Linux provides a [system package](https://archlinux.org/packages/community/any/r10k/) for r10k.
81
+ Arch Linux provides a [system package](https://archlinux.org/packages/extra/any/r10k/) for r10k.
82
82
  This is built against the [system Ruby](https://archlinux.org/packages/extra/x86_64/ruby/) (which is Ruby 3.0.2 as of 2021-08-03).
83
83
  This package is maintained by [Tim Meusel](https://github.com/bastelfreak).
84
84
 
@@ -12,8 +12,7 @@ Use a [Control Repo](https://docs.puppet.com/pe/latest/cmgmt_control_repo.html)
12
12
  to store your `Puppetfile`.
13
13
 
14
14
  Hiera data should be in the Control repo OR as a separate source in
15
- `r10k.yaml`. Any `hiera.yaml` in the Control repo will be ignored on a per
16
- environment basis, locating it at `/etc/puppetlabs/puppet/hiera.yaml` is prefered.
15
+ `r10k.yaml`.
17
16
 
18
17
  Each puppet module should be contained in its own independent forge module or
19
18
  repository.
@@ -160,6 +160,18 @@ git:
160
160
  See the [git provider documentation](../git/providers.mkd) for more information
161
161
  regarding Git providers.
162
162
 
163
+ #### default_ref
164
+
165
+ r10k is unable to deploy a git module if no `ref` is specified. A `default_ref` can be
166
+ set in the r10k config that will become the ref a module uses if not otherwise specified. This
167
+ is the lowest priority setting for a module's `ref`. Read the [Puppetfile documentation](../puppetfile.mkd#git)
168
+ for higher priority settings to determine a module's ref.
169
+
170
+ ```yaml
171
+ git:
172
+ default_ref: main
173
+ ```
174
+
163
175
  #### proxy
164
176
 
165
177
  The 'proxy' setting allows you to set or override the global proxy setting specifically
@@ -437,7 +449,7 @@ deploy:
437
449
 
438
450
  #### exclude_spec
439
451
 
440
- During module deployment, r10k's default behavior is to deploy the spec directory. Setting
452
+ During module deployment, r10k's default behavior is to delete the spec directory. Setting
441
453
  `exclude_spec` to true will deploy modules without their spec directory. This behavior
442
454
  can be configured for all modules using the `exclude_spec` setting in the r10k config.
443
455
  It can also be passed as a CLI argument for `deploy environment/module`, overriding the
data/doc/puppetfile.mkd CHANGED
@@ -135,6 +135,12 @@ operations when updating the repo, which can speed up install times. When
135
135
  Module versions can also be specified using `:branch` to track a specific
136
136
  branch reference.
137
137
 
138
+ In r10k 3.x the default branch was hardcoded to `master`; in 4.x that was
139
+ removed. A `default_ref` can be specified in the r10k config to
140
+ to mimic that old behavior, but it is recommended to set the ref on a
141
+ per-module basis in the Puppetfile. Read [here](dynamic-environments/configuration.mkd#default_ref) for more info
142
+ on the `default_ref` setting.
143
+
138
144
  #### Examples
139
145
 
140
146
  ```ruby
@@ -327,15 +333,15 @@ on managing internal and external modules in the same directory.
327
333
 
328
334
  ### Per-Item spec dir deployment
329
335
 
330
- During deployment, r10k's default behavior is to deploy the spec directory. The
336
+ During deployment, r10k's default behavior is to delete the spec directory. The
331
337
  Puppetfile can modify this per module, overriding settings from the default
332
- r10k config. The following example sets the module to not deploy the spec
338
+ r10k config. The following example sets the module to deploy the spec
333
339
  directory.
334
340
 
335
341
  ```
336
342
  mod 'apache',
337
343
  :git => 'git@github.com:puppetlabs/puppetlabs-apache.git',
338
- :exclude_spec => true
344
+ :exclude_spec => false
339
345
  ```
340
346
 
341
347
  ### Per-Item Install Path
@@ -6,7 +6,7 @@ test_name 'RK-110 - C88671 - Specify a bad proxy to r10k'
6
6
  confine(:to, :platform => ['el', 'sles'])
7
7
 
8
8
  #Init
9
- master_platform = fact_on(master, 'osfamily')
9
+ master_platform = fact_on(master, 'os.family')
10
10
  r10k_fqp = get_r10k_fqp(master)
11
11
 
12
12
  #Verification
@@ -6,7 +6,7 @@ test_name 'RK-110 - C87652 - Specify the proxy in the r10k.yaml'
6
6
  confine(:to, :platform => ['el', 'sles'])
7
7
 
8
8
  #Init
9
- master_platform = fact_on(master, 'osfamily')
9
+ master_platform = fact_on(master, 'os.family')
10
10
  env_path = on(master, puppet('config print environmentpath')).stdout.rstrip
11
11
  r10k_fqp = get_r10k_fqp(master)
12
12
 
@@ -6,7 +6,7 @@ test_name 'RK-110 - C87651 - Specify a proxy in an environment variable'
6
6
  confine(:to, :platform => ['el', 'sles'])
7
7
 
8
8
  #Init
9
- master_platform = fact_on(master, 'osfamily')
9
+ master_platform = fact_on(master, 'os.family')
10
10
  r10k_fqp = get_r10k_fqp(master)
11
11
 
12
12
  case master_platform
@@ -10,12 +10,12 @@ confine(:to, :platform => ['el', 'ubuntu', 'sles'])
10
10
 
11
11
  if ENV['GIT_PROVIDER'] == 'shellgit'
12
12
  skip_test('Skipping test because removing Git from the system affects other "shellgit" tests.')
13
- elsif fact_on(master, 'osfamily') == 'RedHat' and fact_on(master, "operatingsystemmajrelease").to_i < 6
13
+ elsif fact_on(master, 'os.family') == 'RedHat' and fact_on(master, "os.release.major").to_i < 6
14
14
  skip_test('This version of EL is not supported by this test case!')
15
15
  end
16
16
 
17
17
  #Init
18
- master_platform = fact_on(master, 'osfamily')
18
+ master_platform = fact_on(master, 'os.family')
19
19
  master_certname = on(master, puppet('config', 'print', 'certname')).stdout.rstrip
20
20
  env_path = on(master, puppet('config print environmentpath')).stdout.rstrip
21
21
  r10k_fqp = get_r10k_fqp(master)
@@ -87,7 +87,7 @@ step 'Remove "git" Package from System'
87
87
  if master_platform == 'RedHat'
88
88
  on(master, 'yum remove -y git')
89
89
  elsif master_platform == 'Debian'
90
- if fact_on(master, "operatingsystemmajrelease") == '10.04'
90
+ if fact_on(master, "os.release.major") == '10.04'
91
91
  on(master, 'apt-get remove -y git-core')
92
92
  else
93
93
  on(master, 'apt-get remove -y git')
@@ -8,12 +8,12 @@ confine(:to, :platform => ['el', 'ubuntu', 'sles'])
8
8
 
9
9
  if ENV['GIT_PROVIDER'] == 'shellgit'
10
10
  skip_test('Skipping test because removing Git from the system affects other "shellgit" tests.')
11
- elsif fact_on(master, 'osfamily') == 'RedHat' and fact_on(master, "operatingsystemmajrelease").to_i < 6
11
+ elsif fact_on(master, 'os.family') == 'RedHat' and fact_on(master, "os.release.major").to_i < 6
12
12
  skip_test('This version of EL is not supported by this test case!')
13
13
  end
14
14
 
15
15
  #Init
16
- master_platform = fact_on(master, 'osfamily')
16
+ master_platform = fact_on(master, 'os.family')
17
17
  master_certname = on(master, puppet('config', 'print', 'certname')).stdout.rstrip
18
18
  env_path = on(master, puppet('config print environmentpath')).stdout.rstrip
19
19
  r10k_fqp = get_r10k_fqp(master)
@@ -86,7 +86,7 @@ step 'Remove "git" Package from System'
86
86
  if master_platform == 'RedHat'
87
87
  on(master, 'yum remove -y git')
88
88
  elsif master_platform == 'Debian'
89
- if fact_on(master, "operatingsystemmajrelease") == '10.04'
89
+ if fact_on(master, "os.release.major") == '10.04'
90
90
  on(master, 'apt-get remove -y git-core')
91
91
  else
92
92
  on(master, 'apt-get remove -y git')
@@ -5,7 +5,7 @@ test_name 'CODEMGMT-92 - C59235 - Single Git Source Using "GIT" Transport Protoc
5
5
 
6
6
  confine(:to, :platform => 'el')
7
7
 
8
- if fact_on(master, "operatingsystemmajrelease").to_i < 6
8
+ if fact_on(master, "os.release.major").to_i < 6 || fact_on(master, "os.release.major").to_i > 8
9
9
  skip_test('This version of EL is not supported by this test case!')
10
10
  end
11
11
 
@@ -1,7 +1,7 @@
1
1
  require 'git_utils'
2
2
  require 'r10k_utils'
3
3
  require 'master_manipulator'
4
- test_name 'RK-257 - C98046 - r10k does not purge files on whitelist'
4
+ test_name 'RK-257 - C98046 - r10k does not purge files on allowlist'
5
5
 
6
6
  #Init
7
7
  env_path = on(master, puppet('config print environmentpath')).stdout.rstrip
@@ -39,7 +39,7 @@ sources:
39
39
  remote: "#{git_control_remote}"
40
40
  deploy:
41
41
  purge_levels: ['deployment', 'environment', 'puppetfile']
42
- purge_whitelist: ['**/*.pp']
42
+ purge_allowlist: ['**/*.pp']
43
43
  CONF
44
44
 
45
45
  step 'Update the "r10k" Config'
@@ -2,7 +2,7 @@ require 'git_utils'
2
2
  require 'r10k_utils'
3
3
  test_name 'CODEMGMT-86 - C59265 - Attempt to Deploy Environment to Disk with Insufficient Free Space'
4
4
 
5
- if fact_on(master, 'osfamily') == 'RedHat' and fact_on(master, "operatingsystemmajrelease").to_i < 6
5
+ if fact_on(master, 'os.family') == 'RedHat' and fact_on(master, "os.release.major").to_i < 6
6
6
  skip_test('This version of EL is not supported by this test case!')
7
7
  end
8
8
 
@@ -3,7 +3,7 @@ require 'r10k_utils'
3
3
  require 'master_manipulator'
4
4
  test_name 'CODEMGMT-62 - C59239 - Single Environment with 10,000 Files'
5
5
 
6
- if fact_on(master, 'osfamily') == 'RedHat' and fact_on(master, "operatingsystemmajrelease").to_i < 6
6
+ if fact_on(master, 'os.family') == 'RedHat' and fact_on(master, "os.release.major").to_i < 6
7
7
  skip_test('This version of EL is not supported by this test case!')
8
8
  end
9
9
 
@@ -3,7 +3,7 @@ require 'r10k_utils'
3
3
  require 'master_manipulator'
4
4
  test_name 'CODEMGMT-62 - C59242 - Single Environment with Large Binary Files'
5
5
 
6
- if fact_on(master, 'osfamily') == 'RedHat' and fact_on(master, "operatingsystemmajrelease").to_i < 6
6
+ if fact_on(master, 'os.family') == 'RedHat' and fact_on(master, "os.release.major").to_i < 6
7
7
  skip_test('This version of EL is not supported by this test case!')
8
8
  end
9
9
 
@@ -45,6 +45,7 @@ module R10K
45
45
  incremental: @incremental
46
46
  },
47
47
  modules: {
48
+ default_ref: settings.dig(:git, :default_ref),
48
49
  exclude_spec: settings.dig(:deploy, :exclude_spec),
49
50
  requested_modules: [],
50
51
  deploy_modules: @modules,
@@ -53,8 +54,7 @@ module R10K
53
54
  },
54
55
  purging: {
55
56
  purge_levels: settings.dig(:deploy, :purge_levels) || [],
56
- purge_allowlist: read_purge_allowlist(settings.dig(:deploy, :purge_whitelist) || [],
57
- settings.dig(:deploy, :purge_allowlist) || [])
57
+ purge_allowlist: settings.dig(:deploy, :purge_allowlist) || []
58
58
  },
59
59
  forge: {
60
60
  allow_puppetfile_override: settings.dig(:forge, :allow_puppetfile_override) || false
@@ -83,23 +83,6 @@ module R10K
83
83
 
84
84
  private
85
85
 
86
- def read_purge_allowlist (whitelist, allowlist)
87
- whitelist_has_content = !whitelist.empty?
88
- allowlist_has_content = !allowlist.empty?
89
- case
90
- when whitelist_has_content == false && allowlist_has_content == false
91
- []
92
- when whitelist_has_content && allowlist_has_content
93
- raise R10K::Error.new "Values found for both purge_whitelist and purge_allowlist. Setting " <<
94
- "purge_whitelist is deprecated, please only use purge_allowlist."
95
- when allowlist_has_content
96
- allowlist
97
- else
98
- logger.warn "Setting purge_whitelist is deprecated; please use purge_allowlist instead."
99
- whitelist
100
- end
101
- end
102
-
103
86
  def visit_deployment(deployment)
104
87
  # Ensure that everything can be preloaded. If we cannot preload all
105
88
  # sources then we can't fully enumerate all environments which
@@ -39,6 +39,7 @@ module R10K
39
39
  generate_types: @generate_types
40
40
  },
41
41
  modules: {
42
+ default_ref: settings.dig(:git, :default_ref),
42
43
  exclude_spec: settings.dig(:deploy, :exclude_spec),
43
44
  pool_size: @settings[:pool_size] || 4,
44
45
  requested_modules: @argv.map.to_a,
@@ -9,12 +9,19 @@ module R10K
9
9
 
10
10
  def call
11
11
  options = { basedir: @root }
12
+ options[:overrides] = {}
13
+ options[:overrides][:modules] = { default_ref: @settings.dig(:git, :default_ref) }
12
14
  options[:moduledir] = @moduledir if @moduledir
13
15
  options[:puppetfile] = @puppetfile if @puppetfile
14
16
 
15
17
  loader = R10K::ModuleLoader::Puppetfile.new(**options)
16
18
  begin
17
19
  loader.load!
20
+ loader.modules.each do |mod|
21
+ if mod.instance_of?(R10K::Module::Git)
22
+ mod.validate_ref_defined
23
+ end
24
+ end
18
25
  $stderr.puts _("Syntax OK")
19
26
  true
20
27
  rescue => e
@@ -12,6 +12,7 @@ module R10K
12
12
  def call
13
13
  begin
14
14
  options = { basedir: @root, overrides: { force: @force || false } }
15
+ options[:overrides][:modules] = { default_ref: @settings.dig(:git, :default_ref) }
15
16
  options[:moduledir] = @moduledir if @moduledir
16
17
  options[:puppetfile] = @puppetfile if @puppetfile
17
18
  options[:module_exclude_regex] = @module_exclude_regex if @module_exclude_regex
@@ -10,6 +10,19 @@ require 'cri'
10
10
 
11
11
  module R10K::CLI
12
12
  module Deploy
13
+
14
+ class TransformExcludeSpec
15
+ def call(input)
16
+ # To be backward compatible with the 3.x flag version of this setting,
17
+ # r10k allows this flag to have an optional argument. When no argument
18
+ # is supplied, cri defaults to setting the class to true, so we check
19
+ # for TrueClass here as well as "true".
20
+ return true if input == true || input == 'true'
21
+ return false if input == 'false'
22
+ raise ArgumentError
23
+ end
24
+ end
25
+
13
26
  def self.command
14
27
  @cmd ||= Cri::Command.define do
15
28
  name 'deploy'
@@ -24,7 +37,8 @@ module R10K::CLI
24
37
  option nil, :cachedir, 'Specify a cachedir, overriding the value in config', argument: :required
25
38
  flag nil, :'no-force', 'Prevent the overwriting of local module modifications'
26
39
  flag nil, :'generate-types', 'Run `puppet generate types` after updating an environment'
27
- flag nil, :'exclude-spec', 'Exclude the module\'s spec dir from deployment'
40
+ option nil, :'exclude-spec', 'Exclude the module\'s spec dir for deployment', argument: :optional,
41
+ transform: TransformExcludeSpec.new
28
42
  option nil, :'puppet-path', 'Path to puppet executable', argument: :required do |value, cmd|
29
43
  unless File.executable? value
30
44
  $stderr.puts "The specified puppet executable #{value} is not executable."
@@ -31,7 +31,6 @@ module R10K
31
31
  require 'r10k/environment/base'
32
32
  require 'r10k/environment/with_modules'
33
33
  require 'r10k/environment/plain'
34
- require 'r10k/environment/bare'
35
34
  require 'r10k/environment/git'
36
35
  require 'r10k/environment/svn'
37
36
  require 'r10k/environment/tarball'
@@ -119,7 +119,7 @@ class R10K::Git::Rugged::WorkingRepository < R10K::Git::Rugged::BaseRepository
119
119
  with_repo { |repo| repo.config['remote.origin.url'] }
120
120
  end
121
121
 
122
- def dirty?(exclude_spec=false)
122
+ def dirty?(exclude_spec=true)
123
123
  with_repo do |repo|
124
124
  if exclude_spec
125
125
  diff = repo.diff_workdir('HEAD').select { |d| ! d.delta.old_file[:path].start_with?('spec/') }
@@ -90,7 +90,7 @@ class R10K::Git::ShellGit::WorkingRepository < R10K::Git::ShellGit::BaseReposito
90
90
  end
91
91
 
92
92
  # does the working tree have local modifications to tracked files?
93
- def dirty?(exclude_spec=false)
93
+ def dirty?(exclude_spec=true)
94
94
  result = git(['diff-index', '--exit-code', '--name-only', 'HEAD'], :path => @path.to_s, :raise_on_fail => false)
95
95
 
96
96
  if result.exit_code != 0
@@ -101,7 +101,7 @@ class R10K::Git::ShellGit::WorkingRepository < R10K::Git::ShellGit::BaseReposito
101
101
  logger.debug(_("Found local modifications in %{file_path}" % {file_path: File.join(@path, file)}))
102
102
 
103
103
  # Do this in a block so that the extra subprocess only gets invoked when needed.
104
- logger.debug1 { git(['diff-index', '-p', 'HEAD', file], :path => @path.to_s, :raise_on_fail => false).stdout }
104
+ logger.debug1 { git(['diff-index', '-p', 'HEAD', '--', file], :path => @path.to_s, :raise_on_fail => false).stdout }
105
105
  end
106
106
 
107
107
  return dirty_files.size > 0
@@ -36,7 +36,7 @@ class R10K::Git::StatefulRepository
36
36
  end
37
37
 
38
38
  # Returns true if the sync actually updated the repo, false otherwise
39
- def sync(ref, force=true, exclude_spec=false)
39
+ def sync(ref, force=true, exclude_spec=true)
40
40
  @cache.sync if sync_cache?(ref)
41
41
 
42
42
  sha = @cache.resolve(ref)
@@ -75,7 +75,7 @@ class R10K::Git::StatefulRepository
75
75
  updated
76
76
  end
77
77
 
78
- def status(ref, exclude_spec=false)
78
+ def status(ref, exclude_spec=true)
79
79
  if !@repo.exist?
80
80
  :absent
81
81
  elsif !@cache.exist?
@@ -60,8 +60,8 @@ class R10K::Module::Base
60
60
  @environment = environment
61
61
  @overrides = args.delete(:overrides) || {}
62
62
  @spec_deletable = true
63
- @exclude_spec = false
64
- @exclude_spec = @overrides.dig(:modules, :exclude_spec) if @overrides.dig(:modules, :exclude_spec)
63
+ @exclude_spec = true
64
+ @exclude_spec = @overrides.dig(:modules, :exclude_spec) unless @overrides.dig(:modules, :exclude_spec).nil?
65
65
  if args.has_key?(:exclude_spec)
66
66
  logger.debug2 _("Overriding :exclude_spec setting with per module setting for #{@title}")
67
67
  @exclude_spec = args.delete(:exclude_spec)
@@ -78,7 +78,7 @@ class R10K::Module::Base
78
78
  path.to_s
79
79
  end
80
80
 
81
- # Delete the spec dir if @exclude_spec has been set to true and @spec_deletable is also true
81
+ # Delete the spec dir if @exclude_spec is true and @spec_deletable is also true
82
82
  def maybe_delete_spec_dir
83
83
  if @exclude_spec
84
84
  if @spec_deletable
@@ -63,15 +63,14 @@ class R10K::Module::Git < R10K::Module::Base
63
63
  :commit => :desired_ref,
64
64
  :ref => :desired_ref,
65
65
  :git => :remote,
66
- :default_branch => :default_ref,
66
+ :default_branch => :default_branch,
67
67
  :default_branch_override => :default_override_ref,
68
68
  }, :raise_on_unhandled => false)
69
69
 
70
+ @default_ref = @default_branch.nil? ? @overrides.dig(:modules, :default_ref) : @default_branch
70
71
  force = @overrides[:force]
71
72
  @force = force == false ? false : true
72
73
 
73
- @desired_ref ||= 'master'
74
-
75
74
  if @desired_ref == :control_branch
76
75
  if @environment && @environment.respond_to?(:ref)
77
76
  @desired_ref = @environment.ref
@@ -116,6 +115,14 @@ class R10K::Module::Git < R10K::Module::Base
116
115
  @repo.cache.sanitized_dirname
117
116
  end
118
117
 
118
+ def validate_ref_defined
119
+ if @desired_ref.nil? && @default_ref.nil? && @default_override_ref.nil?
120
+ msg = "No ref defined for module #{@name}. Add a ref to the module definition "
121
+ msg << "or set git:default_ref in the r10k.yaml config to configure a global default ref."
122
+ raise ArgumentError, msg
123
+ end
124
+ end
125
+
119
126
  private
120
127
 
121
128
  def validate_ref(desired, default, default_override)
@@ -147,7 +154,9 @@ class R10K::Module::Git < R10K::Module::Base
147
154
  msg << "or resolve default ref '%{default}'"
148
155
  vars[:default] = default
149
156
  else
150
- msg << "and no default provided"
157
+ msg << "and no default provided. r10k no longer hardcodes 'master' as the default ref."
158
+ msg << "Consider setting a ref per module in the Puppetfile or setting git:default_ref"
159
+ msg << "in your r10k config."
151
160
  end
152
161
 
153
162
  raise ArgumentError, _(msg.join(' ')) % vars
@@ -175,13 +175,6 @@ module R10K
175
175
  @modules << mod
176
176
  end
177
177
 
178
- # @deprecated
179
- # @return [String] The base directory that contains the Puppetfile
180
- def basedir
181
- logger.warn _('"basedir" is deprecated. Please use "environment_name" instead. "basedir" will be removed in a future version.')
182
- @basedir
183
- end
184
-
185
178
  private
186
179
 
187
180
  def empty_load_output
data/lib/r10k/settings.rb CHANGED
@@ -19,6 +19,10 @@ module R10K
19
19
  def self.git_settings
20
20
  R10K::Settings::Collection.new(:git, [
21
21
 
22
+ Definition.new(:default_ref, {
23
+ :desc => "User-defined default ref from which to deploy modules when not otherwise specified; nil unless configured via the r10k.yaml config.",
24
+ :default => nil}),
25
+
22
26
  EnumDefinition.new(:provider, {
23
27
  :desc => "The Git provider to use. Valid values: 'shellgit', 'rugged'",
24
28
  :normalize => lambda { |input| input.to_sym },
@@ -175,11 +179,6 @@ module R10K
175
179
  :default => [],
176
180
  }),
177
181
 
178
- Definition.new(:purge_whitelist, {
179
- :desc => "Deprecated; please use purge_allowlist instead. This setting will be removed in a future version.",
180
- :default => [],
181
- }),
182
-
183
182
  Definition.new(:generate_types, {
184
183
  :desc => "Controls whether to generate puppet types after deploying an environment. Defaults to false.",
185
184
  :default => false,
@@ -207,8 +206,8 @@ module R10K
207
206
  end
208
207
  }),
209
208
  Definition.new(:exclude_spec, {
210
- :desc => "Whether or not to deploy the spec dir of a module. Defaults to false.",
211
- :default => false,
209
+ :desc => "Whether or not to deploy the spec dir of a module. Defaults to true.",
210
+ :default => true,
212
211
  :validate => lambda do |value|
213
212
  unless !!value == value
214
213
  raise ArgumentError, "`exclude_spec` can only be a boolean value, not '#{value}'"
data/lib/r10k/version.rb CHANGED
@@ -2,5 +2,5 @@ module R10K
2
2
  # When updating to a new major (X) or minor (Y) version, include `#major` or
3
3
  # `#minor` (respectively) in your commit message to trigger the appropriate
4
4
  # release. Otherwise, a new patch (Z) version will be released.
5
- VERSION = '3.16.0'
5
+ VERSION = '4.0.1'
6
6
  end
data/locales/r10k.pot CHANGED
@@ -6,11 +6,11 @@
6
6
  #, fuzzy
7
7
  msgid ""
8
8
  msgstr ""
9
- "Project-Id-Version: r10k 3.9.3-289-g2f5deb72\n"
9
+ "Project-Id-Version: r10k 3.9.3-373-g117587fb\n"
10
10
  "\n"
11
11
  "Report-Msgid-Bugs-To: docs@puppetlabs.com\n"
12
- "POT-Creation-Date: 2023-06-27 17:39+0000\n"
13
- "PO-Revision-Date: 2023-06-27 17:39+0000\n"
12
+ "POT-Creation-Date: 2023-07-26 22:34+0000\n"
13
+ "PO-Revision-Date: 2023-07-26 22:34+0000\n"
14
14
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
15
15
  "Language-Team: LANGUAGE <LL@li.org>\n"
16
16
  "Language: \n"
@@ -31,47 +31,47 @@ msgstr ""
31
31
  msgid "Reason: %{write_lock}"
32
32
  msgstr ""
33
33
 
34
- #: ../lib/r10k/action/deploy/environment.rb:116
34
+ #: ../lib/r10k/action/deploy/environment.rb:99
35
35
  msgid "Environment(s) \\'%{environments}\\' cannot be found in any source and will not be deployed."
36
36
  msgstr ""
37
37
 
38
- #: ../lib/r10k/action/deploy/environment.rb:136
38
+ #: ../lib/r10k/action/deploy/environment.rb:119
39
39
  msgid "Executing postrun command."
40
40
  msgstr ""
41
41
 
42
- #: ../lib/r10k/action/deploy/environment.rb:150
42
+ #: ../lib/r10k/action/deploy/environment.rb:133
43
43
  msgid "Environment %{env_dir} does not match environment name filter, skipping"
44
44
  msgstr ""
45
45
 
46
- #: ../lib/r10k/action/deploy/environment.rb:158
46
+ #: ../lib/r10k/action/deploy/environment.rb:141
47
47
  msgid "Deploying environment %{env_path}"
48
48
  msgstr ""
49
49
 
50
- #: ../lib/r10k/action/deploy/environment.rb:161
50
+ #: ../lib/r10k/action/deploy/environment.rb:144
51
51
  msgid "Environment %{env_dir} is now at %{env_signature}"
52
52
  msgstr ""
53
53
 
54
- #: ../lib/r10k/action/deploy/environment.rb:165
54
+ #: ../lib/r10k/action/deploy/environment.rb:148
55
55
  msgid "Environment %{env_dir} is new, updating all modules"
56
56
  msgstr ""
57
57
 
58
- #: ../lib/r10k/action/deploy/module.rb:81
58
+ #: ../lib/r10k/action/deploy/module.rb:82
59
59
  msgid "Running postrun command for environments: %{envs_to_run}."
60
60
  msgstr ""
61
61
 
62
- #: ../lib/r10k/action/deploy/module.rb:91
62
+ #: ../lib/r10k/action/deploy/module.rb:92
63
63
  msgid "No environments were modified, not executing postrun command."
64
64
  msgstr ""
65
65
 
66
- #: ../lib/r10k/action/deploy/module.rb:103
66
+ #: ../lib/r10k/action/deploy/module.rb:104
67
67
  msgid "Only updating modules in environment(s) %{opt_env} skipping environment %{env_path}"
68
68
  msgstr ""
69
69
 
70
- #: ../lib/r10k/action/deploy/module.rb:105
70
+ #: ../lib/r10k/action/deploy/module.rb:106
71
71
  msgid "Updating modules %{modules} in environment %{env_path}"
72
72
  msgstr ""
73
73
 
74
- #: ../lib/r10k/action/puppetfile/check.rb:18
74
+ #: ../lib/r10k/action/puppetfile/check.rb:25
75
75
  msgid "Syntax OK"
76
76
  msgstr ""
77
77
 
@@ -111,10 +111,6 @@ msgstr ""
111
111
  msgid "Unable to load sources; the supplied configuration does not define the 'sources' key"
112
112
  msgstr ""
113
113
 
114
- #: ../lib/r10k/environment/bare.rb:6
115
- msgid "\"bare\" environment type is deprecated; please use \"plain\" instead (environment: %{name})"
116
- msgstr ""
117
-
118
114
  #: ../lib/r10k/environment/base.rb:89 ../lib/r10k/environment/base.rb:105 ../lib/r10k/environment/base.rb:114 ../lib/r10k/source/base.rb:83
119
115
  msgid "%{class} has not implemented method %{method}"
120
116
  msgstr ""
@@ -327,7 +323,7 @@ msgstr ""
327
323
  msgid "Fetching remote '%{remote}' at %{path}"
328
324
  msgstr ""
329
325
 
330
- #: ../lib/r10k/git/rugged/working_repository.rb:129 ../lib/r10k/git/shellgit/working_repository.rb:101
326
+ #: ../lib/r10k/git/rugged/working_repository.rb:131 ../lib/r10k/git/shellgit/working_repository.rb:101
331
327
  msgid "Found local modifications in %{file_path}"
332
328
  msgstr ""
333
329
 
@@ -407,7 +403,7 @@ msgstr ""
407
403
  msgid "The module %{title} does not exist on %{url}."
408
404
  msgstr ""
409
405
 
410
- #: ../lib/r10k/module/git.rb:79
406
+ #: ../lib/r10k/module/git.rb:78
411
407
  msgid "Cannot track control repo branch for content '%{name}' when not part of a git-backed environment, will use default if available."
412
408
  msgstr ""
413
409
 
@@ -443,19 +439,15 @@ msgstr ""
443
439
  msgid "Ignoring Forge declaration in Puppetfile, using value from settings: %{forge}."
444
440
  msgstr ""
445
441
 
446
- #: ../lib/r10k/module_loader/puppetfile.rb:181
447
- msgid "\"basedir\" is deprecated. Please use \"environment_name\" instead. \"basedir\" will be removed in a future version."
448
- msgstr ""
449
-
450
- #: ../lib/r10k/module_loader/puppetfile.rb:200 ../lib/r10k/puppetfile.rb:104
442
+ #: ../lib/r10k/module_loader/puppetfile.rb:193 ../lib/r10k/puppetfile.rb:104
451
443
  msgid "Puppetfile %{path} missing or unreadable"
452
444
  msgstr ""
453
445
 
454
- #: ../lib/r10k/module_loader/puppetfile.rb:242
446
+ #: ../lib/r10k/module_loader/puppetfile.rb:235
455
447
  msgid "Puppetfiles cannot contain duplicate module names."
456
448
  msgstr ""
457
449
 
458
- #: ../lib/r10k/module_loader/puppetfile.rb:244
450
+ #: ../lib/r10k/module_loader/puppetfile.rb:237
459
451
  msgid "Remove the duplicates of the following modules: %{dupes}"
460
452
  msgstr ""
461
453
 
data/r10k.gemspec CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
18
18
  dynamic environments.
19
19
  DESCRIPTION
20
20
 
21
- s.required_ruby_version = '>= 2.3.0'
21
+ s.required_ruby_version = '>= 2.6.0'
22
22
 
23
23
  s.license = 'Apache-2.0'
24
24
 
@@ -28,11 +28,9 @@ Gem::Specification.new do |s|
28
28
  s.add_dependency 'log4r', '1.1.10'
29
29
  s.add_dependency 'multi_json', '~> 1.10'
30
30
 
31
- s.add_dependency 'puppet_forge', ['>= 2.3.0', '< 4.0.0']
31
+ s.add_dependency 'puppet_forge', '>= 4.1', '< 6'
32
32
 
33
- s.add_dependency 'gettext-setup', ['>=0.24', '< 2.0.0']
34
- s.add_dependency 'fast_gettext', ['>= 1.1.0', '< 3.0.0']
35
- s.add_dependency 'gettext', ['>= 3.0.2', '< 4.0.0']
33
+ s.add_dependency 'gettext-setup', '>=0.24', '<2.0'
36
34
 
37
35
  s.add_dependency 'jwt', '>= 2.2.3', '< 2.8.0'
38
36
  s.add_dependency 'minitar', '~> 0.9'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: r10k
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.16.0
4
+ version: 4.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrien Thebo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-26 00:00:00.000000000 Z
11
+ date: 2023-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colored2
@@ -72,20 +72,20 @@ dependencies:
72
72
  requirements:
73
73
  - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: 2.3.0
75
+ version: '4.1'
76
76
  - - "<"
77
77
  - !ruby/object:Gem::Version
78
- version: 4.0.0
78
+ version: '6'
79
79
  type: :runtime
80
80
  prerelease: false
81
81
  version_requirements: !ruby/object:Gem::Requirement
82
82
  requirements:
83
83
  - - ">="
84
84
  - !ruby/object:Gem::Version
85
- version: 2.3.0
85
+ version: '4.1'
86
86
  - - "<"
87
87
  - !ruby/object:Gem::Version
88
- version: 4.0.0
88
+ version: '6'
89
89
  - !ruby/object:Gem::Dependency
90
90
  name: gettext-setup
91
91
  requirement: !ruby/object:Gem::Requirement
@@ -95,7 +95,7 @@ dependencies:
95
95
  version: '0.24'
96
96
  - - "<"
97
97
  - !ruby/object:Gem::Version
98
- version: 2.0.0
98
+ version: '2.0'
99
99
  type: :runtime
100
100
  prerelease: false
101
101
  version_requirements: !ruby/object:Gem::Requirement
@@ -105,47 +105,7 @@ dependencies:
105
105
  version: '0.24'
106
106
  - - "<"
107
107
  - !ruby/object:Gem::Version
108
- version: 2.0.0
109
- - !ruby/object:Gem::Dependency
110
- name: fast_gettext
111
- requirement: !ruby/object:Gem::Requirement
112
- requirements:
113
- - - ">="
114
- - !ruby/object:Gem::Version
115
- version: 1.1.0
116
- - - "<"
117
- - !ruby/object:Gem::Version
118
- version: 3.0.0
119
- type: :runtime
120
- prerelease: false
121
- version_requirements: !ruby/object:Gem::Requirement
122
- requirements:
123
- - - ">="
124
- - !ruby/object:Gem::Version
125
- version: 1.1.0
126
- - - "<"
127
- - !ruby/object:Gem::Version
128
- version: 3.0.0
129
- - !ruby/object:Gem::Dependency
130
- name: gettext
131
- requirement: !ruby/object:Gem::Requirement
132
- requirements:
133
- - - ">="
134
- - !ruby/object:Gem::Version
135
- version: 3.0.2
136
- - - "<"
137
- - !ruby/object:Gem::Version
138
- version: 4.0.0
139
- type: :runtime
140
- prerelease: false
141
- version_requirements: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - ">="
144
- - !ruby/object:Gem::Version
145
- version: 3.0.2
146
- - - "<"
147
- - !ruby/object:Gem::Version
148
- version: 4.0.0
108
+ version: '2.0'
149
109
  - !ruby/object:Gem::Dependency
150
110
  name: jwt
151
111
  requirement: !ruby/object:Gem::Requirement
@@ -312,7 +272,7 @@ files:
312
272
  - integration/tests/i18n/deploy_module_with_unicode_in_file_name.rb
313
273
  - integration/tests/purging/content_not_purged_at_root.rb
314
274
  - integration/tests/purging/default_purging.rb
315
- - integration/tests/purging/does_not_purge_files_on_white_list.rb
275
+ - integration/tests/purging/does_not_purge_files_on_allowlist.rb
316
276
  - integration/tests/user_scenario/basic_workflow/multi_env_1000_branches.rb
317
277
  - integration/tests/user_scenario/basic_workflow/multi_env_custom_forge_git_module.rb
318
278
  - integration/tests/user_scenario/basic_workflow/multi_env_custom_forge_git_module_static.rb
@@ -372,7 +332,6 @@ files:
372
332
  - lib/r10k/deployment.rb
373
333
  - lib/r10k/deployment/config.rb
374
334
  - lib/r10k/environment.rb
375
- - lib/r10k/environment/bare.rb
376
335
  - lib/r10k/environment/base.rb
377
336
  - lib/r10k/environment/git.rb
378
337
  - lib/r10k/environment/name.rb
@@ -480,7 +439,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
480
439
  requirements:
481
440
  - - ">="
482
441
  - !ruby/object:Gem::Version
483
- version: 2.3.0
442
+ version: 2.6.0
484
443
  required_rubygems_version: !ruby/object:Gem::Requirement
485
444
  requirements:
486
445
  - - ">="
@@ -1,13 +0,0 @@
1
- class R10K::Environment::Bare < R10K::Environment::Plain
2
-
3
- R10K::Environment.register(:bare, self)
4
-
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
8
- end
9
-
10
- def signature
11
- 'bare-default'
12
- end
13
- end