Re-vendoring notary in order to deal with a canonical JSON serialization issue.

Signed-off-by: cyli <cyli@twistedmatrix.com>
This commit is contained in:
cyli 2016-01-08 16:44:10 -08:00
parent a082f80832
commit 5719b136de
7 changed files with 15 additions and 18 deletions

View file

@ -153,7 +153,7 @@ RUN set -x \
&& rm -rf "$GOPATH" && rm -rf "$GOPATH"
# Install notary server # Install notary server
ENV NOTARY_VERSION docker-v1.10-1 ENV NOTARY_VERSION docker-v1.10-2
RUN set -x \ RUN set -x \
&& export GOPATH="$(mktemp -d)" \ && export GOPATH="$(mktemp -d)" \
&& git clone https://github.com/docker/notary.git "$GOPATH/src/github.com/docker/notary" \ && git clone https://github.com/docker/notary.git "$GOPATH/src/github.com/docker/notary" \

View file

@ -47,7 +47,7 @@ clone git github.com/docker/distribution 568bf038af6d65b376165d02886b1c7fcaef1f6
clone git github.com/vbatts/tar-split v0.9.11 clone git github.com/vbatts/tar-split v0.9.11
# get desired notary commit, might also need to be updated in Dockerfile # get desired notary commit, might also need to be updated in Dockerfile
clone git github.com/docker/notary docker-v1.10-1 clone git github.com/docker/notary docker-v1.10-2
clone git google.golang.org/grpc 174192fc93efcb188fc8f46ca447f0da606b6885 https://github.com/grpc/grpc-go.git clone git google.golang.org/grpc 174192fc93efcb188fc8f46ca447f0da606b6885 https://github.com/grpc/grpc-go.git
clone git github.com/miekg/pkcs11 80f102b5cac759de406949c47f0928b99bd64cdf clone git github.com/miekg/pkcs11 80f102b5cac759de406949c47f0928b99bd64cdf

View file

