helm-diff icon indicating copy to clipboard operation
helm-diff copied to clipboard

`diff uninstall` command

Open gytis-ivaskevicius opened this issue 1 year ago • 6 comments

I am using this project in custom tooling and I wanted to ask if there are plans to add a feature which would show the whole state that is about to be removed before executing helm uninstall

gytis-ivaskevicius avatar Dec 28 '23 14:12 gytis-ivaskevicius

@mumoshu @databus23 WDTY?

yxxhero avatar Jan 17 '24 04:01 yxxhero

Sounds like a good idea to me!

mumoshu avatar Jan 17 '24 05:01 mumoshu

I'm not sure I understand what is requested. Can't you just do a helm get manifest to learn about all the resources that are about to be removed? How would this be different?

databus23 avatar Jan 17 '24 08:01 databus23

@databus23 @yxxhero I'd love clarification from @gytis-ivaskevicius, but my understanding is this-

When you build a custom tool around helm-diff, it can produce diff not only on helm install/upgrade but also on uninstall.

Instead of doing helm get manifest followed by a difflib call, one wants something like helm diff uninstall that exactly does that for you. It makes integration with helm-diff from the custom tooling easier, as it does not need to directly depend on the version of difflib that helm-diff depends on and does not need to care about how helm-diff produces diffs.

...Well, thinking more and more about this seems to tell me that this isn't strictly needed, a nice-to-have feature to helm-diff 😺

@databus23 @yxxhero What are your thoughts? We'd better NOT add this?

mumoshu avatar Jan 22 '24 01:01 mumoshu

When you build a custom tool around helm-diff, it can produce diff not only on helm install/upgrade but also uninstall.

Yep, that's right. And yes, it's more of a nice-to-have feature

I did not consider the idea of running helm get manifest and performing a little bit of magic to make it seem like a removal diff but that would solve my issue

gytis-ivaskevicius avatar Jan 29 '24 06:01 gytis-ivaskevicius

@gytis-ivaskevicius Thanks for confirming! Ok then! FYI, here's how we compare current and desired manifests one by one: https://github.com/databus23/helm-diff/blob/adb33d2c01df54e8447e517bf4634f56cc584597/diff/diff.go#L313

We basically build a map of manifest names to manifest contents, for the desired and the current state, and compare them one by one using difflib. Your solution could be much simpler because you can just parse the helm get manifest output and run difflib diff against the empty string for each parsed manifest.

mumoshu avatar Jan 29 '24 07:01 mumoshu