r10k 3.14.0 → 3.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/docker.yml +5 -0
  3. data/.github/workflows/rspec_tests.yml +4 -3
  4. data/.github/workflows/stale.yml +2 -0
  5. data/.gitignore +1 -0
  6. data/CHANGELOG.mkd +22 -0
  7. data/README.mkd +2 -2
  8. data/doc/dynamic-environments/configuration.mkd +44 -16
  9. data/doc/dynamic-environments/usage.mkd +4 -0
  10. data/doc/dynamic-environments/workflow-guide.mkd +3 -3
  11. data/doc/faq.mkd +1 -1
  12. data/doc/git/providers.mkd +22 -0
  13. data/docker/Makefile +18 -11
  14. data/docker/r10k/Dockerfile +1 -1
  15. data/docker/r10k/release.Dockerfile +1 -1
  16. data/integration/tests/git_source/HTTP_proxy_and_git_source.rb +1 -1
  17. data/integration/tests/git_source/git_source_repeated_remote.rb +2 -2
  18. data/integration/tests/purging/content_not_purged_at_root.rb +2 -2
  19. data/integration/tests/user_scenario/basic_workflow/multi_env_custom_forge_git_module.rb +1 -1
  20. data/integration/tests/user_scenario/basic_workflow/multi_env_custom_forge_git_module_static.rb +1 -1
  21. data/integration/tests/user_scenario/basic_workflow/multi_source_custom_forge_git_module.rb +1 -1
  22. data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_git_module.rb +1 -1
  23. data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_git_module_ref.rb +1 -1
  24. data/integration/tests/user_scenario/basic_workflow/single_env_custom_forge_git_module.rb +1 -1
  25. data/integration/tests/user_scenario/basic_workflow/single_env_switch_forge_git_module.rb +1 -1
  26. data/lib/r10k/environment/with_modules.rb +25 -2
  27. data/lib/r10k/git/rugged/bare_repository.rb +1 -1
  28. data/lib/r10k/git/rugged/credentials.rb +1 -1
  29. data/lib/r10k/git/rugged/thin_repository.rb +7 -0
  30. data/lib/r10k/git/rugged/working_repository.rb +8 -4
  31. data/lib/r10k/git/shellgit/thin_repository.rb +4 -0
  32. data/lib/r10k/git/shellgit/working_repository.rb +3 -2
  33. data/lib/r10k/git/stateful_repository.rb +4 -4
  34. data/lib/r10k/module/base.rb +6 -2
  35. data/lib/r10k/module/forge.rb +10 -10
  36. data/lib/r10k/module/git.rb +2 -4
  37. data/lib/r10k/module/local.rb +1 -1
  38. data/lib/r10k/module_loader/puppetfile/dsl.rb +1 -1
  39. data/lib/r10k/module_loader/puppetfile.rb +11 -6
  40. data/lib/r10k/settings/container.rb +1 -0
  41. data/lib/r10k/version.rb +1 -1
  42. data/locales/r10k.pot +23 -15
  43. data/r10k.gemspec +5 -7
  44. data/spec/fixtures/unit/puppetfile/various-modules/modules/apt/.gitkeep +1 -0
  45. data/spec/fixtures/unit/puppetfile/various-modules/modules/baz/.gitkeep +1 -0
  46. data/spec/fixtures/unit/puppetfile/various-modules/modules/buzz/.gitkeep +1 -0
  47. data/spec/fixtures/unit/puppetfile/various-modules/modules/canary/.gitkeep +1 -0
  48. data/spec/fixtures/unit/puppetfile/various-modules/modules/fizz/.gitkeep +1 -0
  49. data/spec/fixtures/unit/puppetfile/various-modules/modules/rpm/.gitkeep +1 -0
  50. data/spec/integration/git/stateful_repository_spec.rb +16 -0
  51. data/spec/unit/action/deploy/module_spec.rb +7 -7
  52. data/spec/unit/environment/git_spec.rb +2 -2
  53. data/spec/unit/environment/with_modules_spec.rb +47 -0
  54. data/spec/unit/git/alternates_spec.rb +28 -28
  55. data/spec/unit/git/cache_spec.rb +1 -1
  56. data/spec/unit/git/rugged/cache_spec.rb +2 -2
  57. data/spec/unit/git/shellgit/cache_spec.rb +1 -1
  58. data/spec/unit/git/stateful_repository_spec.rb +1 -1
  59. data/spec/unit/module/forge_spec.rb +9 -7
  60. data/spec/unit/module/git_spec.rb +5 -5
  61. data/spec/unit/module_loader/puppetfile_spec.rb +18 -5
  62. data/spec/unit/module_spec.rb +14 -7
  63. data/spec/unit/util/cacheable_spec.rb +2 -2
  64. metadata +24 -13
  65. data/.travis.yml +0 -42
