Skip to content

Configurable manual sort order #8

@prokher

Description

@prokher

Dear @pascalre ,

I would like to ask if it is possible to add a configurable option with witch I could manually specify sort order for some keys. Let me explain. The main reason I use YAML sort plugin if to reduce difficulties during merging YAML-configuration across different git branches. It is much easier to merge when the order of keys is the same in the conflicting branches. Most of the YAML files I work with is either Kubernetes manifests or different their variations, e.g. Kustomize rules (kustomization.yaml). The thing is, in such files there is some natural order of keys which is not always alphabetical. I've seen #3 about Kubernetes-friendly sort, but I suppose it is better to have an option, so I can manually configure the plugin specifically for my project. Just as a motivating example, please, consider typical kustomization.yaml:

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
commonLabels: ...
patches: ...
resources: ...

For this type of files the "natural" sort order is the following:

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources: ...
patches: ...
commonLabels: ...

which obviously differs from the alphabetical order.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions