Open davidweterings opened 1 year ago
Perhaps interesting: https://github.com/editorconfig/editorconfig-core-go/tree/master
Based on Frasers project:
- yq -i '.mach_composer.plugins |= sort_keys(..)' {{ .target }}-config-{{ .environment }}.yaml
- yq -i '.global.terraform_config.providers |= sort_keys(..)' {{ .target }}-config-{{ .environment }}.yaml
- yq -i '.sites.[].components |= sort_by(.name)' {{ .target }}-config-{{ .environment }}.yaml
- yq -i '.sites.[].components.[].variables |= sort_keys(..)' {{ .target }}-config-{{ .environment }}.yaml
- yq -i '.sites.[].components.[].secrets |= sort_keys(..)' {{ .target }}-config-{{ .environment }}.yaml
- yq -i 'del(.. | select(. == null))' {{ .target }}-config-{{ .environment }}.yaml
Is your proposal related to a problem?
We have several MACH configs in different repos, sometimes I want to compare versions or variable settings. I've found comparing them is easier if everything in the yml is sorted consistently
Describe the solution you'd like
Add mach-composer fmt to format a MACH config yaml file in a strict-defined order:
Describe alternatives you've considered
Precommit hook yaml sorting kinda works; https://github.com/leehambley/pre-commit-sort-yaml-keys