mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Revert #14884
This reverts commit 810d3b2642
.
Signed-off-by: Arnaud Porterie <arnaud.porterie@docker.com>
This commit is contained in:
parent
e26ee9a317
commit
4f3b0d0f4a
3 changed files with 11 additions and 40 deletions
|
@ -44,13 +44,12 @@ func (s *TagStore) NewPusher(endpoint registry.APIEndpoint, localRepo Repository
|
||||||
switch endpoint.Version {
|
switch endpoint.Version {
|
||||||
case registry.APIVersion2:
|
case registry.APIVersion2:
|
||||||
return &v2Pusher{
|
return &v2Pusher{
|
||||||
TagStore: s,
|
TagStore: s,
|
||||||
endpoint: endpoint,
|
endpoint: endpoint,
|
||||||
localRepo: localRepo,
|
localRepo: localRepo,
|
||||||
repoInfo: repoInfo,
|
repoInfo: repoInfo,
|
||||||
config: imagePushConfig,
|
config: imagePushConfig,
|
||||||
sf: sf,
|
sf: sf,
|
||||||
layersSeen: make(map[string]bool),
|
|
||||||
}, nil
|
}, nil
|
||||||
case registry.APIVersion1:
|
case registry.APIVersion1:
|
||||||
return &v1Pusher{
|
return &v1Pusher{
|
||||||
|
|
|
@ -27,11 +27,6 @@ type v2Pusher struct {
|
||||||
config *ImagePushConfig
|
config *ImagePushConfig
|
||||||
sf *streamformatter.StreamFormatter
|
sf *streamformatter.StreamFormatter
|
||||||
repo distribution.Repository
|
repo distribution.Repository
|
||||||
|
|
||||||
// layersSeen is the set of layers known to exist on the remote side.
|
|
||||||
// This avoids redundant queries when pushing multiple tags that
|
|
||||||
// involve the same layers.
|
|
||||||
layersSeen map[string]bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *v2Pusher) Push() (fallback bool, err error) {
|
func (p *v2Pusher) Push() (fallback bool, err error) {
|
||||||
|
@ -92,6 +87,8 @@ func (p *v2Pusher) pushV2Tag(tag string) error {
|
||||||
return fmt.Errorf("tag does not exist: %s", tag)
|
return fmt.Errorf("tag does not exist: %s", tag)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
layersSeen := make(map[string]bool)
|
||||||
|
|
||||||
layer, err := p.graph.Get(layerID)
|
layer, err := p.graph.Get(layerID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -120,7 +117,7 @@ func (p *v2Pusher) pushV2Tag(tag string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if p.layersSeen[layer.ID] {
|
if layersSeen[layer.ID] {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,7 +172,7 @@ func (p *v2Pusher) pushV2Tag(tag string) error {
|
||||||
m.FSLayers = append(m.FSLayers, manifest.FSLayer{BlobSum: dgst})
|
m.FSLayers = append(m.FSLayers, manifest.FSLayer{BlobSum: dgst})
|
||||||
m.History = append(m.History, manifest.History{V1Compatibility: string(jsonData)})
|
m.History = append(m.History, manifest.History{V1Compatibility: string(jsonData)})
|
||||||
|
|
||||||
p.layersSeen[layer.ID] = true
|
layersSeen[layer.ID] = true
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Infof("Signed manifest for %s:%s using daemon's key: %s", p.repo.Name(), tag, p.trustKey.KeyID())
|
logrus.Infof("Signed manifest for %s:%s using daemon's key: %s", p.repo.Name(), tag, p.trustKey.KeyID())
|
||||||
|
|
|
@ -60,32 +60,7 @@ func (s *DockerRegistrySuite) TestPushMultipleTags(c *check.C) {
|
||||||
|
|
||||||
dockerCmd(c, "tag", "busybox", repoTag2)
|
dockerCmd(c, "tag", "busybox", repoTag2)
|
||||||
|
|
||||||
out, _ := dockerCmd(c, "push", repoName)
|
dockerCmd(c, "push", repoName)
|
||||||
|
|
||||||
// There should be no duplicate hashes in the output
|
|
||||||
imageSuccessfullyPushed := ": Image successfully pushed"
|
|
||||||
imageAlreadyExists := ": Image already exists"
|
|
||||||
imagePushHashes := make(map[string]struct{})
|
|
||||||
outputLines := strings.Split(out, "\n")
|
|
||||||
for _, outputLine := range outputLines {
|
|
||||||
if strings.Contains(outputLine, imageSuccessfullyPushed) {
|
|
||||||
hash := strings.TrimSuffix(outputLine, imageSuccessfullyPushed)
|
|
||||||
if _, present := imagePushHashes[hash]; present {
|
|
||||||
c.Fatalf("Duplicate image push: %s", outputLine)
|
|
||||||
}
|
|
||||||
imagePushHashes[hash] = struct{}{}
|
|
||||||
} else if strings.Contains(outputLine, imageAlreadyExists) {
|
|
||||||
hash := strings.TrimSuffix(outputLine, imageAlreadyExists)
|
|
||||||
if _, present := imagePushHashes[hash]; present {
|
|
||||||
c.Fatalf("Duplicate image push: %s", outputLine)
|
|
||||||
}
|
|
||||||
imagePushHashes[hash] = struct{}{}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(imagePushHashes) == 0 {
|
|
||||||
c.Fatal(`Expected at least one line containing "Image successfully pushed"`)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *DockerRegistrySuite) TestPushInterrupt(c *check.C) {
|
func (s *DockerRegistrySuite) TestPushInterrupt(c *check.C) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue