Skip to content

Commit

Permalink
Add kubeconfig parameter for all defined types to better support Helm v3
Browse files Browse the repository at this point in the history
  • Loading branch information
treydock committed Jan 14, 2021
1 parent 9f24618 commit a40c1d1
Show file tree
Hide file tree
Showing 21 changed files with 94 additions and 21 deletions.
1 change: 1 addition & 0 deletions lib/puppet/parser/functions/helm_chart_update_flags.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ module Puppet::Parser::Functions
flags << "--home '#{opts['home']}'" if opts['home'] && opts['home'].to_s != 'undef'
flags << "--host '#{opts['host']}'" if opts['host'] && opts['host'].to_s != 'undef'
flags << "--kube-context '#{opts['kube_context']}'" if opts['kube_context'] && opts['kube_context'].to_s != 'undef'
flags << "--kubeconfig '#{opts['kubeconfig']}'" if opts['kubeconfig'] && opts['kubeconfig'].to_s != 'undef'
flags << "--namespace '#{opts['namespace']}'" if opts['namespace'] && opts['namespace'].to_s != 'undef'
flags << '--no-hooks' if opts['no_hooks']
flags << '--recreate-pods' if opts['recreate_pods']
Expand Down
1 change: 1 addition & 0 deletions lib/puppet/parser/functions/helm_create_flags.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module Puppet::Parser::Functions
flags << "--home '#{opts['home']}'" if opts['home'] && opts['home'].to_s != 'undef'
flags << "--host '#{opts['host']}'" if opts['host'] && opts['host'].to_s != 'undef'
flags << "--kube-context '#{opts['kube_context']}'" if opts['kube_context'] && opts['kube_context'].to_s != 'undef'
flags << "--kubeconfig '#{opts['kubeconfig']}'" if opts['kubeconfig'] && opts['kubeconfig'].to_s != 'undef'
flags << "--starter '#{opts['starter']}" if opts['starter'] && opts['starter'].to_s != 'undef'
flags << "--tiller-namespace '#{opts['tiller_namespace']}'" if opts['tiller_namespace'] && opts['tiller_namespace'].to_s != 'undef'
flags << "'#{opts['chart_path']}/#{opts['chart_name']}'" if opts['chart_path'] && opts['chart_path'].to_s != 'undef' && opts['chart_name'].to_s != 'undef'
Expand Down
1 change: 1 addition & 0 deletions lib/puppet/parser/functions/helm_delete_flags.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module Puppet::Parser::Functions
flags << "--home '#{opts['home']}'" if opts['home'].to_s != 'undef'
flags << "--host '#{opts['host']}'" if opts['host'].to_s != 'undef'
flags << "--kube-context '#{opts['kube_context']}'" if opts['kube_context'].to_s != 'undef'
flags << "--kubeconfig '#{opts['kubeconfig']}'" if opts['kubeconfig'] && opts['kubeconfig'].to_s != 'undef'
flags << '--no-hooks' if opts['no_hooks']
flags << '--purge' if opts['purge']
flags << "--timeout '#{opts['timeout']}'" if opts['timeout'] && opts['timeout'].to_s != 'undef'
Expand Down
1 change: 1 addition & 0 deletions lib/puppet/parser/functions/helm_install_flags.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module Puppet::Parser::Functions
flags << "--home '#{opts['home']}'" if opts['home'] && opts['home'].to_s != 'undef'
flags << "--host '#{opts['host']}'" if opts['host'] && opts['host'].to_s != 'undef'
flags << "--kube-context '#{opts['kube_context']}'" if opts['kube_context'] && opts['kube_context'].to_s != 'undef'
flags << "--kubeconfig '#{opts['kubeconfig']}'" if opts['kubeconfig'] && opts['kubeconfig'].to_s != 'undef'
flags << "--name '#{opts['release_name']}'" if opts['release_name'] && opts['release_name'].to_s != 'undef'
flags << "--name-template '#{opts['name_template']}'" if opts['name_template'] && opts['name_template'].to_s != 'undef'
flags << "--namespace '#{opts['namespace']}'" if opts['namespace'] && opts['namespace'].to_s != 'undef'
Expand Down
1 change: 1 addition & 0 deletions lib/puppet/parser/functions/helm_ls_flags.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module Puppet::Parser::Functions
flags << "--home '#{opts['home']}'" if opts['home'] && opts['home'].to_s != 'undef'
flags << "--host '#{opts['host']}'" if opts['host'] && opts['host'].to_s != 'undef'
flags << "--kube-context '#{opts['kube_context']}'" if opts['kube_context'] && opts['kube_context'].to_s != 'undef'
flags << "--kubeconfig '#{opts['kubeconfig']}'" if opts['kubeconfig'] && opts['kubeconfig'].to_s != 'undef'
flags << "--tiller-namespace '#{opts['tiller_namespace']}'" if opts['tiller_namespace'] && opts['tiller_namespace'].to_s != 'undef'
flags << '--short' if opts['short']
flags << '--tls' if opts['tls']
Expand Down
1 change: 1 addition & 0 deletions lib/puppet/parser/functions/helm_package_flags.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module Puppet::Parser::Functions
flags << "--key '#{opts['key']}'" if opts['key'] && opts['key'].to_s != 'undef'
flags << "--keystring '#{opts['keystrings']}'" if opts['keystring'] && opts['keystring'].to_s != 'undef'
flags << "--kube-context '#{opts['kube_context']}'" if opts['kube_context'] && opts['kube_context'].to_s != 'undef'
flags << "--kubeconfig '#{opts['kubeconfig']}'" if opts['kubeconfig'] && opts['kubeconfig'].to_s != 'undef'
flags << '--save' if opts['save']
flags << '--sign' if opts['sign']
flags << "--tiller-namespace '#{opts['tiller_namespace']}'" if opts['tiller_namespace'] && opts['tiller_namespace'].to_s != 'undef'
Expand Down
1 change: 1 addition & 0 deletions lib/puppet/parser/functions/helm_repo_add_flags.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module Puppet::Parser::Functions
flags << "--home '#{opts['home']}'" if opts['home'] && opts['home'].to_s != 'undef'
flags << "--host '#{opts['host']}'" if opts['host'] && opts['host'].to_s != 'undef'
flags << "--kube-context '#{opts['kube_context']}'" if opts['kube_context'] && opts['kube_context'].to_s != 'undef'
flags << "--kubeconfig '#{opts['kubeconfig']}'" if opts['kubeconfig'] && opts['kubeconfig'].to_s != 'undef'
flags << "--tiller-namespace '#{opts['tiller_namespace']}'" if opts['tiller_namespace'] && opts['tiller_namespace'].to_s != 'undef'
flags << "--username '#{opts['username']}'" if opts['username'] && opts['username'].to_s != 'undef'
flags << "--password '#{opts['password']}'" if opts['password'] && opts['password'].to_s != 'undef'
Expand Down
1 change: 1 addition & 0 deletions lib/puppet/parser/functions/helm_repo_remove_flags.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module Puppet::Parser::Functions
flags << "--home '#{opts['home']}'" if opts['home'] && opts['home'].to_s != 'undef'
flags << "--host '#{opts['host']}'" if opts['host'] && opts['host'].to_s != 'undef'
flags << "--kube-context '#{opts['kube_context']}'" if opts['kube_context'] && opts['kube_context'].to_s != 'undef'
flags << "--kubeconfig '#{opts['kubeconfig']}'" if opts['kubeconfig'] && opts['kubeconfig'].to_s != 'undef'
flags << "--tiller-namespace '#{opts['tiller_namespace']}'" if opts['tiller_namespace'] && opts['tiller_namespace'].to_s != 'undef'
flags << "'#{opts['repo_name']}'" if opts['repo_name'] && opts['repo_name'].to_s != 'undef'
flags.flatten.join(' ')
Expand Down
1 change: 1 addition & 0 deletions lib/puppet/parser/functions/helm_repo_update_flags.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module Puppet::Parser::Functions
flags << "--home '#{opts['home']}'" if opts['home'] && opts['home'].to_s != 'undef'
flags << "--host '#{opts['host']}'" if opts['host'] && opts['host'].to_s != 'undef'
flags << "--kube-context '#{opts['kube_context']}'" if opts['kube_context'] && opts['kube_context'].to_s != 'undef'
flags << "--kubeconfig '#{opts['kubeconfig']}'" if opts['kubeconfig'] && opts['kubeconfig'].to_s != 'undef'
flags << "--tiller-namespace '#{opts['tiller_namespace']}'" if opts['tiller_namespace'] && opts['tiller_namespace'].to_s != 'undef'
flags << 'update' if opts['update']
flags.flatten.join(' ')
Expand Down
10 changes: 10 additions & 0 deletions manifests/chart.pp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
# @param kube_context
# Name of the kubeconfig context.
#
# @param kubeconfig
# Path to the kubeconfig (v3 only)
#
# @param name_template
# The template used to name the release.
#
Expand Down Expand Up @@ -121,6 +124,7 @@
Optional[String] $home = undef,
Optional[String] $host = undef,
Optional[String] $kube_context = undef,
Optional[String] $kubeconfig = undef,
Optional[String] $name_template = undef,
Optional[String] $namespace = undef,
Boolean $no_hooks = false,
Expand Down Expand Up @@ -153,9 +157,11 @@
if versioncmp($helm::version, '3.0.0') >= 0 {
$_home = undef
$_tiller_namespace = undef
$_kubeconfig = $kubeconfig
} else {
$_home = $home
$_tiller_namespace = $tiller_namespace
$_kubeconfig = undef
}