@@ -33,21 +33,17 @@ describe R10K::Module::Forge do
33
33
 
34
34
  describe "implementing the Puppetfile spec" do
35
35
  it "should implement 'branan/eight_hundred', '8.0.0'" do
36
- expect(described_class).to be_implement('branan/eight_hundred', { version: '8.0.0' })
36
+ expect(described_class).to be_implement('branan/eight_hundred', { type: 'forge', version: '8.0.0' })
37
37
  end
38
38
 
39
39
  it "should implement 'branan-eight_hundred', '8.0.0'" do
40
- expect(described_class).to be_implement('branan-eight_hundred', { version: '8.0.0' })
41
- end
42
-
43
- it "should fail with an invalid title" do
44
- expect(described_class).to_not be_implement('branan!eight_hundred', { version: '8.0.0' })
40
+ expect(described_class).to be_implement('branan-eight_hundred', { type: 'forge', version: '8.0.0' })
45
41
  end
46
42
  end
47
43
 
48
44
  describe "implementing the standard options interface" do
49
45
  it "should implement {type: forge}" do
50
- expect(described_class).to be_implement('branan-eight_hundred', {type: 'forge', version: '8.0.0', source: 'not implemented'})
46
+ expect(described_class).to be_implement('branan-eight_hundred', { type: 'forge', version: '8.0.0', source: 'not implemented' })
51
47
  end
52
48
  end
53
49
 
@@ -71,6 +67,12 @@ describe R10K::Module::Forge do
71
67
  end
72
68
  end
73
69
 
70
+ describe "invalid attributes" do
71
+ it "errors on invalid versions" do
72
+ expect { described_class.new('branan/eight_hundred', '/moduledir', { version: '_8.0.0_' }) }.to raise_error ArgumentError, /version/
73
+ end
74
+ end
75
+
74
76
  describe "properties" do
75
77
  subject { described_class.new('branan/eight_hundred', fixture_modulepath, { version: '8.0.0' }) }
76
78
 
@@ -44,7 +44,7 @@ describe R10K::Module::Git do
44
44
  described_class.new(
45
45
  'branan/eight_hundred',
46
46
  '/moduledir',
47
- { :git => 'git://git-server.site/branan/puppet-eight_hundred' }
47
+ { :git => 'https://git-server.site/branan/puppet-eight_hundred' }
48
48
  )
49
49
  end
50
50
 
@@ -66,7 +66,7 @@ describe R10K::Module::Git do
66
66
  described_class.new(
67
67
  'eight_hundred',
68
68
  '/moduledir',
69
- { :git => 'git://git-server.site/branan/puppet-eight_hundred' }
69
+ { :git => 'https://git-server.site/branan/puppet-eight_hundred' }
70
70
  )
71
71
  end
72
72
 
@@ -86,7 +86,7 @@ describe R10K::Module::Git do
86
86
 
87
87
  describe "properties" do
88
88
  subject do
89
- described_class.new('boolean', '/moduledir', {:git => 'git://git.example.com/adrienthebo/puppet-boolean'})
89
+ described_class.new('boolean', '/moduledir', {:git => 'https://git.example.com/adrienthebo/puppet-boolean'})
90
90
  end
91
91
 
92
92
  before(:each) do
@@ -154,7 +154,7 @@ describe R10K::Module::Git do
154
154
  described_class.new(
155
155
  'boolean',
156
156
  '/moduledir',
157
- { :git => 'git://git.example.com/adrienthebo/puppet-boolean' }
157
+ { :git => 'https://git.example.com/adrienthebo/puppet-boolean' }
158
158
  )
159
159
  end
160
160
 
@@ -171,7 +171,7 @@ describe R10K::Module::Git do
171
171
  described_class.new('boolean', '/moduledir', base_opts.merge(extra_opts), env)
172
172
  end
173
173
 
174
- let(:base_opts) { { git: 'git://git.example.com/adrienthebo/puppet-boolean' } }
174
+ let(:base_opts) { { git: 'https://git.example.com/adrienthebo/puppet-boolean' } }
175
175
 
176
176
  before(:each) do
177
177
  allow(mock_repo).to receive(:head).and_return('abc123')
@@ -12,7 +12,7 @@ describe R10K::ModuleLoader::Puppetfile do
12
12
  environment: R10K::Environment::Git.new('env',
13
13
  '/test/basedir/',
14
14
  'env',
15
- { remote: 'git://foo/remote',
15
+ { remote: 'https://foo/remote',
16
16
  ref: 'env' })
17
17
  }
