From d1aff4a5f3f3c599e57d2f49f84727758aac669b Mon Sep 17 00:00:00 2001 From: olavst-spk Date: Thu, 15 Feb 2024 15:05:36 +0100 Subject: [PATCH] Make cni_plugins download url configurable with a template string --- REFERENCE.md | 18 +++++++++--------- manifests/install/cni_plugins.pp | 18 +++++++++++------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/REFERENCE.md b/REFERENCE.md index 1e1b3d3..906877e 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -499,18 +499,10 @@ Class: k8s::install::cni_plugins The following parameters are available in the `k8s::install::cni_plugins` class: -* [`arch`](#-k8s--install--cni_plugins--arch) * [`ensure`](#-k8s--install--cni_plugins--ensure) * [`method`](#-k8s--install--cni_plugins--method) * [`version`](#-k8s--install--cni_plugins--version) - -##### `arch` - -Data type: `String[1]` - -sets the arch to use for binary download - -Default value: `'amd64'` +* [`download_url_template`](#-k8s--install--cni_plugins--download_url_template) ##### `ensure` @@ -536,6 +528,14 @@ sets the version to use Default value: `'v1.2.0'` +##### `download_url_template` + +Data type: `String[1]` + +template string for the cni_plugins download url + +Default value: `'https://github.com/containernetworking/plugins/releases/download/%{version}/cni-plugins-linux-%{arch}-%{version}.tgz'` + ### `k8s::install::container_runtime` Class: k8s::install::container_runtime diff --git a/manifests/install/cni_plugins.pp b/manifests/install/cni_plugins.pp index 8fe1721..50715a9 100644 --- a/manifests/install/cni_plugins.pp +++ b/manifests/install/cni_plugins.pp @@ -2,16 +2,16 @@ # # @summary manages the installation of the cni plugins # -# @param arch sets the arch to use for binary download # @param ensure set ensure for installation or deinstallation # @param method installation method # @param version sets the version to use +# @param download_url_template template string for the cni_plugins download url # class k8s::install::cni_plugins ( - K8s::Ensure $ensure = $k8s::ensure, - String[1] $version = 'v1.2.0', - String[1] $arch = 'amd64', - String[1] $method = $k8s::native_packaging, + K8s::Ensure $ensure = $k8s::ensure, + String[1] $version = 'v1.2.0', + String[1] $method = $k8s::native_packaging, + String[1] $download_url_template = 'https://github.com/containernetworking/plugins/releases/download/%{version}/cni-plugins-linux-%{arch}-%{version}.tgz', ) { file { default: @@ -24,14 +24,18 @@ case $method { 'tarball', 'loose': { + $_url = k8s::format_url($download_url_template, { + version => $version, + }) + file { '/opt/cni/bin': ensure => directory, } archive { 'cni-plugins': ensure => $ensure, - path => "/tmp/cni-plugins-linux--${arch}-${version}.tgz", - source => "https://github.com/containernetworking/plugins/releases/download/${version}/cni-plugins-linux-${arch}-${version}.tgz", + path => "/tmp/cni-plugins-linux-${version}.tgz", + source => $_url, extract => true, extract_path => '/opt/cni/bin', creates => '/opt/cni/bin/bridge',