diff --git a/hack/lib/serverless.bash b/hack/lib/serverless.bash index 6be1703106..272a5a0a82 100644 --- a/hack/lib/serverless.bash +++ b/hack/lib/serverless.bash @@ -14,29 +14,26 @@ function ensure_serverless_installed { # Otherwise, we cannot change log level by configmap. enable_debug_log - local csv + local channel csv if [[ "${INSTALL_OLDEST_COMPATIBLE}" == "true" ]]; then + channel="$(metadata.get "olm.channels.list[3]")" csv="$(metadata.get "upgrade_sequence[0].csv")" OLM_SOURCE=redhat-operators elif [[ "${INSTALL_PREVIOUS_VERSION}" == "true" ]]; then + channel="$(metadata.get "olm.channels.list[2]")" csv="$PREVIOUS_CSV" else + channel="$(metadata.get "olm.channels.list[1]")" csv="$CURRENT_CSV" fi - # Remove installplan from previous installations, leaving this would make the operator - # upgrade to the latest version immediately - if [[ "$csv" != "$CURRENT_CSV" ]]; then - remove_installplan "$CURRENT_CSV" - fi - - logger.info "Installing Serverless version $csv" + logger.info "Installing Serverless version $channel" - deploy_serverless_operator "$csv" + deploy_serverless_operator "$channel" install_knative_resources "${csv#serverless-operator.v}" - logger.success "Serverless is installed: $csv" + logger.success "Serverless is installed: $channel" } function install_knative_resources { @@ -68,26 +65,14 @@ function install_knative_resources { fi } -function remove_installplan { - local install_plan csv - csv="${1:?Pass a CSV as arg[1]}" - logger.info "Removing installplan for $csv" - install_plan=$(find_install_plan "$csv") - if [[ -n $install_plan ]]; then - oc delete "$install_plan" -n "${OPERATORS_NAMESPACE}" - else - logger.debug "No install plan for $csv" - fi -} - function deploy_serverless_operator_latest { - deploy_serverless_operator "$CURRENT_CSV" + deploy_serverless_operator "${OLM_UPGRADE_CHANNEL}" } function deploy_serverless_operator { - local csv tmpfile - csv="${1:?Pass as CSV as arg[1]}" - logger.info "Install the Serverless Operator: ${csv}" + local channel tmpfile + channel="${1:?Pass a channel as arg[1]}" + logger.info "Install the Serverless Operator: ${channel}" tmpfile=$(mktemp /tmp/subscription.XXXXXX.yaml) cat > "$tmpfile" <