r10k 3.14.1 → 5.0.1

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.
Files changed (246) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +17 -0
  3. data/.github/workflows/docker.yml +9 -4
  4. data/.github/workflows/release.yml +3 -2
  5. data/.github/workflows/rspec_tests.yml +8 -10
  6. data/CHANGELOG.mkd +100 -0
  7. data/CODEOWNERS +1 -2
  8. data/Gemfile +2 -2
  9. data/README.mkd +18 -19
  10. data/doc/common-patterns.mkd +1 -2
  11. data/doc/dynamic-environments/configuration.mkd +91 -12
  12. data/doc/dynamic-environments/usage.mkd +4 -0
  13. data/doc/dynamic-environments/workflow-guide.mkd +3 -3
  14. data/doc/faq.mkd +1 -1
  15. data/doc/puppetfile.mkd +9 -3
  16. data/integration/Gemfile +3 -4
  17. data/integration/Rakefile +58 -23
  18. data/integration/files/pre-suite/git_config.pp.erb +1 -1
  19. data/integration/pre-suite/00_pe_install.rb +3 -0
  20. data/integration/pre-suite/10_git_config.rb +1 -3
  21. data/integration/tests/Puppetfile/HTTP_PROXY_affects_git_source.rb +5 -4
  22. data/integration/tests/basic_functionality/negative/negative_bad_proxy.rb +1 -1
  23. data/integration/tests/basic_functionality/proxy_specified_in_configuration.rb +2 -2
  24. data/integration/tests/basic_functionality/proxy_with_puppetfile.rb +2 -2
  25. data/integration/tests/basic_functionality/rugged_git_provider_with_ssh.rb +3 -3
  26. data/integration/tests/basic_functionality/rugged_git_provider_without_ssh.rb +3 -3
  27. data/integration/tests/command_line/deploy_env_without_mod_update.rb +0 -3
  28. data/integration/tests/command_line/negative/neg_deploy_env_with_module_update.rb +0 -3
  29. data/integration/tests/git_source/HTTP_proxy_and_git_source.rb +5 -10
  30. data/integration/tests/git_source/git_source_git.rb +1 -4
  31. data/integration/tests/git_source/git_source_repeated_remote.rb +2 -5
  32. data/integration/tests/git_source/git_source_submodule.rb +1 -1
  33. data/integration/tests/git_source/negative/neg_git_unauthorized_ssh.rb +1 -1
  34. data/integration/tests/purging/content_not_purged_at_root.rb +2 -5
  35. data/integration/tests/purging/default_purging.rb +0 -3
  36. data/integration/tests/purging/{does_not_purge_files_on_white_list.rb → does_not_purge_files_on_allowlist.rb} +2 -5
  37. data/integration/tests/user_scenario/basic_workflow/multi_env_custom_forge_git_module.rb +1 -4
  38. data/integration/tests/user_scenario/basic_workflow/multi_env_custom_forge_git_module_static.rb +1 -4
  39. data/integration/tests/user_scenario/basic_workflow/multi_source_custom_forge_git_module.rb +1 -4
  40. data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_forge_module.rb +0 -3
  41. data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_git_module.rb +1 -1
  42. data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_git_module_ref.rb +1 -1
  43. data/integration/tests/user_scenario/basic_workflow/negative/neg_disk_full.rb +1 -1
  44. data/integration/tests/user_scenario/basic_workflow/negative/neg_duplicate_module_names.rb +0 -3
  45. data/integration/tests/user_scenario/basic_workflow/negative/neg_inaccessible_forge.rb +3 -2
  46. data/integration/tests/user_scenario/basic_workflow/negative/neg_specify_deleted_forge_module.rb +1 -5
  47. data/integration/tests/user_scenario/basic_workflow/single_env_10000_files.rb +1 -1
  48. data/integration/tests/user_scenario/basic_workflow/single_env_custom_forge_git_module.rb +1 -4
  49. data/integration/tests/user_scenario/basic_workflow/single_env_custom_forge_module.rb +0 -3
  50. data/integration/tests/user_scenario/basic_workflow/single_env_large_files.rb +1 -1
  51. data/integration/tests/user_scenario/basic_workflow/single_env_module_already_installed.rb +0 -3
  52. data/integration/tests/user_scenario/basic_workflow/single_env_purge_unmanaged_modules.rb +0 -3
  53. data/integration/tests/user_scenario/basic_workflow/single_env_switch_forge_git_module.rb +1 -4
  54. data/integration/tests/user_scenario/basic_workflow/single_env_upgrade_forge_mod_revert_change.rb +0 -3
  55. data/integration/tests/user_scenario/complex_workflow/multi_env_add_change_remove.rb +0 -3
  56. data/lib/r10k/action/deploy/environment.rb +2 -19
  57. data/lib/r10k/action/deploy/module.rb +1 -0
  58. data/lib/r10k/action/puppetfile/check.rb +7 -0
  59. data/lib/r10k/action/puppetfile/install.rb +3 -1
  60. data/lib/r10k/cli/deploy.rb +15 -1
  61. data/lib/r10k/cli/puppetfile.rb +1 -0
  62. data/lib/r10k/content_synchronizer.rb +7 -2
  63. data/lib/r10k/environment/with_modules.rb +24 -1
  64. data/lib/r10k/environment.rb +0 -1
  65. data/lib/r10k/git/rugged/bare_repository.rb +5 -4
  66. data/lib/r10k/git/rugged/thin_repository.rb +7 -0
  67. data/lib/r10k/git/rugged/working_repository.rb +13 -7
  68. data/lib/r10k/git/shellgit/thin_repository.rb +5 -1
  69. data/lib/r10k/git/shellgit/working_repository.rb +5 -4
  70. data/lib/r10k/git/stateful_repository.rb +4 -4
  71. data/lib/r10k/module/base.rb +3 -3
  72. data/lib/r10k/module/git.rb +19 -5
  73. data/lib/r10k/module_loader/puppetfile/dsl.rb +4 -0
  74. data/lib/r10k/module_loader/puppetfile.rb +22 -14
  75. data/lib/r10k/puppetfile.rb +1 -1
  76. data/lib/r10k/settings/container.rb +1 -0
  77. data/lib/r10k/settings.rb +6 -7
  78. data/lib/r10k/tarball.rb +1 -1
  79. data/lib/r10k/version.rb +1 -1
  80. data/locales/r10k.pot +34 -82
  81. data/r10k.gemspec +8 -18
  82. metadata +40 -213
  83. data/.github/workflows/stale.yml +0 -21
  84. data/.travis.yml +0 -42
  85. data/docker/.gitignore +0 -1
  86. data/docker/.rspec +0 -4
  87. data/docker/Gemfile +0 -11
  88. data/docker/Makefile +0 -92
  89. data/docker/README.md +0 -28
  90. data/docker/docker-compose.yml +0 -18
  91. data/docker/r10k/Dockerfile +0 -68
  92. data/docker/r10k/adduser.sh +0 -13
  93. data/docker/r10k/docker-entrypoint.d/10-analytics.sh +0 -30
  94. data/docker/r10k/docker-entrypoint.sh +0 -10
  95. data/docker/r10k/release.Dockerfile +0 -55
  96. data/docker/spec/dockerfile_spec.rb +0 -37
  97. data/docker/spec/fixtures/Puppetfile +0 -2
  98. data/integration/tests/basic_functionality/install_pe_only_module_with_puppetfile.rb +0 -83
  99. data/integration/tests/basic_functionality/proxy_with_pe_only_module.rb +0 -128
  100. data/integration/tests/purging/invalid_whitelist_types.rb +0 -63
  101. data/integration/tests/user_scenario/basic_workflow/negative/neg_module_specified_at_deleted_release.rb +0 -49
  102. data/integration/tests/user_scenario/basic_workflow/single_env_module_last_release_deleted.rb +0 -68
  103. data/lib/r10k/environment/bare.rb +0 -13
  104. data/spec/fixtures/empty/.empty +0 -0
  105. data/spec/fixtures/integration/git/puppet-boolean-bare.tar +0 -0
  106. data/spec/fixtures/module/forge/bad_module/metadata.json +0 -1
  107. data/spec/fixtures/module/forge/eight_hundred/Modulefile +0 -8
  108. data/spec/fixtures/module/forge/eight_hundred/metadata.json +0 -19
  109. data/spec/fixtures/tarball/tarball.tar.gz +0 -0
  110. data/spec/fixtures/unit/action/r10k.yaml +0 -5
  111. data/spec/fixtures/unit/action/r10k_cachedir.yaml +0 -2
  112. data/spec/fixtures/unit/action/r10k_creds.yaml +0 -9
  113. data/spec/fixtures/unit/action/r10k_forge_auth.yaml +0 -4
  114. data/spec/fixtures/unit/action/r10k_forge_auth_no_url.yaml +0 -3
  115. data/spec/fixtures/unit/action/r10k_generate_types.yaml +0 -3
  116. data/spec/fixtures/unit/action/r10k_logging.yaml +0 -12
  117. data/spec/fixtures/unit/action/r10k_puppet_path.yaml +0 -3
  118. data/spec/fixtures/unit/puppetfile/argument-error/Puppetfile +0 -1
  119. data/spec/fixtures/unit/puppetfile/default-branch-override/Puppetfile +0 -5
  120. data/spec/fixtures/unit/puppetfile/duplicate-module-error/Puppetfile +0 -10
  121. data/spec/fixtures/unit/puppetfile/forge-override/Puppetfile +0 -8
  122. data/spec/fixtures/unit/puppetfile/invalid-syntax/Puppetfile +0 -1
  123. data/spec/fixtures/unit/puppetfile/load-error/Puppetfile +0 -1
  124. data/spec/fixtures/unit/puppetfile/name-error/Puppetfile +0 -1
  125. data/spec/fixtures/unit/puppetfile/valid-forge-with-version/Puppetfile +0 -1
  126. data/spec/fixtures/unit/puppetfile/valid-forge-without-version/Puppetfile +0 -1
  127. data/spec/fixtures/unit/puppetfile/various-modules/Puppetfile +0 -10
  128. data/spec/fixtures/unit/puppetfile/various-modules/Puppetfile.new +0 -10
  129. data/spec/fixtures/unit/util/purgeable/managed_one/expected_1 +0 -0
  130. data/spec/fixtures/unit/util/purgeable/managed_one/managed_subdir_1/managed_symlink_file +0 -1
  131. data/spec/fixtures/unit/util/purgeable/managed_one/managed_subdir_1/subdir_allowlisted_2/ignored_1 +0 -0
  132. data/spec/fixtures/unit/util/purgeable/managed_one/managed_subdir_1/subdir_expected_1 +0 -0
  133. data/spec/fixtures/unit/util/purgeable/managed_one/managed_subdir_1/subdir_unmanaged_1 +0 -0
  134. data/spec/fixtures/unit/util/purgeable/managed_one/managed_subdir_1/unmanaged_symlink_dir +0 -1
  135. data/spec/fixtures/unit/util/purgeable/managed_one/managed_symlink_dir +0 -1
  136. data/spec/fixtures/unit/util/purgeable/managed_one/unmanaged_1 +0 -0
  137. data/spec/fixtures/unit/util/purgeable/managed_one/unmanaged_symlink_file +0 -1
  138. data/spec/fixtures/unit/util/purgeable/managed_two/.hidden/unmanaged_3 +0 -0
  139. data/spec/fixtures/unit/util/purgeable/managed_two/expected_2 +0 -0
  140. data/spec/fixtures/unit/util/purgeable/managed_two/unmanaged_2 +0 -0
  141. data/spec/fixtures/unit/util/subprocess/runner/no-execute.sh +0 -3
  142. data/spec/integration/git/rugged/bare_repository_spec.rb +0 -13
  143. data/spec/integration/git/rugged/cache_spec.rb +0 -33
  144. data/spec/integration/git/rugged/thin_repository_spec.rb +0 -14
  145. data/spec/integration/git/rugged/working_repository_spec.rb +0 -48
  146. data/spec/integration/git/shellgit/bare_repository_spec.rb +0 -13
  147. data/spec/integration/git/shellgit/thin_repository_spec.rb +0 -14
  148. data/spec/integration/git/shellgit/working_repository_spec.rb +0 -13
  149. data/spec/integration/git/stateful_repository_spec.rb +0 -159
  150. data/spec/integration/util/purageable_spec.rb +0 -41
  151. data/spec/matchers/exit_with.rb +0 -28
  152. data/spec/matchers/match_realpath.rb +0 -18
  153. data/spec/r10k-mocks/mock_config.rb +0 -33
  154. data/spec/r10k-mocks/mock_env.rb +0 -18
  155. data/spec/r10k-mocks/mock_source.rb +0 -17
  156. data/spec/r10k-mocks.rb +0 -3
  157. data/spec/shared-contexts/git-fixtures.rb +0 -55
  158. data/spec/shared-contexts/tarball.rb +0 -32
  159. data/spec/shared-examples/deploy-actions.rb +0 -69
  160. data/spec/shared-examples/git/bare_repository.rb +0 -132
  161. data/spec/shared-examples/git/thin_repository.rb +0 -26
  162. data/spec/shared-examples/git/working_repository.rb +0 -207
  163. data/spec/shared-examples/git-repository.rb +0 -38
  164. data/spec/shared-examples/puppetfile-action.rb +0 -39
  165. data/spec/shared-examples/settings/ancestry.rb +0 -44
  166. data/spec/shared-examples/subprocess-runner.rb +0 -89
  167. data/spec/spec_helper.rb +0 -41
  168. data/spec/unit/action/cri_runner_spec.rb +0 -72
  169. data/spec/unit/action/deploy/deploy_helpers_spec.rb +0 -38
  170. data/spec/unit/action/deploy/display_spec.rb +0 -61
  171. data/spec/unit/action/deploy/environment_spec.rb +0 -640
  172. data/spec/unit/action/deploy/module_spec.rb +0 -476
  173. data/spec/unit/action/puppetfile/check_spec.rb +0 -53
  174. data/spec/unit/action/puppetfile/cri_runner_spec.rb +0 -47
  175. data/spec/unit/action/puppetfile/install_spec.rb +0 -112
  176. data/spec/unit/action/puppetfile/purge_spec.rb +0 -60
  177. data/spec/unit/action/runner_spec.rb +0 -407
  178. data/spec/unit/action/visitor_spec.rb +0 -39
  179. data/spec/unit/cli_spec.rb +0 -9
  180. data/spec/unit/deployment/config_spec.rb +0 -33
  181. data/spec/unit/deployment_spec.rb +0 -162
  182. data/spec/unit/environment/bare_spec.rb +0 -13
  183. data/spec/unit/environment/base_spec.rb +0 -122
  184. data/spec/unit/environment/git_spec.rb +0 -114
  185. data/spec/unit/environment/name_spec.rb +0 -181
  186. data/spec/unit/environment/plain_spec.rb +0 -8
  187. data/spec/unit/environment/svn_spec.rb +0 -146
  188. data/spec/unit/environment/tarball_spec.rb +0 -45
  189. data/spec/unit/environment/with_modules_spec.rb +0 -75
  190. data/spec/unit/errors/formatting_spec.rb +0 -84
  191. data/spec/unit/feature_spec.rb +0 -50
  192. data/spec/unit/forge/module_release_spec.rb +0 -213
  193. data/spec/unit/git/alternates_spec.rb +0 -116
  194. data/spec/unit/git/cache_spec.rb +0 -66
  195. data/spec/unit/git/rugged/cache_spec.rb +0 -48
  196. data/spec/unit/git/rugged/credentials_spec.rb +0 -215
  197. data/spec/unit/git/shellgit/cache_spec.rb +0 -27
  198. data/spec/unit/git/stateful_repository_spec.rb +0 -45
  199. data/spec/unit/git_spec.rb +0 -102
  200. data/spec/unit/initializers_spec.rb +0 -68
  201. data/spec/unit/instance_cache_spec.rb +0 -78
  202. data/spec/unit/keyed_factory_spec.rb +0 -51
  203. data/spec/unit/logging/terminaloutputter_spec.rb +0 -53
  204. data/spec/unit/logging_spec.rb +0 -68
  205. data/spec/unit/module/base_spec.rb +0 -118
  206. data/spec/unit/module/forge_spec.rb +0 -271
  207. data/spec/unit/module/git_spec.rb +0 -387
  208. data/spec/unit/module/metadata_file_spec.rb +0 -68
  209. data/spec/unit/module/svn_spec.rb +0 -208
  210. data/spec/unit/module/tarball_spec.rb +0 -70
  211. data/spec/unit/module_loader/puppetfile_spec.rb +0 -421
  212. data/spec/unit/module_spec.rb +0 -114
  213. data/spec/unit/puppetfile_spec.rb +0 -304
  214. data/spec/unit/settings/collection_spec.rb +0 -123
  215. data/spec/unit/settings/container_spec.rb +0 -92
  216. data/spec/unit/settings/definition_spec.rb +0 -79
  217. data/spec/unit/settings/enum_definition_spec.rb +0 -20
  218. data/spec/unit/settings/inheritance_spec.rb +0 -38
  219. data/spec/unit/settings/list_spec.rb +0 -88
  220. data/spec/unit/settings/loader_spec.rb +0 -110
  221. data/spec/unit/settings/uri_definition_spec.rb +0 -23
  222. data/spec/unit/settings_spec.rb +0 -303
  223. data/spec/unit/source/base_spec.rb +0 -31
  224. data/spec/unit/source/exec_spec.rb +0 -81
  225. data/spec/unit/source/git_spec.rb +0 -233
  226. data/spec/unit/source/hash_spec.rb +0 -54
  227. data/spec/unit/source/svn_spec.rb +0 -196
  228. data/spec/unit/source/yaml_spec.rb +0 -42
  229. data/spec/unit/source_spec.rb +0 -10
  230. data/spec/unit/svn/remote_spec.rb +0 -21
  231. data/spec/unit/svn/working_dir_spec.rb +0 -56
  232. data/spec/unit/tarball_spec.rb +0 -57
  233. data/spec/unit/util/attempt_spec.rb +0 -82
  234. data/spec/unit/util/cacheable_spec.rb +0 -23
  235. data/spec/unit/util/commands_spec.rb +0 -61
  236. data/spec/unit/util/downloader_spec.rb +0 -98
  237. data/spec/unit/util/exec_env_spec.rb +0 -56
  238. data/spec/unit/util/purgeable_spec.rb +0 -267
  239. data/spec/unit/util/setopts_spec.rb +0 -83
  240. data/spec/unit/util/subprocess/result_spec.rb +0 -36
  241. data/spec/unit/util/subprocess/runner/posix_spec.rb +0 -7
  242. data/spec/unit/util/subprocess/runner/pump_spec.rb +0 -79
  243. data/spec/unit/util/subprocess/runner/windows_spec.rb +0 -7
  244. data/spec/unit/util/subprocess/subprocess_error_spec.rb +0 -26
  245. data/spec/unit/util/subprocess_spec.rb +0 -65
  246. data/spec/unit/util/symbolize_keys_spec.rb +0 -67
