Skip to content
This repository was archived by the owner on Jan 15, 2026. It is now read-only.
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions image/autodetect.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ func Autodetect(path string) (string, error) {

header := struct {
SchemaVersion int `json:"schemaVersion"`
MediaType string `json:"mediaType"`
Config interface{} `json:"config"`
Manifests interface{} `json:"manifests"`
}{}

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

switch {
case header.MediaType == string(schema.ValidatorMediaTypeManifest):
case header.SchemaVersion == 2 && header.Config != nil:
return TypeManifest, nil

case header.MediaType == string(schema.ValidatorMediaTypeImageIndex):
case header.Manifests != nil:
return TypeImageIndex, nil

case header.MediaType == "" && header.SchemaVersion == 0 && header.Config != nil:
case header.SchemaVersion == 0 && header.Config != nil:
// config files don't have mediaType/schemaVersion header
return TypeConfig, nil
}
Expand Down