Skip to content

Commit 17c1b4a

Browse files
author
zhouhao
committed
Modify the automatic determination of the Config type
Signed-off-by: zhouhao <[email protected]>
1 parent 0a1e5dc commit 17c1b4a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

image/autodetect.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
package image
1616

1717
import (
18-
"encoding/json"
1918
"io"
2019
"io/ioutil"
2120
"net/http"
@@ -79,8 +78,8 @@ func Autodetect(path string) (string, error) {
7978

8079
header := struct {
8180
SchemaVersion int `json:"schemaVersion"`
82-
MediaType string `json:"mediaType"`
8381
Config interface{} `json:"config"`
82+
Manifests interface{} `json:"manifests"`
8483
}{}
8584

8685
if err := json.NewDecoder(f).Decode(&header); err != nil {
@@ -97,16 +96,17 @@ func Autodetect(path string) (string, error) {
9796
}
9897

9998
switch {
100-
case header.MediaType == string(schema.MediaTypeManifest):
99+
case header.SchemaVersion == 2 && header.Config != nil:
101100
return TypeManifest, nil
102101

103-
case header.MediaType == string(schema.MediaTypeManifestList):
102+
case header.Manifests != nil:
104103
return TypeManifestList, nil
105104

106-
case header.MediaType == "" && header.SchemaVersion == 0 && header.Config != nil:
105+
case header.SchemaVersion == 0 && header.Config != nil:
107106
// config files don't have mediaType/schemaVersion header
108107
return TypeConfig, nil
109108
}
110109

111110
return "", errors.New("unknown media type")
111+
112112
}

0 commit comments

Comments
 (0)