fix: support different type of registry response
This commit is contained in:
parent
83671f42a2
commit
cbe74b24c4
@ -116,7 +116,7 @@ func GetTagDigest(image reference.Named) (string, error) {
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
registryRes := struct {
|
registryResT1 := struct {
|
||||||
SchemaVersion int
|
SchemaVersion int
|
||||||
MediaType string
|
MediaType string
|
||||||
Manifests []struct {
|
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
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
var digest string
|
var digest string
|
||||||
for _, manifest := range registryRes.Manifests {
|
for _, manifest := range registryResT1.Manifests {
|
||||||
if string(manifest.Platform.Architecture) == "amd64" {
|
if string(manifest.Platform.Architecture) == "amd64" {
|
||||||
digest = strings.Split(manifest.Digest, ":")[1][:7]
|
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 == "" {
|
if digest == "" {
|
||||||
return "", fmt.Errorf("Unable to retrieve amd64 digest for '%s'", image)
|
return "", fmt.Errorf("Unable to retrieve amd64 digest for '%s'", image)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user