18
18
  end
@@ -80,7 +80,8 @@ describe R10K::ModuleLoader::Puppetfile do
80
80
  describe 'adding modules' do
81
81
  let(:basedir) { '/test/basedir' }
82
82
 
83
- subject { R10K::ModuleLoader::Puppetfile.new(basedir: basedir) }
83
+ subject { R10K::ModuleLoader::Puppetfile.new(basedir: basedir,
84
+ overrides: {modules: {exclude_spec: true}}) }
84
85
 
85
86
  it 'should transform Forge modules with a string arg to have a version key' do
86
87
  expect(R10K::Module).to receive(:from_metadata).with('puppet/test_module', subject.moduledir, hash_including(version: '1.2.3'), anything).and_call_original
@@ -94,11 +95,23 @@ describe R10K::ModuleLoader::Puppetfile do
94
95
 
95
96
  expect {
96
97
  subject.add_module('puppet/test_module', '< 1.2.0')
97
- }.to raise_error(RuntimeError, /module puppet\/test_module.*doesn't have an implementation/i)
98
+ }.to raise_error(ArgumentError, /module version .* is not a valid forge module version/i)
98
99
 
99
100
  expect(subject.modules.collect(&:name)).not_to include('test_module')
100
101
  end
101
102
 
103
+ it 'should not modify the overrides when adding modules' do
104
+ module_opts = { git: 'git@example.com:puppet/test_module.git' }
105
+ subject.add_module('puppet/test_module', module_opts)
106
+ expect(subject.instance_variable_get("@overrides")[:modules]).to eq({exclude_spec: true})
107
+ end
108
+
109
+ it 'should read the `exclude_spec` setting in the module definition and override the overrides' do
110
+ module_opts = { git: 'git@example.com:puppet/test_module.git', exclude_spec: false }
111
+ subject.add_module('puppet/test_module', module_opts)
112
+ expect(subject.modules[0].instance_variable_get("@exclude_spec")).to be false
113
+ end
114
+
102
115
  it 'should set :spec_deletable to true for modules in the basedir' do
103
116
  module_opts = { git: 'git@example.com:puppet/test_module.git' }
104
117
  subject.add_module('puppet/test_module', module_opts)
@@ -372,7 +385,7 @@ describe R10K::ModuleLoader::Puppetfile do
372
385
  expect(metadata['canary']).to eq('0.0.0')
373
386
  end
374
387
 
375
- it 'does not load module implementations for static versioned' do
388
+ it 'does not load module implementations for static versions unless the module install path does not exist on disk' do
376
389
  @path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'various-modules')
377
390
  subject.load_metadata
378
391
  modules = subject.load[:modules].map { |mod| [ mod.name, mod ] }.to_h
@@ -381,7 +394,7 @@ describe R10K::ModuleLoader::Puppetfile do
381
394
  expect(modules['concat']).to be_a_kind_of(R10K::Module::Forge)
382
395
  expect(modules['rpm']).to be_a_kind_of(R10K::Module::Definition)
383
396
  expect(modules['foo']).to be_a_kind_of(R10K::Module::Git)
384
- expect(modules['bar']).to be_a_kind_of(R10K::Module::Definition)
397
+ expect(modules['bar']).to be_a_kind_of(R10K::Module::Git)
385
398
  expect(modules['baz']).to be_a_kind_of(R10K::Module::Definition)
386
399
  expect(modules['fizz']).to be_a_kind_of(R10K::Module::Definition)
387
400
  expect(modules['buzz']).to be_a_kind_of(R10K::Module::Git)
@@ -31,12 +31,11 @@ describe R10K::Module do
31
31
  'bar-quux',
32
32
  ].each do |scenario|
33
33
  it "accepts a name matching #{scenario} and version nil" do
34
- obj = R10K::Module.new(scenario, '/modulepath', { version: nil })
34
+ obj = R10K::Module.new(scenario, '/modulepath', { type: 'forge', version: nil })
35
35
  expect(obj).to be_a_kind_of(R10K::Module::Forge)
36
36
  end
37
37
  end
