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
@@ -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)
39
+ def sync(ref, force=true, exclude_spec=false)
40
40
  @cache.sync if sync_cache?(ref)
41
41
 
42
42
  sha = @cache.resolve(ref)
@@ -45,7 +45,7 @@ class R10K::Git::StatefulRepository
45
45
  raise R10K::Git::UnresolvableRefError.new(_("Unable to sync repo to unresolvable ref '%{ref}'") % {ref: ref}, :git_dir => @repo.git_dir)
46
46
  end
47
47
 
48
- workdir_status = status(ref)
48
+ workdir_status = status(ref, exclude_spec)
49
49
 
50
50
  updated = true
51
51
  case workdir_status
@@ -75,7 +75,7 @@ class R10K::Git::StatefulRepository
75
75
  updated
76
76
  end
77
77
 
78
- def status(ref)
78
+ def status(ref, exclude_spec=false)
79
79
  if !@repo.exist?
80
80
  :absent
81
81
  elsif !@cache.exist?
@@ -88,7 +88,7 @@ class R10K::Git::StatefulRepository
88
88
  :mismatched
89
89
  elsif @repo.head.nil?
90
90
  :mismatched
91
- elsif @repo.dirty?
91
+ elsif @repo.dirty?(exclude_spec)
92
92
  :dirty
93
93
  elsif !(@repo.head == @cache.resolve(ref))
94
94
  :outdated
@@ -60,8 +60,12 @@ class R10K::Module::Base
60
60
  @environment = environment
61
61
  @overrides = args.delete(:overrides) || {}
62
62
  @spec_deletable = true
63
- @exclude_spec = args.delete(:exclude_spec)
64
- @exclude_spec = @overrides[:modules].delete(:exclude_spec) if @overrides.dig(:modules, :exclude_spec)
63
+ @exclude_spec = false
64
+ @exclude_spec = @overrides.dig(:modules, :exclude_spec) if @overrides.dig(:modules, :exclude_spec)
65
+ if args.has_key?(:exclude_spec)
66
+ logger.debug2 _("Overriding :exclude_spec setting with per module setting for #{@title}")
67
+ @exclude_spec = args.delete(:exclude_spec)
68
+ end
65
69
  @origin = 'external' # Expect Puppetfile or R10k::Environment to set this to a specific value
66
70
 
67
71
  @requested_modules = @overrides.dig(:modules, :requested_modules) || []
@@ -13,16 +13,7 @@ class R10K::Module::Forge < R10K::Module::Base
13
13
  R10K::Module.register(self)
14
14
 
15
15
  def self.implement?(name, args)
16
- args[:type].to_s == 'forge' ||
17
- (!!
18
- ((args.keys & %i{git svn type}).empty? &&
19
- args.has_key?(:version) &&
20
- name.match(%r[\w+[/-]\w+]) &&
21
- valid_version?(args[:version])))
22
- end
23
-
24
- def self.valid_version?(expected_version)
25
- expected_version == :latest || expected_version.nil? || PuppetForge::Util.version_valid?(expected_version)
16
+ args[:type].to_s == 'forge'
26
17
  end
27
18
 
28
19
  def self.statically_defined_version(name, args)
@@ -54,11 +45,20 @@ class R10K::Module::Forge < R10K::Module::Base
54
45
  :type => ::R10K::Util::Setopts::Ignore,
55
46
  }, :raise_on_unhandled => false)
56
47
 
48
+ # Validate version and raise on issue. Title is validated by base class.
49
+ unless valid_version?(@expected_version)
50
+ raise ArgumentError, _("Module version %{ver} is not a valid Forge module version") % {ver: @expected_version}
51
+ end
52
+
57
53
  @expected_version ||= current_version || :latest
58
54
 
59
55
  @v3_module = PuppetForge::V3::Module.new(:slug => @title)
60
56
  end
61
57
 
58
+ def valid_version?(version)
59
+ version == :latest || version.nil? || PuppetForge::Util.version_valid?(version)
60
+ end
61
+
62
62
  # @param [Hash] opts Deprecated
