diff --git a/client/registry.go b/client/registry.go index 89d6d796..4af11137 100644 --- a/client/registry.go +++ b/client/registry.go @@ -116,7 +116,7 @@ func GetTagDigest(image reference.Named) (string, error) { return "", err } - registryRes := struct { + registryResT1 := struct { SchemaVersion int MediaType string Manifests []struct { @@ -130,17 +130,39 @@ func GetTagDigest(image reference.Named) (string, error) { } }{} - if err := json.Unmarshal(body, ®istryRes); err != nil { + registryResT2 := struct { + SchemaVersion int + MediaType string + Config struct { + MediaType string + Size int + Digest string + } + Layers []struct { + MediaType string + Size int + Digest string + } + }{} + + if err := json.Unmarshal(body, ®istryResT1); err != nil { return "", err } var digest string - for _, manifest := range registryRes.Manifests { + for _, manifest := range registryResT1.Manifests { if string(manifest.Platform.Architecture) == "amd64" { digest = strings.Split(manifest.Digest, ":")[1][:7] } } + if digest == "" { + if err := json.Unmarshal(body, ®istryResT2); err != nil { + return "", err + } + digest = strings.Split(registryResT2.Config.Digest, ":")[1][:7] + } + if digest == "" { return "", fmt.Errorf("Unable to retrieve amd64 digest for '%s'", image) }