gitpod/scripts/branch-namespace.sh
Manuel Alejandro de Brito Fontes 9dfea94c9b Run shellcheck against scripts
2021-06-04 16:26:37 -04:00

9 lines
455 B
Bash
Executable File

#!/bin/bash
branch=$(git symbolic-ref HEAD 2>&1) || error "cannot set kubectl namespace: no branch"
currentContext=$(kubectl config current-context 2>&1) || error "cannot set kubectl namespace: no current context"
namespace=staging-$(echo "$branch" | awk '{ sub(/^refs\/heads\//, ""); $0 = tolower($0); gsub(/[^-a-z0-9]/, "-"); print }')
echo "Setting kubectl namespace: $namespace"
kubectl config set-context "$currentContext" --namespace "$namespace"