Ensure the canonical manifest digest and length are sent to notification endpoints.

Signed-off-by: Richard Scothern <richard.scothern@gmail.com>
This commit is contained in:
Richard Scothern 2016-01-20 11:21:04 -08:00
parent 47a064d419
commit 4f822100f7
2 changed files with 11 additions and 12 deletions

View file

@ -103,10 +103,16 @@ func (b *bridge) createManifestEvent(action string, repo string, sm distribution
return nil, err return nil, err
} }
// Ensure we have the canonical manifest descriptor here
_, desc, err := distribution.UnmarshalManifest(mt, p)
if err != nil {
return nil, err
}
event.Target.MediaType = mt event.Target.MediaType = mt
event.Target.Length = int64(len(p)) event.Target.Length = desc.Size
event.Target.Size = int64(len(p)) event.Target.Size = desc.Size
event.Target.Digest = digest.FromBytes(p) event.Target.Digest = desc.Digest
event.Target.URL, err = b.ub.BuildManifestURL(repo, event.Target.Digest.String()) event.Target.URL, err = b.ub.BuildManifestURL(repo, event.Target.Digest.String())
if err != nil { if err != nil {

View file

@ -4,13 +4,10 @@ import (
"testing" "testing"
"github.com/docker/distribution/digest" "github.com/docker/distribution/digest"
"github.com/docker/libtrust"
"github.com/docker/distribution/manifest/schema1" "github.com/docker/distribution/manifest/schema1"
"github.com/docker/distribution/registry/api/v2" "github.com/docker/distribution/registry/api/v2"
"github.com/docker/distribution/uuid" "github.com/docker/distribution/uuid"
"github.com/docker/libtrust"
) )
var ( var (
@ -85,11 +82,7 @@ func createTestEnv(t *testing.T, fn testSinkFn) Listener {
t.Fatalf("error signing manifest: %v", err) t.Fatalf("error signing manifest: %v", err)
} }
_, payload, err = sm.Payload() payload = sm.Canonical
if err != nil {
t.Fatalf("error getting manifest payload: %v", err)
}
dgst = digest.FromBytes(payload) dgst = digest.FromBytes(payload)
return NewBridge(ub, source, actor, request, fn) return NewBridge(ub, source, actor, request, fn)