Skip to content

refactor(diff): extract secret handling to preHandleSecrets #787

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

Merged
merged 3 commits into from
May 25, 2025

Conversation

yxxhero
Copy link
Collaborator

@yxxhero yxxhero commented May 24, 2025

This pull request refactors the handling of secrets in the diff package to improve code reuse and readability. The changes include introducing a helper function for decoding secrets, updating related methods to use this helper, and adding a new test case to ensure correct behavior when both stringData and data fields are present in Kubernetes secrets.

Refactoring for code reuse and clarity:

  • Introduced a new helper function preHandleSecrets in diff/diff.go to centralize the logic for decoding secrets and handling errors. This function is now used in both redactSecrets and decodeSecrets to avoid code duplication. [1] [2] [3]

Testing improvements:

  • Added a new test case in diff_test.go to verify that decodeSecrets correctly prioritizes stringData over data when both fields are present in Kubernetes secrets. This ensures the expected behavior when handling secret resources.

Verified

This commit was signed with the committer’s verified signature.
magurotuna Yusuke Tanaka
Signed-off-by: yxxhero <[email protected]>
@yxxhero
Copy link
Collaborator Author

yxxhero commented May 24, 2025

see: #785

@yxxhero
Copy link
Collaborator Author

yxxhero commented May 24, 2025

@lucasfcnunes is this ok for you? I added tests for your case.

yxxhero and others added 2 commits May 25, 2025 10:59

Verified

This commit was signed with the committer’s verified signature.
magurotuna Yusuke Tanaka
Co-authored-by: Lucas Fernando Cardoso Nunes <[email protected]>
Signed-off-by: yxxhero <[email protected]>
@yxxhero
Copy link
Collaborator Author

yxxhero commented May 25, 2025

@lucasfcnunes all done!

@yxxhero
Copy link
Collaborator Author

yxxhero commented May 25, 2025

@lucasfcnunes thanks for your reviewing. it's good comments.

@yxxhero yxxhero merged commit c69efe6 into master May 25, 2025
16 checks passed
@yxxhero yxxhero deleted the fix-issue-decodeed-secret-issue branch May 28, 2025 23:45
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.

None yet

2 participants