diff options
| author | Cheng Fang <cfang@redhat.com> | 2024-07-02 09:01:53 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-02 09:01:53 -0400 |
| commit | d8d3b018247be19cb4df90230327b0c4bb235c96 (patch) | |
| tree | 7bd0d0ac3e36e454203a93b8078a418fcb6970c8 | |
| parent | 80f6c968b37b352980a9afd6f2306d921ee24c74 (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.go | 14 |
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 } |