63
63
  # @return [Boolean] true if the module was updated, false otherwise
64
64
  def sync(opts={})
@@ -9,8 +9,6 @@ class R10K::Module::Git < R10K::Module::Base
9
9
 
10
10
  def self.implement?(name, args)
11
11
  args.has_key?(:git) || args[:type].to_s == 'git'
12
- rescue
13
- false
14
12
  end
15
13
 
16
14
  # Will be called if self.implement? above returns true. Will return
@@ -69,7 +67,7 @@ class R10K::Module::Git < R10K::Module::Base
69
67
  :default_branch_override => :default_override_ref,
70
68
  }, :raise_on_unhandled => false)
71
69
 
72
- force = @overrides.dig(:modules, :force)
70
+ force = @overrides[:force]
73
71
  @force = force == false ? false : true
74
72
 
75
73
  @desired_ref ||= 'master'
@@ -102,7 +100,7 @@ class R10K::Module::Git < R10K::Module::Base
102
100
  def sync(opts={})
103
101
  force = opts[:force] || @force
104
102
  if should_sync?
105
- updated = @repo.sync(version, force)
103
+ updated = @repo.sync(version, force, @exclude_spec)
106
104
  else
107
105
  updated = false
108
106
  end
@@ -8,7 +8,7 @@ class R10K::Module::Local < R10K::Module::Base
8
8
  R10K::Module.register(self)
9
9
 
10
10
  def self.implement?(name, args)
11
- args.is_a?(Hash) && (args[:local] || args[:type].to_s == 'local')
11
+ args[:local] || args[:type].to_s == 'local'
12
12
  end
13
13
 
14
14
  def self.statically_defined_version(*)
@@ -15,7 +15,7 @@ module R10K
15
15
  if args.is_a?(Hash)
16
16
  opts = args
17
17
  else
18
- opts = { version: args }
18
+ opts = { type: 'forge', version: args }
19
19
  end
20
20
 
21
21
  if @metadata_only
@@ -157,11 +157,14 @@ module R10K
157
157
  return @modules
158
158
  end
159
159
 
160
- # If this module's metadata has a static version and that version
161
- # matches the existing module declaration use it, otherwise create
162
- # a regular module to sync.
163
- unless mod.version && (mod.version == @existing_module_versions_by_name[mod.name])
164
- mod = mod.to_implementation
160
+ # If this module's metadata has a static version, and that version
161
+ # matches the existing module declaration, and it ostensibly
162
+ # has already has been deployed to disk, use it. Otherwise create a
163
+ # regular module to sync.
164
+ unless mod.version &&
165
+ mod.version == @existing_module_versions_by_name[mod.name] &&
166
+ File.directory?(mod.path)
167
+ mod = mod.to_implementation
165
168
  end
166
169
 
167
170
  @modules << mod
@@ -196,8 +199,10 @@ module R10K
196
199
  end
197
200
 
198
201
  def parse_module_definition(name, info)
202
+ # The only valid (deprecated) way a module can be defined with a
203
+ # non-hash info is if it is a Forge module.
199
204
  if !info.is_a?(Hash)
200
- info = { version: info }
205
+ info = { type: 'forge', version: info }
201
206
  end
202
207
 
203
208
  info[:overrides] = @overrides
@@ -1,3 +1,4 @@
1
+ require 'set'
1
2
  # Defines a collection for application settings
2
3
  #
3
4
  # This implements a hierarchical interface to application settings. Containers
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.14.0'
5
+ VERSION = '3.15.0'
6
6
  end
data/locales/r10k.pot CHANGED
@@ -1,16 +1,16 @@
1
1
  # SOME DESCRIPTIVE TITLE.
2
- # Copyright (C) 2021 Puppet, Inc.
2
+ # Copyright (C) 2022 Puppet, Inc.
3
3
  # This file is distributed under the same license as the r10k package.
4
- # FIRST AUTHOR <EMAIL@ADDRESS>, 2021.
4
+ # FIRST AUTHOR <EMAIL@ADDRESS>, 2022.
5
5
  #
6
6
  #, fuzzy
