This is an automated email from the ASF dual-hosted git repository. pcongiusti pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit d2d0965c9b6c3d9da4133b3a3cf5cce9e581031c Author: phantomjinx <[email protected]> AuthorDate: Fri Mar 25 18:53:15 2022 +0000 Refactors proxy reset to its own script * Makes pre-flight test reset proxy as well as cleanup --- .github/actions/kamel-cleanup/cleanup.sh | 32 +------------- .github/actions/kamel-cleanup/reset-proxy.sh | 56 +++++++++++++++++++++++++ .github/actions/kamel-preflight-test/action.yml | 8 ++++ 3 files changed, 65 insertions(+), 31 deletions(-) diff --git a/.github/actions/kamel-cleanup/cleanup.sh b/.github/actions/kamel-cleanup/cleanup.sh index da4ef64aa..b6cacae93 100755 --- a/.github/actions/kamel-cleanup/cleanup.sh +++ b/.github/actions/kamel-cleanup/cleanup.sh @@ -53,37 +53,7 @@ shift $((OPTIND-1)) # which would require a catalogsource # if [ -n "${BUILD_CATALOG_SOURCE}" ]; then - set +e - -# -# Remove values altogther -# - PATCH=$(mktemp /tmp/proxy-patch.XXXXXXXX) - cat >${PATCH} <<EOF -[ - { - "op": "replace", - "path": "/spec", - "value": {} - }, - { - "op": "replace", - "path": "/status", - "value": {} - } -] -EOF - - kubectl patch --type='json' Proxy cluster --patch-file "${PATCH}" - - if [ $? != 0 ]; then - echo "Error: Failed to reset the Proxy" - exit 1 - fi - - rm -f "${PATCH}" - - set -e + ./.github/actions/kamel-cleanup/reset-proxy.sh fi if [ "${SAVE_NAMESPACES}" == "true" ]; then diff --git a/.github/actions/kamel-cleanup/reset-proxy.sh b/.github/actions/kamel-cleanup/reset-proxy.sh new file mode 100755 index 000000000..07f031970 --- /dev/null +++ b/.github/actions/kamel-cleanup/reset-proxy.sh @@ -0,0 +1,56 @@ +#!/bin/bash + +# --------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# --------------------------------------------------------------------------- + +set +e + +kubectl get Proxy cluster >& /dev/null +if [ $? != 0 ]; then + echo "Cluster does not have proxy called 'cluster'. Nothing to do." + exit 0 +fi + +# +# Remove values altogther +# +PATCH=$(mktemp /tmp/proxy-patch.XXXXXXXX) +cat >${PATCH} <<EOF +[ +{ + "op": "replace", + "path": "/spec", + "value": {} +}, +{ + "op": "replace", + "path": "/status", + "value": {} +} +] +EOF + +kubectl patch --type='json' Proxy cluster --patch-file "${PATCH}" + +if [ $? != 0 ]; then + echo "Error: Failed to reset the Proxy" + exit 1 +fi + +rm -f "${PATCH}" + +set -e diff --git a/.github/actions/kamel-preflight-test/action.yml b/.github/actions/kamel-preflight-test/action.yml index 5cf1041ec..b5cd3e2d6 100644 --- a/.github/actions/kamel-preflight-test/action.yml +++ b/.github/actions/kamel-preflight-test/action.yml @@ -42,6 +42,14 @@ runs: using: "composite" steps: + - id: proxy-reset + name: Ensure Proxy has been reset + shell: bash + run: | + if [ -n "${{ inputs.build-catalog-source }}" ]; then + ./.github/actions/kamel-cleanup/reset-proxy.sh + fi + - id: preflight-test name: Execute Preflight Test shell: bash
