Skip to content

Commit

Permalink
fix typo
Browse files Browse the repository at this point in the history
Signed-off-by: Lixia (Sylvia) Lei <[email protected]>
  • Loading branch information
Wwwsylvia committed Jul 24, 2023
1 parent 103dd22 commit c83bd0d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
18 changes: 9 additions & 9 deletions registry/remote/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ import (
)

const (
// headerdockerContentDigest is the "Docker-Content-Digest" header.
// headerDockerContentDigest is the "Docker-Content-Digest" header.
// If present on the response, it contains the canonical digest of the
// uploaded blob.
//
// References:
// - https://docs.docker.com/registry/spec/api/#digest-header
// - https://github.com/opencontainers/distribution-spec/blob/v1.1.0-rc1/spec.md#pull
headerdockerContentDigest = "Docker-Content-Digest"
headerDockerContentDigest = "Docker-Content-Digest"

// headerOCIFiltersApplied is the "OCI-Filters-Applied" header.
// If present on the response, it contains a comma-separated list of the
Expand Down Expand Up @@ -1442,13 +1442,13 @@ func (s *manifestStore) generateDescriptor(resp *http.Response, ref registry.Ref

// 4. Validate Server Digest (if present)
var serverHeaderDigest digest.Digest
if serverHeaderDigestStr := resp.Header.Get(headerdockerContentDigest); serverHeaderDigestStr != "" {
if serverHeaderDigestStr := resp.Header.Get(headerDockerContentDigest); serverHeaderDigestStr != "" {
if serverHeaderDigest, err = digest.Parse(serverHeaderDigestStr); err != nil {
return ocispec.Descriptor{}, fmt.Errorf(
"%s %q: invalid response header value: `%s: %s`; %w",
resp.Request.Method,
resp.Request.URL,
headerdockerContentDigest,
headerDockerContentDigest,
serverHeaderDigestStr,
err,
)
Expand All @@ -1465,7 +1465,7 @@ func (s *manifestStore) generateDescriptor(resp *http.Response, ref registry.Ref
// immediate fail
return ocispec.Descriptor{}, fmt.Errorf(
"HTTP %s request missing required header %q",
httpMethod, headerdockerContentDigest,
httpMethod, headerDockerContentDigest,
)
}
// Otherwise, just trust the client-supplied digest
Expand All @@ -1487,7 +1487,7 @@ func (s *manifestStore) generateDescriptor(resp *http.Response, ref registry.Ref
return ocispec.Descriptor{}, fmt.Errorf(
"%s %q: invalid response; digest mismatch in %s: received %q when expecting %q",
resp.Request.Method, resp.Request.URL,
headerdockerContentDigest, contentDigest,
headerDockerContentDigest, contentDigest,
refDigest,
)
}
Expand Down Expand Up @@ -1519,7 +1519,7 @@ func calculateDigestFromResponse(resp *http.Response, maxMetadataBytes int64) (d
// OCI distribution-spec states the Docker-Content-Digest header is optional.
// Reference: https://github.com/opencontainers/distribution-spec/blob/v1.0.1/spec.md#legacy-docker-support-http-headers
func verifyContentDigest(resp *http.Response, expected digest.Digest) error {
digestStr := resp.Header.Get(headerdockerContentDigest)
digestStr := resp.Header.Get(headerDockerContentDigest)

if len(digestStr) == 0 {
return nil
Expand All @@ -1530,15 +1530,15 @@ func verifyContentDigest(resp *http.Response, expected digest.Digest) error {
return fmt.Errorf(
"%s %q: invalid response header: `%s: %s`",
resp.Request.Method, resp.Request.URL,
headerdockerContentDigest, digestStr,
headerDockerContentDigest, digestStr,
)
}

if contentDigest != expected {
return fmt.Errorf(
"%s %q: invalid response; digest mismatch in %s: received %q when expecting %q",
resp.Request.Method, resp.Request.URL,
headerdockerContentDigest, contentDigest,
headerDockerContentDigest, contentDigest,
expected,
)
}
Expand Down
6 changes: 3 additions & 3 deletions registry/remote/repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ func TestRepository_Mount(t *testing.T) {
t.Errorf("unexpected value for 'from' parameter; got %q want %q", got, want)
}
gotMount++
w.Header().Set(headerdockerContentDigest, blobDesc.Digest.String())
w.Header().Set(headerDockerContentDigest, blobDesc.Digest.String())
w.WriteHeader(201)
return
default:
Expand Down Expand Up @@ -3101,7 +3101,7 @@ func Test_generateBlobDescriptorWithVariousDockerContentDigestHeaders(t *testing
resp := http.Response{
Header: http.Header{
"Content-Type": []string{"application/vnd.docker.distribution.manifest.v2+json"},
headerdockerContentDigest: []string{dcdIOStruct.serverCalculatedDigest.String()},
headerDockerContentDigest: []string{dcdIOStruct.serverCalculatedDigest.String()},
},
}
if method == http.MethodGet {
Expand Down Expand Up @@ -5114,7 +5114,7 @@ func Test_ManifestStore_generateDescriptorWithVariousDockerContentDigestHeaders(
resp := http.Response{
Header: http.Header{
"Content-Type": []string{"application/vnd.docker.distribution.manifest.v2+json"},
headerdockerContentDigest: []string{dcdIOStruct.serverCalculatedDigest.String()},
headerDockerContentDigest: []string{dcdIOStruct.serverCalculatedDigest.String()},
},
}
if method == http.MethodGet {
Expand Down

0 comments on commit c83bd0d

Please sign in to comment.