You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use TEST_IMAGE_PREFIX in cluster image policy test template
🐞 Bug fix🧪 Tests🕐 Less than 5 minutes
AI Description
• Fix cluster image policy test template to reference the image prefix variable.
• Align template inputs with expected test configuration keys.
• Prevent template rendering failures or incorrect image glob matching in tests.
Directly switching the template variable to .TEST_IMAGE_PREFIX is the simplest and most maintainable fix, assuming the test harness now provides TEST_IMAGE_PREFIX as the canonical input.
Files changed (1) +1 / -1
Bug fix (1) +1 / -1
common_cluster_image_policy.yaml.tplUpdate image glob variable to TEST_IMAGE_PREFIX+1/-1
Update image glob variable to TEST_IMAGE_PREFIX
• Replaces the glob template variable from .TEST_IMAGE to .TEST_IMAGE_PREFIX so rendered ClusterImagePolicy manifests match the test harness' configured image prefix input.
1. Glob won't match digests✓ Resolved🐞 Bug≡ Correctness
Description
common_cluster_image_policy.yaml.tpl now sets spec.images[0].glob to TEST_IMAGE_PREFIX (repository
only) without any wildcard, so it will not match the digest/tag-qualified TEST_IMAGE values used in
e2e workloads. This prevents the ClusterImagePolicy from applying to the test image, causing
Verify()’s “unsigned image should be rejected” assertions to fail because workload creation will be
allowed.
ⓘ Recommendations generated based on similar findings in past PRs
Evidence
The template now uses the repo-only prefix as the glob (no wildcard). In e2e, TEST_IMAGE is a digest
reference and TEST_IMAGE_PREFIX is derived by stripping @/:; Verify() creates workloads using
TEST_IMAGE, so the new glob will not match those image strings under standard glob semantics (as
documented in this repo via use of **).
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
### Issue description
The ClusterImagePolicy template uses `{{ .TEST_IMAGE_PREFIX }}` as an `images[].glob` value, but `TEST_IMAGE_PREFIX` strips tag/digest and the resulting glob is an exact string. E2E workloads use digest/tag-qualified image references, so the policy won’t match/apply.
### Issue Context
`TEST_IMAGE_PREFIX` is computed by stripping everything after `@` or `:` from `TEST_IMAGE`, while `TEST_IMAGE` is commonly a digest reference (e.g. `repo/image@sha256:...`). The docs in this repo show glob patterns use wildcard semantics (`"**"`), implying that without a wildcard the match is exact.
### Fix Focus Areas
- test/utils/custom_resources/cluster_image_policies/common_cluster_image_policy.yaml.tpl[6-8]
### Suggested change
Update the template to include a wildcard suffix, e.g.:
```yaml
images:
- glob: "{{ .TEST_IMAGE_PREFIX }}*"
```
(or an equivalent pattern accepted by policy-controller such as `{{ .TEST_IMAGE_PREFIX }}**`).
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.