r10k 3.15.0 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (240) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +17 -0
  3. data/.github/workflows/docker.yml +4 -4
  4. data/.github/workflows/release.yml +2 -2
  5. data/.github/workflows/rspec_tests.yml +10 -11
  6. data/.github/workflows/stale.yml +1 -1
  7. data/CHANGELOG.mkd +66 -0
  8. data/CODEOWNERS +1 -2
  9. data/Gemfile +2 -2
  10. data/README.mkd +16 -17
  11. data/doc/common-patterns.mkd +1 -2
  12. data/doc/dynamic-environments/configuration.mkd +78 -2
  13. data/doc/puppetfile.mkd +9 -3
  14. data/integration/Gemfile +1 -1
  15. data/integration/Rakefile +1 -1
  16. data/integration/files/pre-suite/git_config.pp.erb +1 -1
  17. data/integration/pre-suite/00_pe_install.rb +3 -0
  18. data/integration/pre-suite/10_git_config.rb +0 -3
  19. data/integration/tests/Puppetfile/HTTP_PROXY_affects_git_source.rb +5 -4
  20. data/integration/tests/basic_functionality/negative/negative_bad_proxy.rb +1 -1
  21. data/integration/tests/basic_functionality/proxy_specified_in_configuration.rb +2 -2
  22. data/integration/tests/basic_functionality/proxy_with_puppetfile.rb +2 -2
  23. data/integration/tests/basic_functionality/rugged_git_provider_with_ssh.rb +3 -3
  24. data/integration/tests/basic_functionality/rugged_git_provider_without_ssh.rb +3 -3
  25. data/integration/tests/command_line/deploy_env_without_mod_update.rb +0 -3
  26. data/integration/tests/command_line/negative/neg_deploy_env_with_module_update.rb +0 -3
  27. data/integration/tests/git_source/HTTP_proxy_and_git_source.rb +5 -10
  28. data/integration/tests/git_source/git_source_git.rb +1 -4
  29. data/integration/tests/git_source/git_source_repeated_remote.rb +0 -3
  30. data/integration/tests/git_source/git_source_submodule.rb +1 -1
  31. data/integration/tests/git_source/negative/neg_git_unauthorized_ssh.rb +1 -1
  32. data/integration/tests/purging/content_not_purged_at_root.rb +0 -3
  33. data/integration/tests/purging/default_purging.rb +0 -3
  34. data/integration/tests/purging/{does_not_purge_files_on_white_list.rb → does_not_purge_files_on_allowlist.rb} +2 -5
  35. data/integration/tests/user_scenario/basic_workflow/multi_env_custom_forge_git_module.rb +0 -3
  36. data/integration/tests/user_scenario/basic_workflow/multi_env_custom_forge_git_module_static.rb +0 -3
  37. data/integration/tests/user_scenario/basic_workflow/multi_source_custom_forge_git_module.rb +0 -3
  38. data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_forge_module.rb +0 -3
  39. data/integration/tests/user_scenario/basic_workflow/negative/neg_disk_full.rb +1 -1
  40. data/integration/tests/user_scenario/basic_workflow/negative/neg_duplicate_module_names.rb +0 -3
  41. data/integration/tests/user_scenario/basic_workflow/negative/neg_inaccessible_forge.rb +3 -2
  42. data/integration/tests/user_scenario/basic_workflow/negative/neg_specify_deleted_forge_module.rb +1 -5
  43. data/integration/tests/user_scenario/basic_workflow/single_env_10000_files.rb +1 -1
  44. data/integration/tests/user_scenario/basic_workflow/single_env_custom_forge_git_module.rb +0 -3
  45. data/integration/tests/user_scenario/basic_workflow/single_env_custom_forge_module.rb +0 -3
  46. data/integration/tests/user_scenario/basic_workflow/single_env_large_files.rb +1 -1
  47. data/integration/tests/user_scenario/basic_workflow/single_env_module_already_installed.rb +0 -3
  48. data/integration/tests/user_scenario/basic_workflow/single_env_purge_unmanaged_modules.rb +0 -3
  49. data/integration/tests/user_scenario/basic_workflow/single_env_switch_forge_git_module.rb +0 -3
  50. data/integration/tests/user_scenario/basic_workflow/single_env_upgrade_forge_mod_revert_change.rb +0 -3
  51. data/integration/tests/user_scenario/complex_workflow/multi_env_add_change_remove.rb +0 -3
  52. data/lib/r10k/action/deploy/environment.rb +2 -19
  53. data/lib/r10k/action/deploy/module.rb +1 -0
  54. data/lib/r10k/action/puppetfile/check.rb +7 -0
  55. data/lib/r10k/action/puppetfile/install.rb +3 -1
  56. data/lib/r10k/cli/deploy.rb +15 -1
  57. data/lib/r10k/cli/puppetfile.rb +1 -0
  58. data/lib/r10k/content_synchronizer.rb +7 -2
  59. data/lib/r10k/environment.rb +0 -1
  60. data/lib/r10k/git/rugged/bare_repository.rb +4 -3
  61. data/lib/r10k/git/rugged/working_repository.rb +7 -5
  62. data/lib/r10k/git/shellgit/working_repository.rb +3 -3
  63. data/lib/r10k/git/stateful_repository.rb +2 -2
  64. data/lib/r10k/module/base.rb +3 -3
  65. data/lib/r10k/module/git.rb +18 -4
  66. data/lib/r10k/module_loader/puppetfile.rb +14 -9
  67. data/lib/r10k/puppetfile.rb +1 -1
  68. data/lib/r10k/settings.rb +6 -7
  69. data/lib/r10k/version.rb +1 -1
  70. data/locales/r10k.pot +34 -82
  71. data/r10k.gemspec +5 -7
  72. metadata +22 -211
  73. data/docker/.gitignore +0 -1
  74. data/docker/.rspec +0 -4
  75. data/docker/Gemfile +0 -11
  76. data/docker/Makefile +0 -99
  77. data/docker/README.md +0 -28
  78. data/docker/docker-compose.yml +0 -18
  79. data/docker/r10k/Dockerfile +0 -68
  80. data/docker/r10k/adduser.sh +0 -13
  81. data/docker/r10k/docker-entrypoint.d/10-analytics.sh +0 -30
  82. data/docker/r10k/docker-entrypoint.sh +0 -10
  83. data/docker/r10k/release.Dockerfile +0 -55
  84. data/docker/spec/dockerfile_spec.rb +0 -37
  85. data/docker/spec/fixtures/Puppetfile +0 -2
  86. data/integration/tests/basic_functionality/install_pe_only_module_with_puppetfile.rb +0 -83
  87. data/integration/tests/basic_functionality/proxy_with_pe_only_module.rb +0 -128
  88. data/integration/tests/purging/invalid_whitelist_types.rb +0 -63
  89. data/integration/tests/user_scenario/basic_workflow/negative/neg_module_specified_at_deleted_release.rb +0 -49
  90. data/integration/tests/user_scenario/basic_workflow/single_env_module_last_release_deleted.rb +0 -68
  91. data/lib/r10k/environment/bare.rb +0 -13
  92. data/spec/fixtures/empty/.empty +0 -0
  93. data/spec/fixtures/integration/git/puppet-boolean-bare.tar +0 -0
  94. data/spec/fixtures/module/forge/bad_module/metadata.json +0 -1
  95. data/spec/fixtures/module/forge/eight_hundred/Modulefile +0 -8
  96. data/spec/fixtures/module/forge/eight_hundred/metadata.json +0 -19
  97. data/spec/fixtures/tarball/tarball.tar.gz +0 -0
  98. data/spec/fixtures/unit/action/r10k.yaml +0 -5
  99. data/spec/fixtures/unit/action/r10k_cachedir.yaml +0 -2
  100. data/spec/fixtures/unit/action/r10k_creds.yaml +0 -9
  101. data/spec/fixtures/unit/action/r10k_forge_auth.yaml +0 -4
  102. data/spec/fixtures/unit/action/r10k_forge_auth_no_url.yaml +0 -3
  103. data/spec/fixtures/unit/action/r10k_generate_types.yaml +0 -3
  104. data/spec/fixtures/unit/action/r10k_logging.yaml +0 -12
  105. data/spec/fixtures/unit/action/r10k_puppet_path.yaml +0 -3
  106. data/spec/fixtures/unit/puppetfile/argument-error/Puppetfile +0 -1
  107. data/spec/fixtures/unit/puppetfile/default-branch-override/Puppetfile +0 -5
  108. data/spec/fixtures/unit/puppetfile/duplicate-module-error/Puppetfile +0 -10
  109. data/spec/fixtures/unit/puppetfile/forge-override/Puppetfile +0 -8
  110. data/spec/fixtures/unit/puppetfile/invalid-syntax/Puppetfile +0 -1
  111. data/spec/fixtures/unit/puppetfile/load-error/Puppetfile +0 -1
  112. data/spec/fixtures/unit/puppetfile/name-error/Puppetfile +0 -1
  113. data/spec/fixtures/unit/puppetfile/valid-forge-with-version/Puppetfile +0 -1
  114. data/spec/fixtures/unit/puppetfile/valid-forge-without-version/Puppetfile +0 -1
  115. data/spec/fixtures/unit/puppetfile/various-modules/Puppetfile +0 -10
  116. data/spec/fixtures/unit/puppetfile/various-modules/Puppetfile.new +0 -10
  117. data/spec/fixtures/unit/puppetfile/various-modules/modules/apt/.gitkeep +0 -1
  118. data/spec/fixtures/unit/puppetfile/various-modules/modules/baz/.gitkeep +0 -1
  119. data/spec/fixtures/unit/puppetfile/various-modules/modules/buzz/.gitkeep +0 -1
  120. data/spec/fixtures/unit/puppetfile/various-modules/modules/canary/.gitkeep +0 -1
  121. data/spec/fixtures/unit/puppetfile/various-modules/modules/fizz/.gitkeep +0 -1
  122. data/spec/fixtures/unit/puppetfile/various-modules/modules/rpm/.gitkeep +0 -1
  123. data/spec/fixtures/unit/util/purgeable/managed_one/expected_1 +0 -0
  124. data/spec/fixtures/unit/util/purgeable/managed_one/managed_subdir_1/managed_symlink_file +0 -1
  125. data/spec/fixtures/unit/util/purgeable/managed_one/managed_subdir_1/subdir_allowlisted_2/ignored_1 +0 -0
  126. data/spec/fixtures/unit/util/purgeable/managed_one/managed_subdir_1/subdir_expected_1 +0 -0
  127. data/spec/fixtures/unit/util/purgeable/managed_one/managed_subdir_1/subdir_unmanaged_1 +0 -0
  128. data/spec/fixtures/unit/util/purgeable/managed_one/managed_subdir_1/unmanaged_symlink_dir +0 -1
  129. data/spec/fixtures/unit/util/purgeable/managed_one/managed_symlink_dir +0 -1
  130. data/spec/fixtures/unit/util/purgeable/managed_one/unmanaged_1 +0 -0
  131. data/spec/fixtures/unit/util/purgeable/managed_one/unmanaged_symlink_file +0 -1
  132. data/spec/fixtures/unit/util/purgeable/managed_two/.hidden/unmanaged_3 +0 -0
  133. data/spec/fixtures/unit/util/purgeable/managed_two/expected_2 +0 -0
  134. data/spec/fixtures/unit/util/purgeable/managed_two/unmanaged_2 +0 -0
  135. data/spec/fixtures/unit/util/subprocess/runner/no-execute.sh +0 -3
  136. data/spec/integration/git/rugged/bare_repository_spec.rb +0 -13
  137. data/spec/integration/git/rugged/cache_spec.rb +0 -33
  138. data/spec/integration/git/rugged/thin_repository_spec.rb +0 -14
  139. data/spec/integration/git/rugged/working_repository_spec.rb +0 -48
  140. data/spec/integration/git/shellgit/bare_repository_spec.rb +0 -13
  141. data/spec/integration/git/shellgit/thin_repository_spec.rb +0 -14
  142. data/spec/integration/git/shellgit/working_repository_spec.rb +0 -13
  143. data/spec/integration/git/stateful_repository_spec.rb +0 -175
  144. data/spec/integration/util/purageable_spec.rb +0 -41
  145. data/spec/matchers/exit_with.rb +0 -28
  146. data/spec/matchers/match_realpath.rb +0 -18
  147. data/spec/r10k-mocks/mock_config.rb +0 -33
  148. data/spec/r10k-mocks/mock_env.rb +0 -18
  149. data/spec/r10k-mocks/mock_source.rb +0 -17
  150. data/spec/r10k-mocks.rb +0 -3
  151. data/spec/shared-contexts/git-fixtures.rb +0 -55
  152. data/spec/shared-contexts/tarball.rb +0 -32
  153. data/spec/shared-examples/deploy-actions.rb +0 -69
  154. data/spec/shared-examples/git/bare_repository.rb +0 -132
  155. data/spec/shared-examples/git/thin_repository.rb +0 -26
  156. data/spec/shared-examples/git/working_repository.rb +0 -207
  157. data/spec/shared-examples/git-repository.rb +0 -38
  158. data/spec/shared-examples/puppetfile-action.rb +0 -39
  159. data/spec/shared-examples/settings/ancestry.rb +0 -44
  160. data/spec/shared-examples/subprocess-runner.rb +0 -89
  161. data/spec/spec_helper.rb +0 -41
  162. data/spec/unit/action/cri_runner_spec.rb +0 -72
  163. data/spec/unit/action/deploy/deploy_helpers_spec.rb +0 -38
  164. data/spec/unit/action/deploy/display_spec.rb +0 -61
  165. data/spec/unit/action/deploy/environment_spec.rb +0 -640
  166. data/spec/unit/action/deploy/module_spec.rb +0 -476
  167. data/spec/unit/action/puppetfile/check_spec.rb +0 -53
  168. data/spec/unit/action/puppetfile/cri_runner_spec.rb +0 -47
  169. data/spec/unit/action/puppetfile/install_spec.rb +0 -112
  170. data/spec/unit/action/puppetfile/purge_spec.rb +0 -60
  171. data/spec/unit/action/runner_spec.rb +0 -407
  172. data/spec/unit/action/visitor_spec.rb +0 -39
  173. data/spec/unit/cli_spec.rb +0 -9
  174. data/spec/unit/deployment/config_spec.rb +0 -33
  175. data/spec/unit/deployment_spec.rb +0 -162
  176. data/spec/unit/environment/bare_spec.rb +0 -13
  177. data/spec/unit/environment/base_spec.rb +0 -122
  178. data/spec/unit/environment/git_spec.rb +0 -114
  179. data/spec/unit/environment/name_spec.rb +0 -181
  180. data/spec/unit/environment/plain_spec.rb +0 -8
  181. data/spec/unit/environment/svn_spec.rb +0 -146
  182. data/spec/unit/environment/tarball_spec.rb +0 -45
  183. data/spec/unit/environment/with_modules_spec.rb +0 -122
  184. data/spec/unit/errors/formatting_spec.rb +0 -84
  185. data/spec/unit/feature_spec.rb +0 -50
  186. data/spec/unit/forge/module_release_spec.rb +0 -213
  187. data/spec/unit/git/alternates_spec.rb +0 -116
  188. data/spec/unit/git/cache_spec.rb +0 -66
  189. data/spec/unit/git/rugged/cache_spec.rb +0 -48
  190. data/spec/unit/git/rugged/credentials_spec.rb +0 -215
  191. data/spec/unit/git/shellgit/cache_spec.rb +0 -27
  192. data/spec/unit/git/stateful_repository_spec.rb +0 -45
  193. data/spec/unit/git_spec.rb +0 -102
  194. data/spec/unit/initializers_spec.rb +0 -68
  195. data/spec/unit/instance_cache_spec.rb +0 -78
  196. data/spec/unit/keyed_factory_spec.rb +0 -51
  197. data/spec/unit/logging/terminaloutputter_spec.rb +0 -53
  198. data/spec/unit/logging_spec.rb +0 -68
  199. data/spec/unit/module/base_spec.rb +0 -118
  200. data/spec/unit/module/forge_spec.rb +0 -271
  201. data/spec/unit/module/git_spec.rb +0 -387
  202. data/spec/unit/module/metadata_file_spec.rb +0 -68
  203. data/spec/unit/module/svn_spec.rb +0 -208
  204. data/spec/unit/module/tarball_spec.rb +0 -70
  205. data/spec/unit/module_loader/puppetfile_spec.rb +0 -421
  206. data/spec/unit/module_spec.rb +0 -114
  207. data/spec/unit/puppetfile_spec.rb +0 -304
  208. data/spec/unit/settings/collection_spec.rb +0 -123
  209. data/spec/unit/settings/container_spec.rb +0 -92
  210. data/spec/unit/settings/definition_spec.rb +0 -79
  211. data/spec/unit/settings/enum_definition_spec.rb +0 -20
  212. data/spec/unit/settings/inheritance_spec.rb +0 -38
  213. data/spec/unit/settings/list_spec.rb +0 -88
  214. data/spec/unit/settings/loader_spec.rb +0 -110
  215. data/spec/unit/settings/uri_definition_spec.rb +0 -23
  216. data/spec/unit/settings_spec.rb +0 -303
  217. data/spec/unit/source/base_spec.rb +0 -31
  218. data/spec/unit/source/exec_spec.rb +0 -81
  219. data/spec/unit/source/git_spec.rb +0 -233
  220. data/spec/unit/source/hash_spec.rb +0 -54
  221. data/spec/unit/source/svn_spec.rb +0 -196
  222. data/spec/unit/source/yaml_spec.rb +0 -42
  223. data/spec/unit/source_spec.rb +0 -10
  224. data/spec/unit/svn/remote_spec.rb +0 -21
  225. data/spec/unit/svn/working_dir_spec.rb +0 -56
  226. data/spec/unit/tarball_spec.rb +0 -57
  227. data/spec/unit/util/attempt_spec.rb +0 -82
  228. data/spec/unit/util/cacheable_spec.rb +0 -23
  229. data/spec/unit/util/commands_spec.rb +0 -61
  230. data/spec/unit/util/downloader_spec.rb +0 -98
  231. data/spec/unit/util/exec_env_spec.rb +0 -56
  232. data/spec/unit/util/purgeable_spec.rb +0 -267
  233. data/spec/unit/util/setopts_spec.rb +0 -83
  234. data/spec/unit/util/subprocess/result_spec.rb +0 -36
  235. data/spec/unit/util/subprocess/runner/posix_spec.rb +0 -7
  236. data/spec/unit/util/subprocess/runner/pump_spec.rb +0 -79
  237. data/spec/unit/util/subprocess/runner/windows_spec.rb +0 -7
  238. data/spec/unit/util/subprocess/subprocess_error_spec.rb +0 -26
  239. data/spec/unit/util/subprocess_spec.rb +0 -65
  240. data/spec/unit/util/symbolize_keys_spec.rb +0 -67
