Skip to content

Commit

Permalink
Merge pull request #82 from StatensPensjonskasse/cni_plugins_download…
Browse files Browse the repository at this point in the history
…_url

Make cni_plugins download url configurable with a template string
  • Loading branch information
rwaffen authored Feb 20, 2024
2 parents 8087b7e + d1aff4a commit 4393ce5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
18 changes: 9 additions & 9 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

##### <a name="-k8s--install--cni_plugins--arch"></a>`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)

##### <a name="-k8s--install--cni_plugins--ensure"></a>`ensure`

Expand All @@ -536,6 +528,14 @@ sets the version to use

Default value: `'v1.2.0'`

##### <a name="-k8s--install--cni_plugins--download_url_template"></a>`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'`

### <a name="k8s--install--container_runtime"></a>`k8s::install::container_runtime`

Class: k8s::install::container_runtime
Expand Down
18 changes: 11 additions & 7 deletions manifests/install/cni_plugins.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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',
Expand Down

0 comments on commit 4393ce5

Please sign in to comment.