r10k 3.6.0 → 3.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4e54158e0a651c799246229971ba62ad36bd40a670ca84e61479aa5280306c8a
4
- data.tar.gz: 153cc105ce9276d79e2501dc99accb398bba8fec423fbf0726a1b183993a2748
3
+ metadata.gz: d8b9e50ee8c5d0887c46aaf294074c57626229cb19218fc08dd87f5ae1812888
4
+ data.tar.gz: 96c59ea0332a86792c6922f354fdf5bed5c9cb31a37b608e09692fbce00cb1bb
5
5
  SHA512:
6
- metadata.gz: 264ea2591c062d460edab02b8edf7a59c9ebc08ebea27ee2b103e43bdf71c936b797094014d66b776573196d4a9e86dfc9f0fd345626f27d7e25c8170ebaa83a
7
- data.tar.gz: 224e40f3f13466ab2ea3296bc3741b10d591ea65c97ba60b3dd81078f70149770c07c46ac1464a44fd59af0d20dbc8bbf1a5e3990e5d7921cc05403772d99640
6
+ metadata.gz: 45e41d47b78d5951e533f6b2dece2f2f127610b6ac6a9d3d95927699eb11369159add33e467198e0b7869442c1803b5e183e02a44c00ccc8eadf43aabf263b8e
7
+ data.tar.gz: 4790f4189c4e15502cfc633d52605e000a9607acc1b59ec2b011d14736eed3dbcb05333e3bb2817d6bad3e08603c8472267f3a19dca0d64c3f1df10c99eb4200
@@ -1,4 +1,4 @@
1
1
  Please add all notable changes to the "Unreleased" section of the CHANGELOG in the format:
2
2
  ```
3
- - (JIRA ticket) Summary of changes. [Issue or PR #](link to issue or PR)
3
+ - Summary of changes. [Issue or PR #](link to issue or PR)
4
4
  ```
@@ -0,0 +1,81 @@
1
+ name: Rspec tests
2
+
3
+ on:
4
+ pull_request:
5
+ branches:
6
+ - master
7
+
8
+ jobs:
9
+ rspec_tests:
10
+ name: ${{ matrix.cfg.os }}(ruby ${{ matrix.cfg.ruby }})
11
+ strategy:
12
+ matrix:
13
+ cfg:
14
+ - {os: ubuntu-18.04, ruby: 2.4}
15
+ - {os: ubuntu-18.04, ruby: 2.5}
16
+ - {os: ubuntu-18.04, ruby: 2.6}
17
+ - {os: ubuntu-18.04, ruby: 2.7}
18
+ - {os: ubuntu-18.04, ruby: jruby-9.2.9.0}
19
+ - {os: windows-2016, ruby: 2.5}
20
+ - {os: windows-2016, ruby: 2.6}
21
+ - {os: windows-2016, ruby: 2.7}
22
+
23
+ runs-on: ${{ matrix.cfg.os }}
24
+ steps:
25
+ - name: Checkout current PR
26
+ uses: actions/checkout@v2
27
+
28
+ - name: Install ruby version ${{ matrix.cfg.ruby }}
29
+ uses: ruby/setup-ruby@v1
30
+ with:
31
+ ruby-version: ${{ matrix.cfg.ruby }}
32
+
33
+ - name: Install bundler and gems
34
+ run: |
35
+ gem install bundler
36
+ bundle config set without packaging documentation
37
+ bundle install --jobs 4 --retry 3
38
+
39
+ - name: Run tests on Windows
40
+ if: runner.os == 'Windows'
41
+ run: |
42
+ # https://github.com/ruby/ruby/pull/2791/files#diff-ff5ff976e81bebd977f0834e60416abbR97-R100
43
+ # Actions uses UTF8, causes test failures, similar to normal OS setup
44
+ $PSDefaultParameterValues['*:Encoding'] = 'utf8'
45
+ [Console]::OutputEncoding = [System.Text.Encoding]::GetEncoding("IBM437")
46
+ [Console]::InputEncoding = [System.Text.Encoding]::GetEncoding("IBM437")
47
+ $Env:LOG_SPEC_ORDER = 'true'
48
+
49
+ # debug information
50
+ chcp
51
+ Get-WinSystemLocale
52
+ Get-ChildItem Env: | % { Write-Output "$($_.Key): $($_.Value)" }
53
+ # list current OpenSSL install
54
+ gem list openssl
55
+ ruby -ropenssl -e 'puts \"OpenSSL Version - #{OpenSSL::OPENSSL_VERSION}\"; puts \"OpenSSL Library Version - #{OpenSSL::OPENSSL_LIBRARY_VERSION}\"'
56
+ Get-Content Gemfile.lock
57
+ ruby -v
58
+ gem --version
59
+ bundle --version
60
+
61
+ # Run tests
62
+ bundle exec rspec --color --format documentation spec/unit
63
+
64
+ - name: Run tests on Linux
65
+ if: runner.os == 'Linux'
66
+ run: |
67
+ # debug information
68
+ cat Gemfile.lock
69
+ ruby -v
70
+ gem --version
71
+ bundle --version
72
+
73
+ if [[ ${{ matrix.cfg.ruby }} =~ "jruby" ]]; then
74
+ export _JAVA_OPTIONS='-Xmx1024m -Xms512m'
75
+
76
+ # workaround for PUP-10683
77
+ sudo apt remove rpm
78
+ fi
79
+
80
+ # Run tests
81
+ bundle exec rspec --color --format documentation spec/unit
@@ -4,6 +4,13 @@ CHANGELOG
4
4
  Unreleased