7
7
  msgid ""
8
8
  msgstr ""
9
- "Project-Id-Version: r10k 3.9.3-170-g8cb36435\n"
9
+ "Project-Id-Version: r10k 3.9.3-208-gb88bb368\n"
10
10
  "\n"
11
11
  "Report-Msgid-Bugs-To: docs@puppetlabs.com\n"
12
- "POT-Creation-Date: 2021-11-16 21:43+0000\n"
13
- "PO-Revision-Date: 2021-11-16 21:43+0000\n"
12
+ "POT-Creation-Date: 2022-02-07 21:13+0000\n"
13
+ "PO-Revision-Date: 2022-02-07 21:13+0000\n"
14
14
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
15
15
  "Language-Team: LANGUAGE <LL@li.org>\n"
16
16
  "Language: \n"
@@ -115,7 +115,7 @@ msgstr ""
115
115
  msgid "%{class} has not implemented method %{method}"
116
116
  msgstr ""
117
117
 
118
- #: ../lib/r10k/environment/name.rb:78
118
+ #: ../lib/r10k/environment/name.rb:83
119
119
  msgid "Improper configuration value given for strip_component setting in %{src} source. Value must be a string, a /regex/, false, or omitted. Got \"%{val}\" (%{type})"
120
120
  msgstr ""
121
121
 
@@ -395,27 +395,31 @@ msgstr ""
395
395
  msgid "Module %{name} with args %{args} doesn't have an implementation. (Are you using the right arguments?)"
396
396
  msgstr ""
397
397
 
398
- #: ../lib/r10k/module/base.rb:83
398
+ #: ../lib/r10k/module/base.rb:66
399
+ msgid "Overriding :exclude_spec setting with per module setting for #{@title}"
400
+ msgstr ""
401
+
402
+ #: ../lib/r10k/module/base.rb:87
399
403
  msgid "Spec dir for #{@title} will not be deleted because it is not in the moduledir"
400
404
  msgstr ""
401
405
 
402
- #: ../lib/r10k/module/base.rb:95
406
+ #: ../lib/r10k/module/base.rb:99
403
407
  msgid "Deleting spec data at #{spec_path}"
404
408
  msgstr ""
405
409
 
406
- #: ../lib/r10k/module/base.rb:103
410
+ #: ../lib/r10k/module/base.rb:107
407
411
  msgid "No spec dir detected at #{spec_path}, skipping deletion"
408
412
  msgstr ""
409
413
 
410
- #: ../lib/r10k/module/base.rb:116
414
+ #: ../lib/r10k/module/base.rb:120
411
415
  msgid "Deploying module to %{path}"
412
416
  msgstr ""
413
417
 
414
- #: ../lib/r10k/module/base.rb:119
418
+ #: ../lib/r10k/module/base.rb:123
415
419
  msgid "Only updating modules %{modules}, skipping module %{name}"
416
420
  msgstr ""
417
421
 
418
- #: ../lib/r10k/module/base.rb:175
422
+ #: ../lib/r10k/module/base.rb:179
419
423
  msgid "Module name (%{title}) must match either 'modulename' or 'owner/modulename'"
420
424
  msgstr ""
421
425
 
@@ -423,6 +427,10 @@ msgstr ""
423
427
  msgid "Not updating module %{name}, assuming content unchanged"
424
428
  msgstr ""
425
429
 
430
+ #: ../lib/r10k/module/forge.rb:50
431
+ msgid "Module version %{ver} is not a valid Forge module version"
432
+ msgstr ""
433
+
426
434
  #: ../lib/r10k/module/forge.rb:98
427
435
  msgid "The module %{title} does not appear to have any published releases, cannot determine latest version."
428
436
  msgstr ""
@@ -435,7 +443,7 @@ msgstr ""
435
443
  msgid "Forge module names must match 'owner/modulename', instead got #{title}"
436
444
  msgstr ""
437
445
 
438
- #: ../lib/r10k/module/git.rb:81
446
+ #: ../lib/r10k/module/git.rb:79
439
447
  msgid "Cannot track control repo branch for content '%{name}' when not part of a git-backed environment, will use default if available."
