forked from TrueCloudLab/distribution
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.
This commit is contained in:
parent
98f5f30e75
commit
b73a6c1998
1 changed files with 5 additions and 2 deletions
|
@ -6,6 +6,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/Sirupsen/logrus"
|
||||||
|
|
||||||
"github.com/docker/libtrust"
|
"github.com/docker/libtrust"
|
||||||
|
|
||||||
"github.com/docker/docker-registry/digest"
|
"github.com/docker/docker-registry/digest"
|
||||||
|
@ -78,7 +80,7 @@ type Manifest struct {
|
||||||
// SignedManifest. This typically won't be used within the registry, except
|
// SignedManifest. This typically won't be used within the registry, except
|
||||||
// for testing.
|
// for testing.
|
||||||
func (m *Manifest) Sign(pk libtrust.PrivateKey) (*SignedManifest, error) {
|
func (m *Manifest) Sign(pk libtrust.PrivateKey) (*SignedManifest, error) {
|
||||||
p, err := json.Marshal(m)
|
p, err := json.MarshalIndent(m, "", " ")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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
|
// The public key of the first element in the chain must be the public key
|
||||||
// corresponding with the sign key.
|
// corresponding with the sign key.
|
||||||
func (m *Manifest) SignWithChain(key libtrust.PrivateKey, chain []*x509.Certificate) (*SignedManifest, error) {
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -148,6 +150,7 @@ type SignedManifest struct {
|
||||||
func (sm *SignedManifest) Verify() ([]libtrust.PublicKey, error) {
|
func (sm *SignedManifest) Verify() ([]libtrust.PublicKey, error) {
|
||||||
js, err := libtrust.ParsePrettySignature(sm.Raw, "signatures")
|
js, err := libtrust.ParsePrettySignature(sm.Raw, "signatures")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
logrus.WithField("err", err).Debugf("(*SignedManifest).Verify")
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue