Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions manifest/docker_schema2_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,17 @@ func (list *Schema2List) ChooseInstance(ctx *types.SystemContext) (digest.Digest
if ctx != nil && ctx.OSChoice != "" {
wantedOS = ctx.OSChoice
}
wantedVariant := ""
if ctx != nil && ctx.VariantChoice != "" {
wantedVariant = ctx.VariantChoice
}

for _, d := range list.Manifests {
if d.Platform.Architecture == wantedArch && d.Platform.OS == wantedOS {
if d.Platform.Architecture == wantedArch && d.Platform.OS == wantedOS && (d.Platform.Variant == wantedVariant || wantedVariant == "") {
return d.Digest, nil
}
}
return "", fmt.Errorf("no image found in manifest list for architecture %s, OS %s", wantedArch, wantedOS)
return "", fmt.Errorf("no image found in manifest list for architecture %s(variant \"%s\"), OS %s", wantedArch, wantedVariant, wantedOS)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, could you add a space after the %s and before the new paren? %s (variant

}

// Serialize returns the list in a blob format.
Expand Down
8 changes: 6 additions & 2 deletions manifest/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,14 @@ func TestChooseInstance(t *testing.T) {
require.NoError(t, err)
// Match found
for arch, expected := range manifestList.matchedInstances {
digest, err := list.ChooseInstance(&types.SystemContext{
ctx := &types.SystemContext{
ArchitectureChoice: arch,
OSChoice: "linux",
})
}
if arch == "arm" {
ctx.VariantChoice = "v5"
}
digest, err := list.ChooseInstance(ctx)
require.NoError(t, err, arch)
assert.Equal(t, expected, digest)
}
Expand Down
2 changes: 2 additions & 0 deletions types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,8 @@ type SystemContext struct {
LegacyFormatAuthFilePath string
// If not "", overrides the use of platform.GOARCH when choosing an image or verifying architecture match.
ArchitectureChoice string
// If not "", overrides the use of Architecture variant when choosing an image or verifying architecture match.
VariantChoice string
// If not "", overrides the use of platform.GOOS when choosing an image or verifying OS match.
OSChoice string
// If not "", overrides the system's default directory containing a blob info cache.
Expand Down