440
448
  msgstr ""
441
449
 
@@ -479,11 +487,11 @@ msgstr ""
479
487
  msgid "Puppetfile %{path} missing or unreadable"
480
488
  msgstr ""
481
489
 
482
- #: ../lib/r10k/module_loader/puppetfile.rb:228
490
+ #: ../lib/r10k/module_loader/puppetfile.rb:230
483
491
  msgid "Puppetfiles cannot contain duplicate module names."
484
492
  msgstr ""
485
493
 
486
- #: ../lib/r10k/module_loader/puppetfile.rb:230
494
+ #: ../lib/r10k/module_loader/puppetfile.rb:232
487
495
  msgid "Remove the duplicates of the following modules: %{dupes}"
488
496
  msgstr ""
489
497
 
data/r10k.gemspec CHANGED
@@ -23,21 +23,19 @@ Gem::Specification.new do |s|
23
23
  s.license = 'Apache-2.0'
24
24
 
25
25
  s.add_dependency 'colored2', '3.1.2'
26
- s.add_dependency 'cri', '2.15.10'
26
+ s.add_dependency 'cri', '>= 2.15.10'
27
27
 
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'
31
+ s.add_dependency 'puppet_forge', '>= 2.3.0'
32
32
 
33
33
  s.add_dependency 'gettext-setup', '~>0.24'
34
- # These two pins narrow what is allowed by gettext-setup,
35
- # to preserve compatability with Ruby 2.4
36
- s.add_dependency 'fast_gettext', '~> 1.1.0'
37
- s.add_dependency 'gettext', ['>= 3.0.2', '< 3.3.0']
34
+ s.add_dependency 'fast_gettext', ['>= 1.1.0', '< 3.0.0']
35
+ s.add_dependency 'gettext', ['>= 3.0.2', '< 4.0.0']
38
36
 
39
37
  s.add_dependency 'jwt', '~> 2.2.3'
40
- s.add_dependency 'minitar', '~> 0.9.0'
38
+ s.add_dependency 'minitar', '~> 0.9'
41
39
 
42
40
  s.add_development_dependency 'rspec', '~> 3.1'
43
41
 
@@ -0,0 +1 @@
1
+ This only exists so the directory can be committed to git for testing purposes.
@@ -0,0 +1 @@
1
+ This only exists so the directory can be committed to git for testing purposes.
@@ -0,0 +1 @@
1
+ This only exists so the directory can be committed to git for testing purposes.
@@ -0,0 +1 @@
1
+ This only exists so the directory can be committed to git for testing purposes.
@@ -0,0 +1 @@
1
+ This only exists so the directory can be committed to git for testing purposes.
@@ -0,0 +1 @@
1
+ This only exists so the directory can be committed to git for testing purposes.
@@ -83,6 +83,22 @@ describe R10K::Git::StatefulRepository do
83
83
  end
84
84
  end
85
85
 
86
+ describe "when the workdir has spec dir modifications" do
87
+ before(:each) do
88
+ thinrepo.clone(remote, {:ref => ref})
89
+ FileUtils.mkdir_p(File.join(thinrepo.path, 'spec'))
90
+ File.open(File.join(thinrepo.path, 'spec', 'file_spec.rb'), 'a') { |f| f.write('local modifications!') }
91
+ thinrepo.stage_files(['spec/file_spec.rb'])
92
+ end
93
+ it "is dirty with exclude_spec false" do
94
+ expect(subject.status(ref, false)).to eq :dirty
95
+ end
96
+
97
+ it "is insync with exclude_spec true" do
98
+ expect(subject.status(ref, true)).to eq :insync
99
+ end
100
+ end
101
+
86
102
  describe "if the right ref is checked out" do
87
103
  it "is insync" do
88
104
  thinrepo.clone(remote, {:ref => ref})
