Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix inspection of unsigned schema1 images #1748

Merged
merged 2 commits into from
Nov 21, 2023
Merged
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
18 changes: 11 additions & 7 deletions libimage/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,22 +180,26 @@ func (i *Image) Inspect(ctx context.Context, options *InspectOptions) (*ImageDat
}

// Docker image
case manifest.DockerV2Schema1MediaType, manifest.DockerV2Schema2MediaType:
case manifest.DockerV2Schema2MediaType:
rawConfig, err := i.rawConfigBlob(ctx)
if err != nil {
return nil, err
}
var dockerManifest manifest.Schema2V1Image
if err := json.Unmarshal(rawConfig, &dockerManifest); err != nil {
var dockerConfig manifest.Schema2V1Image
if err := json.Unmarshal(rawConfig, &dockerConfig); err != nil {
return nil, err
}
data.Comment = dockerManifest.Comment
data.Comment = dockerConfig.Comment
// NOTE: Health checks may be listed in the container config or
// the config.
data.HealthCheck = dockerManifest.ContainerConfig.Healthcheck
if data.HealthCheck == nil && dockerManifest.Config != nil {
data.HealthCheck = dockerManifest.Config.Healthcheck
data.HealthCheck = dockerConfig.ContainerConfig.Healthcheck
if data.HealthCheck == nil && dockerConfig.Config != nil {
data.HealthCheck = dockerConfig.Config.Healthcheck
}

case manifest.DockerV2Schema1MediaType, manifest.DockerV2Schema1SignedMediaType:
// There seem to be at least _some_ images with .Healthcheck set in schema1 (possibly just as an artifact
// of testing format conversion?), so this could plausibly read these values.
}

if data.Annotations == nil {
Expand Down