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: Allow suppressing annotations and labels #468

Conversation

antoinedeschenes
Copy link
Contributor

Allows suppressing annotations and labels in the diff output.

Fixes #390.

Useful to ignore changes that might not make an helm upgrade worthwhile, such as chart version labels.
Also allows hiding labels containing sensitive information, such as kubectl.kubernetes.io/last-applied-configuration on secrets when using three-way-merge.

It currently doesn't handle pod templates in deployments, etc. which could still be very useful (to hide checksum annotation changes, for example).

@antoinedeschenes antoinedeschenes marked this pull request as draft June 7, 2023 19:58
@antoinedeschenes antoinedeschenes force-pushed the feat-suppress-annotations-labels branch 2 times, most recently from e03fd59 to 9722a15 Compare June 7, 2023 21:03
@antoinedeschenes antoinedeschenes force-pushed the feat-suppress-annotations-labels branch from 9722a15 to 1923e2b Compare June 7, 2023 21:49
@@ -101,6 +105,10 @@ func contentSearch(report *Report, possiblyRemoved []string, oldIndex map[string
redactSecrets(oldContent, newContent)
}

if len(options.SuppressedAnnotations) > 0 || len(options.SuppressedLabels) > 0 {
suppressAnnotationsAndLabels(oldContent, newContent, options)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Presuming all diffMappingResults calls need to be preceded by the new function calls, can we instead put this code inside diffMappingResults for maintainability, changing the third parameter of it to the options instead of a bool? 🐱

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late answer, I have running code also handling nested labels/annotations in pod templates, but I think it quickly gets too specialized, having to handle all cases one by one (CronJob, Job, Deployment, StatefulSet, etc.)

I think having a render script hook before diff could make sense, that would make it possible to run a custom script deleting/sanitizing required fields.

I know there are post-renderer flags passed to helm, but these are only applied to the target helm template command.

WDYT?

@yxxhero
Copy link
Collaborator

yxxhero commented Feb 13, 2024

@antoinedeschenes any updates?

@yxxhero
Copy link
Collaborator

yxxhero commented May 25, 2024

#475

@yxxhero yxxhero closed this May 25, 2024
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.

Secret: kubectl.kubernetes.io/last-applied-configuration not redacted
3 participants