summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCheng Fang <cfang@redhat.com>2024-07-02 09:01:53 -0400
committerGitHub <noreply@github.com>2024-07-02 09:01:53 -0400
commitd8d3b018247be19cb4df90230327b0c4bb235c96 (patch)
tree7bd0d0ac3e36e454203a93b8078a418fcb6970c8
parent80f6c968b37b352980a9afd6f2306d921ee24c74 (diff)
fix: add check for the optional ref.Platform field to avoid nil pointer in TagInfoFromReferences (#759)
Signed-off-by: Cheng Fang <cfang@redhat.com>
-rw-r--r--pkg/registry/client.go14
1 files changed, 10 insertions, 4 deletions
diff --git a/pkg/registry/client.go b/pkg/registry/client.go
index b92b291..2c2ddde 100644
--- a/pkg/registry/client.go
+++ b/pkg/registry/client.go
@@ -361,12 +361,18 @@ func TagInfoFromReferences(client *registryClient, opts *options.ManifestOptions
platforms := []string{}
for _, ref := range references {
- platforms = append(platforms, ref.Platform.OS+"/"+ref.Platform.Architecture)
- logCtx.Tracef("Found %s", options.PlatformKey(ref.Platform.OS, ref.Platform.Architecture, ref.Platform.Variant))
- if !opts.WantsPlatform(ref.Platform.OS, ref.Platform.Architecture, ref.Platform.Variant) {
+ var refOS, refArch, refVariant string
+ if ref.Platform != nil {
+ refOS = ref.Platform.OS
+ refArch = ref.Platform.Architecture
+ refVariant = ref.Platform.Variant
+ }
+ platforms = append(platforms, refOS+"/"+refArch)
+ logCtx.Tracef("Found %s", options.PlatformKey(refOS, refArch, refVariant))
+ if !opts.WantsPlatform(refOS, refArch, refVariant) {
logCtx.Tracef("Ignoring referenced manifest %v because platform %s does not match any of: %s",
ref.Digest,
- options.PlatformKey(ref.Platform.OS, ref.Platform.Architecture, ref.Platform.Variant),
+ options.PlatformKey(refOS, refArch, refVariant),
strings.Join(opts.Platforms(), ","))
continue
}