structured-merge-diff icon indicating copy to clipboard operation
structured-merge-diff copied to clipboard

Support semantic equality on List fields

Open nan-yu opened this issue 1 year ago • 1 comments

When comparing list fields within two objects, a simple equality check isn't enough. We need to implement a semantic check on the individual list items to ensure accurate comparisons.

  • Code Reference: The current equality check can be found here: https://github.com/kubernetes-sigs/structured-merge-diff/blob/v4.4.1/typed/compare.go#L148

  • Example: The following two objects should be evaluated as identical, even though their list item order differs:

kind: Role
metadata:
  name: test-role
  namespace: test-ns
rules:
- apiGroups:
  - batch/v1
  resources:
  - jobs
  verbs:
  - '*'
- apiGroups:
  - apps/v1
  resources:
  - deployments
  verbs:
  - '*'

and

kind: Role
metadata:
  name: test-role
  namespace: test-ns
rules:
- apiGroups:
  - apps/v1
  resources:
  - deployments
  verbs:
  - '*'
- apiGroups:
  - batch/v1
  resources:
  - jobs
  verbs:
  - '*'

nan-yu avatar Jul 17 '24 18:07 nan-yu