feat: Rename detection for Kubernetes resources #409
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.
Hello!
This pull request adds git-like rename detection logic for Kubernetes documents comparison.
For now, I have implemented this only for Kubernetes resources, whose name "keys" can be computed from
metadata.name
and other fields.This is because additions and deletions can be computed only if these "keys" are present.
The heuristic rename detection logic was mostly taken from https://github.com/go-git/go-git.
I would love to use this feature in my use-case, that is, using configMapGenerator with kustomize.
Currently, changing file contents a little bit results in a huge diff, because the kustomize adds hash suffix to resource names.
This use-case is added as a test case under
./assets/kubernetes/rename
directory.Example of real-life use-case: traPtitech/manifest#600 (comment)
The implementation may still be rough-cut, so please feel free to correct or point out anything you don't like.
I've prepared a (pre-)release in my forked repository so you can install it and try it out with the following one-line script.
https://github.com/motoki317/dyff/releases
curl --silent --location https://git.io/JYfAY | ORG=motoki317 REPO=dyff bash
Thank you in advance!
resolves #359