38
- [ {version: '8.0.0'},
39
- {type: 'forge', version: '8.0.0'},
38
+ [ {type: 'forge', version: '8.0.0'},
40
39
  ].each do |scenario|
41
40
  it "accepts a name matching bar-quux and args #{scenario.inspect}" do
42
41
  obj = R10K::Module.new('bar-quux', '/modulepath', scenario)
@@ -65,7 +64,7 @@ describe R10K::Module do
65
64
  end
66
65
 
67
66
  it 'sets the expected version to what is found in the metadata' do
68
- obj = R10K::Module.new(@title, @dirname, {version: nil})
67
+ obj = R10K::Module.new(@title, @dirname, {type: 'forge', version: nil})
69
68
  expect(obj.send(:instance_variable_get, :'@expected_version')).to eq('1.2.0')
70
69
  end
71
70
  end
@@ -82,7 +81,6 @@ describe R10K::Module do
82
81
  ['name', {type: 'git', source: 'git url'}],
83
82
  ['name', {svn: 'svn url'}],
84
83
  ['name', {type: 'svn', source: 'svn url'}],
85
- ['namespace-name', {version: '8.0.0'}],
86
84
  ['namespace-name', {type: 'forge', version: '8.0.0'}]
87
85
  ].each do |(name, options)|
88
86
  it 'can handle the default_branch_override option' do
@@ -92,12 +90,21 @@ describe R10K::Module do
92
90
  }.not_to raise_error
93
91
  end
94
92
  describe 'the exclude_spec setting' do
93
+ it 'sets the exclude_spec instance variable to false by default' do
94
+ obj = R10K::Module.new(name, '/modulepath', options)
95
+ expect(obj.instance_variable_get("@exclude_spec")).to eq(false)
96
+ end
95
97
  it 'sets the exclude_spec instance variable' do
96
98
  obj = R10K::Module.new(name, '/modulepath', options.merge({exclude_spec: true}))
97
99
  expect(obj.instance_variable_get("@exclude_spec")).to eq(true)
98
100
  end
99
- it 'can be overridden by the overrides map' do
100
- options = options.merge({exclude_spec: false, overrides: {modules: {exclude_spec: true}}})
101
+ it 'cannot be overridden by the settings from the cli, r10k.yaml, or settings default' do
102
+ options = options.merge({exclude_spec: true, overrides: {modules: {exclude_spec: false}}})
103
+ obj = R10K::Module.new(name, '/modulepath', options)
104
+ expect(obj.instance_variable_get("@exclude_spec")).to eq(true)
105
+ end
106
+ it 'reads the setting from the cli, r10k.yaml, or settings default when not provided directly' do
107
+ options = options.merge({overrides: {modules: {exclude_spec: true}}})
101
108
  obj = R10K::Module.new(name, '/modulepath', options)
102
109
  expect(obj.instance_variable_get("@exclude_spec")).to eq(true)
103
110
  end
@@ -6,10 +6,10 @@ RSpec.describe R10K::Util::Cacheable do
6
6
  subject { Object.new.extend(R10K::Util::Cacheable) }
7
7
 
8
8
  describe "dirname sanitization" do
9
- let(:input) { 'git://some/git/remote' }
9
+ let(:input) { 'https://some/git/remote' }
10
10
 
11
11
  it 'sanitizes URL to directory name' do
12
- expect(subject.sanitized_dirname(input)).to eq('git---some-git-remote')
12
+ expect(subject.sanitized_dirname(input)).to eq('https---some-git-remote')
13
13
  end
14
14
 
15
15
  context 'with username and password' do
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.14.0
4
+ version: 3.15.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: 2021-11-29 00:00:00.000000000 Z
11
+ date: 2022-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colored2
@@ -28,14 +28,14 @@ dependencies:
28
28
  name: cri
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 2.15.10
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 2.15.10
41
41
  - !ruby/object:Gem::Dependency
@@ -70,14 +70,14 @@ dependencies:
70
70
  name: puppet_forge
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: 2.3.0
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: 2.3.0
83
83
  - !ruby/object:Gem::Dependency
@@ -98,16 +98,22 @@ dependencies:
98
98
  name: fast_gettext
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - "~>"
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: 1.1.0
104
+ - - "<"
105
+ - !ruby/object:Gem::Version
106
+ version: 3.0.0
104
107
  type: :runtime
105
108
  prerelease: false
106
109
  version_requirements: !ruby/object:Gem::Requirement
107
110
  requirements:
108
- - - "~>"
111
+ - - ">="
109
112
  - !ruby/object:Gem::Version
110
113
  version: 1.1.0
114
+ - - "<"
115
+ - !ruby/object:Gem::Version
116
+ version: 3.0.0
111
117
  - !ruby/object:Gem::Dependency
112
118
  name: gettext
113
119
  requirement: !ruby/object:Gem::Requirement
@@ -117,7 +123,7 @@ dependencies:
117
123
  version: 3.0.2
118
124
  - - "<"
119
125
  - !ruby/object:Gem::Version
120
- version: 3.3.0
126
+ version: 4.0.0
121
127
  type: :runtime