if $ensure == present {
Expand All @@ -172,6 +178,7 @@
home => $_home,
host => $host,
kube_context => $kube_context,
kubeconfig => $_kubeconfig,
name_template => $name_template,
namespace => $namespace,
no_hooks => $no_hooks,
Expand All @@ -198,6 +205,7 @@
home => $_home,
host => $host,
kube_context => $kube_context,
kubeconfig => $_kubeconfig,
tiller_namespace => $_tiller_namespace,
short => true,
tls => $tls,
Expand All @@ -217,6 +225,7 @@
home => $_home,
host => $host,
kube_context => $kube_context,
kubeconfig => $_kubeconfig,
name_template => $name_template,
namespace => $namespace,
no_hooks => $no_hooks,
Expand All @@ -237,6 +246,7 @@
home => $_home,
host => $host,
kube_context => $kube_context,
kubeconfig => $_kubeconfig,
tiller_namespace => $_tiller_namespace,
short => true,
tls => $tls,
Expand Down
9 changes: 9 additions & 0 deletions manifests/chart_update.pp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
# @param kube_context
# Name of the kubeconfig context.
#
# @param kubeconfig
# Path to the kubeconfig (v3 only)
#
# @param recreate_pods
# Performs pods restart for the resource if applicable
#
Expand Down Expand Up @@ -130,6 +133,7 @@
Optional[String] $host = undef,
Boolean $install = true,
Optional[String] $kube_context = undef,
Optional[String] $kubeconfig = undef,
Optional[String] $namespace = undef,
Boolean $no_hooks = false,
Array $path = undef,
Expand Down Expand Up @@ -163,9 +167,11 @@
if versioncmp($helm::version, '3.0.0') >= 0 {
$_home = undef
$_tiller_namespace = undef
$_kubeconfig = $kubeconfig
} else {
$_home = $home
$_tiller_namespace = $tiller_namespace
$_kubeconfig = undef
}

if $ensure == present {
Expand All @@ -183,6 +189,7 @@
host => $host,
install => $install,
kube_context => $kube_context,
kubeconfig => $_kubeconfig,
namespace => $namespace,
no_hooks => $no_hooks,
recreate_pods => $recreate_pods,
Expand Down Expand Up @@ -216,6 +223,7 @@
home => $_home,
host => $host,
kube_context => $kube_context,
kubeconfig => $_kubeconfig,
namespace => $namespace,
no_hooks => $no_hooks,
purge => $purge,
Expand All @@ -235,6 +243,7 @@
home => $_home,
host => $host,
kube_context => $kube_context,
kubeconfig => $_kubeconfig,
tiller_namespace => $_tiller_namespace,
short => true,
tls => $tls,
Expand Down
7 changes: 7 additions & 0 deletions manifests/create.pp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
# @param kube_context
# The name of the kubeconfig context.
#
# @param kubeconfig
# Path to the kubeconfig (v3 only)
#
# @param path
# The PATH variable used for exec types.
#
Expand All @@ -44,6 +47,7 @@
Optional[String] $home = undef,
Optional[String] $host = undef,
Optional[String] $kube_context = undef,
Optional[String] $kubeconfig = undef,
Optional[Array] $path = undef,
Optional[String] $starter = undef,
Optional[String] $tiller_namespace = undef,
Expand All @@ -55,9 +59,11 @@
if versioncmp($helm::version, '3.0.0') >= 0 {
$_home = undef
$_tiller_namespace = undef
$_kubeconfig = $kubeconfig
} else {
$_home = $home
$_tiller_namespace = $tiller_namespace
$_kubeconfig = undef
}

$helm_create_flags = helm_create_flags({
Expand All @@ -67,6 +73,7 @@
home => $_home,
host => $host,
kube_context => $kube_context,
kubeconfig => $_kubeconfig,
starter => $starter,
tiller_namespace => $_tiller_namespace,
})
Expand Down
7 changes: 7 additions & 0 deletions manifests/package.pp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
# The name for the kubeconfig context.
# Defaults to `undef`.
#
# @param kubeconfig
# Path to the kubeconfig (v3 only)
#
# @param save
# Specifies whether to save the packaged chart to the local chart repository.
# Valid values are `true`, `false`.
Expand Down Expand Up @@ -78,6 +81,7 @@
Optional[String] $key = undef,
Optional[String] $keystring = undef,
Optional[String] $kube_context = undef,
Optional[String] $kubeconfig = undef,
Optional[Array] $path = undef,
Boolean $save = true,
Boolean $sign = false,
Expand All @@ -91,9 +95,11 @@
if versioncmp($helm::version, '3.0.0') >= 0 {
$_home = undef
$_tiller_namespace = undef
$_kubeconfig = $kubeconfig
} else {
$_home = $home
$_tiller_namespace = $tiller_namespace
$_kubeconfig = undef
}

$helm_package_flags = helm_package_flags({
Expand All @@ -107,6 +113,7 @@
key => $key,
keystring => $keystring,
kube_context => $kube_context,
kubeconfig => $_kubeconfig,
save => $save,
sign => $sign,
tiller_namespace => $_tiller_namespace,
Expand Down
8 changes: 8 additions & 0 deletions manifests/repo.pp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
# @param kube_context
# The name for the kubeconfig context to use.
#
# @param kubeconfig
# Path to the kubeconfig (v3 only)
#
# @param path
# The PATH variable used for exec types.
#
Expand Down Expand Up @@ -65,6 +68,7 @@
Optional[String] $home = undef,
Optional[String] $host = undef,
Optional[String] $kube_context = undef,
Optional[String] $kubeconfig = undef,
Optional[Array] $path = undef,
Optional[String] $tiller_namespace = undef,
Optional[String] $username = undef,
Expand All @@ -79,9 +83,11 @@
if versioncmp($helm::version, '3.0.0') >= 0 {
$_home = undef
$_tiller_namespace = undef
$_kubeconfig = $kubeconfig
} else {
$_home = $home
$_tiller_namespace = $tiller_namespace
$_kubeconfig = undef
}

if $ensure == present {
Expand All @@ -95,6 +101,7 @@
home => $_home,
host => $host,
kube_context => $kube_context,
kubeconfig => $_kubeconfig,
tiller_namespace => $_tiller_namespace,
username => $username,
password => $password,
Expand All @@ -111,6 +118,7 @@
home => $_home,
host => $host,
kube_context => $kube_context,
kubeconfig => $_kubeconfig,
repo_name => $repo_name,
tiller_namespace => $_tiller_namespace,
})
Expand Down
7 changes: 7 additions & 0 deletions manifests/repo_update.pp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
# @param kube_context
# The name for the kubeconfig context to use.
#
# @param kubeconfig
# Path to the kubeconfig (v3 only)
#
# @param path
# The PATH variable used for exec types.
#
Expand All @@ -35,6 +38,7 @@
Optional[String] $home = undef,
Optional[String] $host = undef,
Optional[String] $kube_context = undef,
Optional[String] $kubeconfig = undef,
Optional[Array] $path = undef,
Optional[String] $tiller_namespace = undef,
Boolean $update = true,
Expand All @@ -46,9 +50,11 @@
if versioncmp($helm::version, '3.0.0') >= 0 {
$_home = undef
$_tiller_namespace = undef
$_kubeconfig = $kubeconfig
} else {
$_home = $home
$_tiller_namespace = $tiller_namespace
$_kubeconfig = undef
}

if $update {
Expand All @@ -57,6 +63,7 @@
home => $_home,
host => $host,
kube_context => $kube_context,
kubeconfig => $_kubeconfig,
tiller_namespace => $_tiller_namespace,
update => $update,
})
Expand Down

0 comments on commit a40c1d1

Please sign in to comment.