Skip to content

Commit

Permalink
Merge pull request #83 from StatensPensjonskasse/crictl_download_url
Browse files Browse the repository at this point in the history
Use a template string for the crictl download URL
  • Loading branch information
rwaffen authored Feb 20, 2024
2 parents 4393ce5 + daf861e commit 497e043
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 24 deletions.
17 changes: 4 additions & 13 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -618,11 +618,10 @@ The following parameters are available in the `k8s::install::crictl` class:

* [`ensure`](#-k8s--install--crictl--ensure)
* [`version`](#-k8s--install--crictl--version)
* [`arch`](#-k8s--install--crictl--arch)
* [`config`](#-k8s--install--crictl--config)
* [`crictl_package`](#-k8s--install--crictl--crictl_package)
* [`manage_repo`](#-k8s--install--crictl--manage_repo)
* [`download_url`](#-k8s--install--crictl--download_url)
* [`download_url_template`](#-k8s--install--crictl--download_url_template)

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

Expand All @@ -640,14 +639,6 @@ the k8s version

Default value: `'v1.26.0'`

##### <a name="-k8s--install--crictl--arch"></a>`arch`

Data type: `String[1]`

os architecture

Default value: `'amd64'`

##### <a name="-k8s--install--crictl--config"></a>`config`

Data type: `Hash`
Expand Down Expand Up @@ -675,13 +666,13 @@ whether to manage the repo or not

Default value: `$k8s::manage_repo`

##### <a name="-k8s--install--crictl--download_url"></a>`download_url`
##### <a name="-k8s--install--crictl--download_url_template"></a>`download_url_template`

Data type: `Stdlib::HTTPUrl`

where to download the tar.gz from
template string for the URL to download tar.gz from

Default value: `"https://github.com/kubernetes-sigs/cri-tools/releases/download/${version}/crictl-${version}-linux-${arch}.tar.gz"`
Default value: `'https://github.com/kubernetes-sigs/cri-tools/releases/download/%{version}/crictl-%{version}-linux-%{arch}.tar.gz'`

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

Expand Down
24 changes: 13 additions & 11 deletions manifests/install/crictl.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,21 @@
#
# @param ensure set ensure for installation or deinstallation
# @param version the k8s version
# @param arch os architecture
# @param config config for crictl, for example:
# k8s::install::crictl::config:
# 'runtime-endpoint': 'unix:///run/containerd/containerd.sock'
# 'image-endpoint': 'unix:///run/containerd/containerd.sock'
# @param crictl_package the package name of crictl
# @param manage_repo whether to manage the repo or not
# @param download_url where to download the tar.gz from
# @param download_url_template template string for the URL to download tar.gz from
#
class k8s::install::crictl (
Boolean $manage_repo = $k8s::manage_repo,
Hash $config = {},
K8s::Ensure $ensure = $k8s::ensure,
Optional[String[1]] $crictl_package = $k8s::crictl_package,
String[1] $arch = 'amd64',
String[1] $version = 'v1.26.0',
Stdlib::HTTPUrl $download_url = "https://github.com/kubernetes-sigs/cri-tools/releases/download/${version}/crictl-${version}-linux-${arch}.tar.gz",
Boolean $manage_repo = $k8s::manage_repo,
Hash $config = {},
K8s::Ensure $ensure = $k8s::ensure,
Optional[String[1]] $crictl_package = $k8s::crictl_package,
String[1] $version = 'v1.26.0',
Stdlib::HTTPUrl $download_url_template = 'https://github.com/kubernetes-sigs/cri-tools/releases/download/%{version}/crictl-%{version}-linux-%{arch}.tar.gz',
) {
if $manage_repo {
$pkg = pick($crictl_package, 'cri-tools')
Expand All @@ -33,10 +31,14 @@

$config_require = Package[$pkg]
} else {
$_url = k8s::format_url($download_url_template, {
version => $version,
})

archive { 'crictl':
ensure => $ensure,
path => "/tmp/crictl-${version}-linux-${arch}.tar.gz",
source => $download_url,
path => "/tmp/crictl-${version}-linux.tar.gz",
source => $_url,
extract => true,
extract_path => '/usr/local/bin',
creates => '/usr/local/bin/crictl',
Expand Down

0 comments on commit 497e043

Please sign in to comment.