From ebb762a479a75753f3cdb6f4fc5126111299d03c Mon Sep 17 00:00:00 2001 From: Fabio Bertinatto Date: Fri, 8 Nov 2024 15:20:22 -0300 Subject: [PATCH] Archive the output dir when MOM command fails --- scripts/test-operator-integration.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/test-operator-integration.sh b/scripts/test-operator-integration.sh index 04f0822..fc12d8b 100644 --- a/scripts/test-operator-integration.sh +++ b/scripts/test-operator-integration.sh @@ -1,6 +1,5 @@ #!/usr/bin/env bash -set -o errexit set -o nounset set -o pipefail set -x @@ -40,4 +39,12 @@ APPLY_CONFIG_ARGS=( ) # Run the apply-configuration command from the operator -"${MOM_CMD}" "${APPLY_CONFIG_ARGS[@]}" +if ! "${MOM_CMD}" "${APPLY_CONFIG_ARGS[@]}"; then + # If the command fails, create an archive for easy downloading + TMP_DIR="$(mktemp -d)" + ARCHIVE_PATH="${TMP_DIR}/archive.tar.gz" + tar -czf "${ARCHIVE_PATH}" -C "${APPLY_CONFIG_OUTPUT_DIR}" . + mv "${ARCHIVE_PATH}" "${APPLY_CONFIG_OUTPUT_DIR}" + rmdir "${TMP_DIR}" + exit 1 +fi