mirror of
https://github.com/containerd/containerd.git
synced 2026-08-12 12:14:44 +00:00
Check expected digest when committing as a sanity check
This commit also adds an info-level log message for the case where the registry doesn't send a digest header since the computed digest is a valuable part of our content Commit interface. Signed-off-by: Max Jonas Werner <max@coppersoft.com>
This commit is contained in:
@@ -526,6 +526,8 @@ func (pw *pushWriter) Commit(ctx context.Context, size int64, expected digest.Di
|
||||
|
||||
if expected == "" {
|
||||
expected = status.Expected
|
||||
} else if expected != status.Expected {
|
||||
return fmt.Errorf("unexpected digest received: got %q, expected %q", status.Expected, expected)
|
||||
}
|
||||
|
||||
if dgstHdr := resp.Header.Get("Docker-Content-Digest"); dgstHdr != "" {
|
||||
@@ -537,6 +539,8 @@ func (pw *pushWriter) Commit(ctx context.Context, size int64, expected digest.Di
|
||||
if actual != expected {
|
||||
return fmt.Errorf("got digest %s, expected %s", actual, expected)
|
||||
}
|
||||
} else {
|
||||
log.G(ctx).Info("registry did not send a Docker-Content-Digest header")
|
||||
}
|
||||
|
||||
status.Committed = true
|
||||
|
||||
Reference in New Issue
Block a user