Skip to content

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.

@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
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.

3 participants