Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Rename detection for Kubernetes resources #409

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

motoki317
Copy link

@motoki317 motoki317 commented Oct 24, 2024

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

@motoki317
Copy link
Author

@HeavyWombat Hello! Sorry to bother, but since you appear to be the main maintainer of this repository.
Do you have any bandwidth to review and possibly get this feature merged?

I know the change is a bit large, so I'll be happy to explain the changes if anything is unclear.

I'm already making heavy use of this feature in GitOps repositories at my hobby project and also at my company.
It would be awesome if dyff supported this officially.

@motoki317
Copy link
Author

@HeavyWombat Hi, any updates? 👀

@HeavyWombat
Copy link
Member

@HeavyWombat Hi, any updates? 👀

Thanks for asking and thank you for your patience and understanding. I am trying to use as much time as I can in my PTO to work on my Homeport projects.

@HeavyWombat
Copy link
Member

HeavyWombat commented Jan 15, 2025

Thanks for the PR and your patience. I took the liberty to rebase and update the feature branch so that the tests pass again. I still need some time to digest all the proposed changes here. And I need to dig into the license question a bit, because this would be the first time for the project to copy/incorporate foreign code into the project. So far, everything in dyff was written from scratch.

Copy link

codecov bot commented Jan 15, 2025

Codecov Report

Attention: Patch coverage is 80.80000% with 24 lines in your changes missing coverage. Please review.

Project coverage is 81.11%. Comparing base (f88bf7f) to head (3307ed2).

Files with missing lines Patch % Lines
pkg/dyff/rename_detect.go 72.41% 11 Missing and 5 partials ⚠️
pkg/dyff/core.go 86.66% 5 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #409      +/-   ##
==========================================
+ Coverage   80.97%   81.11%   +0.14%     
==========================================
  Files          15       16       +1     
  Lines        2092     2187      +95     
==========================================
+ Hits         1694     1774      +80     
- Misses        326      333       +7     
- Partials       72       80       +8     
Flag Coverage Δ
unittests 81.11% <80.80%> (+0.14%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dyff only data of confimaps generated with suffix
2 participants