Skip to content

Commit

Permalink
fix: Don't quote mimir-rules-action namespace selection variable (#9324)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

* Changelog

Signed-off-by: Nick Pillitteri <[email protected]>

---------

Signed-off-by: Nick Pillitteri <[email protected]>
  • Loading branch information
56quarters committed Sep 18, 2024
1 parent c061e0b commit 0c4857a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion operations/mimir-rules-action/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
12 changes: 8 additions & 4 deletions operations/mimir-rules-action/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
Expand Down

0 comments on commit 0c4857a

Please sign in to comment.