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.
master
Stephen J Day 2014-12-01 16:11:27 -08:00
parent 98f5f30e75
commit b73a6c1998
1 changed files with 5 additions and 2 deletions

View File

@ -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
}