Skip to content

Commit

Permalink
Merge pull request #2096 from lcarva/KFLUXBUGS-1616
Browse files Browse the repository at this point in the history
Validate the Image Index as well
  • Loading branch information
lcarva authored Oct 23, 2024
2 parents 6b03664 + 363d8b7 commit f74e26e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
4 changes: 2 additions & 2 deletions internal/applicationsnapshot/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ func expandImageIndex(ctx context.Context, snap *app.SnapshotSpec) {
continue
}

// The image is an image index and accessible so remove the image index itself and add index manifests
components = components[:len(components)-1]
// Add the platform-specific image references (Image Manifests) to the list of components so
// each is validated as well as the multi-platform image reference (Image Index).
for i, manifest := range indexManifest.Manifests {
var arch string
if manifest.Platform != nil && manifest.Platform.Architecture != "" {
Expand Down
23 changes: 13 additions & 10 deletions internal/applicationsnapshot/input_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,23 +276,26 @@ func TestExpandImageIndex(t *testing.T) {
}

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

amd64Image, arm64Image, noarchImage := false, false, false
for _, archImage := range snap.Components {
switch {
case strings.Contains(archImage.Name, "some-image-name-sha256:digest1-amd64"):
indexImage, amd64Image, arm64Image, noarchImage := false, false, false, false
for _, component := range snap.Components {
switch component.Name {
case "some-image-name":
indexImage = true
case "some-image-name-sha256:digest1-amd64":
amd64Image = true
case strings.Contains(archImage.Name, "some-image-name-sha256:digest2-arm64"):
case "some-image-name-sha256:digest2-arm64":
arm64Image = true
case strings.Contains(archImage.Name, "some-image-name-sha256:digest3-noarch-2"):
case "some-image-name-sha256:digest3-noarch-2":
noarchImage = true
}
}

assert.True(t, amd64Image, "An amd64 image should be present in the component")
assert.True(t, arm64Image, "An arm64 image should be present in the component")
assert.True(t, noarchImage, "A noarch image should be present in the component")
assert.True(t, indexImage, "Index Image should be present in components")
assert.True(t, amd64Image, "An amd64 image should be present in components")
assert.True(t, arm64Image, "An arm64 image should be present in components")
assert.True(t, noarchImage, "A noarch image should be present in components")
}

func TestExpandImageImage_Errors(t *testing.T) {
Expand Down

0 comments on commit f74e26e

Please sign in to comment.