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

puppet8 support #175

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion examples/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
# Learn more about module testing here:
# https://docs.puppet.com/guides/tests_smoke.html
#
include ::helm
include helm
4 changes: 2 additions & 2 deletions manifests/binary.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Optional[String] $proxy = $helm::proxy,
String $archive_baseurl = $helm::archive_baseurl,
) {
case $::architecture {
case $facts['os']['architecture'] {
'amd64': {
$arch = 'amd64'
}
Expand All @@ -19,7 +19,7 @@
$arch = 'amd64'
}
default: {
fail("${::architecture} is not supported")
fail("${facts['os']['architecture']} is not supported")
}
}

Expand Down
32 changes: 17 additions & 15 deletions manifests/chart.pp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@
# @param chart
# The file system location of the package.
#
# @param namespace
#
# @param tiller_namespace
#
# @param tls_key
#
define helm::chart (
String $ensure = present,
Optional[String] $ca_file = undef,
Expand All @@ -129,27 +135,27 @@
Boolean $replace = false,
Optional[String] $repo = undef,
Optional[String] $release_name = undef,
Array $set = [],
Optional[Array] $set = undef,
Optional[Integer] $timeout = undef,
String $tiller_namespace = 'kube-system',
Boolean $tls = false,
Optional[String] $tls_ca_cert = undef,
Optional[String] $tls_cert = undef,
Optional[String] $tls_key = undef,
Boolean $tls_verify = false,
Array $values = [],
Optional[Array] $values = undef,
Boolean $verify = false,
Optional[String] $version = undef,
Boolean $wait = false,
) {
include ::helm::params
include helm::params

if ($release_name == undef) {
fail("\nYou must specify a name for the service with the release_name attribute \neg: release_name => 'mysql'")
}

if $ensure == present {
$helm_install_flags = helm_install_flags( {
$helm_install_flags = helm_install_flags({
ensure => $ensure,
ca_file => $ca_file,
cert_file => $cert_file,
Expand Down Expand Up @@ -180,11 +186,10 @@
verify => $verify,
version => $version,
wait => $wait,
}
)
})
$exec = "helm install ${name}"
$exec_chart = "helm ${helm_install_flags}"
$helm_ls_flags = helm_ls_flags( {
$helm_ls_flags = helm_ls_flags({
ls => true,
home => $home,
host => $host,
Expand All @@ -196,13 +201,12 @@
tls_cert => $tls_cert,
tls_key => $tls_key,
tls_verify => $tls_verify,
}
)
})
$unless_chart = "helm ${helm_ls_flags} | grep -q '^${release_name}$'"
}

if $ensure == absent {
$helm_delete_flags = helm_delete_flags( {
$helm_delete_flags = helm_delete_flags({
ensure => $ensure,
debug => $debug,
dry_run => $dry_run,
Expand All @@ -221,11 +225,10 @@
tls_cert => $tls_cert,
tls_key => $tls_key,
tls_verify => $tls_verify,
}
)
})
$exec = "helm delete ${name}"
$exec_chart = "helm ${helm_delete_flags}"
$helm_ls_flags = helm_ls_flags( {
$helm_ls_flags = helm_ls_flags({
ls => true,
home => $home,
host => $host,
Expand All @@ -237,8 +240,7 @@
tls_cert => $tls_cert,
tls_key => $tls_key,
tls_verify => $tls_verify,
}
)
})
$unless_chart = "helm ${helm_ls_flags} | awk '{if(\$1 == \"${release_name}\") exit 1}'"
}

Expand Down
25 changes: 13 additions & 12 deletions manifests/chart_update.pp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@
# @param chart
# The file system location of the package.
#
# @param namespace
#
# @param no_hooks
#
define helm::chart_update (
String $ensure = present,
Optional[String] $ca_file = undef,
Expand All @@ -138,27 +142,27 @@
Optional[String] $recreate_pods = undef,
Optional[String] $reset_values = undef,
Optional[String] $reuse_values = undef,
Array $set = [],
Optional[Array] $set = undef,
Optional[Integer] $timeout = undef,
String $tiller_namespace = 'kube-system',
Boolean $tls = false,
Optional[String] $tls_ca_cert = undef,
Optional[String] $tls_cert = undef,
Optional[String] $tls_key = undef,
Boolean $tls_verify = false,
Array $values = [],
Optional[Array] $values = undef,
Boolean $verify = false,
Optional[String] $version = undef,
Boolean $wait = false,
) {
include ::helm::params
include helm::params

if ($release_name == undef) {
fail("\nYou must specify a name for the service with the release_name attribute \neg: release_name => 'mysql'")
}

if $ensure == present {
$helm_chart_update_flags = helm_chart_update_flags( {
$helm_chart_update_flags = helm_chart_update_flags({
ensure => $ensure,
ca_file => $ca_file,
cert_file => $cert_file,
Expand Down Expand Up @@ -191,15 +195,14 @@
verify => $verify,
version => $version,
wait => $wait,
}
)
})
$exec = "helm upgrade ${name}"
$exec_chart = "helm ${helm_chart_update_flags}"
$unless_chart = undef
}

if $ensure == absent {
$helm_delete_flags = helm_delete_flags( {
$helm_delete_flags = helm_delete_flags({
ensure => $ensure,
debug => $debug,
dry_run => $dry_run,
Expand All @@ -217,11 +220,10 @@
tls_cert => $tls_cert,
tls_key => $tls_key,
tls_verify => $tls_verify,
}
)
})
$exec = "helm delete ${name}"
$exec_chart = "helm ${helm_delete_flags}"
$helm_ls_flags = helm_ls_flags( {
$helm_ls_flags = helm_ls_flags({
ls => true,
home => $home,
host => $host,
Expand All @@ -233,8 +235,7 @@
tls_cert => $tls_cert,
tls_key => $tls_key,
tls_verify => $tls_verify,
}
)
})
$unless_chart = "helm ${helm_ls_flags} | awk '{if(\$1 == \"${release_name}\") exit 1}'"
}

Expand Down
7 changes: 3 additions & 4 deletions manifests/create.pp
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@
Optional[String] $starter = undef,
Optional[String] $tiller_namespace = undef,
) {
include ::helm::params
include helm::params

$helm_create_flags = helm_create_flags( {
$helm_create_flags = helm_create_flags({
chart_name => $chart_name,
chart_path => $chart_path,
debug => $debug,
Expand All @@ -59,8 +59,7 @@
kube_context => $kube_context,
starter => $starter,
tiller_namespace => $tiller_namespace,
}
)
})

$exec_chart = "helm create ${helm_create_flags}"

Expand Down
16 changes: 10 additions & 6 deletions manifests/helm_init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@
# @param upgrade
# Specifies whether to upgrade if Tiller is installed.
# Valid values are `true`, `false`.
#
#
# @param overrides
#
# @param node_selectors
#
define helm::helm_init (
Boolean $init = true,
Boolean $canary_image = false,
Expand Down Expand Up @@ -110,10 +114,10 @@
Optional[String] $tls_ca_cert = undef,
Boolean $upgrade = false,
) {
include ::helm::params
include helm::params

if $init {
$helm_init_flags = helm_init_flags( {
$helm_init_flags = helm_init_flags({
init => $init,
canary_image => $canary_image,
client_only => $client_only,
Expand All @@ -136,12 +140,12 @@
tiller_tls_key => $tiller_tls_key,
tls_ca_cert => $tls_ca_cert,
upgrade => $upgrade,
}
)
})

if $home != undef {
$is_client_init_cmd = "test -d ${home}/plugins"
} else {
}
else {
$is_client_init_cmd = 'test -d ~/.helm/plugins'
}

Expand Down
15 changes: 8 additions & 7 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
#
# @param archive_baseurl
# The base URL for downloading the helm archive, must contain file helm-v${version}-linux-${arch}.tar.gz
# Defaults to https://get.helm.sh
# Defaults to https://kubernetes-helm.storage.googleapis.com
# URLs supported by puppet/archive module will work, e.g. puppet:///modules/helm_files
#
class helm (
Expand Down Expand Up @@ -155,21 +155,22 @@
String $version = $helm::params::version,
String $archive_baseurl = $helm::params::archive_baseurl,
) inherits helm::params {
if $::kernel {
assert_type(Pattern[/Linux/], $::kernel) |$a, $b| {
if $facts['kernel'] {
assert_type(Pattern[/Linux/], $facts['kernel']) |$a, $b| {
fail('This module only supports the Linux kernel')
}
}

contain ::helm::binary
contain ::helm::config
contain helm::binary
contain helm::config

if $client_only == false {
contain ::helm::account_config
contain helm::account_config
Class['helm::binary']
-> Class['helm::account_config']
-> Class['helm::config']
} else {
}
else {
Class['helm::binary']
-> Class['helm::config']
}
Expand Down
11 changes: 7 additions & 4 deletions manifests/package.pp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@
# The location of the public keys that are used for verification.
# Defaults to `undef`.
#
# @param host
#
# @param path
#
define helm::package (
Optional[String] $chart_name = undef,
Optional[String] $chart_path = undef,
Expand All @@ -84,9 +88,9 @@
Optional[String] $tiller_namespace = undef,
Optional[String] $version = undef,
) {
include ::helm::params
include helm::params

$helm_package_flags = helm_package_flags( {
$helm_package_flags = helm_package_flags({
chart_name => $chart_name,
chart_path => $chart_path,
debug => $debug,
Expand All @@ -101,8 +105,7 @@
sign => $sign,
tiller_namespace => $tiller_namespace,
version => $version,
}
)
})

$exec_package = "helm package ${helm_package_flags}"

Expand Down
2 changes: 1 addition & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
$tls_ca_cert = undef
$upgrade = false
$version = '2.7.2'
$archive_baseurl = 'https://get.helm.sh'
$archive_baseurl = 'https://kubernetes-helm.storage.googleapis.com'
}
12 changes: 5 additions & 7 deletions manifests/repo.pp
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@
Optional[String] $repo_name = undef,
Optional[String] $url = undef,
) {
include ::helm::params
include helm::params

if $ensure == present {
$helm_repo_add_flags = helm_repo_add_flags( {
$helm_repo_add_flags = helm_repo_add_flags({
ensure => $ensure,
ca_file => $ca_file,
cert_file => $cert_file,
Expand All @@ -90,22 +90,20 @@
password => $password,
repo_name => $repo_name,
url => $url,
}
)
})
$exec_repo = "helm repo ${helm_repo_add_flags}"
$unless_repo = "helm repo list | awk '{if(NR>1)print \$1}' | grep -w ${repo_name}"
}

if $ensure == absent {
$helm_repo_remove_flags = helm_repo_remove_flags( {
$helm_repo_remove_flags = helm_repo_remove_flags({
ensure => $ensure,
home => $home,
host => $host,
kube_context => $kube_context,
repo_name => $repo_name,
tiller_namespace => $tiller_namespace,
}
)
})
$exec_repo = "helm repo ${helm_repo_remove_flags}"
$unless_repo = "helm repo list | awk '{if (\$1 == \"${repo_name}\") exit 1}'"
}
Expand Down
Loading