Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/maven/fixes/9.0' into maven/rele…
Browse files Browse the repository at this point in the history
…ase/9.0
  • Loading branch information
metaventis-build committed Aug 28, 2024
2 parents 2ea3562 + 42e8998 commit a0cfdfe
Showing 1 changed file with 181 additions and 124 deletions.
305 changes: 181 additions & 124 deletions archetypes/helm/src/main/resources/archetype-resources/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,45 @@ set -o pipefail

if [[ -z $1 ]] ; then
echo ""
echo "deploy.sh [-s skip checks and deploy directly] <release> <chart> [<version|path>]"
echo "deploy.sh [options] <release> <chart> [<version|path>]"
echo " options:"
echo " -s # skip checks and deploy directly"
echo " -d # run diff"
echo " -t # run try run"
echo " -e # run execute deployment"
echo ""
exit 0
fi

SKIP=false
while getopts s: opt; do
WIZARD=true
DIFF=false
TRY_RUN=false
DEPLOY=false
while getopts sdte opt; do
case $opt in
s) SKIP=true
s)
SKIP=true
;;
d)
WIZARD=false
DIFF=true
;;
t)
WIZARD=false
TRY_RUN=true
;;
e)
WIZARD=false
DEPLOY=true
;;
*)
;;
esac
shift
done

shift $(( "$OPTIND" - 1))

RELEASE=${1?"release required"}
CHART=${2?"chart required"}
VERSION=${3:-"":->=0.0.0-0}
Expand Down Expand Up @@ -92,127 +118,158 @@ fi

popd >/dev/null || exit

if [ "$SKIP" = false ] ; then
echo ""
echo "--------------------------------------------------------------------------------"
echo ""
echo "cluster: ${CONTEXT}"
echo "namespace: ${NAMESPACE}"
echo ""
echo "--------------------------------------------------------------------------------"
echo ""
read -p "---> kubectl context ok [y/N] " answer
echo ""
echo "--------------------------------------------------------------------------------"
echo ""
case ${answer:0:1} in
y | Y)
echo "Request existing releases, please wait ..."
echo ""
helm repo update >/dev/null
helm ls -a
;;
*)
exit 0
;;
esac

echo ""
echo "--------------------------------------------------------------------------------"
echo ""
echo "release: ${RELEASE}"
echo ""
echo "--------------------------------------------------------------------------------"
echo ""
read -p "---> helm release ok [y/N] " answer
echo ""
echo "--------------------------------------------------------------------------------"
echo ""

case ${answer:0:1} in
y | Y)
echo "Request existing revisions, please wait ..."
echo ""
helm history ${RELEASE} 2>/dev/null || echo "skipped ..."
;;
*)
exit 0
;;
esac

echo ""
echo "--------------------------------------------------------------------------------"
echo ""
echo "chart: ${CHART}"
echo "version: ${VERSION}"
echo "options: ${ARGS[@]}"
echo ""
echo "--------------------------------------------------------------------------------"
echo ""
read -p "---> helm parameter ok [y/N] " answer
echo ""
echo "--------------------------------------------------------------------------------"
echo ""

if [[ ! -f ${CHART} ]] ; then

ARGS+=("--version")
ARGS+=("${VERSION}")
diff() {
echo "Request diff from last revision, please wait ..."
echo ""
helm diff upgrade --install "${RELEASE}" "${CHART}" "${ARGS[@]}"
}

tryRun(){
echo "Dry-run, please wait ..."
echo ""
helm upgrade --install "${RELEASE}" "${CHART}" "${ARGS[@]}" --dry-run --debug
}

execute(){
echo "Execute, please wait ..."
echo ""
helm upgrade --install "${RELEASE}" "${CHART}" "${ARGS[@]}" --timeout=30m
}