@ -2,6 +2,7 @@ package client
import ( import (
"bytes" "bytes"
"encoding/json"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
@ -12,8 +13,6 @@ import (
"time" "time"
"github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
"github.com/jfrazelle/go/canonical/json"
"github.com/docker/notary/certs" "github.com/docker/notary/certs"
"github.com/docker/notary/client/changelist" "github.com/docker/notary/client/changelist"
"github.com/docker/notary/cryptoservice" "github.com/docker/notary/cryptoservice"
@ -324,7 +323,7 @@ func (r *NotaryRepository) AddDelegation(name string, threshold int,
logrus.Debugf(`Adding delegation "%s" with threshold %d, and %d keys\n`, logrus.Debugf(`Adding delegation "%s" with threshold %d, and %d keys\n`,
name, threshold, len(delegationKeys)) name, threshold, len(delegationKeys))
tdJSON, err := json.MarshalCanonical(&changelist.TufDelegation{ tdJSON, err := json.Marshal(&changelist.TufDelegation{
NewThreshold: threshold, NewThreshold: threshold,
AddKeys: data.KeyList(delegationKeys), AddKeys: data.KeyList(delegationKeys),
AddPaths: paths, AddPaths: paths,
@ -386,7 +385,7 @@ func (r *NotaryRepository) AddTarget(target *Target, roles ...string) error {
logrus.Debugf("Adding target \"%s\" with sha256 \"%x\" and size %d bytes.\n", target.Name, target.Hashes["sha256"], target.Length) logrus.Debugf("Adding target \"%s\" with sha256 \"%x\" and size %d bytes.\n", target.Name, target.Hashes["sha256"], target.Length)
meta := data.FileMeta{Length: target.Length, Hashes: target.Hashes} meta := data.FileMeta{Length: target.Length, Hashes: target.Hashes}
metaJSON, err := json.MarshalCanonical(meta) metaJSON, err := json.Marshal(meta)
if err != nil { if err != nil {
return err return err
} }
@ -690,7 +689,7 @@ func (r *NotaryRepository) saveMetadata(ignoreSnapshot bool) error {
if err != nil { if err != nil {
return err return err
} }
targetsJSON, err := json.MarshalCanonical(signedTargets) targetsJSON, err := json.Marshal(signedTargets)
if err != nil { if err != nil {
return err return err
} }
@ -838,7 +837,7 @@ func (r *NotaryRepository) rootFileKeyChange(role, action string, key data.Publi
RoleName: role, RoleName: role,
Keys: kl, Keys: kl,
} }
metaJSON, err := json.MarshalCanonical(meta) metaJSON, err := json.Marshal(meta)
if err != nil { if err != nil {
return err return err
} }

View file

@ -1,14 +1,13 @@
package client package client
import ( import (
"encoding/json"
"fmt" "fmt"
"net/http" "net/http"
"path" "path"
"time" "time"
"github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
"github.com/jfrazelle/go/canonical/json"
"github.com/docker/notary/client/changelist" "github.com/docker/notary/client/changelist"
tuf "github.com/docker/notary/tuf" tuf "github.com/docker/notary/tuf"
"github.com/docker/notary/tuf/data" "github.com/docker/notary/tuf/data"
@ -262,5 +261,5 @@ func serializeCanonicalRole(tufRepo *tuf.Repo, role string) (out []byte, err err
return return
} }
return json.MarshalCanonical(s) return json.Marshal(s)
} }

View file

@ -27,12 +27,12 @@ type Snapshot struct {
// and targets objects // and targets objects
func NewSnapshot(root *Signed, targets *Signed) (*SignedSnapshot, error) { func NewSnapshot(root *Signed, targets *Signed) (*SignedSnapshot, error) {
logrus.Debug("generating new snapshot...") logrus.Debug("generating new snapshot...")
targetsJSON, err := json.MarshalCanonical(targets) targetsJSON, err := json.Marshal(targets)
if err != nil { if err != nil {
logrus.Debug("Error Marshalling Targets") logrus.Debug("Error Marshalling Targets")
return nil, err return nil, err
} }
rootJSON, err := json.MarshalCanonical(root) rootJSON, err := json.Marshal(root)
if err != nil { if err != nil {
logrus.Debug("Error Marshalling Root") logrus.Debug("Error Marshalling Root")
return nil, err return nil, err

View file

@ -24,7 +24,7 @@ type Timestamp struct {
// NewTimestamp initializes a timestamp with an existing snapshot // NewTimestamp initializes a timestamp with an existing snapshot
func NewTimestamp(snapshot *Signed) (*SignedTimestamp, error) { func NewTimestamp(snapshot *Signed) (*SignedTimestamp, error) {
snapshotJSON, err := json.MarshalCanonical(snapshot) snapshotJSON, err := json.Marshal(snapshot)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View file

@ -5,14 +5,13 @@ import (
"bytes" "bytes"
"crypto/sha256" "crypto/sha256"
"encoding/hex" "encoding/hex"
"encoding/json"
"fmt" "fmt"
"path" "path"
"strings" "strings"
"time" "time"
"github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
"github.com/jfrazelle/go/canonical/json"
"github.com/docker/notary/tuf/data" "github.com/docker/notary/tuf/data"
"github.com/docker/notary/tuf/keys" "github.com/docker/notary/tuf/keys"
"github.com/docker/notary/tuf/signed" "github.com/docker/notary/tuf/signed"
@ -607,7 +606,7 @@ func (tr *Repo) RemoveTargets(role string, targets ...string) error {
// UpdateSnapshot updates the FileMeta for the given role based on the Signed object // UpdateSnapshot updates the FileMeta for the given role based on the Signed object
func (tr *Repo) UpdateSnapshot(role string, s *data.Signed) error { func (tr *Repo) UpdateSnapshot(role string, s *data.Signed) error {
jsonData, err := json.MarshalCanonical(s) jsonData, err := json.Marshal(s)
if err != nil { if err != nil {
return err return err
} }
@ -622,7 +621,7 @@ func (tr *Repo) UpdateSnapshot(role string, s *data.Signed) error {
// UpdateTimestamp updates the snapshot meta in the timestamp based on the Signed object // UpdateTimestamp updates the snapshot meta in the timestamp based on the Signed object
func (tr *Repo) UpdateTimestamp(s *data.Signed) error { func (tr *Repo) UpdateTimestamp(s *data.Signed) error {
jsonData, err := json.MarshalCanonical(s) jsonData, err := json.Marshal(s)
if err != nil { if err != nil {
return err return err
} }