-
Notifications
You must be signed in to change notification settings - Fork 33
/
helm_create_flags.rb
22 lines (21 loc) · 1.12 KB
/
helm_create_flags.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# frozen_string_literal: true
require 'shellwords'
#
# helm_create_flags.rb
#
module Puppet::Parser::Functions
# Transforms a hash into a string of helm create flags
newfunction(:helm_create_flags, :type => :rvalue) do |args|
opts = args[0] || {}
flags = []
flags << '--debug' if opts['debug']
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'
flags.flatten.join(' ')
end
end