fix: avoid re-mounting GCR volume with credentials
Description
This PR adds a validation to ensure that a volume containing GCR credentials is present before proceeding. If such a volume is already mounted, the logic prevents redundant re-mounting to avoid duplication and potential conflicts.
Related issues
- Close #2407
Checklist
- [ ] I've read the guidelines for contributing to this repository.
- [ ] I've added tests that prove my fix is effective or that my feature works.
- [ ] I've updated the documentation with the relevant information (if needed).
- [ ] I've added usage information (if the PR introduces new options)
- [ ] I've included a "before" and "after" example to the description (if the PR is a user interface change).
@simar7 I remember you have a meticulous attitude toward testing, and I was thinking about how to add tests here.
A simple table-driven test for createEnvAndVolumeForGcr doesn’t make much sense in this context.
Once we resolve issues #2595 and #2769, we’ll be able to add a more meaningful test that covers multiple containers.
@simar7 I remember you have a meticulous attitude toward testing, and I was thinking about how to add tests here.
A simple table-driven test for
createEnvAndVolumeForGcrdoesn’t make much sense in this context.Once we resolve issues #2595 and #2769, we’ll be able to add a more meaningful test that covers multiple containers.
I left an idea https://github.com/aquasecurity/trivy-operator/pull/2801/files#r2591586352