Wilfred / difftastic

a structural diff that understands syntax 🟥🟩
https://difftastic.wilfred.me.uk/
MIT License
20.59k stars 333 forks source link

YAML files syntactic changes #723

Closed tomasdedic closed 2 months ago

tomasdedic commented 4 months ago

When I difft two yaml files where only difference is position of element I am still getting diff change. I would expect it the be syntactically the same files.

image

difft --version
Difftastic 0.57.0 (built with rustc 1.77.1)
difft cluster-monitoring-config.yaml cluster-monitoring-config2.yaml --check-only
cluster-monitoring-config2.yaml --- YAML
Has syntactic changes.
#cluster-monitoring-config.yaml
apiVersion: v1
kind: ConfigMap
data:
  prometheusOperator:
    nodeSelector:
      node-role.kubernetes.io/worker: ''
  enableUserWorkload: true
  prometheusK8s:
    retention: 3d
    additionalAlertmanagerConfigs:
    - apiVersion: v2
      pathPrefix: /
      scheme: http
      timeout: "30s"
      tlsConfig:
        insecureSkipVerify: true
#cluster-monitoring-config2.yaml
apiVersion: v1
kind: ConfigMap
data:
  enableUserWorkload: true
  prometheusOperator:
    nodeSelector:
      node-role.kubernetes.io/worker: ''
  prometheusK8s:
    retention: 3d
    additionalAlertmanagerConfigs:
    - apiVersion: v2
      pathPrefix: /
      scheme: http
      timeout: "30s"
      tlsConfig:
        insecureSkipVerify: true
Wilfred commented 2 months ago

Yeah, I'm afraid difftastic considers order to be important for all syntax. This is a relatively common question, so I've added an FAQ item: https://github.com/wilfred/difftastic?tab=readme-ov-file#can-difftastic-ignore-reordering