Browse code

Fixes layer MediaTypes in manifests created from a cross-repository push

Signed-off-by: Brian Bland <brian.bland@docker.com>

Brian Bland authored on 2016/01/21 04:39:32
Showing 2 changed files
... ...
@@ -311,6 +311,8 @@ func (pd *v2PushDescriptor) Upload(ctx context.Context, progressOutput progress.
311 311
 	case distribution.ErrBlobMounted:
312 312
 		progress.Updatef(progressOutput, pd.ID(), "Mounted from %s", err.From.Name())
313 313
 
314
+		err.Descriptor.MediaType = schema2.MediaTypeLayer
315
+
314 316
 		pd.pushState.Lock()
315 317
 		pd.pushState.confirmedV2 = true
316 318
 		pd.pushState.remoteLayers[diffID] = err.Descriptor
... ...
@@ -10,6 +10,7 @@ import (
10 10
 	"strings"
11 11
 	"time"
12 12
 
13
+	"github.com/docker/distribution/digest"
13 14
 	"github.com/docker/docker/cliconfig"
14 15
 	"github.com/docker/docker/pkg/integration/checker"
15 16
 	"github.com/go-check/check"
... ...
@@ -158,6 +159,9 @@ func (s *DockerRegistrySuite) TestCrossRepositoryLayerPush(c *check.C) {
158 158
 	// ensure that none of the layers were mounted from another repository during push
159 159
 	c.Assert(strings.Contains(out1, "Mounted from"), check.Equals, false)
160 160
 
161
+	digest1 := digest.DigestRegexp.FindString(out1)
162
+	c.Assert(len(digest1), checker.GreaterThan, 0, check.Commentf("no digest found for pushed manifest"))
163
+
161 164
 	destRepoName := fmt.Sprintf("%v/dockercli/crossrepopush", privateRegistryURL)
162 165
 	// retag the image to upload the same layers to another repo in the same registry
163 166
 	dockerCmd(c, "tag", "busybox", destRepoName)
... ...
@@ -167,6 +171,10 @@ func (s *DockerRegistrySuite) TestCrossRepositoryLayerPush(c *check.C) {
167 167
 	// ensure that layers were mounted from the first repo during push
168 168
 	c.Assert(strings.Contains(out2, "Mounted from dockercli/busybox"), check.Equals, true)
169 169
 
170
+	digest2 := digest.DigestRegexp.FindString(out2)
171
+	c.Assert(len(digest2), checker.GreaterThan, 0, check.Commentf("no digest found for pushed manifest"))
172
+	c.Assert(digest1, check.Equals, digest2)
173
+
170 174
 	// ensure that we can pull and run the cross-repo-pushed repository
171 175
 	dockerCmd(c, "rmi", destRepoName)
172 176
 	dockerCmd(c, "pull", destRepoName)
... ...
@@ -184,6 +192,9 @@ func (s *DockerSchema1RegistrySuite) TestCrossRepositoryLayerPushNotSupported(c
184 184
 	// ensure that none of the layers were mounted from another repository during push
185 185
 	c.Assert(strings.Contains(out1, "Mounted from"), check.Equals, false)
186 186
 
187
+	digest1 := digest.DigestRegexp.FindString(out1)
188
+	c.Assert(len(digest1), checker.GreaterThan, 0, check.Commentf("no digest found for pushed manifest"))
189
+
187 190
 	destRepoName := fmt.Sprintf("%v/dockercli/crossrepopush", privateRegistryURL)
188 191
 	// retag the image to upload the same layers to another repo in the same registry
189 192
 	dockerCmd(c, "tag", "busybox", destRepoName)
... ...
@@ -193,6 +204,10 @@ func (s *DockerSchema1RegistrySuite) TestCrossRepositoryLayerPushNotSupported(c
193 193
 	// schema1 registry should not support cross-repo layer mounts, so ensure that this does not happen
194 194
 	c.Assert(strings.Contains(out2, "Mounted from dockercli/busybox"), check.Equals, false)
195 195
 
196
+	digest2 := digest.DigestRegexp.FindString(out2)
197
+	c.Assert(len(digest2), checker.GreaterThan, 0, check.Commentf("no digest found for pushed manifest"))
198
+	c.Assert(digest1, check.Equals, digest2)
199
+
196 200
 	// ensure that we can pull and run the second pushed repository
197 201
 	dockerCmd(c, "rmi", destRepoName)
198 202
 	dockerCmd(c, "pull", destRepoName)