From b73a6c19980a2bdbcfcbac8d8af957dd7be6c764 Mon Sep 17 00:00:00 2001 From: Stephen J Day Date: Mon, 1 Dec 2014 16:11:27 -0800 Subject: [PATCH] Use json.MashalIndent for raw manifest json This provides compatibility with what is in docker core, ensuring that image manifests generated here have the same formatting. We'll need to automate this some how. --- storage/manifest.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/storage/manifest.go b/storage/manifest.go index 895a112e..000bc617 100644 --- a/storage/manifest.go +++ b/storage/manifest.go @@ -6,6 +6,8 @@ import ( "fmt" "strings" + "github.com/Sirupsen/logrus" + "github.com/docker/libtrust" "github.com/docker/docker-registry/digest" @@ -78,7 +80,7 @@ type Manifest struct { // SignedManifest. This typically won't be used within the registry, except // for testing. func (m *Manifest) Sign(pk libtrust.PrivateKey) (*SignedManifest, error) { - p, err := json.Marshal(m) + p, err := json.MarshalIndent(m, "", " ") if err != nil { return nil, err } @@ -107,7 +109,7 @@ func (m *Manifest) Sign(pk libtrust.PrivateKey) (*SignedManifest, error) { // The public key of the first element in the chain must be the public key // corresponding with the sign key. func (m *Manifest) SignWithChain(key libtrust.PrivateKey, chain []*x509.Certificate) (*SignedManifest, error) { - p, err := json.Marshal(m) + p, err := json.MarshalIndent(m, "", " ") if err != nil { return nil, err } @@ -148,6 +150,7 @@ type SignedManifest struct { func (sm *SignedManifest) Verify() ([]libtrust.PublicKey, error) { js, err := libtrust.ParsePrettySignature(sm.Raw, "signatures") if err != nil { + logrus.WithField("err", err).Debugf("(*SignedManifest).Verify") return nil, err }