akerl-r10k 3.14.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitattributes +1 -0
- data/.github/pull_request_template.md +4 -0
- data/.github/workflows/docker.yml +64 -0
- data/.github/workflows/release.yml +37 -0
- data/.github/workflows/rspec_tests.yml +81 -0
- data/.github/workflows/stale.yml +21 -0
- data/.gitignore +10 -0
- data/.travis.yml +42 -0
- data/CHANGELOG.mkd +1879 -0
- data/CODEOWNERS +2 -0
- data/CONTRIBUTING.mkd +105 -0
- data/Gemfile +15 -0
- data/LICENSE +14 -0
- data/README.mkd +139 -0
- data/Rakefile +3 -0
- data/bin/r10k +17 -0
- data/doc/common-patterns.mkd +45 -0
- data/doc/dynamic-environments/configuration.mkd +850 -0
- data/doc/dynamic-environments/git-environments.mkd +75 -0
- data/doc/dynamic-environments/introduction.mkd +69 -0
- data/doc/dynamic-environments/master-configuration.mkd +40 -0
- data/doc/dynamic-environments/quickstart.mkd +201 -0
- data/doc/dynamic-environments/svn-environments.mkd +45 -0
- data/doc/dynamic-environments/usage.mkd +163 -0
- data/doc/dynamic-environments/workflow-guide.mkd +247 -0
- data/doc/dynamic-environments.mkd +31 -0
- data/doc/faq.mkd +164 -0
- data/doc/git/cloning-and-mirroring.mkd +60 -0
- data/doc/git/providers.mkd +133 -0
- data/doc/puppetfile.mkd +355 -0
- data/doc/updating-your-puppetfile.mkd +38 -0
- data/docker/.gitignore +1 -0
- data/docker/.rspec +4 -0
- data/docker/Gemfile +11 -0
- data/docker/Makefile +99 -0
- data/docker/README.md +28 -0
- data/docker/docker-compose.yml +18 -0
- data/docker/r10k/Dockerfile +68 -0
- data/docker/r10k/adduser.sh +13 -0
- data/docker/r10k/docker-entrypoint.d/10-analytics.sh +30 -0
- data/docker/r10k/docker-entrypoint.sh +10 -0
- data/docker/r10k/release.Dockerfile +55 -0
- data/docker/spec/dockerfile_spec.rb +37 -0
- data/docker/spec/fixtures/Puppetfile +2 -0
- data/integration/Gemfile +19 -0
- data/integration/README.mkd +29 -0
- data/integration/Rakefile +79 -0
- data/integration/component/pre-suite/05_install_dev_r10k.rb +12 -0
- data/integration/files/README.mkd +4 -0
- data/integration/files/hiera.yaml +8 -0
- data/integration/files/modules/helloworld/manifests/init.pp +3 -0
- data/integration/files/modules/hieratest/manifests/init.pp +3 -0
- data/integration/files/modules/unicode/files/pretend_unicode +1 -0
- data/integration/files/modules/unicode/manifests/init.pp +6 -0
- data/integration/files/pre-suite/git_config.pp.erb +19 -0
- data/integration/files/pre-suite/prod_env.config +3 -0
- data/integration/files/r10k_conf.yaml.erb +9 -0
- data/integration/lib/README.mkd +4 -0
- data/integration/lib/git_utils.rb +205 -0
- data/integration/lib/master_manipulator.rb +205 -0
- data/integration/lib/r10k_utils.rb +222 -0
- data/integration/manifests/README.mkd +4 -0
- data/integration/pre-suite/00_pe_install.rb +6 -0
- data/integration/pre-suite/10_git_config.rb +48 -0
- data/integration/pre-suite/20_pe_r10k.rb +55 -0
- data/integration/pre-suite/README.mkd +5 -0
- data/integration/tests/Puppetfile/HTTP_PROXY_affects_forge_source.rb +72 -0
- data/integration/tests/Puppetfile/HTTP_PROXY_affects_git_source.rb +70 -0
- data/integration/tests/README.mkd +4 -0
- data/integration/tests/basic_functionality/basic_deployment.rb +176 -0
- data/integration/tests/basic_functionality/install_pe_only_module_with_puppetfile.rb +83 -0
- data/integration/tests/basic_functionality/negative/neg_deploy_with_invalid_r10k_yaml.rb +51 -0
- data/integration/tests/basic_functionality/negative/neg_deploy_with_missing_r10k_yaml.rb +28 -0
- data/integration/tests/basic_functionality/negative/neg_invalid_git_provider.rb +45 -0
- data/integration/tests/basic_functionality/negative/negative_bad_proxy.rb +34 -0
- data/integration/tests/basic_functionality/proxy_specified_in_configuration.rb +103 -0
- data/integration/tests/basic_functionality/proxy_with_pe_only_module.rb +128 -0
- data/integration/tests/basic_functionality/proxy_with_puppetfile.rb +61 -0
- data/integration/tests/basic_functionality/rugged_git_provider_with_ssh.rb +109 -0
- data/integration/tests/basic_functionality/rugged_git_provider_without_ssh.rb +108 -0
- data/integration/tests/command_line/deploy_env_without_mod_update.rb +76 -0
- data/integration/tests/command_line/negative/neg_deploy_env_with_module_update.rb +77 -0
- data/integration/tests/command_line/negative/neg_invalid_cmd_line_arg.rb +23 -0
- data/integration/tests/git_source/HTTP_proxy_and_git_source.rb +70 -0
- data/integration/tests/git_source/git_source_git.rb +128 -0
- data/integration/tests/git_source/git_source_repeated_remote.rb +68 -0
- data/integration/tests/git_source/git_source_ssh.rb +87 -0
- data/integration/tests/git_source/git_source_submodule.rb +70 -0
- data/integration/tests/git_source/negative/neg_git_broken_remote.rb +38 -0
- data/integration/tests/git_source/negative/neg_git_unauthorized_https.rb +46 -0
- data/integration/tests/git_source/negative/neg_git_unauthorized_ssh.rb +73 -0
- data/integration/tests/git_source/negative/neg_git_unicode_branch.rb +35 -0
- data/integration/tests/i18n/deploy_module_with_unicode_in_file_name.rb +64 -0
- data/integration/tests/purging/content_not_purged_at_root.rb +89 -0
- data/integration/tests/purging/default_purging.rb +125 -0
- data/integration/tests/purging/does_not_purge_files_on_white_list.rb +93 -0
- data/integration/tests/purging/invalid_whitelist_types.rb +63 -0
- data/integration/tests/user_scenario/basic_workflow/multi_env_1000_branches.rb +66 -0
- data/integration/tests/user_scenario/basic_workflow/multi_env_custom_forge_git_module.rb +112 -0
- data/integration/tests/user_scenario/basic_workflow/multi_env_custom_forge_git_module_static.rb +118 -0
- data/integration/tests/user_scenario/basic_workflow/multi_env_hiera.rb +100 -0
- data/integration/tests/user_scenario/basic_workflow/multi_env_multi_source.rb +133 -0
- data/integration/tests/user_scenario/basic_workflow/multi_source_custom_forge_git_module.rb +161 -0
- data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_basedir.rb +46 -0
- data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_forge_module.rb +48 -0
- data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_git_module.rb +45 -0
- data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_git_module_ref.rb +43 -0
- data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_git_remote.rb +45 -0
- data/integration/tests/user_scenario/basic_workflow/negative/neg_branch_name_collision.rb +64 -0
- data/integration/tests/user_scenario/basic_workflow/negative/neg_disk_full.rb +75 -0
- data/integration/tests/user_scenario/basic_workflow/negative/neg_duplicate_module_names.rb +44 -0
- data/integration/tests/user_scenario/basic_workflow/negative/neg_inaccessible_forge.rb +58 -0
- data/integration/tests/user_scenario/basic_workflow/negative/neg_invalid_env_name.rb +34 -0
- data/integration/tests/user_scenario/basic_workflow/negative/neg_invalid_puppet_file.rb +36 -0
- data/integration/tests/user_scenario/basic_workflow/negative/neg_module_specified_at_deleted_release.rb +49 -0
- data/integration/tests/user_scenario/basic_workflow/negative/neg_read_only.rb +58 -0
- data/integration/tests/user_scenario/basic_workflow/negative/neg_specify_deleted_forge_module.rb +45 -0
- data/integration/tests/user_scenario/basic_workflow/single_env_10000_files.rb +75 -0
- data/integration/tests/user_scenario/basic_workflow/single_env_custom_forge_git_module.rb +105 -0
- data/integration/tests/user_scenario/basic_workflow/single_env_custom_forge_module.rb +81 -0
- data/integration/tests/user_scenario/basic_workflow/single_env_custom_module.rb +49 -0
- data/integration/tests/user_scenario/basic_workflow/single_env_large_files.rb +75 -0
- data/integration/tests/user_scenario/basic_workflow/single_env_module_already_installed.rb +82 -0
- data/integration/tests/user_scenario/basic_workflow/single_env_module_last_release_deleted.rb +68 -0
- data/integration/tests/user_scenario/basic_workflow/single_env_non-existent_base_dir.rb +94 -0
- data/integration/tests/user_scenario/basic_workflow/single_env_purge_unmanaged_modules.rb +89 -0
- data/integration/tests/user_scenario/basic_workflow/single_env_switch_forge_git_module.rb +117 -0
- data/integration/tests/user_scenario/basic_workflow/single_env_unicode_paths.rb +60 -0
- data/integration/tests/user_scenario/basic_workflow/single_env_upgrade_forge_mod_revert_change.rb +166 -0
- data/integration/tests/user_scenario/complex_workflow/multi_env_add_change_remove.rb +163 -0
- data/integration/tests/user_scenario/complex_workflow/multi_env_remove_re-add.rb +111 -0
- data/integration/tests/user_scenario/complex_workflow/multi_env_unamanaged.rb +78 -0
- data/integration/tests/user_scenario/complex_workflow/single_env_git_module_update.rb +100 -0
- data/lib/r10k/action/base.rb +41 -0
- data/lib/r10k/action/cri_runner.rb +72 -0
- data/lib/r10k/action/deploy/deploy_helpers.rb +38 -0
- data/lib/r10k/action/deploy/display.rb +128 -0
- data/lib/r10k/action/deploy/environment.rb +260 -0
- data/lib/r10k/action/deploy/module.rb +139 -0
- data/lib/r10k/action/deploy.rb +9 -0
- data/lib/r10k/action/puppetfile/check.rb +35 -0
- data/lib/r10k/action/puppetfile/cri_runner.rb +26 -0
- data/lib/r10k/action/puppetfile/install.rb +48 -0
- data/lib/r10k/action/puppetfile/purge.rb +37 -0
- data/lib/r10k/action/puppetfile.rb +10 -0
- data/lib/r10k/action/runner.rb +171 -0
- data/lib/r10k/action/visitor.rb +34 -0
- data/lib/r10k/cli/deploy.rb +126 -0
- data/lib/r10k/cli/ext/logging.rb +15 -0
- data/lib/r10k/cli/help.rb +7 -0
- data/lib/r10k/cli/puppetfile.rb +73 -0
- data/lib/r10k/cli/version.rb +31 -0
- data/lib/r10k/cli.rb +51 -0
- data/lib/r10k/content_synchronizer.rb +95 -0
- data/lib/r10k/deployment/config.rb +56 -0
- data/lib/r10k/deployment.rb +132 -0
- data/lib/r10k/environment/bare.rb +13 -0
- data/lib/r10k/environment/base.rb +230 -0
- data/lib/r10k/environment/git.rb +93 -0
- data/lib/r10k/environment/name.rb +109 -0
- data/lib/r10k/environment/plain.rb +16 -0
- data/lib/r10k/environment/svn.rb +98 -0
- data/lib/r10k/environment/tarball.rb +78 -0
- data/lib/r10k/environment/with_modules.rb +174 -0
- data/lib/r10k/environment.rb +39 -0
- data/lib/r10k/errors/formatting.rb +28 -0
- data/lib/r10k/errors.rb +66 -0
- data/lib/r10k/feature/collection.rb +23 -0
- data/lib/r10k/feature.rb +56 -0
- data/lib/r10k/features.rb +20 -0
- data/lib/r10k/forge/module_release.rb +229 -0
- data/lib/r10k/git/alternates.rb +63 -0
- data/lib/r10k/git/cache.rb +107 -0
- data/lib/r10k/git/errors.rb +34 -0
- data/lib/r10k/git/rugged/bare_repository.rb +85 -0
- data/lib/r10k/git/rugged/base_repository.rb +104 -0
- data/lib/r10k/git/rugged/cache.rb +19 -0
- data/lib/r10k/git/rugged/credentials.rb +205 -0
- data/lib/r10k/git/rugged/thin_repository.rb +96 -0
- data/lib/r10k/git/rugged/working_repository.rb +149 -0
- data/lib/r10k/git/rugged.rb +17 -0
- data/lib/r10k/git/shellgit/bare_repository.rb +43 -0
- data/lib/r10k/git/shellgit/base_repository.rb +137 -0
- data/lib/r10k/git/shellgit/cache.rb +11 -0
- data/lib/r10k/git/shellgit/thin_repository.rb +73 -0
- data/lib/r10k/git/shellgit/working_repository.rb +112 -0
- data/lib/r10k/git/shellgit.rb +9 -0
- data/lib/r10k/git/stateful_repository.rb +109 -0
- data/lib/r10k/git.rb +200 -0
- data/lib/r10k/initializers.rb +93 -0
- data/lib/r10k/instance_cache.rb +32 -0
- data/lib/r10k/keyed_factory.rb +39 -0
- data/lib/r10k/logging/terminaloutputter.rb +36 -0
- data/lib/r10k/logging.rb +186 -0
- data/lib/r10k/module/base.rb +182 -0
- data/lib/r10k/module/definition.rb +64 -0
- data/lib/r10k/module/forge.rb +208 -0
- data/lib/r10k/module/git.rb +156 -0
- data/lib/r10k/module/local.rb +40 -0
- data/lib/r10k/module/metadata_file.rb +31 -0
- data/lib/r10k/module/svn.rb +129 -0
- data/lib/r10k/module/tarball.rb +101 -0
- data/lib/r10k/module.rb +57 -0
- data/lib/r10k/module_loader/puppetfile/dsl.rb +42 -0
- data/lib/r10k/module_loader/puppetfile.rb +290 -0
- data/lib/r10k/puppetfile.rb +211 -0
- data/lib/r10k/settings/collection.rb +123 -0
- data/lib/r10k/settings/container.rb +97 -0
- data/lib/r10k/settings/definition.rb +124 -0
- data/lib/r10k/settings/enum_definition.rb +30 -0
- data/lib/r10k/settings/helpers.rb +38 -0
- data/lib/r10k/settings/list.rb +107 -0
- data/lib/r10k/settings/loader.rb +99 -0
- data/lib/r10k/settings/mixin.rb +54 -0
- data/lib/r10k/settings/uri_definition.rb +19 -0
- data/lib/r10k/settings.rb +312 -0
- data/lib/r10k/source/base.rb +93 -0
- data/lib/r10k/source/exec.rb +51 -0
- data/lib/r10k/source/git.rb +178 -0
- data/lib/r10k/source/hash.rb +182 -0
- data/lib/r10k/source/svn.rb +142 -0
- data/lib/r10k/source/yaml.rb +20 -0
- data/lib/r10k/source/yamldir.rb +32 -0
- data/lib/r10k/source.rb +42 -0
- data/lib/r10k/svn/remote.rb +68 -0
- data/lib/r10k/svn/working_dir.rb +125 -0
- data/lib/r10k/svn.rb +6 -0
- data/lib/r10k/tarball.rb +183 -0
- data/lib/r10k/util/attempt.rb +84 -0
- data/lib/r10k/util/basedir.rb +65 -0
- data/lib/r10k/util/cacheable.rb +31 -0
- data/lib/r10k/util/cleaner.rb +21 -0
- data/lib/r10k/util/commands.rb +31 -0
- data/lib/r10k/util/downloader.rb +134 -0
- data/lib/r10k/util/exec_env.rb +36 -0
- data/lib/r10k/util/license.rb +24 -0
- data/lib/r10k/util/platform.rb +42 -0
- data/lib/r10k/util/purgeable.rb +154 -0
- data/lib/r10k/util/setopts.rb +78 -0
- data/lib/r10k/util/subprocess/result.rb +56 -0
- data/lib/r10k/util/subprocess/runner/jruby.rb +23 -0
- data/lib/r10k/util/subprocess/runner/posix.rb +103 -0
- data/lib/r10k/util/subprocess/runner/pump.rb +59 -0
- data/lib/r10k/util/subprocess/runner/windows.rb +23 -0
- data/lib/r10k/util/subprocess/runner.rb +26 -0
- data/lib/r10k/util/subprocess/subprocess_error.rb +24 -0
- data/lib/r10k/util/subprocess.rb +85 -0
- data/lib/r10k/util/symbolize_keys.rb +35 -0
- data/lib/r10k/version.rb +6 -0
- data/lib/r10k.rb +11 -0
- data/locales/config.yaml +21 -0
- data/locales/r10k.pot +693 -0
- data/r10k.gemspec +52 -0
- data/r10k.yaml.example +140 -0
- data/spec/fixtures/empty/.empty +0 -0
- data/spec/fixtures/integration/git/puppet-boolean-bare.tar +0 -0
- data/spec/fixtures/module/forge/bad_module/metadata.json +1 -0
- data/spec/fixtures/module/forge/eight_hundred/Modulefile +8 -0
- data/spec/fixtures/module/forge/eight_hundred/metadata.json +19 -0
- data/spec/fixtures/tarball/tarball.tar.gz +0 -0
- data/spec/fixtures/unit/action/r10k.yaml +5 -0
- data/spec/fixtures/unit/action/r10k_cachedir.yaml +2 -0
- data/spec/fixtures/unit/action/r10k_creds.yaml +9 -0
- data/spec/fixtures/unit/action/r10k_forge_auth.yaml +4 -0
- data/spec/fixtures/unit/action/r10k_forge_auth_no_url.yaml +3 -0
- data/spec/fixtures/unit/action/r10k_generate_types.yaml +3 -0
- data/spec/fixtures/unit/action/r10k_logging.yaml +12 -0
- data/spec/fixtures/unit/action/r10k_puppet_path.yaml +3 -0
- data/spec/fixtures/unit/puppetfile/argument-error/Puppetfile +1 -0
- data/spec/fixtures/unit/puppetfile/default-branch-override/Puppetfile +5 -0
- data/spec/fixtures/unit/puppetfile/duplicate-module-error/Puppetfile +10 -0
- data/spec/fixtures/unit/puppetfile/forge-override/Puppetfile +8 -0
- data/spec/fixtures/unit/puppetfile/invalid-syntax/Puppetfile +1 -0
- data/spec/fixtures/unit/puppetfile/load-error/Puppetfile +1 -0
- data/spec/fixtures/unit/puppetfile/name-error/Puppetfile +1 -0
- data/spec/fixtures/unit/puppetfile/valid-forge-with-version/Puppetfile +1 -0
- data/spec/fixtures/unit/puppetfile/valid-forge-without-version/Puppetfile +1 -0
- data/spec/fixtures/unit/puppetfile/various-modules/Puppetfile +10 -0
- data/spec/fixtures/unit/puppetfile/various-modules/Puppetfile.new +10 -0
- data/spec/fixtures/unit/puppetfile/various-modules/modules/apt/.gitkeep +1 -0
- data/spec/fixtures/unit/puppetfile/various-modules/modules/baz/.gitkeep +1 -0
- data/spec/fixtures/unit/puppetfile/various-modules/modules/buzz/.gitkeep +1 -0
- data/spec/fixtures/unit/puppetfile/various-modules/modules/canary/.gitkeep +1 -0
- data/spec/fixtures/unit/puppetfile/various-modules/modules/fizz/.gitkeep +1 -0
- data/spec/fixtures/unit/puppetfile/various-modules/modules/rpm/.gitkeep +1 -0
- data/spec/fixtures/unit/util/purgeable/managed_one/expected_1 +0 -0
- data/spec/fixtures/unit/util/purgeable/managed_one/managed_subdir_1/managed_symlink_file +1 -0
- data/spec/fixtures/unit/util/purgeable/managed_one/managed_subdir_1/subdir_allowlisted_2/ignored_1 +0 -0
- data/spec/fixtures/unit/util/purgeable/managed_one/managed_subdir_1/subdir_expected_1 +0 -0
- data/spec/fixtures/unit/util/purgeable/managed_one/managed_subdir_1/subdir_unmanaged_1 +0 -0
- data/spec/fixtures/unit/util/purgeable/managed_one/managed_subdir_1/unmanaged_symlink_dir +1 -0
- data/spec/fixtures/unit/util/purgeable/managed_one/managed_symlink_dir +1 -0
- data/spec/fixtures/unit/util/purgeable/managed_one/unmanaged_1 +0 -0
- data/spec/fixtures/unit/util/purgeable/managed_one/unmanaged_symlink_file +1 -0
- data/spec/fixtures/unit/util/purgeable/managed_two/.hidden/unmanaged_3 +0 -0
- data/spec/fixtures/unit/util/purgeable/managed_two/expected_2 +0 -0
- data/spec/fixtures/unit/util/purgeable/managed_two/unmanaged_2 +0 -0
- data/spec/fixtures/unit/util/subprocess/runner/no-execute.sh +3 -0
- data/spec/integration/git/rugged/bare_repository_spec.rb +13 -0
- data/spec/integration/git/rugged/cache_spec.rb +33 -0
- data/spec/integration/git/rugged/thin_repository_spec.rb +14 -0
- data/spec/integration/git/rugged/working_repository_spec.rb +48 -0
- data/spec/integration/git/shellgit/bare_repository_spec.rb +13 -0
- data/spec/integration/git/shellgit/thin_repository_spec.rb +14 -0
- data/spec/integration/git/shellgit/working_repository_spec.rb +13 -0
- data/spec/integration/git/stateful_repository_spec.rb +175 -0
- data/spec/integration/util/purageable_spec.rb +41 -0
- data/spec/matchers/exit_with.rb +28 -0
- data/spec/matchers/match_realpath.rb +18 -0
- data/spec/r10k-mocks/mock_config.rb +33 -0
- data/spec/r10k-mocks/mock_env.rb +18 -0
- data/spec/r10k-mocks/mock_source.rb +17 -0
- data/spec/r10k-mocks.rb +3 -0
- data/spec/shared-contexts/git-fixtures.rb +55 -0
- data/spec/shared-contexts/tarball.rb +32 -0
- data/spec/shared-examples/deploy-actions.rb +69 -0
- data/spec/shared-examples/git/bare_repository.rb +132 -0
- data/spec/shared-examples/git/thin_repository.rb +26 -0
- data/spec/shared-examples/git/working_repository.rb +207 -0
- data/spec/shared-examples/git-repository.rb +38 -0
- data/spec/shared-examples/puppetfile-action.rb +39 -0
- data/spec/shared-examples/settings/ancestry.rb +44 -0
- data/spec/shared-examples/subprocess-runner.rb +89 -0
- data/spec/spec_helper.rb +41 -0
- data/spec/unit/action/cri_runner_spec.rb +72 -0
- data/spec/unit/action/deploy/deploy_helpers_spec.rb +38 -0
- data/spec/unit/action/deploy/display_spec.rb +61 -0
- data/spec/unit/action/deploy/environment_spec.rb +640 -0
- data/spec/unit/action/deploy/module_spec.rb +476 -0
- data/spec/unit/action/puppetfile/check_spec.rb +53 -0
- data/spec/unit/action/puppetfile/cri_runner_spec.rb +47 -0
- data/spec/unit/action/puppetfile/install_spec.rb +112 -0
- data/spec/unit/action/puppetfile/purge_spec.rb +60 -0
- data/spec/unit/action/runner_spec.rb +407 -0
- data/spec/unit/action/visitor_spec.rb +39 -0
- data/spec/unit/cli_spec.rb +9 -0
- data/spec/unit/deployment/config_spec.rb +33 -0
- data/spec/unit/deployment_spec.rb +162 -0
- data/spec/unit/environment/bare_spec.rb +13 -0
- data/spec/unit/environment/base_spec.rb +122 -0
- data/spec/unit/environment/git_spec.rb +114 -0
- data/spec/unit/environment/name_spec.rb +181 -0
- data/spec/unit/environment/plain_spec.rb +8 -0
- data/spec/unit/environment/svn_spec.rb +146 -0
- data/spec/unit/environment/tarball_spec.rb +45 -0
- data/spec/unit/environment/with_modules_spec.rb +122 -0
- data/spec/unit/errors/formatting_spec.rb +84 -0
- data/spec/unit/feature_spec.rb +50 -0
- data/spec/unit/forge/module_release_spec.rb +213 -0
- data/spec/unit/git/alternates_spec.rb +116 -0
- data/spec/unit/git/cache_spec.rb +66 -0
- data/spec/unit/git/rugged/cache_spec.rb +48 -0
- data/spec/unit/git/rugged/credentials_spec.rb +215 -0
- data/spec/unit/git/shellgit/cache_spec.rb +27 -0
- data/spec/unit/git/stateful_repository_spec.rb +45 -0
- data/spec/unit/git_spec.rb +102 -0
- data/spec/unit/initializers_spec.rb +68 -0
- data/spec/unit/instance_cache_spec.rb +78 -0
- data/spec/unit/keyed_factory_spec.rb +51 -0
- data/spec/unit/logging/terminaloutputter_spec.rb +53 -0
- data/spec/unit/logging_spec.rb +68 -0
- data/spec/unit/module/base_spec.rb +118 -0
- data/spec/unit/module/forge_spec.rb +271 -0
- data/spec/unit/module/git_spec.rb +387 -0
- data/spec/unit/module/metadata_file_spec.rb +68 -0
- data/spec/unit/module/svn_spec.rb +208 -0
- data/spec/unit/module/tarball_spec.rb +70 -0
- data/spec/unit/module_loader/puppetfile_spec.rb +421 -0
- data/spec/unit/module_spec.rb +114 -0
- data/spec/unit/puppetfile_spec.rb +304 -0
- data/spec/unit/settings/collection_spec.rb +123 -0
- data/spec/unit/settings/container_spec.rb +92 -0
- data/spec/unit/settings/definition_spec.rb +79 -0
- data/spec/unit/settings/enum_definition_spec.rb +20 -0
- data/spec/unit/settings/inheritance_spec.rb +38 -0
- data/spec/unit/settings/list_spec.rb +88 -0
- data/spec/unit/settings/loader_spec.rb +110 -0
- data/spec/unit/settings/uri_definition_spec.rb +23 -0
- data/spec/unit/settings_spec.rb +303 -0
- data/spec/unit/source/base_spec.rb +31 -0
- data/spec/unit/source/exec_spec.rb +81 -0
- data/spec/unit/source/git_spec.rb +233 -0
- data/spec/unit/source/hash_spec.rb +54 -0
- data/spec/unit/source/svn_spec.rb +196 -0
- data/spec/unit/source/yaml_spec.rb +42 -0
- data/spec/unit/source_spec.rb +10 -0
- data/spec/unit/svn/remote_spec.rb +21 -0
- data/spec/unit/svn/working_dir_spec.rb +56 -0
- data/spec/unit/tarball_spec.rb +57 -0
- data/spec/unit/util/attempt_spec.rb +82 -0
- data/spec/unit/util/cacheable_spec.rb +23 -0
- data/spec/unit/util/commands_spec.rb +61 -0
- data/spec/unit/util/downloader_spec.rb +98 -0
- data/spec/unit/util/exec_env_spec.rb +56 -0
- data/spec/unit/util/purgeable_spec.rb +267 -0
- data/spec/unit/util/setopts_spec.rb +83 -0
- data/spec/unit/util/subprocess/result_spec.rb +36 -0
- data/spec/unit/util/subprocess/runner/posix_spec.rb +7 -0
- data/spec/unit/util/subprocess/runner/pump_spec.rb +79 -0
- data/spec/unit/util/subprocess/runner/windows_spec.rb +7 -0
- data/spec/unit/util/subprocess/subprocess_error_spec.rb +26 -0
- data/spec/unit/util/subprocess_spec.rb +65 -0
- data/spec/unit/util/symbolize_keys_spec.rb +67 -0
- metadata +637 -0
@@ -0,0 +1,421 @@
|
|
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: 'https://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 versions unless the module install path does not exist on disk' 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::Git)
|
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
|
@@ -0,0 +1,114 @@
|
|
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
|