5
5
  ----------
6
6
 
7
+ 3.7.0
8
+ -----
9
+
10
+ - Use %LOCALAPPDATA% for Windows cachedir [#1049](https://github.com/puppetlabs/r10k/issues/1049)
11
+ - Add support for defining custom puppet.conf when generating types [#993](https://github.com/puppetlabs/r10k/pull/993)
12
+ - Update test cases to account for error message changes in Puppet 7
13
+
7
14
  3.6.0
8
15
  -----
9
16
 
data/README.mkd CHANGED
@@ -17,8 +17,8 @@ implementation of Puppet [environments][workflow].
17
17
  Requirements
18
18
  ------------
19
19
 
20
- R10k supports the Ruby versions `>= 2.3.0`. It's tested on Ruby 2.3.0 up to
21
- Ruby 2.6.0 + Jruby.
20
+ R10k supports the Ruby versions `>= 2.4.0`. It's tested on Ruby 2.4.0 up to
21
+ Ruby 2.7.0 + Jruby.
22
22
 
23
23
  R10k requires additional components, depending on how you plan on managing
24
24
  environments and modules.
@@ -327,6 +327,15 @@ deploy:
327
327
  puppet_path: '/usr/local/bin/puppet'
328
328
  ```
329
329
 
330
+ #### puppet\_conf
331
+
332
+ The path to the puppet.conf file used for generating types. Defaults to `/etc/puppetlabs/puppet/puppet.conf`.
333
+
334
+ ```yaml
335
+ deploy:
336
+ puppet_conf: '/opt/puppet/conf/puppet.conf'
337
+ ```
338
+
330
339
  Source options
331
340
  --------------
332
341
 
@@ -24,7 +24,7 @@ stage_env_notify_message = 'This is a different message'
24
24
  stage_env_notify_message_regex = /#{stage_env_notify_message}/
25
25
 
26
26
  #Verification for "test" Environment
27
- test_env_error_message_regex = /Error:.*Could not find environment 'test'/
27
+ test_env_error_message_regex = /Error:.*Could not.*environment '?test'?/
28
28
 
29
29
  #Verification for "temp" Environment
30
30
  test_env_notify_message_regex = /I am in the temp environment/
@@ -15,7 +15,7 @@ initial_env_names = ['production', 'stage']
15
15
 
16
16
  #Verification
17
17
  notify_message_regex = /I am in the production environment/
18
- stage_env_error_message_regex = /Error:.*Could not find environment 'stage'/
18
+ stage_env_error_message_regex = /Error:.*Could not.*environment '?stage'?/
19
19
 
20
20
  #Manifest
21
21
  site_pp_path = File.join(git_environments_path, 'manifests', 'site.pp')
@@ -22,7 +22,7 @@ site_pp = create_site_pp(master_certname, ' include helloworld')
22
22
  notify_message_prod_env_regex = /I am in the production environment/
23
23
  notify_message_test_env_regex = /I am in the test environment/
24
24
  removal_message_test_env_regex = /Removing unmanaged path.*test/
25
- error_message_regex = /Could not retrieve catalog from remote server/
25
+ error_message_regex = /Could not retrieve (catalog from remote server|information from environment test)/
26
26
 
27
27
  #Teardown
28
28
  teardown do
@@ -188,6 +188,7 @@ module R10K
188
188
  'no-force': :self,
189
189
  'generate-types': :self,
190
190
  'puppet-path': :self,
191
+ 'puppet-conf': :self,
191
192
  'default-branch-override': :self)
192
193
  end
193
194
  end
@@ -76,7 +76,8 @@ module R10K
76
76
  cachedir: :self,
77
77
  'no-force': :self,
78
78
  'generate-types': :self,
79
- 'puppet-path': :self)
79
+ 'puppet-path': :self,
80
+ 'puppet-conf': :self)
80
81
  end
81
82
  end
82
83
  end
@@ -46,6 +46,7 @@ module R10K
46
46
  overrides[:cachedir] = @opts[:cachedir] if @opts.key?(:cachedir)
47
47
  overrides[:deploy] = {} if @opts.key?(:'puppet-path') || @opts.key?(:'generate-types')
48
48
  overrides[:deploy][:puppet_path] = @opts[:'puppet-path'] if @opts.key?(:'puppet-path')
49
+ overrides[:deploy][:puppet_conf] = @opts[:'puppet-conf'] unless @opts[:'puppet-conf'].nil?
49
50
  overrides[:deploy][:generate_types] = @opts[:'generate-types'] if @opts.key?(:'generate-types')
50
51
 
51
52
  with_overrides = config_settings.merge(overrides) do |key, oldval, newval|
@@ -31,6 +31,7 @@ module R10K::CLI
31
31
  exit 1
32
32
  end
33
33
  end
34
+ option nil, :'puppet-conf', 'Path to puppet.conf', argument: :required
34
35
 
35
36
  run do |opts, args, cmd|
36
37
  puts cmd.help(:verbose => opts[:verbose])
@@ -137,7 +137,7 @@ class R10K::Environment::Base
137
137
  end
138
138
 
139
139
  def generate_types!
140
- argv = [R10K::Settings.puppet_path, 'generate', 'types', '--environment', dirname, '--environmentpath', basedir]
140
+ argv = [R10K::Settings.puppet_path, 'generate', 'types', '--environment', dirname, '--environmentpath', basedir, '--config', R10K::Settings.puppet_conf]
141
141
  subproc = R10K::Util::Subprocess.new(argv)
142
142
  subproc.raise_on_fail = true
143
143
  subproc.logger = logger
@@ -16,7 +16,17 @@ class R10K::Git::Cache
16
16
 
17
17
  include R10K::Settings::Mixin
18
18
 
19
- def_setting_attr :cache_root, File.expand_path(ENV['HOME'] ? '~/.r10k/git': '/root/.r10k/git')
19
+ #@api private
20
+ def self.determine_cache_root
21
+ if R10K::Util::Platform.windows?
22
+ File.join(ENV['LOCALAPPDATA'], 'r10k', 'git')
23
+ else
24
+ File.expand_path(ENV['HOME'] ? '~/.r10k/git': '/root/.r10k/git')
25
+ end
26
+ end
27
+ private_class_method :determine_cache_root
28
+
29
+ def_setting_attr :cache_root, determine_cache_root
20
30
 
21
31
  @instance_cache = R10K::InstanceCache.new(self)
22
32
 
@@ -44,6 +44,7 @@ module R10K
44
44
  class DeployInitializer < BaseInitializer
45
45
  def call
46
46
  with_setting(:puppet_path) { |value| R10K::Settings.puppet_path = value }
47
+ with_setting(:puppet_conf) { |value| R10K::Settings.puppet_conf = value }
47
48
  end
48
49
  end
49
50
 
@@ -12,6 +12,8 @@ module R10K
12
12
  class << self
13
13
  # Path to puppet executable
14
14
  attr_accessor :puppet_path
15
+ # Path to puppet.conf
16
+ attr_accessor :puppet_conf
15
17
  end
16
18
 
17
19
  def self.git_settings
@@ -131,6 +133,15 @@ module R10K
131
133
  end
132
134
  end
133
135
  }),
136
+ Definition.new(:puppet_conf, {
137
+ :desc => "Path to puppet.conf. Defaults to /etc/puppetlabs/puppet/puppet.conf.",
138
+ :default => '/etc/puppetlabs/puppet/puppet.conf',
139
+ :validate => lambda do |value|
140
+ unless File.readable? value
141
+ raise ArgumentError, "The specified puppet.conf #{value} is not readable"
142
+ end
143
+ end
144
+ }),
134
145
  ])
135
146
  end
136
147
 
@@ -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.6.0'
5
+ VERSION = '3.7.0'
6
6
  end
@@ -32,23 +32,29 @@ shared_examples_for "a subprocess runner" do |fixture_root|
32
32
  end
33
33
  end
34
34
 
35
- describe "running 'ls' with a different working directory" do
35
+ describe "running 'ls' or 'dir' with a different working directory" do
36
36
  subject do
37
- described_class.new(%w[ls]).tap do |o|
38
- o.cwd = fixture_root
37
+ if R10K::Util::Platform.windows?
38
+ described_class.new(%w[cmd /c dir]).tap do |o|
39
+ o.cwd = fixture_root
40
+ end
41
+ else
42
+ described_class.new(%w[ls]).tap do |o|
43
+ o.cwd = fixture_root
44
+ end
39
45
  end
40
46
  end
41
47
 
42
48
  it "returns the contents of the given working directory" do
43
49
  result = subject.run
44
- expect(result.stdout).to eq 'no-execute.sh'
50
+ expect(result.stdout).to match('no-execute.sh')
45
51
  end
46
52
  end
47
53
 
48
54
  describe "running 'false'" do
49
55
  subject { described_class.new(%w[false]) }
50
56
 
51
- it "sets the exit code to 1" do
57
+ it "sets the exit code to 1", unless: R10K::Util::Platform.windows? do
52
58
  result = subject.run
53
59
  expect(result.exit_code).to eq 1
54
60
  end
@@ -331,6 +331,15 @@ describe R10K::Action::Deploy::Environment do
331
331
  expect(subject.instance_variable_get(:@puppet_path)).to eq('/nonexistent')
332
332
  end
333
333
  end
334
+
335
+ describe 'with puppet-conf' do
336
+
337
+ subject { described_class.new({ config: '/some/nonexistent/path', 'puppet-conf': '/nonexistent' }, []) }
338
+
339
+ it 'sets puppet_conf' do
340
+ expect(subject.instance_variable_get(:@puppet_conf)).to eq('/nonexistent')
341
+ end
342
+ end
334
343
  end
335
344
 
336
345
  describe "write_environment_info!" do
@@ -26,6 +26,10 @@ describe R10K::Action::Deploy::Module do
26
26
  described_class.new({ 'puppet-path': '/nonexistent' }, [])
27
27
  end
28
28
 
29
+ it 'can accept a puppet-conf option' do
30
+ described_class.new({ 'puppet-conf': '/nonexistent' }, [])
31
+ end
32
+
29
33
  it 'can accept a cachedir option' do
30
34
  described_class.new({ cachedir: '/nonexistent' }, [])
31
35
  end
@@ -128,6 +132,15 @@ describe R10K::Action::Deploy::Module do
128
132
  end
129
133
  end
130
134
 
135
+ describe 'with puppet-conf' do
136
+
137
+ subject { described_class.new({ config: '/some/nonexistent/path', 'puppet-conf': '/nonexistent' }, []) }
138
+
139
+ it 'sets puppet_conf' do
140
+ expect(subject.instance_variable_get(:@puppet_conf)).to eq('/nonexistent')
141
+ end
142
+ end
143
+
131
144
  describe 'with cachedir' do
132
145
 
133
146
  subject { described_class.new({ config: '/some/nonexistent/path', cachedir: '/nonexistent' }, []) }
@@ -3,6 +3,16 @@ require 'r10k/git/cache'
3
3
 
4
4
  describe R10K::Git::Cache do
5
5
 
6
+ describe 'the default cache_root' do
7
+ it 'is in the right location in linux', unless: R10K::Util::Platform.windows? do
8
+ expect(described_class.defaults[:cache_root]).to match(/\.r10k\/git/)
9
+ end
10
+
11
+ it 'is in the right location for windows', if: R10K::Util::Platform.windows? do
12
+ expect(described_class.defaults[:cache_root]).to match(/[^.]r10k\/git/)
13
+ end
14
+ end
15
+
6
16
  let(:subclass) do
7
17
  Class.new(described_class) do
8
18
  def self.bare_repository
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe R10K::Git::Rugged::Credentials, :unless => R10K::Util::Platform.jruby? do
3
+ describe R10K::Git::Rugged::Credentials, :unless => R10K::Util::Platform.jruby? || R10K::Util::Platform.windows? do
4
4
  before(:all) do
5
5
  require 'r10k/git/rugged/credentials'
6
6
  require 'rugged/credentials'
@@ -11,7 +11,7 @@ describe R10K::Git do
11
11
  expect(described_class.default_name).to eq :shellgit
12
12
  end
13
13
 
14
- context 'under c-based rubies', :unless => R10K::Util::Platform.jruby? do
14
+ context 'under c-based rubies with rugged available', :unless => R10K::Util::Platform.jruby? || R10K::Util::Platform.windows? do
15
15
  it 'returns rugged when the git executable is absent and the rugged library is present' do
16
16
  expect(R10K::Features).to receive(:available?).with(:shellgit).and_return false
17
17
  expect(R10K::Features).to receive(:available?).with(:rugged).and_return true
@@ -53,7 +53,7 @@ describe R10K::Git do
53
53
  }.to raise_error(R10K::Error, "Git provider 'shellgit' is not functional.")
54
54
  end
55
55
 
56
- context 'under c-based rubies', :unless => R10K::Util::Platform.jruby? do
56
+ context 'under c-based rubies with rugged available', :unless => R10K::Util::Platform.jruby? || R10K::Util::Platform.windows? do
57
57
  it "sets the current provider if the provider exists and is functional" do
58
58
  expect(R10K::Features).to receive(:available?).with(:rugged).and_return true
59
59
  described_class.provider = :rugged
@@ -71,7 +71,7 @@ describe R10K::Git do
71
71
  end
72
72
 
73
73
  describe "retrieving the current provider" do
74
- context 'under c-based rubies', :unless => R10K::Util::Platform.jruby? do
74
+ context 'under c-based rubies', :unless => R10K::Util::Platform.jruby? || R10K::Util::Platform.windows? do
75
75
  it "uses the default if a provider has not been set" do
76
76
  expect(described_class).to receive(:default_name).and_return :rugged
77
77
  expect(described_class.provider).to eq(R10K::Git::Rugged)
@@ -129,6 +129,18 @@ describe R10K::Settings do
129
129
  expect { subject.evaluate('puppet_path' => '/nonexistent') }.to raise_error(R10K::Settings::Collection::ValidationError)
130
130
  end
131
131
  end
132
+
133
+ describe 'puppet_conf' do
134
+ it 'when file raises no error' do
135
+ allow(File).to receive(:readable?).with('/nonexistent').and_return(true)
136
+ expect { subject.evaluate('puppet_conf' => '/nonexistent') }.not_to raise_error
137
+ end
138
+
139
+ it 'when not file raises error' do
140
+ allow(File).to receive(:readable?).with('/nonexistent').and_return(false)
141
+ expect { subject.evaluate('puppet_conf' => '/nonexistent') }.to raise_error(R10K::Settings::Collection::ValidationError)
142
+ end
143
+ end
132
144
  end
133
145
 
134
146
  describe "global settings" do
@@ -99,7 +99,11 @@ describe R10K::Source::Git do
99
99
 
100
100
  describe "filtering branches with command" do
101
101
  let(:branches) { ['master', 'development', 'production'] }
102
- let(:filter_command) { 'sh -c "[ $R10K_BRANCH != development ]"' }
102
+ if R10K::Util::Platform.windows?
103
+ let(:filter_command) { 'powershell.exe if ($env:R10K_BRANCH.equals(\"development\")) {exit 1} else {exit 0}' }
104
+ else
105
+ let(:filter_command) { 'sh -c "[ $R10K_BRANCH != development ]"' }
106
+ end
103
107
 
104
108
  it "filters branches" do
105
109
  expect(subject.filter_branches_by_command(branches, filter_command)).to eq(['master', 'production'])
@@ -109,7 +113,11 @@ describe R10K::Source::Git do
109
113
  describe "generate_environments respects filter_command setting" do
110
114
  before do
111
115
  allow(subject.cache).to receive(:branches).and_return ['master', 'development', 'production']
112
- subject.instance_variable_set(:@filter_command, '[ $R10K_BRANCH != master ]')
116
+ if R10K::Util::Platform.windows?
117
+ subject.instance_variable_set(:@filter_command, 'powershell.exe if ($env:R10K_BRANCH.equals(\"master\")) {exit 1} else {exit 0}')
118
+ else
119
+ subject.instance_variable_set(:@filter_command, '[ $R10K_BRANCH != master ]')
120
+ end
113
121
  end
114
122
 
115
123
  let(:environments) { subject.generate_environments }
@@ -122,7 +130,11 @@ describe R10K::Source::Git do
122
130
  describe "generate_environments respects filter_command setting and name" do
123
131
  before do
124
132
  allow(subject.cache).to receive(:branches).and_return ['master', 'development', 'production']
125
- subject.instance_variable_set(:@filter_command, '[ $R10K_NAME = mysource ]')
133
+ if R10K::Util::Platform.windows?
134
+ subject.instance_variable_set(:@filter_command, 'powershell.exe if ($env:R10K_NAME.equals(\"mysource\")) {exit 0} else {exit 1}')
135
+ else
136
+ subject.instance_variable_set(:@filter_command, '[ $R10K_NAME = mysource ]')
137
+ end
126
138
  end
127
139
 
128
140
  let(:environments) { subject.generate_environments }
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.6.0
4
+ version: 3.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrien Thebo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-12 00:00:00.000000000 Z
11
+ date: 2020-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colored2
@@ -204,6 +204,7 @@ files:
204
204
  - ".github/pull_request_template.md"
205
205
  - ".github/workflows/docker.yml"
206
206
  - ".github/workflows/release.yml"
207
+ - ".github/workflows/rspec_tests.yml"
207
208
  - ".gitignore"
208
209
  - ".travis.yml"
209
210
  - CHANGELOG.mkd