@@ -231,7 +231,7 @@ describe R10K::Action::Deploy::Module do
231
231
  original.call(settings.merge({
232
232
  sources: {
233
233
  main: {
234
- remote: 'git://not/a/remote',
234
+ remote: 'https://not/a/remote',
235
235
  basedir: '/not/a/basedir',
236
236
  type: 'git'
237
237
  }
@@ -253,9 +253,9 @@ describe R10K::Action::Deploy::Module do
253
253
  loader = environment.loader
254
254
  allow(loader).to receive(:puppetfile_content).and_return('')
255
255
  expect(loader).to receive(:load) do
256
- loader.add_module('mod1', { git: 'git://remote' })
257
- loader.add_module('mod2', { git: 'git://remote' })
258
- loader.add_module('mod3', { git: 'git://remote' })
256
+ loader.add_module('mod1', { git: 'https://remote' })
257
+ loader.add_module('mod2', { git: 'https://remote' })
258
+ loader.add_module('mod3', { git: 'https://remote' })
259
259
 
260
260
  loaded_content = loader.load!
261
261
  loaded_content[:modules].each do |mod|
@@ -290,7 +290,7 @@ describe R10K::Action::Deploy::Module do
290
290
  original.call(settings.merge({
291
291
  sources: {
292
292
  main: {
293
- remote: 'git://not/a/remote',
293
+ remote: 'https://not/a/remote',
294
294
  basedir: '/not/a/basedir',
295
295
  type: 'git'
296
296
  }
@@ -315,8 +315,8 @@ describe R10K::Action::Deploy::Module do
315
315
  # it so it will create the correct loaded_content.
316
316
  allow(loader).to receive(:puppetfile_content).and_return('')
317
317
  expect(loader).to receive(:load) do
318
- loader.add_module('mod1', { git: 'git://remote' })
319
- loader.add_module('mod2', { git: 'git://remote' })
318
+ loader.add_module('mod1', { git: 'https://remote' })
319
+ loader.add_module('mod2', { git: 'https://remote' })
320
320
 
321
321
  loaded_content = loader.load!
322
322
  loaded_content[:modules].each do |mod|
@@ -9,7 +9,7 @@ describe R10K::Environment::Git do
9
9
  '/some/nonexistent/environmentdir',
10
10
  'gitref',
11
11
  {
12
- :remote => 'git://git-server.site/my-repo.git',
12
+ :remote => 'https://git-server.site/my-repo.git',
13
13
  :ref => 'd026ea677116424d2968edb9cee8cbc24d09322b',
14
14
  }
15
15
  )
@@ -45,7 +45,7 @@ describe R10K::Environment::Git do
45
45
  end
46
46
 
47
47
  it "can return the environment remote" do
48
- expect(subject.remote).to eq 'git://git-server.site/my-repo.git'
48
+ expect(subject.remote).to eq 'https://git-server.site/my-repo.git'
49
49
  end
50
50
 
51
51
  it "can return the environment ref" do
@@ -72,4 +72,51 @@ describe R10K::Environment::WithModules do
72
72
  expect(returned_modules.map(&:name).sort).to eq(%w[concat exec stdlib zebra])
73
73
  end
74
74
  end
75
+
76
+ describe "module options" do
77
+ let(:subject_params) {{
78
+ :modules => {
79
+ 'hieradata' => {
80
+ :type => 'git',
81
+ :source => 'git@git.example.com:site_data.git',
82
+ :install_path => ''
83
+ },
84
+ 'site_data_2' => {
85
+ :type => 'git',
86
+ :source => 'git@git.example.com:site_data.git',
87
+ :install_path => 'subdir'
88
+ },
89
+
90
+ }
91
+ }}
92
+
93
+ it "should support empty install_path" do
94
+ modules = subject.modules
95
+ expect(modules[0].title).to eq 'hieradata'
96
+ expect(modules[0].path).to eq Pathname.new('/some/nonexistent/environmentdir/prefix_release42/hieradata')
97
+
98
+ end
99
+
100
+ it "should support install_path" do
101
+ modules = subject.modules
102
+ expect(modules[1].title).to eq 'site_data_2'
103
+ expect(modules[1].path).to eq Pathname.new('/some/nonexistent/environmentdir/prefix_release42/subdir/site_data_2')
104
+ end
105
+
106
+ context "with invalid configuration" do
107
+ let(:subject_params) {{
108
+ :modules => {
109
+ 'site_data_2' => {
110
+ :type => 'git',
111
+ :source => 'git@git.example.com:site_data.git',
112
+ :install_path => '/absolute_path_outside_of_containing_environment'
113
+ }
114
+ }
115
+ }}
116
+
117
+ it "raises an error" do
118
+ expect{ subject.modules }.to raise_error(R10K::Error, /Environment cannot.*outside of containing environment.*/i)
119
+ end
120
+ end
121
+ end
75
122
  end
@@ -13,13 +13,13 @@ describe R10K::Git::Alternates do
13
13
  it "reads the alternates file and splits on lines" do
14
14
  expect(subject.file).to receive(:file?).and_return true
15
15
  expect(subject.file).to receive(:readlines).and_return([
16
- "/var/cache/r10k/git/git---github.com-puppetlabs-puppetlabs-apache.git\n",
17
- "/vagrant/.r10k/git/git---github.com-puppetlabs-puppetlabs-apache.git\n",
16
+ "/var/cache/r10k/git/https---github.com-puppetlabs-puppetlabs-apache.git\n",
17
+ "/vagrant/.r10k/git/https---github.com-puppetlabs-puppetlabs-apache.git\n",
18
18
  ])
19
19
 
20
20
  expect(subject.read).to eq([
21
- "/var/cache/r10k/git/git---github.com-puppetlabs-puppetlabs-apache.git",
22
- "/vagrant/.r10k/git/git---github.com-puppetlabs-puppetlabs-apache.git",
21
+ "/var/cache/r10k/git/https---github.com-puppetlabs-puppetlabs-apache.git",
22
+ "/vagrant/.r10k/git/https---github.com-puppetlabs-puppetlabs-apache.git",
23
23
  ])
24
24
  end
25
25
 
@@ -33,17 +33,17 @@ describe R10K::Git::Alternates do
33
33
  describe "determining if an entry is already present" do
34
34
  before do
35
35
  allow(subject).to receive(:to_a).and_return([
36
- "/var/cache/r10k/git/git---github.com-puppetlabs-puppetlabs-apache.git",
37
- "/vagrant/.r10k/git/git---github.com-puppetlabs-puppetlabs-apache.git",
36
+ "/var/cache/r10k/git/https---github.com-puppetlabs-puppetlabs-apache.git",
37
+ "/vagrant/.r10k/git/https---github.com-puppetlabs-puppetlabs-apache.git",
38
38
  ])
39
39
  end
40
40
 
41
41
  it "is true if the element is in the array of read entries" do
42
- expect(subject).to include("/vagrant/.r10k/git/git---github.com-puppetlabs-puppetlabs-apache.git")
42
+ expect(subject).to include("/vagrant/.r10k/git/https---github.com-puppetlabs-puppetlabs-apache.git")
43
43
  end
44
44
 
45
45
  it "is false if the element is not in the array of read entries" do
46
- expect(subject).to_not include("/tmp/.r10k/git/git---github.com-puppetlabs-puppetlabs-apache.git")
46
+ expect(subject).to_not include("/tmp/.r10k/git/https---github.com-puppetlabs-puppetlabs-apache.git")
47
47
  end
48
48
  end
49
49
 
@@ -52,7 +52,7 @@ describe R10K::Git::Alternates do
52
52
  describe "and the git objects/info directory does not exist" do
53
53
  it "raises an error when the parent directory does not exist" do
54
54
  expect {
55
- subject.write(["/tmp/.r10k/git/git---github.com-puppetlabs-puppetlabs-apache.git"])
55
+ subject.write(["/tmp/.r10k/git/https---github.com-puppetlabs-puppetlabs-apache.git"])
56
56
  }.to raise_error(R10K::Git::GitError,"Cannot write /some/nonexistent/path/.git/objects/info/alternates; parent directory does not exist")
57
57
  end
58
58
  end
@@ -66,51 +66,51 @@ describe R10K::Git::Alternates do
66
66
  end
67
67
 
68
68
  it "creates the alternates file with the new entry when not present" do
69
- subject.write(["/tmp/.r10k/git/git---github.com-puppetlabs-puppetlabs-apache.git"])
70
- expect(io.string).to eq("/tmp/.r10k/git/git---github.com-puppetlabs-puppetlabs-apache.git\n")
69
+ subject.write(["/tmp/.r10k/git/https---github.com-puppetlabs-puppetlabs-apache.git"])
70
+ expect(io.string).to eq("/tmp/.r10k/git/https---github.com-puppetlabs-puppetlabs-apache.git\n")
71
71
  end
72
72
 
73
73
  it "rewrites the file with all alternate entries" do
74
- subject.write(["/var/cache/r10k/git/git---github.com-puppetlabs-puppetlabs-apache.git",
75
- "/vagrant/.r10k/git/git---github.com-puppetlabs-puppetlabs-apache.git",
76
- "/tmp/.r10k/git/git---github.com-puppetlabs-puppetlabs-apache.git"])
74
+ subject.write(["/var/cache/r10k/git/https---github.com-puppetlabs-puppetlabs-apache.git",
75
+ "/vagrant/.r10k/git/https---github.com-puppetlabs-puppetlabs-apache.git",
76
+ "/tmp/.r10k/git/https---github.com-puppetlabs-puppetlabs-apache.git"])
77
77
 
78
78
  expect(io.string).to eq(<<-EOD)
79
- /var/cache/r10k/git/git---github.com-puppetlabs-puppetlabs-apache.git
80
- /vagrant/.r10k/git/git---github.com-puppetlabs-puppetlabs-apache.git
81
- /tmp/.r10k/git/git---github.com-puppetlabs-puppetlabs-apache.git
79
+ /var/cache/r10k/git/https---github.com-puppetlabs-puppetlabs-apache.git
80
+ /vagrant/.r10k/git/https---github.com-puppetlabs-puppetlabs-apache.git
81
+ /tmp/.r10k/git/https---github.com-puppetlabs-puppetlabs-apache.git
82
82
  EOD
83
83
  end
84
84
  end
85
85
 
86
86
  describe "appending a new alternate object entry" do
87
87
  it "re-writes the file with the new entry concatenated to the file" do
88
- expect(subject).to receive(:to_a).and_return(["/var/cache/r10k/git/git---github.com-puppetlabs-puppetlabs-apache.git",
89
- "/vagrant/.r10k/git/git---github.com-puppetlabs-puppetlabs-apache.git"])
88
+ expect(subject).to receive(:to_a).and_return(["/var/cache/r10k/git/https---github.com-puppetlabs-puppetlabs-apache.git",
89
+ "/vagrant/.r10k/git/https---github.com-puppetlabs-puppetlabs-apache.git"])
90
90
 
91
- expect(subject).to receive(:write).with(["/var/cache/r10k/git/git---github.com-puppetlabs-puppetlabs-apache.git",
92
- "/vagrant/.r10k/git/git---github.com-puppetlabs-puppetlabs-apache.git",
93
- "/tmp/.r10k/git/git---github.com-puppetlabs-puppetlabs-apache.git"])
91
+ expect(subject).to receive(:write).with(["/var/cache/r10k/git/https---github.com-puppetlabs-puppetlabs-apache.git",
92
+ "/vagrant/.r10k/git/https---github.com-puppetlabs-puppetlabs-apache.git",
93
+ "/tmp/.r10k/git/https---github.com-puppetlabs-puppetlabs-apache.git"])
94
94
 
95
- subject.add("/tmp/.r10k/git/git---github.com-puppetlabs-puppetlabs-apache.git")
95
+ subject.add("/tmp/.r10k/git/https---github.com-puppetlabs-puppetlabs-apache.git")
96
96
  end
97
97
  end
98
98
  end
99
99
 
100
100
  describe "conditionally appending a new alternate object entry" do
101
101
  before do
102
- expect(subject).to receive(:read).and_return(%w[/var/cache/r10k/git/git---github.com-puppetlabs-puppetlabs-apache.git])
102
+ expect(subject).to receive(:read).and_return(%w[/var/cache/r10k/git/https---github.com-puppetlabs-puppetlabs-apache.git])
103
103
  end
104
104
 
105
105
  it "adds the entry and returns true when the entry doesn't exist" do
106
- expect(subject).to receive(:write).with(["/var/cache/r10k/git/git---github.com-puppetlabs-puppetlabs-apache.git",
107
- "/tmp/.r10k/git/git---github.com-puppetlabs-puppetlabs-apache.git"])
108
- expect(subject.add?("/tmp/.r10k/git/git---github.com-puppetlabs-puppetlabs-apache.git")).to eq true
106
+ expect(subject).to receive(:write).with(["/var/cache/r10k/git/https---github.com-puppetlabs-puppetlabs-apache.git",
107
+ "/tmp/.r10k/git/https---github.com-puppetlabs-puppetlabs-apache.git"])
108
+ expect(subject.add?("/tmp/.r10k/git/https---github.com-puppetlabs-puppetlabs-apache.git")).to eq true
109
109
  end
110
110
 
111
111
  it "doesn't modify the file and returns false when the entry exists" do
112
112
  expect(subject).to_not receive(:write)
113
- expect(subject.add?("/var/cache/r10k/git/git---github.com-puppetlabs-puppetlabs-apache.git")).to eq false
113
+ expect(subject.add?("/var/cache/r10k/git/https---github.com-puppetlabs-puppetlabs-apache.git")).to eq false
114
114
  end
115
115
  end
116
116
  end
@@ -21,7 +21,7 @@ describe R10K::Git::Cache do
21
21
  end
22
22
  end
23
23
 
24
- let(:remote) { 'git://some/git/remote' }
24
+ let(:remote) { 'https://some/git/remote' }
25
25
  subject { subclass.new(remote) }
26
26
 
27
27
  describe "updating the cache" do
@@ -5,7 +5,7 @@ describe R10K::Git::Rugged::Cache, :unless => R10K::Util::Platform.jruby? do
5
5
  require 'r10k/git/rugged/cache'
6
6
  end
7
7
 
8
- subject(:cache) { described_class.new('git://some/git/remote') }
8
+ subject(:cache) { described_class.new('https://some/git/remote') }
9
9
 
10
10
  it "wraps a Rugged::BareRepository instance" do
11
11
  expect(cache.repo).to be_a_kind_of R10K::Git::Rugged::BareRepository
@@ -31,7 +31,7 @@ describe R10K::Git::Rugged::Cache, :unless => R10K::Util::Platform.jruby? do
31
31
  before do
32
32
  allow(subject.repo).to receive(:exist?).and_return true
33
33
  allow(subject.repo).to receive(:fetch)
34
- allow(subject.repo).to receive(:remotes).and_return({ 'origin' => 'git://some/git/remote' })
34
+ allow(subject.repo).to receive(:remotes).and_return({ 'origin' => 'https://some/git/remote' })
35
35
  end
36
36
 
37
37
  it "does not update the URLs if they match" do
@@ -3,7 +3,7 @@ require 'r10k/git/shellgit/cache'
3
3
 
4
4
  describe R10K::Git::ShellGit::Cache do
5
5
 
6
- subject { described_class.new('git://some/git/remote') }
6
+ subject { described_class.new('https://some/git/remote') }
7
7
 
8
8
  it "wraps a ShellGit::BareRepository instance" do
9
9
  expect(subject.repo).to be_a_kind_of R10K::Git::ShellGit::BareRepository
@@ -4,7 +4,7 @@ require 'r10k/git/stateful_repository'
4
4
 
5
5
  describe R10K::Git::StatefulRepository do
6
6
 
7
- let(:remote) { 'git://some.site/some-repo.git' }
7
+ let(:remote) { 'https://some.site/some-repo.git' }
8
8
  let(:ref) { '0.9.x' }
9
9
 
10
10
  subject { described_class.new(remote, '/some/nonexistent/basedir', 'some-dirname') }