Skip to content

Commit 1c9cf95

Browse files
committed
chore: fix tags after errors deletionm
1 parent 0a693db commit 1c9cf95

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

internal/storage/containerd/tags.go

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ package containerd
33
import (
44
"context"
55
"fmt"
6+
"github.com/sirupsen/logrus"
67
"strings"
78

9+
"github.com/containerd/containerd/v2/client"
810
"github.com/containerd/containerd/v2/core/images"
911
"github.com/containerd/errdefs"
1012
"github.com/distribution/distribution/v3"
@@ -14,20 +16,21 @@ import (
1416

1517
// tagService implements distribution.TagService backed by containerd image store.
1618
type tagService struct {
17-
client *Client
19+
client *client.Client
1820
repo reference.Named
1921
}
2022

2123
// Get retrieves an image descriptor by its tag from the containerd image store.
24+
// TODO:
2225
func (t *tagService) Get(ctx context.Context, tag string) (distribution.Descriptor, error) {
23-
// Construct the full reference
24-
ref := fmt.Sprintf("%s:%s", t.repo.String(), tag)
26+
ref, err := reference.WithTag(t.repo, tag)
27+
if err != nil {
28+
return distribution.Descriptor{}, err
29+
}
2530

26-
// Get the image from containerd
27-
img, err := t.client.ImageStore().Get(ctx, ref)
31+
img, err := t.client.ImageService().Get(ctx, ref.String())
2832
if err != nil {
29-
// Log for debugging
30-
fmt.Printf("DEBUG: tagService.Get failed for ref %s: %v\n", ref, err)
33+
logrus.WithField("image", ref.String()).WithError(err).Debug("Failed to get image from containerd image store.")
3134
if errdefs.IsNotFound(err) {
3235
return distribution.Descriptor{}, distribution.ErrTagUnknown{Tag: tag}
3336

@@ -43,9 +46,8 @@ func (t *tagService) Get(ctx context.Context, tag string) (distribution.Descript
4346
}
4447

4548
// Tag associates a tag with a descriptor.
49+
// TODO:
4650
func (t *tagService) Tag(ctx context.Context, tag string, desc distribution.Descriptor) error {
47-
ctx = t.client.Context(ctx)
48-
4951
// Construct the full reference
5052
ref := fmt.Sprintf("%s:%s", t.repo.String(), tag)
5153

@@ -60,10 +62,10 @@ func (t *tagService) Tag(ctx context.Context, tag string, desc distribution.Desc
6062
}
6163

6264
// Try to update first
63-
_, err := t.client.ImageStore().Update(ctx, img)
65+
_, err := t.client.ImageService().Update(ctx, img)
6466
if err != nil {
6567
// If update fails, try to create
66-
_, err = t.client.ImageStore().Create(ctx, img)
68+
_, err = t.client.ImageService().Create(ctx, img)
6769
if err != nil {
6870
return err
6971
}
@@ -73,27 +75,26 @@ func (t *tagService) Tag(ctx context.Context, tag string, desc distribution.Desc
7375
}
7476

7577
// Untag removes a tag.
78+
// TODO:
7679
func (t *tagService) Untag(ctx context.Context, tag string) error {
77-
ctx = t.client.Context(ctx)
78-
7980
// Construct the full reference
8081
ref := fmt.Sprintf("%s:%s", t.repo.String(), tag)
8182

8283
// Delete the image reference
83-
err := t.client.ImageStore().Delete(ctx, ref)
84+
err := t.client.ImageService().Delete(ctx, ref)
8485
if err != nil {
85-
return convertError(err)
86+
// TODO: convert error if possible
87+
return err
8688
}
8789

8890
return nil
8991
}
9092

9193
// All returns all tags for the repository.
94+
// TODO:
9295
func (t *tagService) All(ctx context.Context) ([]string, error) {
93-
ctx = t.client.Context(ctx)
94-
9596
// List all images
96-
images, err := t.client.ImageStore().List(ctx)
97+
images, err := t.client.ImageService().List(ctx)
9798
if err != nil {
9899
return nil, err
99100
}
@@ -114,11 +115,10 @@ func (t *tagService) All(ctx context.Context) ([]string, error) {
114115
}
115116

116117
// Lookup finds tags associated with a descriptor.
118+
// TODO
117119
func (t *tagService) Lookup(ctx context.Context, desc distribution.Descriptor) ([]string, error) {
118-
ctx = t.client.Context(ctx)
119-
120120
// List all images
121-
images, err := t.client.ImageStore().List(ctx)
121+
images, err := t.client.ImageService().List(ctx)
122122
if err != nil {
123123
return nil, err
124124
}

0 commit comments

Comments
 (0)