From 153e206e7c0a4b3f244d5afbee136cc54cc72e84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Couralet?= Date: Thu, 18 Feb 2021 08:38:04 +0100 Subject: [PATCH] Add parameters to `apt::source` to avoid requiring an internet connexion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Cedric Couralet Signed-off-by: Cédric Couralet --- manifests/init.pp | 44 +++++++++++++++------------ spec/classes/gitlab_ci_runner_spec.rb | 34 +++++++++++++++++++++ 2 files changed, 58 insertions(+), 20 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 3d65137..9608389 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -41,6 +41,9 @@ # The name of the package. # @param repo_base_url # The base repository url. +# @param repo_keyid +# Specifies a GPG key to authenticate Apt package signatures. Valid options: a string containing a key ID (8 or 16 hexadecimal +# characters, optionally prefixed with "0x") or a full key fingerprint (40 hexadecimal characters). # @param repo_keyserver # The keyserver which should be used to get the repository key. # @param repo_keycontent @@ -54,26 +57,27 @@ # The path to the config file of Gitlab runner. # class gitlab_ci_runner ( - String $xz_package_name, # Defaults in module hieradata - Hash $runners = {}, - Hash $runner_defaults = {}, - Optional[Integer] $concurrent = undef, - Optional[Integer] $check_interval = undef, - Optional[String] $builds_dir = undef, - Optional[String] $cache_dir = undef, - Optional[Pattern[/.*:.+/]] $metrics_server = undef, - Optional[Pattern[/.*:.+/]] $listen_address = undef, - Optional[String] $sentry_dsn = undef, - Boolean $manage_docker = false, - Boolean $manage_repo = true, - String $package_ensure = installed, - String $package_name = 'gitlab-runner', - Stdlib::HTTPUrl $repo_base_url = 'https://packages.gitlab.com', - Optional[Stdlib::Fqdn] $repo_keyserver = undef, - Optional[String] $repo_keycontent = undef, - Optional[Pattern[/\Ahttps?:\/\//, /\Aftp:\/\//, /\A\/\w+/]] $repo_keysource = undef, - Boolean $repo_keyweak_ssl = false, - String $config_path = '/etc/gitlab-runner/config.toml', + String $xz_package_name, # Defaults in module hieradata + Hash $runners = {}, + Hash $runner_defaults = {}, + Optional[Integer] $concurrent = undef, + Optional[Integer] $check_interval = undef, + Optional[String] $builds_dir = undef, + Optional[String] $cache_dir = undef, + Optional[Pattern[/.*:.+/]] $metrics_server = undef, + Optional[Pattern[/.*:.+/]] $listen_address = undef, + Optional[String] $sentry_dsn = undef, + Boolean $manage_docker = false, + Boolean $manage_repo = true, + String $package_ensure = installed, + String $package_name = 'gitlab-runner', + Stdlib::HTTPUrl $repo_base_url = 'https://packages.gitlab.com', + Optional[Pattern[/\A(0x)?[0-9a-fA-F]{8}\Z/, /\A(0x)?[0-9a-fA-F]{16}\Z/, /\A(0x)?[0-9a-fA-F]{40}\Z/]] $repo_keyid = undef, + Optional[Stdlib::Fqdn] $repo_keyserver = undef, + Optional[String] $repo_keycontent = undef, + Optional[Pattern[/\Ahttps?:\/\//, /\Aftp:\/\//, /\A\/\w+/]] $repo_keysource = undef, + Boolean $repo_keyweak_ssl = false, + String $config_path = '/etc/gitlab-runner/config.toml', ) { if $manage_docker { # workaround for cirunner issue #1617 diff --git a/spec/classes/gitlab_ci_runner_spec.rb b/spec/classes/gitlab_ci_runner_spec.rb index 3991311..ea19d39 100644 --- a/spec/classes/gitlab_ci_runner_spec.rb +++ b/spec/classes/gitlab_ci_runner_spec.rb @@ -298,6 +298,40 @@ end end end + if facts[:os]['family'] == 'Debian' + context 'with manage_repo => true and repo_keysource => http://path.to/gpg.key' do + let(:params) do + super().merge( + manage_repo: true, + repo_keysource: 'http://path.to/gpg.key' + ) + end + + it { is_expected.to compile } + it { is_expected.to contain_class('gitlab_ci_runner::repo') } + + it do + is_expected.to contain_apt__source('apt_gitlabci').with_key('id' => 'F6403F6544A38863DAA0B6E03F01618A51312F3F', 'source' => 'http://path.to/gpg.key') + end + end + end + if facts[:os]['family'] == 'Debian' + context 'with manage_repo => true and repo_keycontent => "somebase64encodedContent"' do + let(:params) do + super().merge( + manage_repo: true, + repo_keycontent: 'somebase64encodedContent' + ) + end + + it { is_expected.to compile } + it { is_expected.to contain_class('gitlab_ci_runner::repo') } + + it do + is_expected.to contain_apt__source('apt_gitlabci').with_key('id' => 'F6403F6544A38863DAA0B6E03F01618A51312F3F', 'content' => 'somebase64encodedContent') + end + end + end end end end