This repository has been archived by the owner on Nov 17, 2021. It is now read-only.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: * yudai/gojsondiff#24 * yudai/gojsondiff#30 These sometimes resulted in diffs that were too noisy and/or showed false information; this has been reported as #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>
mkmik
reviewed
Nov 22, 2018
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried it with --diff-strategy subset
and it shows "ERROR Differences found" although no differences are shown in the output. Example:
---
- live services zerozone.zerozone
+ config services zerozone.zerozone
{
"apiVersion": "v1",
"kind": "Service",
"metadata": {
"labels": {
"name": "foo"
},
"name": "foo",
"namespace": "foo"
},
"spec": {
"ports": [
{
"port": 8080
}
],
"selector": {
"name": "foo"
},
"type": "LoadBalancer"
}
}
ERROR Differences found.
Master, for the same config shows:
...
- "port": 8080
+ "port": 8080
...
This addresses code review comments -- the conditions in original PR were detected incorrectly; this PR changes the condition to the case where the whole Diff is just a single block of DiffEquals change. Also, the latter change moves DiffLineStart to the top of file, so that it doesn't need to be recomputed each time the formatDiff function is called. Signed-off-by: Milan Plzik <milan.plzik@ceai.io>
PTAL. |
LGTM. but sadly EMENOMAINTAINER of this repo; pinging my colleague @anguslees. |
LGTM also, thanks @emempi -- verified it fixes false diff positives |
anguslees
approved these changes
Dec 3, 2018
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was referenced Dec 3, 2018
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
#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