Skip to content

Commit

Permalink
created universal dashboard script
Browse files Browse the repository at this point in the history
  • Loading branch information
ehearneRedHat committed May 14, 2024
1 parent df9b798 commit d888781
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions config/observability/universal-dashboard.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash

# Check if two arguments are provided
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <file1.json> <file2.json>"
exit 1
fi

# Assign provided arguments to variables
public_file="$1"
original_file="$2"

# Check if provided files exist
if [ ! -f "$public_file" ]; then
echo "$public_file does not exist."
exit 1
fi

if [ ! -f "$original_file" ]; then
echo "$original_file does not exist."
exit 1
fi

# Load data from a-public.json
public_data=$(<"$public_file")

# Load data from a.json
original_data=$(<"$original_file")

# Extract __requires field from a-public.json
requires_field=$(echo "$public_data" | jq '.__requires')

# Add __requires field to the outermost bracket of a.json
updated_data=$(echo "$original_data" | jq --argjson requires "$requires_field" '. + { "__requires": $requires }')

# Write the updated data back to a.json
echo "$updated_data" > "$original_file"

# Remove the public file
rm $public_file

0 comments on commit d888781

Please sign in to comment.