Fix registry stripping newlines from manifests

Content must be preserved exactly

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
This commit is contained in:
Derek McGowan 2018-09-05 13:40:42 -07:00
parent 9930542dc5
commit c88728f217
No known key found for this signature in database
GPG key ID: F58C5D0A4405ACDB
3 changed files with 9 additions and 12 deletions

View file

@ -2,7 +2,6 @@ package storage
import (
"context"
"encoding/json"
"fmt"
"github.com/docker/distribution"
@ -23,12 +22,12 @@ var _ ManifestHandler = &manifestListHandler{}
func (ms *manifestListHandler) Unmarshal(ctx context.Context, dgst digest.Digest, content []byte) (distribution.Manifest, error) {
dcontext.GetLogger(ms.ctx).Debug("(*manifestListHandler).Unmarshal")
var m manifestlist.DeserializedManifestList
if err := json.Unmarshal(content, &m); err != nil {
m := &manifestlist.DeserializedManifestList{}
if err := m.UnmarshalJSON(content); err != nil {
return nil, err
}
return &m, nil
return m, nil
}
func (ms *manifestListHandler) Put(ctx context.Context, manifestList distribution.Manifest, skipDependencyVerification bool) (digest.Digest, error) {

View file

@ -2,7 +2,6 @@ package storage
import (
"context"
"encoding/json"
"fmt"
"net/url"
@ -26,12 +25,12 @@ var _ ManifestHandler = &ocischemaManifestHandler{}
func (ms *ocischemaManifestHandler) Unmarshal(ctx context.Context, dgst digest.Digest, content []byte) (distribution.Manifest, error) {
dcontext.GetLogger(ms.ctx).Debug("(*ocischemaManifestHandler).Unmarshal")
var m ocischema.DeserializedManifest
if err := json.Unmarshal(content, &m); err != nil {
m := &ocischema.DeserializedManifest{}
if err := m.UnmarshalJSON(content); err != nil {
return nil, err
}
return &m, nil
return m, nil
}
func (ms *ocischemaManifestHandler) Put(ctx context.Context, manifest distribution.Manifest, skipDependencyVerification bool) (digest.Digest, error) {

View file

@ -2,7 +2,6 @@ package storage
import (
"context"
"encoding/json"
"errors"
"fmt"
"net/url"
@ -33,12 +32,12 @@ var _ ManifestHandler = &schema2ManifestHandler{}
func (ms *schema2ManifestHandler) Unmarshal(ctx context.Context, dgst digest.Digest, content []byte) (distribution.Manifest, error) {
dcontext.GetLogger(ms.ctx).Debug("(*schema2ManifestHandler).Unmarshal")
var m schema2.DeserializedManifest
if err := json.Unmarshal(content, &m); err != nil {
m := &schema2.DeserializedManifest{}
if err := m.UnmarshalJSON(content); err != nil {
return nil, err
}
return &m, nil
return m, nil
}
func (ms *schema2ManifestHandler) Put(ctx context.Context, manifest distribution.Manifest, skipDependencyVerification bool) (digest.Digest, error) {