Skip to content

Commit 859c265

Browse files
committed
remotes/docker: Fix MountedFrom prefixed with target repository
`MountedFrom` was prefixed with the whole target repository instead of just the registry hostname. Also adjust the test cases to use the registry hostname. Signed-off-by: Paweł Gronowski <[email protected]>
1 parent e8770b1 commit 859c265

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

remotes/docker/pusher.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ func (p dockerPusher) push(ctx context.Context, desc ocispec.Descriptor, ref str
188188
resp.Body.Close()
189189
resp = nil
190190
case http.StatusCreated:
191-
mountedFrom = path.Join(p.refspec.Locator, fromRepo)
191+
mountedFrom = path.Join(p.refspec.Hostname(), fromRepo)
192192
}
193193
}
194194

remotes/docker/pusher_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,9 @@ func samplePusher(t *testing.T) (dockerPusher, *uploadableMockRegistry, StatusTr
163163
return dockerPusher{
164164
dockerBase: &dockerBase{
165165
refspec: reference.Spec{
166-
Locator: "sample",
166+
Locator: "example.com/samplerepository:latest",
167167
},
168-
repository: "sample",
168+
repository: "samplerepository",
169169
hosts: []RegistryHost{
170170
{
171171
Client: s.Client(),
@@ -176,7 +176,7 @@ func samplePusher(t *testing.T) (dockerPusher, *uploadableMockRegistry, StatusTr
176176
},
177177
},
178178
},
179-
object: "sample",
179+
object: "latest",
180180
tracker: tracker,
181181
}, reg, tracker, s.Close
182182
}
@@ -354,7 +354,7 @@ func Test_dockerPusher_push(t *testing.T) {
354354
ref: fmt.Sprintf("layer2-%s", layerContentDigest.String()),
355355
unavailableOnFail: false,
356356
annotations: map[string]string{
357-
distributionSourceLabelKey("sample"): "always-mount",
357+
distributionSourceLabelKey("example.com"): "always-mount",
358358
},
359359
},
360360
checkerFunc: func(writer *pushWriter) bool {
@@ -368,7 +368,7 @@ func Test_dockerPusher_push(t *testing.T) {
368368
},
369369
wantErr: fmt.Errorf("content %v on remote: %w", digest.FromBytes(layerContent), errdefs.ErrAlreadyExists),
370370
wantStatus: &PushStatus{
371-
MountedFrom: "sample/always-mount",
371+
MountedFrom: "example.com/always-mount",
372372
Exists: false,
373373
},
374374
},
@@ -383,7 +383,7 @@ func Test_dockerPusher_push(t *testing.T) {
383383
ref: fmt.Sprintf("layer3-%s", layerContentDigest.String()),
384384
unavailableOnFail: false,
385385
annotations: map[string]string{
386-
distributionSourceLabelKey("sample"): "never-mount",
386+
distributionSourceLabelKey("example.com"): "never-mount",
387387
},
388388
},
389389
checkerFunc: func(writer *pushWriter) bool {

0 commit comments

Comments
 (0)