@@ -16,28 +16,24 @@ r10k_config_bak_path = "#{r10k_config_path}.bak"
16
16
 
17
17
  puppetfile =<<-EOS
18
18
  mod 'motd',
19
- :git => 'https://github.com/puppetlabs/puppetlabs-motd'
19
+ :git => 'https://github.com/puppetlabs/puppetlabs-motd', :branch => 'main'
20
20
  EOS
21
21
 
22
- proxy_env_value = 'http://cattastic.net:3219'
23
-
24
22
  #In-line files
25
23
  r10k_conf = <<-CONF
26
24
  cachedir: '/var/cache/r10k'
27
25
  git:
28
26
  provider: '#{git_provider}'
29
27
  repositories:
30
- - remote: 'http://example.com/fake_git_source.git'
28
+ - remote: 'https://something.else/repo'
31
29
  proxy: 'http://foooooooo.unresolvable:3128'
32
30
  sources:
33
31
  control:
34
32
  basedir: "#{env_path}"
35
- remote: "http://example.com/fake_git_source.git"
33
+ remote: 'https://something.else/repo'
36
34
  CONF
37
35
 
38
36
  teardown do
39
- master.clear_env_var('HTTP_PROXY')
40
-
41
37
  step 'Restore Original "r10k" Config'
42
38
  on(master, "mv #{r10k_config_bak_path} #{r10k_config_path}")
