Skip to content

Commit d1e29dc

Browse files
committed
use image.patched
Signed-off-by: Sertac Ozercan <[email protected]>
1 parent 0299747 commit d1e29dc

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

integration/multiarch/patch_test.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import (
2323
//go:embed fixtures/test-images.json
2424
var testImages []byte
2525

26+
const lastPatchedAnnotation = "sh.copa.image.patched"
27+
2628
type testImage struct {
2729
OriginalImage string `json:"originalImage"`
2830
LocalImage string `json:"localImage"`
@@ -409,11 +411,11 @@ func verifyAnnotations(t *testing.T, patchedRef string, platforms []string, repo
409411
t.Logf("platform %s has updated created timestamp: %s", platformStr, createdTime)
410412
}
411413

412-
// Check for Copa last.patched annotation on patched platforms
413-
lastPatched, exists := manifestEntry.Annotations["sh.copa.last.patched"]
414-
assert.True(t, exists, "patched platform %s should have sh.copa.last.patched annotation", platformStr)
415-
assert.NotEmpty(t, lastPatched, "sh.copa.last.patched timestamp should not be empty for patched platform %s", platformStr)
416-
t.Logf("platform %s has Copa last.patched timestamp: %s", platformStr, lastPatched)
414+
// Check for Copa image.patched annotation on patched platforms
415+
lastPatched, exists := manifestEntry.Annotations[lastPatchedAnnotation]
416+
assert.True(t, exists, "patched platform %s should have %s annotation", platformStr, lastPatchedAnnotation)
417+
assert.NotEmpty(t, lastPatched, "%s timestamp should not be empty for patched platform %s", lastPatchedAnnotation, platformStr)
418+
t.Logf("platform %s has %s timestamp: %s", platformStr, lastPatchedAnnotation, lastPatched)
417419

418420
t.Logf("platform %s has %d manifest-level annotations", platformStr, len(manifestEntry.Annotations))
419421

@@ -452,9 +454,9 @@ func verifyAnnotations(t *testing.T, patchedRef string, platforms []string, repo
452454
} else {
453455
t.Logf("checking platform %s (no vulnerability report, not patched)", platformStr)
454456

455-
// Non-patched platforms should NOT have the Copa last.patched annotation
456-
_, exists := manifestEntry.Annotations["sh.copa.last.patched"]
457-
assert.False(t, exists, "non-patched platform %s should not have sh.copa.last.patched annotation", platformStr)
457+
// Non-patched platforms should NOT have the Copa image.patched annotation
458+
_, exists := manifestEntry.Annotations["sh.copa.image.patched"]
459+
assert.False(t, exists, "non-patched platform %s should not have sh.copa.image.patched annotation", platformStr)
458460
}
459461
}
460462
}

pkg/patch/patch.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ func patchSingleArchImage(
468468
// determine which attributes to set for the export
469469
attrs := map[string]string{
470470
"name": patchedImageName,
471-
"annotation." + copaAnnotationKeyPrefix + ".last.patched": time.Now().UTC().Format(time.RFC3339),
471+
"annotation." + copaAnnotationKeyPrefix + ".image.patched": time.Now().UTC().Format(time.RFC3339),
472472
}
473473
if shouldExportOCI {
474474
attrs["oci-mediatypes"] = "true"
@@ -737,8 +737,8 @@ func patchSingleArchImage(
737737
// update creation timestamp to reflect patching
738738
augmentedDesc.Annotations["org.opencontainers.image.created"] = time.Now().UTC().Format(time.RFC3339)
739739

740-
// add Copa last.patched annotation for patched platforms
741-
augmentedDesc.Annotations[copaAnnotationKeyPrefix+".last.patched"] = time.Now().UTC().Format(time.RFC3339)
740+
// add Copa image.patched annotation for patched platforms
741+
augmentedDesc.Annotations[copaAnnotationKeyPrefix+".image.patched"] = time.Now().UTC().Format(time.RFC3339)
742742

743743
patchedDesc = &augmentedDesc
744744
log.Debugf("Preserved %d manifest level annotations for platform %s", len(originalAnnotations), targetPlatform.Platform)

0 commit comments

Comments
 (0)