From 655263b32d7e632800aadd43dace9e5454248fd9 Mon Sep 17 00:00:00 2001 From: Friedrich Wilken Date: Thu, 1 Feb 2024 14:25:08 +0100 Subject: [PATCH] remove obsolete scripts --- scripts/check_release_tag.sh | 14 ----- scripts/check_sec-scanners-config.sh | 34 ------------ scripts/create_draft_release.sh | 37 ------------- scripts/publish_release.sh | 23 -------- scripts/render_and_upload_manifests.sh | 64 ---------------------- scripts/verify-status.sh | 75 -------------------------- 6 files changed, 247 deletions(-) delete mode 100755 scripts/check_release_tag.sh delete mode 100755 scripts/check_sec-scanners-config.sh delete mode 100755 scripts/create_draft_release.sh delete mode 100755 scripts/publish_release.sh delete mode 100755 scripts/render_and_upload_manifests.sh delete mode 100755 scripts/verify-status.sh diff --git a/scripts/check_release_tag.sh b/scripts/check_release_tag.sh deleted file mode 100755 index 8c3c2f4a..00000000 --- a/scripts/check_release_tag.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash - -set -ue - -DESIRED_TAG=$1 - -source .version - -if [[ "$DESIRED_TAG" != "$MODULE_VERSION" ]]; then - echo "Tags mismatch: expected ${MODULE_VERSION}, got $DESIRED_TAG" - exit 1 -fi -echo "Tags are correct" -exit 0 \ No newline at end of file diff --git a/scripts/check_sec-scanners-config.sh b/scripts/check_sec-scanners-config.sh deleted file mode 100755 index 40497b80..00000000 --- a/scripts/check_sec-scanners-config.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env bash - -# This script checks thate the RC-Tag and the eventing-manager image have the tag of the corresponding release. - -# Error handling: -set -o nounset # treat unset variables as an error and exit immediately. -set -o errexit # exit immediately when a command fails. -set -E # needs to be set if we want the ERR trap -set -o pipefail # prevents errors in a pipeline from being masked - -# Get release version -DESIRED_TAG="${1:-"main"}" - -# Get eventing-manager tag from sec-scanners-config.yaml -SEC_SCAN_TO_CHECK="${2:-europe-docker.pkg.dev/kyma-project/prod/eventing-manager}" -IMAGE_TAG=$(cat sec-scanners-config.yaml | grep "${SEC_SCAN_TO_CHECK}" | cut -d : -f 2) - -# Get rc-tag -RC_TAG_TO_CHECK="${3:-rc-tag}" -RC_TAG=$(cat sec-scanners-config.yaml | grep "${RC_TAG_TO_CHECK}" | cut -d : -f 2 | xargs) - -# Check IMAGE_TAG and required image tag -if [[ "$IMAGE_TAG" != "$DESIRED_TAG" ]] || [[ "$RC_TAG" != "$DESIRED_TAG" ]]; then - # ERROR: Tag issue - echo "Tags are not correct: - - wanted: $DESIRED_TAG - - security-scanner image tag: $IMAGE_TAG - - rc-tag: $RC_TAG" - exit 1 -fi - -# OK: Everything is fine -echo "Tags are correct" -exit 0 diff --git a/scripts/create_draft_release.sh b/scripts/create_draft_release.sh deleted file mode 100755 index 738d83f0..00000000 --- a/scripts/create_draft_release.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env bash - -# This script returns the id of the draft release - -# standard bash error handling -set -o nounset # treat unset variables as an error and exit immediately. -set -o errexit # exit immediately when a command fails. -set -E # needs to be set if we want the ERR trap -set -o pipefail # prevents errors in a pipeline from being masked - -RELEASE_TAG=$1 - -REPOSITORY=${REPOSITORY:-kyma-project/eventing-manager} -GITHUB_URL=https://api.github.com/repos/${REPOSITORY} -GITHUB_AUTH_HEADER="Authorization: Bearer ${GITHUB_TOKEN}" -CHANGELOG_FILE=$(cat CHANGELOG.md) - -JSON_PAYLOAD=$(jq -n \ - --arg tag_name "$RELEASE_TAG" \ - --arg name "$RELEASE_TAG" \ - --arg body "$CHANGELOG_FILE" \ - '{ - "tag_name": $tag_name, - "name": $name, - "body": $body, - "draft": true - }') - -CURL_RESPONSE=$(curl -L \ - -X POST \ - -H "Accept: application/vnd.github+json" \ - -H "${GITHUB_AUTH_HEADER}" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - ${GITHUB_URL}/releases \ - -d "$JSON_PAYLOAD") - -echo "$(echo $CURL_RESPONSE | jq -r ".id")" \ No newline at end of file diff --git a/scripts/publish_release.sh b/scripts/publish_release.sh deleted file mode 100755 index 681fc54b..00000000 --- a/scripts/publish_release.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env bash - -# This script publishes a draft release - -# standard bash error handling -set -o nounset # treat unset variables as an error and exit immediately. -set -o errexit # exit immediately when a command fails. -set -E # needs to be set if we want the ERR trap -set -o pipefail # prevents errors in a pipeline from being masked - -RELEASE_ID=$1 - -REPOSITORY=${REPOSITORY:-kyma-project/eventing-manager} -GITHUB_URL=https://api.github.com/repos/${REPOSITORY} -GITHUB_AUTH_HEADER="Authorization: Bearer ${GITHUB_TOKEN}" - -CURL_RESPONSE=$(curl -L \ - -X POST \ - -H "Accept: application/vnd.github+json" \ - -H "${GITHUB_AUTH_HEADER}" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - ${GITHUB_URL}/releases/${RELEASE_ID} \ - -d '{"draft":false}') \ No newline at end of file diff --git a/scripts/render_and_upload_manifests.sh b/scripts/render_and_upload_manifests.sh deleted file mode 100755 index c9e8e604..00000000 --- a/scripts/render_and_upload_manifests.sh +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/env bash - -# standard bash error handling -set -o nounset # treat unset variables as an error and exit immediately. -set -o errexit # exit immediately when a command fails. -set -E # needs to be set if we want the ERR trap -set -o pipefail # prevents errors in a pipeline from being masked - -# Expected variables: -# PULL_BASE_REF - name of the tag -# GITHUB_TOKEN - github token used to upload the template yaml - -uploadFile() { - filePath=${1} - ghAsset=${2} - - echo "Uploading ${filePath} as ${ghAsset}" - response=$(curl -s -o output.txt -w "%{http_code}" \ - --request POST --data-binary @"$filePath" \ - -H "Authorization: token $GITHUB_TOKEN" \ - -H "Content-Type: text/yaml" \ - $ghAsset) - if [[ "$response" != "201" ]]; then - echo "Unable to upload the asset ($filePath): " - echo "HTTP Status: $response" - cat output.txt - exit 1 - else - echo "$filePath uploaded" - fi -} - -echo "PULL_BASE_REF ${PULL_BASE_REF}" - -MODULE_VERSION=${PULL_BASE_REF} make render-manifest - -echo "Generated eventing-manager.yaml:" -cat eventing-manager.yaml - -echo "Updating github release with eventing-manager.yaml" - -echo "Finding release id for: ${PULL_BASE_REF}" -CURL_RESPONSE=$(curl -w "%{http_code}" -sL \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer $GITHUB_TOKEN" \ - https://api.github.com/repos/kyma-project/eventing-manager/releases) -JSON_RESPONSE=$(sed '$ d' <<<"${CURL_RESPONSE}") -HTTP_CODE=$(tail -n1 <<<"${CURL_RESPONSE}") -if [[ "${HTTP_CODE}" != "200" ]]; then - echo "${JSON_RESPONSE}" && exit 1 -fi - -echo "Finding release id for: ${PULL_BASE_REF}" -RELEASE_ID=$(jq <<<${JSON_RESPONSE} --arg tag "${PULL_BASE_REF}" '.[] | select(.tag_name == $ARGS.named.tag) | .id') - -if [ -z "${RELEASE_ID}" ]; then - echo "No release with tag = ${PULL_BASE_REF}" - exit 1 -fi - -UPLOAD_URL="https://uploads.github.com/repos/kyma-project/eventing-manager/releases/${RELEASE_ID}/assets" - -uploadFile "eventing-manager.yaml" "${UPLOAD_URL}?name=eventing-manager.yaml" -uploadFile "config/samples/default.yaml" "${UPLOAD_URL}?name=eventing-default-cr.yaml" diff --git a/scripts/verify-status.sh b/scripts/verify-status.sh deleted file mode 100755 index 21fd686a..00000000 --- a/scripts/verify-status.sh +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/env bash - -echo "Checking status of POST Jobs for Eventing-Manager" - -REF_NAME="${1:-"main"}" -TIMEOUT_TIME="${2:-600}" -INTERVAL_TIME="${3:-3}" -INITIAL_WAIT_TIME="${4:-30}" - -# Generate job Status URL -STATUS_URL="https://api.github.com/repos/kyma-project/eventing-manager/commits/${REF_NAME}/status" - -# Dates -START_TIME=$(date +%s) -TODAY_DATE=$(date '+%Y-%m-%d') - -# Retry function -function retry { - - # Get status result - local statusresult=$(curl -L -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" ${STATUS_URL}) - - # Get overall state - fullstatus=$(echo $statusresult | jq '.state' | tr -d '"') - - # Collect latest run related data - local latestrun=$(echo $statusresult | jq '.statuses[-1]') - local latestrun_state=$(echo $latestrun | jq '.state' | tr -d '"') - local latestrun_createdat=$(echo $latestrun | jq '.created_at' | tr -d '"') - local latestrun_targeturl=$(echo $latestrun | jq '.target_url' | tr -d '"') - - # Check Today's run data - if [[ $latestrun_createdat == *"$TODAY_DATE"* ]]; then - echo $latestrun_createdat - echo $latestrun_state - echo $latestrun_targeturl - fi - - # Show all execution for Today - echo $statusresult | jq --arg t $TODAY_DATE '.statuses[]|select(.created_at | contains($t))' - - # Date time for time-out - local CURRENT_TIME=$(date +%s) - local elapsed_time=$((CURRENT_TIME - START_TIME)) - - # Check time-out - if [ $elapsed_time -ge $TIMEOUT_TIME ]; then - echo "Timeout reached. Exiting." - exit 1 - fi - - if [ "$fullstatus" == "success" ]; then - echo "Success!" - elif [ "$fullstatus" == "failed" ]; then - # Show overall state to user - echo "$statusresult" - echo "Failure! Exiting with an error." - exit 1 - elif [ "$fullstatus" == "pending" ]; then - echo "Status is '$fullstatus'. Retrying in $INTERVAL_TIME seconds..." - sleep $INTERVAL_TIME - else - echo "Invalid result: $result" - exit 1 - fi - -} - -# Initial wait -sleep $INITIAL_WAIT_TIME -# Call retry function -retry -while [ "$fullstatus" == "pending" ]; do - retry -done