Skip to content

Commit

Permalink
Merge pull request #1748 from mtrmac/schema1
Browse files Browse the repository at this point in the history
Fix inspection of unsigned schema1 images
  • Loading branch information
openshift-merge-bot[bot] authored Nov 21, 2023
2 parents fffffcb + 2a7533e commit e2da7be
Showing 1 changed file with 11 additions and 7 deletions.
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

0 comments on commit e2da7be

Please sign in to comment.