Skip to content

Commit f74e26e

Browse files
authored
Merge pull request #2096 from lcarva/KFLUXBUGS-1616
Validate the Image Index as well
2 parents 6b03664 + 363d8b7 commit f74e26e

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

internal/applicationsnapshot/input.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,8 @@ func expandImageIndex(ctx context.Context, snap *app.SnapshotSpec) {
224224
continue
225225
}
226226

227-
// The image is an image index and accessible so remove the image index itself and add index manifests
228-
components = components[:len(components)-1]
227+
// Add the platform-specific image references (Image Manifests) to the list of components so
228+
// each is validated as well as the multi-platform image reference (Image Index).
229229
for i, manifest := range indexManifest.Manifests {
230230
var arch string
231231
if manifest.Platform != nil && manifest.Platform.Architecture != "" {

internal/applicationsnapshot/input_test.go

+13-10
Original file line numberDiff line numberDiff line change
@@ -276,23 +276,26 @@ func TestExpandImageIndex(t *testing.T) {
276276
}
277277

278278
expandImageIndex(ctx, snap)
279-
assert.True(t, len(snap.Components) == 3, "Image Index itself should be removed and be replaced by individual image manifests")
279+
assert.True(t, len(snap.Components) == 4, "Image Index should NOT be removed")
280280

281-
amd64Image, arm64Image, noarchImage := false, false, false
282-
for _, archImage := range snap.Components {
283-
switch {
284-
case strings.Contains(archImage.Name, "some-image-name-sha256:digest1-amd64"):
281+
indexImage, amd64Image, arm64Image, noarchImage := false, false, false, false
282+
for _, component := range snap.Components {
283+
switch component.Name {
284+
case "some-image-name":
285+
indexImage = true
286+
case "some-image-name-sha256:digest1-amd64":
285287
amd64Image = true
286-
case strings.Contains(archImage.Name, "some-image-name-sha256:digest2-arm64"):
288+
case "some-image-name-sha256:digest2-arm64":
287289
arm64Image = true
288-
case strings.Contains(archImage.Name, "some-image-name-sha256:digest3-noarch-2"):
290+
case "some-image-name-sha256:digest3-noarch-2":
289291
noarchImage = true
290292
}
291293
}
292294

293-
assert.True(t, amd64Image, "An amd64 image should be present in the component")
294-
assert.True(t, arm64Image, "An arm64 image should be present in the component")
295-
assert.True(t, noarchImage, "A noarch image should be present in the component")
295+
assert.True(t, indexImage, "Index Image should be present in components")
296+
assert.True(t, amd64Image, "An amd64 image should be present in components")
297+
assert.True(t, arm64Image, "An arm64 image should be present in components")
298+
assert.True(t, noarchImage, "A noarch image should be present in components")
296299
}
297300

298301
func TestExpandImageImage_Errors(t *testing.T) {

0 commit comments

Comments
 (0)