trivy-operator icon indicating copy to clipboard operation
trivy-operator copied to clipboard

fix: avoid re-mounting GCR volume with credentials

Open afdesk opened this issue 5 months ago • 2 comments

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

afdesk avatar Nov 05 '25 05:11 afdesk

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

afdesk avatar Nov 05 '25 06:11 afdesk

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

I left an idea https://github.com/aquasecurity/trivy-operator/pull/2801/files#r2591586352

simar7 avatar Dec 05 '25 06:12 simar7