cmd/config/docs/commands/fmt.md
[Alpha] Format yaml configuration files.
[Alpha] Format yaml configuration files.
Fmt will format input by ordering fields and unordered list items in Kubernetes objects. Inputs may be directories, files or stdin, and their contents must include both apiVersion and kind fields.
For inputs which contain multiple yaml documents separated by \n---\n, each document will be formatted and written back to the file in the original order.
Field ordering roughly follows the ordering defined in the source Kubernetes resource definitions (i.e. go structures), falling back on lexicographical sorting for unrecognized fields.
Unordered list item ordering is defined for specific Resource types and field paths.
# format file1.yaml and file2.yml
kustomize cfg fmt file1.yaml file2.yml
# format all *.yaml and *.yml recursively traversing directories
kustomize cfg fmt my-dir/
# format kubectl output
kubectl get -o yaml deployments | kustomize cfg fmt
# format kustomize output
kustomize build | kustomize cfg fmt