122
128
  prerelease: false
123
129
  version_requirements: !ruby/object:Gem::Requirement
@@ -127,7 +133,7 @@ dependencies:
127
133
  version: 3.0.2
128
134
  - - "<"
129
135
  - !ruby/object:Gem::Version
130
- version: 3.3.0
136
+ version: 4.0.0
131
137
  - !ruby/object:Gem::Dependency
132
138
  name: jwt
133
139
  requirement: !ruby/object:Gem::Requirement
@@ -148,14 +154,14 @@ dependencies:
148
154
  requirements:
149
155
  - - "~>"
150
156
  - !ruby/object:Gem::Version
151
- version: 0.9.0
157
+ version: '0.9'
152
158
  type: :runtime
153
159
  prerelease: false
154
160
  version_requirements: !ruby/object:Gem::Requirement
155
161
  requirements:
156
162
  - - "~>"
157
163
  - !ruby/object:Gem::Version
158
- version: 0.9.0
164
+ version: '0.9'
159
165
  - !ruby/object:Gem::Dependency
160
166
  name: rspec
161
167
  requirement: !ruby/object:Gem::Requirement
@@ -215,7 +221,6 @@ files:
215
221
  - ".github/workflows/rspec_tests.yml"
216
222
  - ".github/workflows/stale.yml"
217
223
  - ".gitignore"
218
- - ".travis.yml"
219
224
  - CHANGELOG.mkd
220
225
  - CODEOWNERS
221
226
  - CONTRIBUTING.mkd
@@ -487,6 +492,12 @@ files:
487
492
  - spec/fixtures/unit/puppetfile/valid-forge-without-version/Puppetfile
488
493
  - spec/fixtures/unit/puppetfile/various-modules/Puppetfile
489
494
  - spec/fixtures/unit/puppetfile/various-modules/Puppetfile.new
495
+ - spec/fixtures/unit/puppetfile/various-modules/modules/apt/.gitkeep
496
+ - spec/fixtures/unit/puppetfile/various-modules/modules/baz/.gitkeep
497
+ - spec/fixtures/unit/puppetfile/various-modules/modules/buzz/.gitkeep
498
+ - spec/fixtures/unit/puppetfile/various-modules/modules/canary/.gitkeep
499
+ - spec/fixtures/unit/puppetfile/various-modules/modules/fizz/.gitkeep
500
+ - spec/fixtures/unit/puppetfile/various-modules/modules/rpm/.gitkeep
490
501
  - spec/fixtures/unit/util/purgeable/managed_one/expected_1
491
502
  - spec/fixtures/unit/util/purgeable/managed_one/managed_subdir_1/managed_symlink_file
492
503
  - spec/fixtures/unit/util/purgeable/managed_one/managed_subdir_1/subdir_allowlisted_2/ignored_1
data/.travis.yml DELETED
@@ -1,42 +0,0 @@
1
- ---
2
- language: ruby
3
- bundler_args: "--without system"
4
- script: "bundle exec rspec --color --format documentation spec"
5
- notifications:
6
- email: false
7
- sudo: false
8
- jdk:
9
- - openjdk11
10
- before_install: gem install bundler -v '< 2' --no-document
11
- matrix:
12
- include:
13
- - stage: r10k tests
14
- rvm: 2.3.0
15
- - stage: r10k container tests
16
- dist: focal
17
- language: ruby
18
- services:
19
- - docker
20
- rvm: 2.6.6
21
- env:
22
- - DOCKER_COMPOSE_VERSION=1.28.6
23
- - DOCKER_BUILDX_VERSION=0.5.1
24
- # necessary to prevent overwhelming TravisCI build output limits
25
- - DOCKER_BUILD_FLAGS="--progress plain"
26
- before_install:
27
- - sudo rm /usr/local/bin/docker-compose
28
- - curl --location https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname --kernel-name`-`uname --machine` > docker-compose
29
- - chmod +x docker-compose
30
- - sudo mv docker-compose /usr/local/bin
31
- - mkdir -vp ~/.docker/cli-plugins
32
- - curl --location https://github.com/docker/buildx/releases/download/v${DOCKER_BUILDX_VERSION}/buildx-v${DOCKER_BUILDX_VERSION}.linux-amd64 > ~/.docker/cli-plugins/docker-buildx
33
- - chmod +x ~/.docker/cli-plugins/docker-buildx
34
- - docker buildx create --name travis_builder --use
35
- script:
36
- - set -e
37
- - cd docker
38
- - make lint
39
- - make build
40
- - make test
41
- after_script:
42
- - docker buildx rm travis_builder