Skip to content
This repository has been archived by the owner on Aug 28, 2021. It is now read-only.

Commit

Permalink
bug: compute tiller_namespace consistently (#124)
Browse files Browse the repository at this point in the history
* fix: compute tiller_namespace consistently
  • Loading branch information
hstenzel authored and msiegenthaler committed Jun 15, 2019
1 parent 503a9d2 commit 1751d02
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
13 changes: 12 additions & 1 deletion assets/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
13 changes: 2 additions & 11 deletions assets/out
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1751d02

Please sign in to comment.