Skip to content

Commit

Permalink
Correct missing sizes for manifest schema 1 images
Browse files Browse the repository at this point in the history
Make sure to encode the updated sizes into image.DockerImageMetadata.Raw
otherwise the changes will be lost.

Signed-off-by: Michal Minář <[email protected]>
  • Loading branch information
Michal Minář committed Sep 13, 2017
1 parent 233358f commit 8c96906
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/dockerregistry/server/manifestschema1handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (h *manifestSchema1Handler) FillImageMetadata(ctx context.Context, image *i
}
image.DockerImageMetadata.Object = meta

return nil
return encodeRawDockerImageMetadata(image, true)
}

func (h *manifestSchema1Handler) Manifest() distribution.Manifest {
Expand Down
6 changes: 5 additions & 1 deletion pkg/dockerregistry/server/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,11 @@ func imageMetadataFromManifest(image *imageapiv1.Image) error {
return fmt.Errorf("unrecognized Docker image manifest schema %d for %q (%s)", manifest.SchemaVersion, image.Name, image.DockerImageReference)
}

if image.DockerImageMetadata.Object != nil && len(image.DockerImageMetadata.Raw) == 0 {
return encodeRawDockerImageMetadata(image, true)
}

func encodeRawDockerImageMetadata(image *imageapiv1.Image, overwrite bool) error {
if image.DockerImageMetadata.Object != nil && (overwrite || len(image.DockerImageMetadata.Raw) == 0) {
meta, ok := image.DockerImageMetadata.Object.(*imageapi.DockerImage)
if !ok {
return fmt.Errorf("docker image metadata object is not docker image")
Expand Down

0 comments on commit 8c96906

Please sign in to comment.