runAsWizard() {
if [ "$SKIP" = false ] ; then
echo ""
echo "--------------------------------------------------------------------------------"
echo ""
echo "cluster: ${CONTEXT}"
echo "namespace: ${NAMESPACE}"
echo ""
echo "--------------------------------------------------------------------------------"
echo ""
read -p "---> kubectl context ok [y/N] " answer
echo ""
echo "--------------------------------------------------------------------------------"
echo ""
case ${answer:0:1} in
y | Y)
echo "Request existing releases, please wait ..."
echo ""
helm repo update >/dev/null
helm ls -a
;;
*)
exit 0
;;
esac

echo ""
echo "--------------------------------------------------------------------------------"
echo ""
echo "release: ${RELEASE}"
echo ""
echo "--------------------------------------------------------------------------------"
echo ""
read -p "---> helm release ok [y/N] " answer
echo ""
echo "--------------------------------------------------------------------------------"
echo ""

case ${answer:0:1} in
y | Y)
echo "Request existing revisions, please wait ..."
echo ""
helm history ${RELEASE} 2>/dev/null || echo "skipped ..."
;;
*)
exit 0
;;
esac

echo ""
echo "--------------------------------------------------------------------------------"
echo ""
echo "chart: ${CHART}"
echo "version: ${VERSION}"
echo "options: ${ARGS[*]}"
echo ""
echo "--------------------------------------------------------------------------------"
echo ""
read -p "---> helm parameter ok [y/N] " answer
echo ""
echo "--------------------------------------------------------------------------------"
echo ""

if [[ ! -f ${CHART} ]] ; then

ARGS+=("--version")
ARGS+=("${VERSION}")

fi

case ${answer:0:1} in
y | Y)
diff
;;
*)
exit 0
;;
esac

echo ""
echo "--------------------------------------------------------------------------------"
echo ""
read -p "---> perform test [y/N] " answer
echo ""
echo "--------------------------------------------------------------------------------"
echo ""

case ${answer:0:1} in
y | Y)
tryRun
;;
*)
echo "skipped ..."
;;
esac

fi
echo ""
echo "--------------------------------------------------------------------------------"
echo ""
read -p "---> perform deployment [y/N] " answer
echo ""
echo "--------------------------------------------------------------------------------"
echo ""

case ${answer:0:1} in
y | Y)
execute
;;
*)
echo "skipped ..."
;;
esac

echo ""
echo "--------------------------------------------------------------------------------"
echo ""
echo "done"
echo ""
}

fi

case ${answer:0:1} in
y | Y)
echo "Request diff from last revision, please wait ..."
echo ""
helm diff upgrade --install "${RELEASE}" "${CHART}" "${ARGS[@]}"
;;
*)
exit 0
;;
esac

echo ""
echo "--------------------------------------------------------------------------------"
echo ""
read -p "---> perform test [y/N] " answer
echo ""
echo "--------------------------------------------------------------------------------"
echo ""

case ${answer:0:1} in
y | Y)
echo "Dry-run, please wait ..."
echo ""
helm upgrade --install "${RELEASE}" "${CHART}" "${ARGS[@]}" --dry-run --debug
;;
*)
echo "skipped ..."
;;
esac
if [[ $WIZARD == "true" ]] ; then
runAsWizard
else
[[ $DIFF == "true" ]] && {
diff
}
[[ $TRY_RUN == "true" ]] && {
tryRun
}

[[ $DEPLOY == "true" ]] && {
execute
}
fi
echo ""
echo "--------------------------------------------------------------------------------"
echo ""
read -p "---> perform deployment [y/N] " answer
echo ""
echo "--------------------------------------------------------------------------------"
echo ""

case ${answer:0:1} in
y | Y)
echo "Run, please wait ..."
echo ""
helm upgrade --install "${RELEASE}" "${CHART}" "${ARGS[@]}" --timeout=30m
;;
*)
echo "skipped ..."
;;
esac

echo ""
echo "--------------------------------------------------------------------------------"
echo ""
echo "done"
echo ""

0 comments on commit a0cfdfe

Please sign in to comment.