-
Notifications
You must be signed in to change notification settings - Fork 33
/
helm_init_flags.rb
35 lines (35 loc) · 2.26 KB
/
helm_init_flags.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
require 'shellwords'
#
# helm_init_flags.rb
#
module Puppet::Parser::Functions
# Transforms a hash into a string of helm init flags
newfunction(:helm_init_flags, :type => :rvalue) do |args|
opts = args[0] || {}
flags = []
flags << 'init' if opts['init']
flags << '--canary-image' if opts['canary_image']
flags << '--client-only' if opts['client_only']
flags << '--debug' if opts['debug']
flags << '--dry_run' if opts['dry_run']
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 << "--local-repo-url '#{opts['local_repo_url']}'" if opts['local_repo_url'] && opts['local_repo_url'].to_s != 'undef'
flags << '--net-host' if opts['net_host']
flags << "--service-account '#{opts['service_account']}'" if opts['service_account'] && opts['service_account'].to_s != 'undef'
flags << '--skip-refresh' if opts['skip_refresh']
flags << "--stable-repo-url '#{opts['stable_repo_url']}'" if opts['stable_repo_url'] && opts['stable_repo_url'].to_s != 'undef'
flags << "--override #{opts['overrides'].join(',')}" if opts['overrides'] && opts['overrides'].to_s != 'undef'
flags << "--node-selectors '#{opts['node_selectors']}'" if opts['node_selectors'] && opts['node_selectors'].to_s != 'undef'
flags << "--tiller-image '#{opts['tiller_image']}'" if opts['tiller_image'] && opts['tiller_image'].to_s != 'undef'
flags << "--tiller-namespace '#{opts['tiller_namespace']}'" if opts['tiller_namespace'] && opts['tiller_namespace'].to_s != 'undef'
flags << '--tiller-tls' if opts['tiller_tls']
flags << "--tiller-tls-cert '#{opts['tiller_tls_cert']}'" if opts['tiller_tls_cert'] && opts['tiller_tls_cert'].to_s != 'undef'
flags << "--tiller-tls-key '#{opts['tiller_tls_key']}'" if opts['tiller_tls_key'] && opts['tiller_tls_key'].to_s != 'undef'
flags << '--tiller-tls-verify' if opts['tiller_tls_verify']
flags << "--tls_ca_cert '#{opts['tls_ca_cert']}'" if opts['tls_ca_cert'] && opts['tls_ca_cert'].to_s != 'undef'
flags << '--upgrade' if opts['upgrade']
flags.flatten.join(' ')
end
end