diff --git a/assets/common.sh b/assets/common.sh index 4c9b29c..1257d52 100644 --- a/assets/common.sh +++ b/assets/common.sh @@ -88,14 +88,25 @@ setup_tls() { } setup_helm() { + # $1 is the name of the payload file + # $2 is the name of the source directory init_server=$(jq -r '.source.helm_init_server // "false"' < $1) + # Compute tiller_namespace as follows: + # If kubeconfig_tiller_namespace is set, then tiller_namespace is the namespace from the kubeconfig + # If tiller_namespace is set and it is the name of a file, then tiller_namespace is the contents of the file + # If tiller_namespace is set and it is not the name of a file, then tiller_namespace is the literal + # Otherwise tiller_namespace defaults to kube-system kubeconfig_tiller_namespace=$(jq -r '.source.kubeconfig_tiller_namespace // "false"' <$1) if [ "$kubeconfig_tiller_namespace" = "true" ] then tiller_namespace=$(kubectl config view --minify -ojson | jq -r .contexts[].context.namespace) else tiller_namespace=$(jq -r '.source.tiller_namespace // "kube-system"' < $1) + if [ "$tiller_namespace" != "kube-system" -a -f "$2/$tiller_namespace" ] + then + tiller_namespace=$(cat "$2/$tiller_namespace") + fi fi tillerless=$(jq -r '.source.tillerless // "false"' < $payload) @@ -234,6 +245,6 @@ setup_resource() { setup_kubernetes $1 $2 echo "Initializing helm..." setup_tls $1 - setup_helm $1 + setup_helm $1 $2 setup_repos $1 } diff --git a/assets/out b/assets/out index cd43280..d09a4cf 100755 --- a/assets/out +++ b/assets/out @@ -20,7 +20,8 @@ echo "Resource setup successful." # Parse parameters tillerless=$(jq -r '.source.tillerless // "false"' < $payload) namespace=$(jq -r '.source.namespace // "default"' < $payload) -tiller_namespace=$(jq -r '.params.tiller_namespace // ""' < $payload) +# tiller_namespace is computed in a more robust manner in common.sh via setup_resource. Don't override it here! +# tiller_namespace=$(jq -r '.params.tiller_namespace // ""' < $payload) chart=$(jq -r '.params.chart // ""' < $payload) version=$(jq -r '.params.version // ""' < $payload) namespace_file=$(jq -r '.params.namespace // ""' < $payload) @@ -84,16 +85,6 @@ if [ "$tls_enabled" = true ]; then tls_flag="--tls" fi -if [ ! -z "$tiller_namespace" ]; then - if [ -f "$source/$tiller_namespace" ]; then - tiller_namespace=`cat $source/$tiller_namespace` - else - tiller_namespace=$tiller_namespace - fi -else - tiller_namespace=$(jq -r '.source.tiller_namespace // "kube-system"' < $payload) -fi - if [ "$tillerless" = true ]; then helm_bin="helm tiller run ${tiller_namespace} -- helm" else