@@ -3,9 +3,10 @@ package containerd
3
3
import (
4
4
"context"
5
5
"fmt"
6
- "github.com/sirupsen/logrus"
7
6
"strings"
8
7
8
+ "github.com/sirupsen/logrus"
9
+
9
10
"github.com/containerd/containerd/v2/client"
10
11
"github.com/containerd/containerd/v2/core/images"
11
12
"github.com/containerd/errdefs"
@@ -15,15 +16,18 @@ import (
15
16
16
17
// tagService implements distribution.TagService backed by the containerd image store.
17
18
type tagService struct {
18
- client * client.Client
19
- repo reference.Named
19
+ client * client.Client
20
+ canonicalRepo reference.Named
20
21
}
21
22
22
23
// Get retrieves an image descriptor by its tag from the containerd image store.
23
24
func (t * tagService ) Get (ctx context.Context , tag string ) (distribution.Descriptor , error ) {
24
- ref , err := reference .WithTag (t .repo , tag )
25
+ ref , err := reference .WithTag (t .canonicalRepo , tag )
25
26
if err != nil {
26
- return distribution.Descriptor {}, err
27
+ return distribution.Descriptor {}, distribution.ErrManifestUnknown {
28
+ Name : t .canonicalRepo .Name (),
29
+ Tag : tag ,
30
+ }
27
31
}
28
32
29
33
img , err := t .client .ImageService ().Get (ctx , ref .String ())
@@ -52,7 +56,7 @@ func (t *tagService) Get(ctx context.Context, tag string) (distribution.Descript
52
56
// It also sets garbage collection labels on the image content in the containerd content store to prevent it from being
53
57
// deleted by garbage collection.
54
58
func (t * tagService ) Tag (ctx context.Context , tag string , desc distribution.Descriptor ) error {
55
- ref , err := reference .WithTag (t .repo , tag )
59
+ ref , err := reference .WithTag (t .canonicalRepo , tag )
56
60
if err != nil {
57
61
return err
58
62
}
@@ -116,7 +120,7 @@ func (t *tagService) Tag(ctx context.Context, tag string, desc distribution.Desc
116
120
// TODO:
117
121
func (t * tagService ) Untag (ctx context.Context , tag string ) error {
118
122
// Construct the full reference
119
- ref := fmt .Sprintf ("%s:%s" , t .repo .String (), tag )
123
+ ref := fmt .Sprintf ("%s:%s" , t .canonicalRepo .String (), tag )
120
124
121
125
// Delete the image reference
122
126
err := t .client .ImageService ().Delete (ctx , ref )
@@ -138,7 +142,7 @@ func (t *tagService) All(ctx context.Context) ([]string, error) {
138
142
}
139
143
140
144
// Filter by repository name
141
- repoName := t .repo .String ()
145
+ repoName := t .canonicalRepo .String ()
142
146
var tags []string
143
147
144
148
for _ , img := range images {
@@ -162,7 +166,7 @@ func (t *tagService) Lookup(ctx context.Context, desc distribution.Descriptor) (
162
166
}
163
167
164
168
// Find tags that point to this descriptor
165
- repoName := t .repo .String ()
169
+ repoName := t .canonicalRepo .String ()
166
170
var tags []string
167
171
168
172
for _ , img := range images {
0 commit comments