Skip to content

Commit 9795a19

Browse files
author
zhouhao
committed
Modify the automatic determination of the Config type
Signed-off-by: zhouhao <[email protected]>
1 parent bc2102b commit 9795a19

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

image/autodetect.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ func Autodetect(path string) (string, error) {
7979

8080
header := struct {
8181
SchemaVersion int `json:"schemaVersion"`
82-
MediaType string `json:"mediaType"`
8382
Config interface{} `json:"config"`
83+
Manifests interface{} `json:"manifests"`
8484
}{}
8585

8686
if err := json.NewDecoder(f).Decode(&header); err != nil {
@@ -97,13 +97,13 @@ func Autodetect(path string) (string, error) {
9797
}
9898

9999
switch {
100-
case header.MediaType == string(schema.ValidatorMediaTypeManifest):
100+
case header.SchemaVersion == 2 && header.Config != nil:
101101
return TypeManifest, nil
102102

103-
case header.MediaType == string(schema.ValidatorMediaTypeImageIndex):
103+
case header.Manifests != nil:
104104
return TypeImageIndex, nil
105105

106-
case header.MediaType == "" && header.SchemaVersion == 0 && header.Config != nil:
106+
case header.SchemaVersion == 0 && header.Config != nil:
107107
// config files don't have mediaType/schemaVersion header
108108
return TypeConfig, nil
109109
}

0 commit comments

Comments
 (0)