Skip to content

Commit

Permalink
Add script for sorting YAML files
Browse files Browse the repository at this point in the history
  • Loading branch information
garyhtou committed Aug 13, 2024
1 parent 9cffb8b commit 205233e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions bin/sort
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

# Get list of zones (and thus filenames)
yq '.zones | keys | .[]' config/production.yaml | while read -r zone; do
# For each file...
FILENAME="$zone"yaml
echo Sorting $FILENAME

# Sort the keys in the file
yq -iMP 'sort_keys(.)' $FILENAME
# - i: in-place
# - M: no color
# - P: pretty print
done

0 comments on commit 205233e

Please sign in to comment.