-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change extract-alerts to associative array + githubCI fix
- Loading branch information
Showing
4 changed files
with
35 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,30 @@ | ||
#!/bin/bash | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
INPUT_YAML="$1" | ||
OUTPUT_DIR="$2" | ||
|
||
mkdir -p "$OUTPUT_DIR" | ||
|
||
# Define RULES_FILES and output files | ||
RULES_FILES=( | ||
"rhods-dashboard-alerting.rules" | ||
"model-mesh-alerting.rules" | ||
"trustyai-alerting.rules" | ||
"odh-model-controller-alerting.rules" | ||
"workbenches-alerting.rules" | ||
"data-science-pipelines-operator-alerting.rules" | ||
"kserve-alerting.rules" | ||
"kueue-alerting.rules" | ||
"ray-alerting.rules" | ||
"codeflare-alerting.rules" | ||
"trainingoperator-alerting.rules" | ||
) | ||
|
||
ALERT_FILES=( | ||
"dashboard_alerts.yaml" | ||
"model_mesh_alerts.yaml" | ||
"trustyai_alerts.yaml" | ||
"model_controller_alerts.yaml" | ||
"workbenches_alerts.yaml" | ||
"data_science_pipelines_operator_alerts.yaml" | ||
"kserve_alerts.yaml" | ||
"kueue_alerts.yaml" | ||
"kuberay_alerts.yaml" | ||
"codeflare_alerts.yaml" | ||
"training_operator_alerts.yaml" | ||
# Define an associative array mapping rule files to alert files | ||
declare -A RULES_TO_ALERTS=( | ||
[rhods-dashboard-alerting.rules]="dashboard_alerts.yaml" | ||
[model-mesh-alerting.rules]="model_mesh_alerts.yaml" | ||
[trustyai-alerting.rules]="trustyai_alerts.yaml" | ||
[odh-model-controller-alerting.rules]="model_controller_alerts.yaml" | ||
[workbenches-alerting.rules]="workbenches_alerts.yaml" | ||
[data-science-pipelines-operator-alerting.rules]="data_science_pipelines_operator_alerts.yaml" | ||
[kserve-alerting.rules]="kserve_alerts.yaml" | ||
[kueue-alerting.rules]="kueue_alerts.yaml" | ||
[ray-alerting.rules]="kuberay_alerts.yaml" | ||
[codeflare-alerting.rules]="codeflare_alerts.yaml" | ||
[trainingoperator-alerting.rules]="training_operator_alerts.yaml" | ||
) | ||
|
||
for i in "${!RULES_FILES[@]}"; do | ||
RULE_FILE="${RULES_FILES[$i]}" | ||
ALERT_FILE="${ALERT_FILES[$i]}" | ||
echo "Extracting $RULE_FILE to $OUTPUT_DIR/$ALERT_FILE" | ||
yq ".data.\"$RULE_FILE\"" "$INPUT_YAML" > "$OUTPUT_DIR/$ALERT_FILE" | ||
for RULE_FILE in "${!RULES_TO_ALERTS[@]}"; do | ||
ALERT_FILE="${RULES_TO_ALERTS[$RULE_FILE]}" | ||
|
||
echo "key: $RULE_FILE" | ||
echo "value: $ALERT_FILE" | ||
|
||
echo "Extracting $RULE_FILE to $OUTPUT_DIR/$ALERT_FILE" | ||
yq ".data.\"$RULE_FILE\"" "$INPUT_YAML" > "$OUTPUT_DIR/$ALERT_FILE" | ||
done |