diff --git a/hack/lib/serverless.bash b/hack/lib/serverless.bash index 9f9fdca8ee..b7e0a8c171 100644 --- a/hack/lib/serverless.bash +++ b/hack/lib/serverless.bash @@ -10,37 +10,45 @@ function ensure_serverless_installed { } function install_serverless_previous { - local rootdir="$(dirname "$(dirname "$(dirname "$(realpath "${BASH_SOURCE[0]}")")")")" + local rootdir current_csv previous_csv + rootdir="$(dirname "$(dirname "$(dirname "$(realpath "${BASH_SOURCE[0]}")")")")" # Remove installplan from previous installations, leaving this would make the operator # upgrade to the latest version immediately - local current_csv=$(${rootdir}/hack/catalog.sh | grep currentCSV | awk '{ print $2 }') - remove_installplan $current_csv + current_csv=$("${rootdir}/hack/catalog.sh" | grep currentCSV | awk '{ print $2 }') + remove_installplan "$current_csv" - local previous_csv=$(${rootdir}/hack/catalog.sh | grep replaces: | tail -n1 | awk '{ print $2 }') - deploy_serverless_operator $previous_csv || return $? + previous_csv=$("${rootdir}/hack/catalog.sh" | grep replaces: | tail -n1 | awk '{ print $2 }') + deploy_serverless_operator "$previous_csv" || return $? deploy_knativeserving_cr || return $? } function remove_installplan { - local install_plan=$(find_install_plan $1) + local install_plan + install_plan=$(find_install_plan $1) if [[ -n $install_plan ]]; then - oc delete $install_plan -n ${OPERATORS_NAMESPACE} + oc delete "$install_plan" -n "${OPERATORS_NAMESPACE}" fi } function install_serverless_latest { - local rootdir="$(dirname "$(dirname "$(dirname "$(realpath "${BASH_SOURCE[0]}")")")")" + deploy_serverless_operator_latest || return $? + deploy_knativeserving_cr || return $? +} + +function deploy_serverless_operator_latest { + local rootdir csv + rootdir="$(dirname "$(dirname "$(dirname "$(realpath "${BASH_SOURCE[0]}")")")")" # Get the current/latest CSV - local csv=$(${rootdir}/hack/catalog.sh | grep currentCSV | awk '{ print $2 }') + csv=$("${rootdir}/hack/catalog.sh" | grep currentCSV | awk '{ print $2 }') - deploy_serverless_operator $csv || return $? - deploy_knativeserving_cr || return $? + deploy_serverless_operator "${csv}" } function deploy_serverless_operator { logger.info 'Install the Serverless Operator' - local csv=$1 + local csv + csv="$1" cat <