From 13d6318ce95c71cb9cdda258ae1886e3069f0797 Mon Sep 17 00:00:00 2001 From: Thomas Ferrandiz Date: Fri, 29 Nov 2024 13:15:40 +0000 Subject: [PATCH] WIP test values --- updatecli/scripts/create-issue.sh | 34 ++++++++++++++++++----------- updatecli/scripts/update-calico.sh | 11 +--------- updatecli/scripts/update-canal.sh | 11 +--------- updatecli/scripts/update-cilium.sh | 11 +--------- updatecli/scripts/update-flannel.sh | 11 +--------- updatecli/scripts/update-multus.sh | 11 +--------- 6 files changed, 26 insertions(+), 63 deletions(-) diff --git a/updatecli/scripts/create-issue.sh b/updatecli/scripts/create-issue.sh index 70634862e..90c835ea9 100644 --- a/updatecli/scripts/create-issue.sh +++ b/updatecli/scripts/create-issue.sh @@ -4,21 +4,29 @@ TARGET_REPOSITORY="rancher/rke2" BODY="Url of the failed run: ${UPDATECLI_GITHUB_WORKFLOW_URL}" create-issue() { - title=$1 +} + +report-error() { + exit_code=$? + trap - EXIT INT - #check if issue already exists - issues=$(gh issue list -R ${TARGET_REPOSITORY} \ - --search "is:open ${title}" \ - --app rke2-issues-updatecli --json number --jq ".[].number" | wc -l) + if [[ $exit_code != 0 ]]; then + #check if issue already exists + issues=$(gh issue list -R ${TARGET_REPOSITORY} \ + --search "is:open ${ISSUE_TITLE}" \ + --app rke2-issues-updatecli --json number --jq ".[].number" | wc -l) - if [[ $issues = 0 ]]; then - echo "Creating issue for: $title" - gh issue create -R ${TARGET_REPOSITORY} \ - --title "${title}" \ - --body "${BODY}" - else - echo "Issue already exists for: ${title}" + if [[ $issues = 0 ]]; then + echo "Creating issue for: $title" + gh issue create -R ${TARGET_REPOSITORY} \ + --title "${ISSUE_TITLE}" \ + --body "${BODY}" + else + echo "Issue already exists for: ${ISSUE_TITLE}" + fi fi + + exit $exit_code } -export -f create-issue +export -f report-error diff --git a/updatecli/scripts/update-calico.sh b/updatecli/scripts/update-calico.sh index f7d3c9d19..17c266023 100755 --- a/updatecli/scripts/update-calico.sh +++ b/updatecli/scripts/update-calico.sh @@ -3,16 +3,7 @@ set -eu source $(dirname $0)/create-issue.sh -report-error() { - exit_code=$? - trap - EXIT INT - - if [[ $exit_code != 0 ]]; then - create-issue "Updatecli failed for calico ${CALICO_VERSION}" - fi - - exit ${exit_code} -} +ISSUE_TITLE="Updatecli failed for calico ${CALICO_VERSION}" trap report-error EXIT INT if [ -n "$CALICO_VERSION" ]; then diff --git a/updatecli/scripts/update-canal.sh b/updatecli/scripts/update-canal.sh index e49dbc1ab..db299c893 100755 --- a/updatecli/scripts/update-canal.sh +++ b/updatecli/scripts/update-canal.sh @@ -3,16 +3,7 @@ set -eu source $(dirname $0)/create-issue.sh -report-error() { - exit_code=$? - trap - EXIT INT - - if [[ $exit_code != 0 ]]; then - create-issue "Updatecli failed for canal with calico ${CALICO_VERSION} and flannel ${FLANNEL_VERSION}" - fi - - exit ${exit_code} -} +ISSUE_TITLE="Updatecli failed for canal ${CALICO_VERSION} / ${FLANNEL_VERSION}" trap report-error EXIT INT if [ -n "$FLANNEL_VERSION" ]; then diff --git a/updatecli/scripts/update-cilium.sh b/updatecli/scripts/update-cilium.sh index 03abba7f5..1f248e343 100755 --- a/updatecli/scripts/update-cilium.sh +++ b/updatecli/scripts/update-cilium.sh @@ -3,16 +3,7 @@ set -eu source $(dirname $0)/create-issue.sh -report-error() { - exit_code=$? - trap - EXIT INT - - if [[ $exit_code != 0 ]]; then - create-issue "Updatecli failed for cilium ${CILIUM_VERSION}" - fi - - exit ${exit_code} -} +ISSUE_TITLE="Updatecli failed for cilium ${CILIUM_VERSION}" trap report-error EXIT INT if [ -n "$CILIUM_VERSION" ]; then diff --git a/updatecli/scripts/update-flannel.sh b/updatecli/scripts/update-flannel.sh index 9560994f0..abe9abeae 100755 --- a/updatecli/scripts/update-flannel.sh +++ b/updatecli/scripts/update-flannel.sh @@ -3,16 +3,7 @@ set -eu source $(dirname $0)/create-issue.sh -report-error() { - exit_code=$? - trap - EXIT INT - - if [[ $exit_code != 0 ]]; then - create-issue "Updatecli failed for flannel ${FLANNEL_VERSION}" - fi - - exit ${exit_code} -} +ISSUE_TITLE="Updatecli failed for flannel ${FLANNEL_VERSION}" trap report-error EXIT INT if [ -n "$FLANNEL_VERSION" ]; then diff --git a/updatecli/scripts/update-multus.sh b/updatecli/scripts/update-multus.sh index 9295aa137..2eb78ff50 100755 --- a/updatecli/scripts/update-multus.sh +++ b/updatecli/scripts/update-multus.sh @@ -3,16 +3,7 @@ set -eux source $(dirname $0)/create-issue.sh -report-error() { - exit_code=$? - trap - EXIT INT - - if [[ $exit_code != 0 ]]; then - create-issue "Updatecli failed for multus ${MULTUS_VERSION}" - fi - - exit ${exit_code} -} +ISSUE_TITLE="Updatecli failed for multus ${MULTUS_VERSION}" trap report-error EXIT INT if [ -n "$MULTUS_VERSION" ]; then