diff --git a/ci-operator/step-registry/rh-ecosystem-edge/assisted-chat/clean-up/OWNERS b/ci-operator/step-registry/rh-ecosystem-edge/assisted-chat/clean-up/OWNERS new file mode 100644 index 0000000000000..25c2d5de241e1 --- /dev/null +++ b/ci-operator/step-registry/rh-ecosystem-edge/assisted-chat/clean-up/OWNERS @@ -0,0 +1,17 @@ +# DO NOT EDIT; this file is auto-generated using https://github.com/openshift/ci-tools. +# Fetched from https://github.com/rh-ecosystem-edge/assisted-chat root OWNERS +# If the repo had OWNERS_ALIASES then the aliases were expanded +# Logins who are not members of 'openshift' organization were filtered out +# See the OWNERS docs: https://git.k8s.io/community/contributors/guide/owners.md + +approvers: +- carbonin +- eranco74 +- jhernand +- omertuc +options: {} +reviewers: +- carbonin +- eranco74 +- jhernand +- omertuc diff --git a/ci-operator/step-registry/rh-ecosystem-edge/assisted-chat/clean-up/rh-ecosystem-edge-assisted-chat-clean-up-commands.sh b/ci-operator/step-registry/rh-ecosystem-edge/assisted-chat/clean-up/rh-ecosystem-edge-assisted-chat-clean-up-commands.sh new file mode 100644 index 0000000000000..4575e0859f357 --- /dev/null +++ b/ci-operator/step-registry/rh-ecosystem-edge/assisted-chat/clean-up/rh-ecosystem-edge-assisted-chat-clean-up-commands.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +set -o nounset +set -o errexit +set -o pipefail + +OC_URL="https://api.stage.openshift.com/api/assisted-install/v2" + +n=4 # number of hours to subtract +current_time=$(date -u +"%Y-%m-%dT%H:%M:%SZ") +past_time=$(date -u -d "$current_time -$n hours" +"%Y-%m-%dT%H:%M") + +echo "Current UTC time: $current_time" +echo "Time $n hours ago (UTC): $past_time" + +if ! command -v ocm >/dev/null 2>&1; then \ + mkdir -p "${HOME}/.local/bin" && \ + curl -sSL -o "${HOME}/.local/bin/ocm" "https://github.com/openshift-online/ocm-cli/releases/latest/download/ocm-linux-amd64" && \ + chmod +x "${HOME}/.local/bin/ocm"; \ + export PATH="${HOME}/.local/bin:${PATH}" +fi + +ocm login --client-id "$(cat /var/run/secrets/sso-ci/client_id)" \ + --client-secret "$(cat /var/run/secrets/sso-ci/client_secret)" \ + --url "${OC_URL}" + +curl -H "Authorization: Bearer $(ocm token)" "${OC_URL}/clusters" > ${ARTIFACT_DIR}/available_clusters.json +cat ${ARTIFACT_DIR}/available_clusters.json | jq '[.[] |{id, name, created_at}]' > ${ARTIFACT_DIR}/relevant_cluster_data.json +cat ${ARTIFACT_DIR}/relevant_cluster_data.json | jq -r ".[] | select(.created_at < \"${past_time}\") | .id" > ${ARTIFACT_DIR}/clusters_to_delete + +cat ${ARTIFACT_DIR}/clusters_to_delete | xargs -I@ curl -X DELETE -H "Authorization: Bearer $(ocm token)" "${OC_URL}/clusters/@" \ No newline at end of file diff --git a/ci-operator/step-registry/rh-ecosystem-edge/assisted-chat/clean-up/rh-ecosystem-edge-assisted-chat-clean-up-ref.metadata.json b/ci-operator/step-registry/rh-ecosystem-edge/assisted-chat/clean-up/rh-ecosystem-edge-assisted-chat-clean-up-ref.metadata.json new file mode 100644 index 0000000000000..5b7b4cb80f5a0 --- /dev/null +++ b/ci-operator/step-registry/rh-ecosystem-edge/assisted-chat/clean-up/rh-ecosystem-edge-assisted-chat-clean-up-ref.metadata.json @@ -0,0 +1,17 @@ +{ + "path": "rh-ecosystem-edge/assisted-chat/clean-up/rh-ecosystem-edge-assisted-chat-clean-up-ref.yaml", + "owners": { + "approvers": [ + "carbonin", + "eranco74", + "jhernand", + "omertuc" + ], + "reviewers": [ + "carbonin", + "eranco74", + "jhernand", + "omertuc" + ] + } +} \ No newline at end of file diff --git a/ci-operator/step-registry/rh-ecosystem-edge/assisted-chat/clean-up/rh-ecosystem-edge-assisted-chat-clean-up-ref.yaml b/ci-operator/step-registry/rh-ecosystem-edge/assisted-chat/clean-up/rh-ecosystem-edge-assisted-chat-clean-up-ref.yaml new file mode 100644 index 0000000000000..f4e19c1cd6a32 --- /dev/null +++ b/ci-operator/step-registry/rh-ecosystem-edge/assisted-chat/clean-up/rh-ecosystem-edge-assisted-chat-clean-up-ref.yaml @@ -0,0 +1,16 @@ +ref: + as: rh-ecosystem-edge-assisted-chat-clean-up + from: src + cli: latest + timeout: 0h30m0s + commands: rh-ecosystem-edge-assisted-chat-clean-up-commands.sh + credentials: + - namespace: test-credentials + name: assisted-chat-sso-ci + mount_path: /var/run/secrets/sso-ci + resources: + requests: + cpu: 1000m + memory: 500Mi + documentation: |- + Run the evaluation tests diff --git a/ci-operator/step-registry/rh-ecosystem-edge/assisted-chat/rh-ecosystem-edge-assisted-chat-workflow.yaml b/ci-operator/step-registry/rh-ecosystem-edge/assisted-chat/rh-ecosystem-edge-assisted-chat-workflow.yaml index f49c3efacc9c4..52b9ce6ee734e 100644 --- a/ci-operator/step-registry/rh-ecosystem-edge/assisted-chat/rh-ecosystem-edge-assisted-chat-workflow.yaml +++ b/ci-operator/step-registry/rh-ecosystem-edge/assisted-chat/rh-ecosystem-edge-assisted-chat-workflow.yaml @@ -9,6 +9,7 @@ workflow: test: - ref: rh-ecosystem-edge-assisted-chat-test post: + - ref: rh-ecosystem-edge-assisted-chat-clean-up - chain: gather documentation: |- Install assisted-chat with all it's dependencies \ No newline at end of file