This repository has been archived on 2024-03-28. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/common/bin/k8s-yaml-sort

18 lines
346 B
Plaintext
Raw Normal View History

2020-02-10 21:25:23 -06:00
#!/usr/bin/env bash
[ "$#" -lt 1 ] && echo "Need a filename." && exit 1
2020-04-20 10:38:19 -05:00
< "$1" yq -s . | jq -S '
2020-02-10 21:25:23 -06:00
sort_by(.metadata.name) |
sort_by(.kind) |
.[] | .spec.template.spec.containers |=
if . == null then empty
else
map(
if . == null then empty
else .env |= sort_by(.name)
| .volumeMounts |= sort_by(.name)
end
)
end
'