Skip to content

Commit d8d3b01

Browse files
authored
fix: add check for the optional ref.Platform field to avoid nil pointer in TagInfoFromReferences (argoproj-labs#759)
Signed-off-by: Cheng Fang <[email protected]>
1 parent 80f6c96 commit d8d3b01

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

pkg/registry/client.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -361,12 +361,18 @@ func TagInfoFromReferences(client *registryClient, opts *options.ManifestOptions
361361
platforms := []string{}
362362

363363
for _, ref := range references {
364-
platforms = append(platforms, ref.Platform.OS+"/"+ref.Platform.Architecture)
365-
logCtx.Tracef("Found %s", options.PlatformKey(ref.Platform.OS, ref.Platform.Architecture, ref.Platform.Variant))
366-
if !opts.WantsPlatform(ref.Platform.OS, ref.Platform.Architecture, ref.Platform.Variant) {
364+
var refOS, refArch, refVariant string
365+
if ref.Platform != nil {
366+
refOS = ref.Platform.OS
367+
refArch = ref.Platform.Architecture
368+
refVariant = ref.Platform.Variant
369+
}
370+
platforms = append(platforms, refOS+"/"+refArch)
371+
logCtx.Tracef("Found %s", options.PlatformKey(refOS, refArch, refVariant))
372+
if !opts.WantsPlatform(refOS, refArch, refVariant) {
367373
logCtx.Tracef("Ignoring referenced manifest %v because platform %s does not match any of: %s",
368374
ref.Digest,
369-
options.PlatformKey(ref.Platform.OS, ref.Platform.Architecture, ref.Platform.Variant),
375+
options.PlatformKey(refOS, refArch, refVariant),
370376
strings.Join(opts.Platforms(), ","))
371377
continue
372378
}

0 commit comments

Comments
 (0)