vmware-archive / kubecfg

A tool for managing complex enterprise Kubernetes environments as code.
Apache License 2.0
727 stars 62 forks source link

Rework kubecfg diff code. #230

Closed mplzik closed 5 years ago

mplzik commented 5 years ago

The old code relied on gojsondiff library, which provides more semantic JSON diffs. This library, however, had some long-standing issues which have not been yet fixed, namely:

These sometimes resulted in diffs that were too noisy and/or showed false information; this has been reported as

https://github.com/ksonnet/kubecfg/issues/229

This patch reworks kubecfg's diff code to first marshal JSON using golang's encoding/json and then calculates the diff using diffmatchpatch library, formatting the output as close to the original as possible. Although this results in a more syntactic-level diff, it might just do the job until gojsondiff gets the above-mentioned bugs fixed.

Signed-off-by: Milan Plzik milan.plzik@ceai.io

mplzik commented 5 years ago

PTAL.

mkmik commented 5 years ago

LGTM.

but sadly EMENOMAINTAINER of this repo; pinging my colleague @anguslees.

jjo commented 5 years ago

LGTM also, thanks @emempi -- verified it fixes false diff positives on numeric values, and much better handles e.g. configmap diffs with multiline valued fields.