Skip to content

Commit

Permalink
code optimizations in run script
Browse files Browse the repository at this point in the history
  • Loading branch information
lukma99 committed Jan 27, 2021
1 parent e141113 commit dc92233
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,17 @@

NEW_ARGS=""
COMMAND=""
CURRENT_CONTEXT=$(kubectl config current-context)
CURRENT_NAMESPACE=$(kubectl config view --minify | grep namespace | cut -d ':' -f 2 | sed 's/^[ \t]*//;s/[ \t]*$//')

HELM_SUDO_PROMPT=${HELM_SUDO_PROMPT:-false}

if [ "$HELM_SUDO_PROMPT" = true ]; then
CURRENT_CONTEXT=$(kubectl config current-context)
CURRENT_NAMESPACE=$(kubectl config view --minify | grep namespace | cut -d ':' -f 2 | sed 's/^[ \t]*//;s/[ \t]*$//')
read -p "WARNING: Currently in context '${CURRENT_CONTEXT}' using namespace '${CURRENT_NAMESPACE:-"default"}'. Continue? (y/N) " -r -n 1 yn
case $yn in
[Yy]* ) ;;
* ) exit 0;;
esac
echo
echo
fi

for arg in "$@"
do
if [ ${arg} != "--"* ] && [ -z "${COMMAND}" ]; then
COMMAND=${arg}
fi
NEW_ARGS="${NEW_ARGS} ${arg}"
done

helm --kube-as-user ${USER} --kube-as-group system:masters ${NEW_ARGS}
helm --kube-as-user ${USER} --kube-as-group system:masters "$@"

0 comments on commit dc92233

Please sign in to comment.