Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make cni_plugins download url configurable with a template string #82

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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