From 0c4857a0073b73bd313d11d531f15d8d20635b75 Mon Sep 17 00:00:00 2001 From: Nick Pillitteri <56quarters@users.noreply.github.com> Date: Wed, 18 Sep 2024 14:45:22 -0400 Subject: [PATCH] fix: Don't quote mimir-rules-action namespace selection variable (#9324) * fix: Don't quote mimir-rules-action namespace selection variable Don't quote the namespace selection variable for the rule sync action since this results in passing `mimirtool` an empty string when the variable is unset or empty. Related #9258 Signed-off-by: Nick Pillitteri * Changelog Signed-off-by: Nick Pillitteri --------- Signed-off-by: Nick Pillitteri --- CHANGELOG.md | 2 +- operations/mimir-rules-action/README.md | 2 +- operations/mimir-rules-action/entrypoint.sh | 12 ++++++++---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f872cafbce4..bd01ae35c20 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -243,7 +243,7 @@ * [ENHANCEMENT] `tsdb-series`: Added `-json` option to generate JSON output for easier post-processing. #8844 * [ENHANCEMENT] `tsdb-series`: Added `-min-time` and `-max-time` options to filter samples that are used for computing data-points per minute. #8844 * [ENHANCEMENT] `mimir-rules-action`: Added new input to support matching target namespaces by regex. #9244 -* [ENHANCEMENT] `mimir-rules-action`: Added new inputs to support ignoring namespaces and ignoring namespaces by regex. #9258 +* [ENHANCEMENT] `mimir-rules-action`: Added new inputs to support ignoring namespaces and ignoring namespaces by regex. #9258 #9324 ## 2.13.0 diff --git a/operations/mimir-rules-action/README.md b/operations/mimir-rules-action/README.md index f9155235510..2d2fd5df796 100644 --- a/operations/mimir-rules-action/README.md +++ b/operations/mimir-rules-action/README.md @@ -20,7 +20,7 @@ This action is configured using environment variables defined in the workflow. T | `NAMESPACES` | Comma-separated list of namespaces to use during a sync or diff. | `false` | N/A | | `NAMESPACES_REGEX` | Regex matching namespaces to check during a sync or diff. | `false` | N/A | | `IGNORED_NAMESPACES` | Comma-separated list of namespaces to ignore during a sync of diff. | `false` | N/A | -| `INGORED_NAMESPACES_REGEX` | Regex matching namespaces to ignore during a sync or diff. | `false` | N/A | +| `IGNORED_NAMESPACES_REGEX` | Regex matching namespaces to ignore during a sync or diff. | `false` | N/A | > NOTE: Only one of the namespace selection inputs (`NAMESPACES`, `NAMESPACES_REGEX`, `IGNORED_NAMESPACES`, `INGORED_NAMESPACES_REGEX`) can be provided. diff --git a/operations/mimir-rules-action/entrypoint.sh b/operations/mimir-rules-action/entrypoint.sh index 186a3972539..f6a2c43015c 100755 --- a/operations/mimir-rules-action/entrypoint.sh +++ b/operations/mimir-rules-action/entrypoint.sh @@ -56,9 +56,9 @@ verifyAndConstructNamespaceSelection() { NAMESPACE_SELECTIONS_COUNT=$((NAMESPACE_SELECTIONS_COUNT + 1)) NAMESPACES_SELECTION="${IGNORED_NAMESPACES:+ --ignored-namespaces=${IGNORED_NAMESPACES}}" fi - if [ -n "${INGORED_NAMESPACES_REGEX}" ]; then + if [ -n "${IGNORED_NAMESPACES_REGEX}" ]; then NAMESPACE_SELECTIONS_COUNT=$((NAMESPACE_SELECTIONS_COUNT + 1)) - NAMESPACES_SELECTION="${INGORED_NAMESPACES_REGEX:+ --ignored-namespaces-regex=${INGORED_NAMESPACES_REGEX}}" + NAMESPACES_SELECTION="${IGNORED_NAMESPACES_REGEX:+ --ignored-namespaces-regex=${IGNORED_NAMESPACES_REGEX}}" fi if [ "${NAMESPACE_SELECTIONS_COUNT}" -gt 1 ]; then @@ -71,13 +71,17 @@ case "${ACTION}" in "$SYNC_CMD") verifyTenantAndAddress verifyAndConstructNamespaceSelection - OUTPUT=$(/bin/mimirtool rules sync --rule-dirs="${RULES_DIR}" "${NAMESPACES_SELECTION}" "$@") + # Don't quote $NAMESPACES_SELECTION since we don't want an empty string when it's not set + # shellcheck disable=SC2086 + OUTPUT=$(/bin/mimirtool rules sync --rule-dirs="${RULES_DIR}" $NAMESPACES_SELECTION "$@") STATUS=$? ;; "$DIFF_CMD") verifyTenantAndAddress verifyAndConstructNamespaceSelection - OUTPUT=$(/bin/mimirtool rules diff --rule-dirs="${RULES_DIR}" "${NAMESPACES_SELECTION}" --disable-color "$@") + # Don't quote $NAMESPACES_SELECTION since we don't want an empty string when it's not set + # shellcheck disable=SC2086 + OUTPUT=$(/bin/mimirtool rules diff --rule-dirs="${RULES_DIR}" $NAMESPACES_SELECTION --disable-color "$@") STATUS=$? ;; "$LINT_CMD")