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

Add knownDigest to ociclient's Resolve* methods #29

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions ociregistry/ociclient/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (c *client) resolve(ctx context.Context, rreq *ocirequest.Request) (ociregi
return ociregistry.Descriptor{}, err
}
resp.Body.Close()
desc, err := descriptorFromResponse(resp, "", true)
desc, err := descriptorFromResponse(resp, ociregistry.Digest(rreq.Digest), true)
if err != nil {
return ociregistry.Descriptor{}, fmt.Errorf("invalid descriptor in response: %v", err)
}
Expand Down Expand Up @@ -176,7 +176,7 @@ func (c *client) read(ctx context.Context, rreq *ocirequest.Request) (_ ociregis
return nil, err
}
resp1.Body.Close()
desc, err = descriptorFromResponse(resp1, "", true)
desc, err = descriptorFromResponse(resp1, ociregistry.Digest(rreq1.Digest), true)
if err != nil {
return nil, err
}
Expand Down
8 changes: 7 additions & 1 deletion ociregistry/ociserver/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,13 @@ func (r *registry) handleManifestHead(ctx context.Context, resp http.ResponseWri
if err != nil {
return err
}
resp.Header().Set("Docker-Content-Digest", string(desc.Digest))
if !r.opts.OmitDigestFromTagGetResponse || rreq.Tag != "" {
// Note: when doing a HEAD of a tag, clients are entitled
// to expect that the digest header is set on the response
// even though the spec says it's only optional in this case.
// TODO raise an issue on the spec about this.
resp.Header().Set("Docker-Content-Digest", string(desc.Digest))
}
resp.Header().Set("Content-Type", desc.MediaType)
resp.Header().Set("Content-Length", fmt.Sprint(desc.Size))
resp.WriteHeader(http.StatusOK)
Expand Down
Loading