@@ -1,421 +0,0 @@
1
- require 'spec_helper'
2
- require 'r10k/module_loader/puppetfile'
3
- require 'tmpdir'
4
-
5
- describe R10K::ModuleLoader::Puppetfile do
6
- describe 'initial parameters' do
7
- describe 'honor' do
8
- let(:options) do
9
- {
10
- basedir: '/test/basedir/env',
11
- overrides: { modules: { deploy_modules: true } },
12
- environment: R10K::Environment::Git.new('env',
13
- '/test/basedir/',
14
- 'env',
15
- { remote: 'git://foo/remote',
16
- ref: 'env' })
17
- }
18
- end
19
-
20
- subject { R10K::ModuleLoader::Puppetfile.new(**options) }
21
-
22
- describe 'the moduledir' do
23
- it 'respects absolute paths' do
24
- absolute_options = options.merge({moduledir: '/opt/puppetlabs/special/modules'})
25
- puppetfile = R10K::ModuleLoader::Puppetfile.new(**absolute_options)
26
- expect(puppetfile.instance_variable_get(:@moduledir)).to eq('/opt/puppetlabs/special/modules')
27
- end
28
-
29
- it 'roots the moduledir in the basepath if a relative path is specified' do
30
- relative_options = options.merge({moduledir: 'my/special/modules'})
31
- puppetfile = R10K::ModuleLoader::Puppetfile.new(**relative_options)
32
- expect(puppetfile.instance_variable_get(:@moduledir)).to eq('/test/basedir/env/my/special/modules')
33
- end
34
- end
35
-
36
- describe 'the Puppetfile' do
37
- it 'respects absolute paths' do
38
- absolute_options = options.merge({puppetfile: '/opt/puppetlabs/special/Puppetfile'})
39
- puppetfile = R10K::ModuleLoader::Puppetfile.new(**absolute_options)
40
- expect(puppetfile.instance_variable_get(:@puppetfile_path)).to eq('/opt/puppetlabs/special/Puppetfile')
41
- end
42
-
43
- it 'roots the Puppetfile in the basepath if a relative path is specified' do
44
- relative_options = options.merge({puppetfile: 'Puppetfile.global'})
45
- puppetfile = R10K::ModuleLoader::Puppetfile.new(**relative_options)
46
- expect(puppetfile.instance_variable_get(:@puppetfile_path)).to eq('/test/basedir/env/Puppetfile.global')
47
- end
48
- end
49
-
50
- it 'the overrides' do
51
- expect(subject.instance_variable_get(:@overrides)).to eq({ modules: { deploy_modules: true }})
52
- end
53
-
54
- it 'the environment' do
55
- expect(subject.instance_variable_get(:@environment).name).to eq('env')
56
- end
57
- end
58
-
59
- describe 'sane defaults' do
60
- subject { R10K::ModuleLoader::Puppetfile.new(basedir: '/test/basedir') }
61
-
62
- it 'has a moduledir rooted in the basedir' do
63
- expect(subject.instance_variable_get(:@moduledir)).to eq('/test/basedir/modules')
64
- end
65
-
66
- it 'has a Puppetfile rooted in the basedir' do
67
- expect(subject.instance_variable_get(:@puppetfile_path)).to eq('/test/basedir/Puppetfile')
68
- end
69
-
70
- it 'creates an empty overrides' do
71
- expect(subject.instance_variable_get(:@overrides)).to eq({})
72
- end
73
-
74
- it 'does not require an environment' do
75
- expect(subject.instance_variable_get(:@environment)).to eq(nil)
76
- end
77
- end
78
- end
79
-
80
- describe 'adding modules' do
81
- let(:basedir) { '/test/basedir' }
82
-
83
- subject { R10K::ModuleLoader::Puppetfile.new(basedir: basedir,
84
- overrides: {modules: {exclude_spec: true}}) }
85
-
86
- it 'should transform Forge modules with a string arg to have a version key' do
87
- expect(R10K::Module).to receive(:from_metadata).with('puppet/test_module', subject.moduledir, hash_including(version: '1.2.3'), anything).and_call_original
88
-
89
- expect { subject.add_module('puppet/test_module', '1.2.3') }.to change { subject.modules }
90
- expect(subject.modules.collect(&:name)).to include('test_module')
91
- end
92
-
93
- it 'should not accept Forge modules with a version comparison' do
94
- expect(R10K::Module).to receive(:from_metadata).with('puppet/test_module', subject.moduledir, hash_including(version: '< 1.2.0'), anything).and_call_original
95
-
96
- expect {
97
- subject.add_module('puppet/test_module', '< 1.2.0')
98
- }.to raise_error(ArgumentError, /module version .* is not a valid forge module version/i)
99
-
100
- expect(subject.modules.collect(&:name)).not_to include('test_module')
101
- end
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
-
115
- it 'should set :spec_deletable to true for modules in the basedir' do
116
- module_opts = { git: 'git@example.com:puppet/test_module.git' }
117
- subject.add_module('puppet/test_module', module_opts)
118
- expect(subject.modules[0].spec_deletable).to be true
119
- end
120
-
121
- it 'should set :spec_deletable to false for modules outside the basedir' do
122
- module_opts = { git: 'git@example.com:puppet/test_module.git', install_path: 'some/path' }
123
- subject.add_module('puppet/test_module', module_opts)
124
- expect(subject.modules[0].spec_deletable).to be false
125
- end
126
-
127
- it 'should accept non-Forge modules with a hash arg' do
128
- module_opts = { git: 'git@example.com:puppet/test_module.git' }
129
-
130
- expect(R10K::Module).to receive(:from_metadata).with('puppet/test_module', subject.moduledir, module_opts, anything).and_call_original
131
-
132
- expect { subject.add_module('puppet/test_module', module_opts) }.to change { subject.modules }
133
- expect(subject.modules.collect(&:name)).to include('test_module')
134
- end
135
-
136
- it 'should accept non-Forge modules with a valid relative :install_path option' do
137
- module_opts = {
138
- install_path: 'vendor',
139
- git: 'git@example.com:puppet/test_module.git',
140
- }
141
-
142
- expect(R10K::Module).to receive(:from_metadata).with('puppet/test_module', File.join(basedir, 'vendor'), module_opts, anything).and_call_original
143
-
144
- expect { subject.add_module('puppet/test_module', module_opts) }.to change { subject.modules }
145
- expect(subject.modules.collect(&:name)).to include('test_module')
146
- end
147
-
148
- it 'should accept non-Forge modules with a valid absolute :install_path option' do
149
- install_path = File.join(basedir, 'vendor')
150
-
151
- module_opts = {
152
- install_path: install_path,
153
- git: 'git@example.com:puppet/test_module.git',
154
- }
155
-
156
- expect(R10K::Module).to receive(:from_metadata).with('puppet/test_module', install_path, module_opts, anything).and_call_original
157
-
158
- expect { subject.add_module('puppet/test_module', module_opts) }.to change { subject.modules }
159
- expect(subject.modules.collect(&:name)).to include('test_module')
160
- end
161
-
162
- it 'should reject non-Forge modules with an invalid relative :install_path option' do
163
- module_opts = {
164
- install_path: '../../vendor',
165
- git: 'git@example.com:puppet/test_module.git',
166
- }
167
-
168
- expect { subject.add_module('puppet/test_module', module_opts) }.to raise_error(R10K::Error, /cannot manage content.*is not within/i).and not_change { subject.modules }
169
- end
170
-
171
- it 'should reject non-Forge modules with an invalid absolute :install_path option' do
172
- module_opts = {
173
- install_path: '/tmp/mydata/vendor',
174
- git: 'git@example.com:puppet/test_module.git',
175
- }
176
-
177
- expect { subject.add_module('puppet/test_module', module_opts) }.to raise_error(R10K::Error, /cannot manage content.*is not within/i).and not_change { subject.modules }
178
- end
179
-
180
- it 'should disable and not add modules that conflict with the environment' do
181
- env = instance_double('R10K::Environment::Base')
182
- mod = instance_double('R10K::Module::Base', name: 'conflict', origin: :puppetfile, 'origin=': nil)
183
- allow(env).to receive(:name).and_return('conflict')
184
- loader = R10K::ModuleLoader::Puppetfile.new(basedir: basedir, environment: env)
185
- allow(env).to receive(:'module_conflicts?').with(mod).and_return(true)
186
- allow(mod).to receive(:spec_deletable=)
187
-
188
- expect(R10K::Module).to receive(:from_metadata).with('conflict', anything, anything, anything).and_return(mod)
189
- expect { loader.add_module('conflict', {}) }.not_to change { loader.modules }
190
- end
191
- end
192
-
193
- describe '#purge_exclusions' do
194
- let(:managed_dirs) { ['dir1', 'dir2'] }
195
- subject { R10K::ModuleLoader::Puppetfile.new(basedir: '/test/basedir') }
196
-
197
- it 'includes managed_directories' do
198
- expect(subject.send(:determine_purge_exclusions, managed_dirs)).to match_array(managed_dirs)
199
- end
200
-
201
- context 'when belonging to an environment' do
202
- let(:env_contents) { ['env1', 'env2' ] }
203
- let(:env) { double(:environment, desired_contents: env_contents) }
204
- before {
205
- allow(env).to receive(:name).and_return('env1')
206
- }
207
- subject { R10K::ModuleLoader::Puppetfile.new(basedir: '/test/basedir', environment: env) }
208
-
209
- it "includes environment's desired_contents" do
210
- expect(subject.send(:determine_purge_exclusions, managed_dirs)).to match_array(managed_dirs + env_contents)
211
- end
212
- end
213
- end
214
-
215
- describe '#managed_directories' do
216
-
217
- let(:basedir) { '/test/basedir' }
218
- subject { R10K::ModuleLoader::Puppetfile.new(basedir: basedir) }
219
-
220
- before do
221
- allow(subject).to receive(:puppetfile_content).and_return('')
222
- end
223
-
224
- it 'returns an array of paths that #purge! will operate within' do
225
- expect(R10K::Module).to receive(:from_metadata).with('puppet/test_module', subject.moduledir, hash_including(version: '1.2.3'), anything).and_call_original
226
- subject.add_module('puppet/test_module', '1.2.3')
227
- subject.load!
228
-
229
- expect(subject.modules.length).to be 1
230
- expect(subject.managed_directories).to match_array([subject.moduledir])
231
- end
232
-
233
- context "with a module with install_path == ''" do
234
- it "basedir isn't in the list of paths to purge" do
235
- module_opts = { install_path: '', git: 'git@example.com:puppet/test_module.git' }
236
-
237
- expect(R10K::Module).to receive(:from_metadata).with('puppet/test_module', basedir, module_opts, anything).and_call_original
238
- subject.add_module('puppet/test_module', module_opts)
239
- subject.load!
240
-
241
- expect(subject.modules.length).to be 1
242
- expect(subject.managed_directories).to be_empty
243
- end
244
- end
245
- end
246
-
247
- describe 'evaluating a Puppetfile' do
248
- def expect_wrapped_error(error, pf_path, error_type)
249
- expect(error).to be_a_kind_of(R10K::Error)
250
- expect(error.message).to eq("Failed to evaluate #{pf_path}")
251
- expect(error.original).to be_a_kind_of(error_type)
252
- end
253
-
254
- subject { described_class.new(basedir: @path) }
255
-
256
- it 'wraps and re-raises syntax errors' do
257
- @path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'invalid-syntax')
258
- pf_path = File.join(@path, 'Puppetfile')
259
- expect {
260
- subject.load!
261
- }.to raise_error do |e|
262
- expect_wrapped_error(e, pf_path, SyntaxError)
263
- end
264
- end
265
-
266
- it 'wraps and re-raises load errors' do
267
- @path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'load-error')
268
- pf_path = File.join(@path, 'Puppetfile')
269
- expect {
270
- subject.load!
271
- }.to raise_error do |e|
272
- expect_wrapped_error(e, pf_path, LoadError)
273
- end
274
- end
275
-
276
- it 'wraps and re-raises argument errors' do
277
- @path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'argument-error')
278
- pf_path = File.join(@path, 'Puppetfile')
279
- expect {
280
- subject.load!
281
- }.to raise_error do |e|
282
- expect_wrapped_error(e, pf_path, ArgumentError)
283
- end
284
- end
285
-
286
- describe 'forge declaration' do
287
- before(:each) do
288
- PuppetForge.host = ""
289
- end
290
-
291
- it 'is respected if `allow_puppetfile_override` is true' do
292
- @path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'forge-override')
293
- puppetfile = R10K::ModuleLoader::Puppetfile.new(basedir: @path, overrides: { forge: { allow_puppetfile_override: true } })
294
- puppetfile.load!
295
- expect(PuppetForge.host).to eq("my.custom.forge.com/")
296
- end
297
-
298
- it 'is ignored if `allow_puppetfile_override` is false' do
299
- @path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'forge-override')
300
- puppetfile = R10K::ModuleLoader::Puppetfile.new(basedir: @path, overrides: { forge: { allow_puppetfile_override: false } })
301
- expect(PuppetForge).not_to receive(:host=).with("my.custom.forge.com")
302
- puppetfile.load!
303
- expect(PuppetForge.host).to eq("/")
304
- end
305
- end
306
-
307
- it 'rejects Puppetfiles with duplicate module names' do
308
- @path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'duplicate-module-error')
309
- pf_path = File.join(@path, 'Puppetfile')
310
- expect {
311
- subject.load!
312
- }.to raise_error(R10K::Error, /Puppetfiles cannot contain duplicate module names/i)
313
- end
314
-
315
- it 'wraps and re-raises name errors' do
316
- @path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'name-error')
317
- pf_path = File.join(@path, 'Puppetfile')
318
- expect {
319
- subject.load!
320
- }.to raise_error do |e|
321
- expect_wrapped_error(e, pf_path, NameError)
322
- end
323
- end
324
-
325
- it 'accepts a forge module with a version' do
326
- @path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'valid-forge-with-version')
327
- pf_path = File.join(@path, 'Puppetfile')
328
- expect { subject.load! }.not_to raise_error
329
- end
330
-
331
- describe 'setting a custom moduledir' do
332
- it 'allows setting an absolute moduledir' do
333
- @path = '/fake/basedir'
334
- allow(subject).to receive(:puppetfile_content).and_return('moduledir "/fake/moduledir"')
335
- subject.load!
336
- expect(subject.instance_variable_get(:@moduledir)).to eq('/fake/moduledir')
337
- end
338
-
339
- it 'roots relative moduledirs in the basedir' do
340
- @path = '/fake/basedir'
341
- allow(subject).to receive(:puppetfile_content).and_return('moduledir "my/moduledir"')
342
- subject.load!
343
- expect(subject.instance_variable_get(:@moduledir)).to eq(File.join(@path, 'my/moduledir'))
344
- end
345
- end
346
-
347
- it 'accepts a forge module without a version' do
348
- @path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'valid-forge-without-version')
349
- pf_path = File.join(@path, 'Puppetfile')
350
- expect { subject.load! }.not_to raise_error
351
- end
352
-
353
- it 'creates a git module and applies the default branch specified in the Puppetfile' do
354
- @path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'default-branch-override')
355
- pf_path = File.join(@path, 'Puppetfile')
356
- expect { subject.load! }.not_to raise_error
357
- git_module = subject.modules[0]
358
- expect(git_module.default_ref).to eq 'here_lies_the_default_branch'
359
- end
360
-
361
- it 'creates a git module and applies the provided default_branch_override' do
362
- @path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'default-branch-override')
363
- pf_path = File.join(@path, 'Puppetfile')
364
- default_branch_override = 'default_branch_override_name'
365
- subject.default_branch_override = default_branch_override
366
- expect { subject.load! }.not_to raise_error
367
- git_module = subject.modules[0]
368
- expect(git_module.default_override_ref).to eq default_branch_override
369
- expect(git_module.default_ref).to eq 'here_lies_the_default_branch'
370
- end
371
-
372
- describe 'using module metadata' do
373
- it 'properly loads module metadata' do
374
- @path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'various-modules')
375
- metadata = subject.load_metadata[:modules].map { |mod| [ mod.name, mod.version ] }.to_h
376
- expect(metadata['apt']).to eq('2.1.1')
377
- expect(metadata['stdlib']).to eq(nil)
378
- expect(metadata['concat']).to eq(nil)
379
- expect(metadata['rpm']).to eq('2.1.1-pre1')
380
- expect(metadata['foo']).to eq(nil)
381
- expect(metadata['bar']).to eq('v1.2.3')
382
- expect(metadata['baz']).to eq('123abc456')
383
- expect(metadata['fizz']).to eq('1234567890abcdef1234567890abcdef12345678')
384
- expect(metadata['buzz']).to eq(nil)
385
- expect(metadata['canary']).to eq('0.0.0')
386
- end
387
-
388
- it 'does not load module implementations for static versioned' do
389
- @path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'various-modules')
390
- subject.load_metadata
391
- modules = subject.load[:modules].map { |mod| [ mod.name, mod ] }.to_h
392
- expect(modules['apt']).to be_a_kind_of(R10K::Module::Definition)
393
- expect(modules['stdlib']).to be_a_kind_of(R10K::Module::Forge)
394
- expect(modules['concat']).to be_a_kind_of(R10K::Module::Forge)
395
- expect(modules['rpm']).to be_a_kind_of(R10K::Module::Definition)
396
- expect(modules['foo']).to be_a_kind_of(R10K::Module::Git)
397
- expect(modules['bar']).to be_a_kind_of(R10K::Module::Definition)
398
- expect(modules['baz']).to be_a_kind_of(R10K::Module::Definition)
399
- expect(modules['fizz']).to be_a_kind_of(R10K::Module::Definition)
400
- expect(modules['buzz']).to be_a_kind_of(R10K::Module::Git)
401
- expect(modules['canary']).to be_a_kind_of(R10K::Module::Definition)
402
- end
403
-
404
- it 'loads module implementations whose static versions are different' do
405
- fixture_path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'various-modules')
406
- @path = Dir.mktmpdir
407
- unsynced_pf_path = File.join(fixture_path, 'Puppetfile')
408
- FileUtils.cp(unsynced_pf_path, @path)
409
-
410
- subject.load_metadata
411
-
412
- synced_pf_path = File.join(fixture_path, 'Puppetfile.new')
413
- FileUtils.cp(synced_pf_path, File.join(@path, 'Puppetfile'))
414
-
415
- modules = subject.load[:modules].map { |mod| [ mod.name, mod ] }.to_h
416
-
417
- expect(modules['apt']).to be_a_kind_of(R10K::Module::Forge)
418
- end
419
- end
420
- end
421
- end
@@ -1,114 +0,0 @@
1
- require 'spec_helper'
2
- require 'r10k/module'
3
-
4
- describe R10K::Module do
5
- describe 'delegating to R10K::Module::Git' do
6
- [ {git: 'git url'},
7
- {type: 'git', source: 'git url'},
8
- ].each do |scenario|
9
- it "accepts a name matching 'test' and args #{scenario.inspect}" do
10
- obj = R10K::Module.new('test', '/modulepath', scenario)
11
- expect(obj).to be_a_kind_of(R10K::Module::Git)
12
- expect(obj.send(:instance_variable_get, :'@remote')).to eq('git url')
13
- end
14
- end
15
- end
16
-
17
- describe 'delegating to R10K::Module::Svn' do
18
- [ {svn: 'svn url'},
19
- {type: 'svn', source: 'svn url'},
20
- ].each do |scenario|
21
- it "accepts a name matching 'test' and args #{scenario.inspect}" do
22
- obj = R10K::Module.new('test', '/modulepath', scenario)
23
- expect(obj).to be_a_kind_of(R10K::Module::SVN)
24
- expect(obj.send(:instance_variable_get, :'@url')).to eq('svn url')
25
- end
26
- end
27
- end
28
-
29
- describe 'delegating to R10K::Module::Forge' do
30
- [ 'bar/quux',
31
- 'bar-quux',
32
- ].each do |scenario|
33
- it "accepts a name matching #{scenario} and version nil" do
34
- obj = R10K::Module.new(scenario, '/modulepath', { type: 'forge', version: nil })
35
- expect(obj).to be_a_kind_of(R10K::Module::Forge)
36
- end
37
- end
38
- [ {type: 'forge', version: '8.0.0'},
39
- ].each do |scenario|
40
- it "accepts a name matching bar-quux and args #{scenario.inspect}" do
41
- obj = R10K::Module.new('bar-quux', '/modulepath', scenario)
42
- expect(obj).to be_a_kind_of(R10K::Module::Forge)
43
- expect(obj.send(:instance_variable_get, :'@expected_version')).to eq('8.0.0')
44
- end
45
- end
46
-
47
- describe 'when the module is ostensibly on disk' do
48
- before do
49
- owner = 'theowner'
50
- module_name = 'themodulename'
51
- @title = "#{owner}-#{module_name}"
52
- metadata = <<~METADATA
53
- {
54
- "name": "#{@title}",
55
- "version": "1.2.0"
56
- }
57
- METADATA
58
- @dirname = Dir.mktmpdir
59
- module_path = File.join(@dirname, module_name)
60
- FileUtils.mkdir(module_path)
61
- File.open("#{module_path}/metadata.json", 'w') do |file|
62
- file.write(metadata)
63
- end
64
- end
65
-
66
- it 'sets the expected version to what is found in the metadata' do
67
- obj = R10K::Module.new(@title, @dirname, {type: 'forge', version: nil})
68
- expect(obj.send(:instance_variable_get, :'@expected_version')).to eq('1.2.0')
69
- end
70
- end
71
- end
72
-
73
- it "raises an error if delegation fails" do
74
- expect {
75
- R10K::Module.new('bar!quux', '/modulepath', {version: ["NOPE NOPE NOPE NOPE!"]})
76
- }.to raise_error RuntimeError, /doesn't have an implementation/
77
- end
78
-
79
- describe 'Given a set of initialization parameters for R10K::Module' do
80
- [ ['name', {git: 'git url'}],
81
- ['name', {type: 'git', source: 'git url'}],
82
- ['name', {svn: 'svn url'}],
83
- ['name', {type: 'svn', source: 'svn url'}],
84
- ['namespace-name', {type: 'forge', version: '8.0.0'}]
85
- ].each do |(name, options)|
86
- it 'can handle the default_branch_override option' do
87
- expect {
88
- obj = R10K::Module.new(name, '/modulepath', options.merge({default_branch_override: 'foo'}))
89
- expect(obj).to be_a_kind_of(R10K::Module::Base)
90
- }.not_to raise_error
91
- end
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
97
- it 'sets the exclude_spec instance variable' do
98
- obj = R10K::Module.new(name, '/modulepath', options.merge({exclude_spec: true}))
99
- expect(obj.instance_variable_get("@exclude_spec")).to eq(true)
100
- end
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}}})
108
- obj = R10K::Module.new(name, '/modulepath', options)
109
- expect(obj.instance_variable_get("@exclude_spec")).to eq(true)
110
- end
111
- end
112
- end
113
- end
114
- end