43
39
 
@@ -45,8 +41,6 @@ teardown do
45
41
  clean_up_r10k(master, last_commit, git_environments_path)
46
42
  end
47
43
 
48
- master.add_env_var('HTTP_PROXY', proxy_env_value)
49
-
50
44
  step 'Backup Current "r10k" Config'
51
45
  on(master, "mv #{r10k_config_path} #{r10k_config_bak_path}")
52
46
 
@@ -64,7 +58,8 @@ git_add_commit_push(master, 'production', 'add Puppetfile', git_environments_pat
64
58
 
65
59
  #test
66
60
  on(master, "#{r10k_fqp} deploy environment -p", :accept_all_exit_codes => true) do |r|
67
- regex = /proxy.*foooooooo\.unresolvable/
61
+ # Rugged as of 0.28 has a different error message than shellgit
62
+ regex = /((failed to resolve address for)|(Could not resolve proxy:)) foooooooo\.unresolvable/
68
63
  assert(r.exit_code == 1, 'expected error code was not observed')
69
64
  assert_match(regex, r.stderr, 'The expected error message was not observed' )
70
65
  end
@@ -5,7 +5,7 @@ test_name 'CODEMGMT-92 - C59235 - Single Git Source Using "GIT" Transport Protoc
5
5
 
6
6
  confine(:to, :platform => 'el')
7
7
 
8
- if fact_on(master, "operatingsystemmajrelease").to_i < 6
8
+ if fact_on(master, "os.release.major").to_i < 6 || fact_on(master, "os.release.major").to_i > 8
9
9
  skip_test('This version of EL is not supported by this test case!')
10
10
  end
11
11
 
@@ -84,9 +84,6 @@ teardown do
84
84
  end
85
85
 
86
86
  #Setup
87
- step 'Stub Forge on Master'
88
- stub_forge_on(master)
89
-
90
87
  step 'Backup Current "r10k" Config'
91
88
  on(master, "mv #{r10k_config_path} #{r10k_config_bak_path}")
92
89
 
@@ -44,9 +44,6 @@ teardown do
44
44
  clean_up_r10k(master, last_commit, git_environments_path)
45
45
  end
46
46
 
47
- step 'Stub the forge'
48
- stub_forge_on(master)
49
-
50
47
  step 'Backup Current "r10k" Config'
51
48
  on(master, "mv #{r10k_config_path} #{r10k_config_bak_path}")
52
49
 
@@ -44,7 +44,7 @@ scp_to(master, helloworld_module_path, File.join(git_clone_module_path, 'hellowo
44
44
  git_add_commit_push(master, 'master', 'Add module.', git_clone_module_path)
45
45
 
46
46
  step 'Add "helloworld" Module Git Repo as Submodule'
47
- on(master, "cd #{git_environments_path};git submodule add file://#{git_repo_module_path} dist")
47
+ on(master, "cd #{git_environments_path};git -c protocol.file.allow=always submodule add file://#{git_repo_module_path} dist")
48
48
 
49
49
  step 'Checkout "production" Branch'
50
50
  git_on(master, 'checkout production', git_environments_path)
@@ -68,6 +68,6 @@ on(master, "chmod 600 #{ssh_private_key_path}")
68
68
 
69
69
  #Tests
70
70
  step 'Attempt to Deploy via r10k'
71
- on(master, "#{r10k_fqp} deploy environment -v", :acceptable_exit_codes => 1) do |result|
71
+ on(master, "SSH_AUTH_SOCK= SSH_CONNECTION= SSH_CLIENT= #{r10k_fqp} deploy environment -v", :acceptable_exit_codes => 1) do |result|
72
72
  assert_match(error_message_regex, result.stderr, 'Expected message not found!')
73
73
  end
@@ -50,9 +50,6 @@ teardown do
50
50
  clean_up_r10k(master, last_commit, git_environments_path)
51
51
  end
52
52
 
53
- step 'Stub the forge'
54
- stub_forge_on(master)
55
-
56
53
  step 'Backup Current "r10k" Config'
57
54
  on(master, "mv #{r10k_config_path} #{r10k_config_bak_path}")
58
55
 
@@ -51,9 +51,6 @@ fake_file_b_to_be_left_alone = "#{fake_environment_path_b}/fakefile2.txt"
51
51
  fake_file_c_to_be_purged = "#{fake_environment_path_c}/fakefile3.txt"
52
52
 
53
53
  # initalize file content
54
- step 'Stub the forge'
55
- stub_forge_on(master)
56
-
57
54
  step 'Backup Current "r10k" Config'
58
55
  on(master, "mv #{r10k_config_path} #{r10k_config_bak_path}")
59
56
 
@@ -1,7 +1,7 @@
1
1
  require 'git_utils'
2
2
  require 'r10k_utils'
3
3
  require 'master_manipulator'
4
- test_name 'RK-257 - C98046 - r10k does not purge files on whitelist'
4
+ test_name 'RK-257 - C98046 - r10k does not purge files on allowlist'
5
5
 
6
6
  #Init
7
7
  env_path = on(master, puppet('config print environmentpath')).stdout.rstrip
@@ -26,9 +26,6 @@ teardown do
26
26
  end
27
27
 
28
28
  # initalize file content
29
- step 'Stub the forge'
30
- stub_forge_on(master)
31
-
32
29
  step 'Backup Current "r10k" Config'
33
30
  on(master, "mv #{r10k_config_path} #{r10k_config_bak_path}")
34
31
 
@@ -42,7 +39,7 @@ sources:
42
39
  remote: "#{git_control_remote}"
43
40
  deploy:
44
41
  purge_levels: ['deployment', 'environment', 'puppetfile']
45
- purge_whitelist: ['**/*.pp']
42
+ purge_allowlist: ['**/*.pp']
46
43
  CONF
47
44
 
48
45
  step 'Update the "r10k" Config'
@@ -62,9 +62,6 @@ teardown do
62
62
  end
63
63
 
64
64
  #Setup
65
- step 'Stub Forge on Master'
66
- stub_forge_on(master)
67
-
68
65
  env_names.each do |env|
69
66
  if env == 'production'
70
67
  step "Checkout \"#{env}\" Branch"
@@ -66,9 +66,6 @@ teardown do
66
66
  end
67
67
 
68
68
  #Setup
69
- step 'Stub Forge on Master'
70
- stub_forge_on(master)
71
-
72
69
  env_names.each do |env|
73
70
  if env == 'production'
74
71
  step "Checkout \"#{env}\" Branch"
@@ -102,9 +102,6 @@ teardown do
102
102
  end
103
103
 
104
104
  #Setup
105
- step 'Stub Forge on Master'
106
- stub_forge_on(master)
107
-
108
105
  step 'Backup Current "r10k" Config'
109
106
  on(master, "mv #{r10k_config_path} #{r10k_config_bak_path}")
110
107
 
@@ -29,9 +29,6 @@ teardown do
29
29
  end
30
30
 
31
31
  #Setup
32
- step 'Stub Forge on Master'
33
- stub_forge_on(master)
34
-
35
32
  step 'Checkout "production" Branch'
36
33
  git_on(master, 'checkout production', git_environments_path)
37
34
 
@@ -2,7 +2,7 @@ require 'git_utils'
2
2
  require 'r10k_utils'
3
3
  test_name 'CODEMGMT-86 - C59265 - Attempt to Deploy Environment to Disk with Insufficient Free Space'
4
4
 
5
- if fact_on(master, 'osfamily') == 'RedHat' and fact_on(master, "operatingsystemmajrelease").to_i < 6
5
+ if fact_on(master, 'os.family') == 'RedHat' and fact_on(master, "os.release.major").to_i < 6
6
6
  skip_test('This version of EL is not supported by this test case!')
7
7
  end
8
8
 
@@ -25,9 +25,6 @@ teardown do
25
25
  end
26
26
 
27
27
  #Setup
28
- step 'Stub Forge on Master'
29
- stub_forge_on(master)
30
-
31
28
  step 'Checkout "production" Branch'
32
29
  git_on(master, 'checkout production', git_environments_path)
33
30
 
@@ -19,7 +19,7 @@ PUPPETFILE
19
19
  puppet_file_path = File.join(git_environments_path, 'Puppetfile')
20
20
 
21
21
  #Verification
22
- error_message_regex = /Error: Could not connect via HTTPS to https:\/\/forgeapi.puppetlabs.com/
22
+ error_message_regex = /Error: Could not connect via HTTPS to https:\/\/forgeapi.puppet(labs)?.com/
23
23
 
24
24
  #Teardown
25
25
  teardown do
@@ -34,7 +34,8 @@ step 'Backup "/etc/hosts" File on Master'
34
34
  on(master, "mv #{hosts_file_path} #{hosts_file_path}.bak")
35
35
 
36
36
  step 'Point Forge Hostname to Localhost'
37
- on(master, "echo '127.0.0.1 forgeapi.puppetlabs.com' > #{hosts_file_path}")
37
+ on(master, "echo '127.0.0.1 forgeapi.puppet.com' > #{hosts_file_path}")
38
+ on(master, "echo '127.0.0.1 forgeapi.puppetlabs.com' >> #{hosts_file_path}")
38
39
 
39
40
  step 'Checkout "production" Branch'
40
41
  git_on(master, 'checkout production', git_environments_path)
@@ -10,7 +10,7 @@ last_commit = git_last_commit(master, git_environments_path)
10
10
  r10k_fqp = get_r10k_fqp(master)
11
11
 
12
12
  #Verification
13
- error_notification_regex = /The module puppetlabs-regret does not appear to have any published releases/
13
+ error_notification_regex = /(The module puppetlabs-regret does not appear to have any published releases)|(module puppetlabs-regret does not exist on)/
14
14
 
15
15
  #File
16
16
  puppet_file = <<-PUPPETFILE
@@ -24,10 +24,6 @@ teardown do
24
24
  clean_up_r10k(master, last_commit, git_environments_path)
25
25
  end
26
26
 
27
- #Setup
28
- step 'Stub Forge on Master'
29
- stub_forge_on(master)
30
-
31
27
  #Tests
32
28
  step 'Checkout "production" Branch'
33
29
  git_on(master, 'checkout production', git_environments_path)
@@ -3,7 +3,7 @@ require 'r10k_utils'
3
3
  require 'master_manipulator'
4
4
  test_name 'CODEMGMT-62 - C59239 - Single Environment with 10,000 Files'
5
5
 
6
- if fact_on(master, 'osfamily') == 'RedHat' and fact_on(master, "operatingsystemmajrelease").to_i < 6
6
+ if fact_on(master, 'os.family') == 'RedHat' and fact_on(master, "os.release.major").to_i < 6
7
7
  skip_test('This version of EL is not supported by this test case!')
8
8
  end
9
9
 
@@ -64,9 +64,6 @@ teardown do
64
64
  end
65
65
 
66
66
  #Setup
67
- step 'Stub Forge on Master'
68
- stub_forge_on(master)
69
-
70
67
  step 'Checkout "production" Branch'
71
68
  git_on(master, 'checkout production', git_environments_path)
72
69
 
@@ -45,9 +45,6 @@ teardown do
45
45
  end
46
46
 
47
47
  #Setup
48
- step 'Stub Forge on Master'
49
- stub_forge_on(master)
50
-
51
48
  step 'Checkout "production" Branch'
52
49
  git_on(master, 'checkout production', git_environments_path)
53
50
 
@@ -3,7 +3,7 @@ require 'r10k_utils'
3
3
  require 'master_manipulator'
4
4
  test_name 'CODEMGMT-62 - C59242 - Single Environment with Large Binary Files'
5
5
 
6
- if fact_on(master, 'osfamily') == 'RedHat' and fact_on(master, "operatingsystemmajrelease").to_i < 6
6
+ if fact_on(master, 'os.family') == 'RedHat' and fact_on(master, "os.release.major").to_i < 6
7
7
  skip_test('This version of EL is not supported by this test case!')
8
8
  end
9
9
 
@@ -44,9 +44,6 @@ teardown do
44
44
  end
45
45
 
46
46
  #Setup
47
- step 'Stub Forge on Master'
48
- stub_forge_on(master)
49
-
50
47
  step 'Add motd module from the forge using the PMT'
51
48
  on(master, puppet('module', 'install', 'puppetlabs-motd', '--modulepath', forge_module_path))
52
49
 
@@ -43,9 +43,6 @@ teardown do
43
43
  end
44
44
 
45
45
  #Setup
46
- step 'Stub Forge on Master'
47
- stub_forge_on(master)
48
-
49
46
  step 'Checkout "production" Branch'
50
47
  git_on(master, 'checkout production', git_remote_environments_path)
51
48
 
@@ -57,9 +57,6 @@ teardown do
57
57
  end
58
58
 
59
59
  #Setup
60
- step 'Stub Forge on Master'
61
- stub_forge_on(master)
62
-
63
60
  step 'Checkout "production" Branch'
64
61
  git_on(master, 'checkout production', git_environments_path)
65
62
 
@@ -60,9 +60,6 @@ teardown do
60
60
  end
61
61
 
62
62
  #Setup
63
- step 'Stub Forge on Master'
64
- stub_forge_on(master)
65
-
66
63
  step 'Checkout "production" Branch'
67
64
  git_on(master, 'checkout production', git_environments_path)
68
65
 
@@ -65,9 +65,6 @@ teardown do
65
65
  end
66
66
 
67
67
  #Setup
68
- step 'Stub Forge on Master'
69
- stub_forge_on(master)
70
-
71
68
  initial_env_names.each do |env|
72
69
  if env == 'production'
73
70
  step "Checkout \"#{env}\" Branch"
@@ -45,6 +45,7 @@ module R10K
45
45
  incremental: @incremental
46
46
  },
47
47
  modules: {
48
+ default_ref: settings.dig(:git, :default_ref),
48
49
  exclude_spec: settings.dig(:deploy, :exclude_spec),
49
50
  requested_modules: [],
50
51
  deploy_modules: @modules,
@@ -53,8 +54,7 @@ module R10K
53
54
  },
54
55
  purging: {
55
56
  purge_levels: settings.dig(:deploy, :purge_levels) || [],
56
- purge_allowlist: read_purge_allowlist(settings.dig(:deploy, :purge_whitelist) || [],
57
- settings.dig(:deploy, :purge_allowlist) || [])
57
+ purge_allowlist: settings.dig(:deploy, :purge_allowlist) || []
58
58
  },
59
59
  forge: {
60
60
  allow_puppetfile_override: settings.dig(:forge, :allow_puppetfile_override) || false
@@ -83,23 +83,6 @@ module R10K
83
83
 
84
84
  private
85
85
 
86
- def read_purge_allowlist (whitelist, allowlist)
87
- whitelist_has_content = !whitelist.empty?
88
- allowlist_has_content = !allowlist.empty?
89
- case
90
- when whitelist_has_content == false && allowlist_has_content == false
91
- []
92
- when whitelist_has_content && allowlist_has_content
93
- raise R10K::Error.new "Values found for both purge_whitelist and purge_allowlist. Setting " <<
94
- "purge_whitelist is deprecated, please only use purge_allowlist."
95
- when allowlist_has_content
96
- allowlist
97
- else
98
- logger.warn "Setting purge_whitelist is deprecated; please use purge_allowlist instead."
99
- whitelist
100
- end
101
- end
102
-
103
86
  def visit_deployment(deployment)
104
87
  # Ensure that everything can be preloaded. If we cannot preload all
105
88
  # sources then we can't fully enumerate all environments which
@@ -39,6 +39,7 @@ module R10K
39
39
  generate_types: @generate_types
40
40
  },
41
41
  modules: {
42
+ default_ref: settings.dig(:git, :default_ref),
42
43
  exclude_spec: settings.dig(:deploy, :exclude_spec),
43
44
  pool_size: @settings[:pool_size] || 4,
44
45
  requested_modules: @argv.map.to_a,
@@ -9,12 +9,19 @@ module R10K
9
9
 
10
10
  def call
11
11
  options = { basedir: @root }
12
+ options[:overrides] = {}
13
+ options[:overrides][:modules] = { default_ref: @settings.dig(:git, :default_ref) }
12
14
  options[:moduledir] = @moduledir if @moduledir
13
15
  options[:puppetfile] = @puppetfile if @puppetfile
14
16
 
15
17
  loader = R10K::ModuleLoader::Puppetfile.new(**options)
16
18
  begin
17
19
  loader.load!
20
+ loader.modules.each do |mod|
21
+ if mod.instance_of?(R10K::Module::Git)
22
+ mod.validate_ref_defined
23
+ end
24
+ end
18
25
  $stderr.puts _("Syntax OK")
19
26
  true
20
27
  rescue => e
@@ -12,8 +12,10 @@ module R10K
12
12
  def call
13
13
  begin
14
14
  options = { basedir: @root, overrides: { force: @force || false } }
15
+ options[:overrides][:modules] = { default_ref: @settings.dig(:git, :default_ref) }
15
16
  options[:moduledir] = @moduledir if @moduledir
16
17
  options[:puppetfile] = @puppetfile if @puppetfile
18
+ options[:module_exclude_regex] = @module_exclude_regex if @module_exclude_regex
17
19
 
18
20
  loader = R10K::ModuleLoader::Puppetfile.new(**options)
19
21
  loaded_content = loader.load!
@@ -40,7 +42,7 @@ module R10K
40
42
  private
41
43
 
42
44
  def allowed_initialize_opts
43
- super.merge(root: :self, puppetfile: :self, moduledir: :self, force: :self )
45
+ super.merge(root: :self, puppetfile: :self, moduledir: :self, :'module-exclude-regex' => :self, force: :self )
44
46
  end
45
47
  end
46
48
  end
@@ -10,6 +10,19 @@ require 'cri'
10
10
 
11
11
  module R10K::CLI
12
12
  module Deploy
13
+
14
+ class TransformExcludeSpec
15
+ def call(input)
16
+ # To be backward compatible with the 3.x flag version of this setting,
17
+ # r10k allows this flag to have an optional argument. When no argument
18
+ # is supplied, cri defaults to setting the class to true, so we check
19
+ # for TrueClass here as well as "true".
20
+ return true if input == true || input == 'true'
21
+ return false if input == 'false'
22
+ raise ArgumentError
23
+ end
24
+ end
25
+
13
26
  def self.command
14
27
  @cmd ||= Cri::Command.define do
15
28
  name 'deploy'
@@ -24,7 +37,8 @@ module R10K::CLI
24
37
  option nil, :cachedir, 'Specify a cachedir, overriding the value in config', argument: :required
25
38
  flag nil, :'no-force', 'Prevent the overwriting of local module modifications'
26
39
  flag nil, :'generate-types', 'Run `puppet generate types` after updating an environment'
27
- flag nil, :'exclude-spec', 'Exclude the module\'s spec dir from deployment'
40
+ option nil, :'exclude-spec', 'Exclude the module\'s spec dir for deployment', argument: :optional,
41
+ transform: TransformExcludeSpec.new
28
42
  option nil, :'puppet-path', 'Path to puppet executable', argument: :required do |value, cmd|
29
43
  unless File.executable? value
30
44
  $stderr.puts "The specified puppet executable #{value} is not executable."
@@ -31,6 +31,7 @@ Puppetfile (http://bombasticmonkey.com/librarian-puppet/).
31
31
  summary 'Install all modules from a Puppetfile'
32
32
  option nil, :moduledir, 'Path to install modules to', argument: :required
33
33
  option nil, :puppetfile, 'Path to puppetfile', argument: :required
34
+ option nil, :'module-exclude-regex', 'A regex to exclude modules from installation. Helpful in CI environments.', argument: :required
34
35
  flag nil, :force, 'Force locally changed files to be overwritten'
35
36
  runner R10K::Action::Puppetfile::CriRunner.wrap(R10K::Action::Puppetfile::Install)
36
37
  end
@@ -79,8 +79,13 @@ module R10K
79
79
  begin
80
80
  while mods = mods_queue.pop(true) do
81
81
  mods.each do |mod|
82
- updated = mod.sync
83
- updated_modules << mod.name if updated
82
+ begin
83
+ updated = mod.sync
84
+ updated_modules << mod.name if updated
85
+ rescue Exception => e
86
+ logger.error _("Module %{mod_name} failed to synchronize due to %{message}") % {mod_name: mod.name, message: e.message}
87
+ raise e
88
+ end
84
89
  end
85
90
  end
86
91
  rescue ThreadError => e
@@ -31,7 +31,6 @@ module R10K
31
31
  require 'r10k/environment/base'
32
32
  require 'r10k/environment/with_modules'
33
33
  require 'r10k/environment/plain'
34
- require 'r10k/environment/bare'
35
34
  require 'r10k/environment/git'
36
35
  require 'r10k/environment/svn'
37
36
  require 'r10k/environment/tarball'
@@ -56,11 +56,12 @@ class R10K::Git::Rugged::BareRepository < R10K::Git::Rugged::BaseRepository
56
56
  logger.warn { _("Rugged versions prior to 0.24.0 do not support pruning stale branches during fetch, please upgrade your \'rugged\' gem. (Current version is: %{version})") % {version: Rugged::Version} }
57
57
  end
58
58
 
59
- options = {:credentials => credentials, :prune => true}
60
- refspecs = ['+refs/*:refs/*']
61
-
62
59
  remote = remotes[remote_name]
63
60
  proxy = R10K::Git.get_proxy_for_remote(remote)
61
+
62
+ options = {:credentials => credentials, :prune => true, :proxy_url => proxy}
63
+ refspecs = ['+refs/*:refs/*']
64
+
64
65
  results = nil
65
66
 
66
67
  R10K::Git.with_proxy(proxy) do
@@ -27,6 +27,7 @@ class R10K::Git::Rugged::WorkingRepository < R10K::Git::Rugged::BaseRepository
27
27
  def clone(remote, opts = {})
28
28
  logger.debug1 { _("Cloning '%{remote}' into %{path}") % {remote: remote, path: @path } }
29
29
 
30
+ proxy = R10K::Git.get_proxy_for_remote(remote)
30
31
  # libgit2/rugged doesn't support cloning a repository and providing an
31
32
  # alternate object database, making the handling of :alternates a noop.
32
33
  # Unfortunately this means that this method can't really use alternates
@@ -34,10 +35,9 @@ class R10K::Git::Rugged::WorkingRepository < R10K::Git::Rugged::BaseRepository
34
35
  # repository. However alternate databases can be handled when an existing
35
36
  # repository is loaded, so loading a cloned repo will correctly use
36
37
  # alternate object database.
37
- options = {:credentials => credentials}
38
+ options = {:credentials => credentials, :proxy_url => proxy}
38
39
  options.merge!(:alternates => [File.join(opts[:reference], 'objects')]) if opts[:reference]
39
40
 
40
- proxy = R10K::Git.get_proxy_for_remote(remote)
41
41
 
42
42
  R10K::Git.with_proxy(proxy) do
43
43
  @_rugged_repo = ::Rugged::Repository.clone_at(remote, @path.to_s, options)
@@ -85,11 +85,13 @@ class R10K::Git::Rugged::WorkingRepository < R10K::Git::Rugged::BaseRepository
85
85
 
86
86
  def fetch(remote_name = 'origin')
87
87
  logger.debug1 { _("Fetching remote '%{remote}' at %{path}") % {remote: remote_name, path: @path} }
88
- options = {:credentials => credentials}
89
- refspecs = ["+refs/heads/*:refs/remotes/#{remote_name}/*"]
90
88
 
91
89
  remote = remotes[remote_name]
92
90
  proxy = R10K::Git.get_proxy_for_remote(remote)
91
+
92
+ options = {:credentials => credentials, :proxy_url => proxy}
93
+ refspecs = ["+refs/heads/*:refs/remotes/#{remote_name}/*"]
94
+
93
95
  results = nil
94
96
 
95
97
  R10K::Git.with_proxy(proxy) do
@@ -117,7 +119,7 @@ class R10K::Git::Rugged::WorkingRepository < R10K::Git::Rugged::BaseRepository
117
119
  with_repo { |repo| repo.config['remote.origin.url'] }
118
120
  end
119
121
 
120
- def dirty?(exclude_spec=false)
122
+ def dirty?(exclude_spec=true)
121
123
  with_repo do |repo|
122
124
  if exclude_spec
123
125
  diff = repo.diff_workdir('HEAD').select { |d| ! d.delta.old_file[:path].start_with?('spec/') }
@@ -90,18 +90,18 @@ class R10K::Git::ShellGit::WorkingRepository < R10K::Git::ShellGit::BaseReposito
90
90
  end
91
91
 
92
92
  # does the working tree have local modifications to tracked files?
93
- def dirty?(exclude_spec=false)
93
+ def dirty?(exclude_spec=true)
94
94
  result = git(['diff-index', '--exit-code', '--name-only', 'HEAD'], :path => @path.to_s, :raise_on_fail => false)
95
95
 
96
96
  if result.exit_code != 0
97
- dirty_files = result.stdout.split('\n')
97
+ dirty_files = result.stdout.split("\n")
98
98
  dirty_files.delete_if { |f| f.start_with?('spec/') } if exclude_spec
99
99
 
100
100
  dirty_files.each do |file|
101
101
  logger.debug(_("Found local modifications in %{file_path}" % {file_path: File.join(@path, file)}))
102
102
 
103
103
  # Do this in a block so that the extra subprocess only gets invoked when needed.
104
- logger.debug1 { git(['diff-index', '-p', 'HEAD', file], :path => @path.to_s, :raise_on_fail => false).stdout }
104
+ logger.debug1 { git(['diff-index', '-p', 'HEAD', '--', file], :path => @path.to_s, :raise_on_fail => false).stdout }
105
105
  end
106
106
 
107
107
  return dirty_files.size > 0
@@ -36,7 +36,7 @@ class R10K::Git::StatefulRepository
36
36
  end
37
37
 
38
38
  # Returns true if the sync actually updated the repo, false otherwise
39
- def sync(ref, force=true, exclude_spec=false)
39
+ def sync(ref, force=true, exclude_spec=true)
40
40
  @cache.sync if sync_cache?(ref)
41
41
 
42
42
  sha = @cache.resolve(ref)
@@ -75,7 +75,7 @@ class R10K::Git::StatefulRepository
75
75
  updated
76
76
  end
77
77
 
78
- def status(ref, exclude_spec=false)
78
+ def status(ref, exclude_spec=true)
79
79
  if !@repo.exist?
80
80
  :absent
81
81
  elsif !@cache.exist?
@@ -60,8 +60,8 @@ class R10K::Module::Base
60
60
  @environment = environment
61
61
  @overrides = args.delete(:overrides) || {}
62
62
  @spec_deletable = true
63
- @exclude_spec = false
64
- @exclude_spec = @overrides.dig(:modules, :exclude_spec) if @overrides.dig(:modules, :exclude_spec)
63
+ @exclude_spec = true
64
+ @exclude_spec = @overrides.dig(:modules, :exclude_spec) unless @overrides.dig(:modules, :exclude_spec).nil?
65
65
  if args.has_key?(:exclude_spec)
66
66
  logger.debug2 _("Overriding :exclude_spec setting with per module setting for #{@title}")
67
67
  @exclude_spec = args.delete(:exclude_spec)
@@ -78,7 +78,7 @@ class R10K::Module::Base
78
78
  path.to_s
79
79
  end
80
80
 
81
- # Delete the spec dir if @exclude_spec has been set to true and @spec_deletable is also true
81
+ # Delete the spec dir if @exclude_spec is true and @spec_deletable is also true
82
82
  def maybe_delete_spec_dir
83
83
  if @exclude_spec
84
84
  if @spec_deletable