Skip to content

Commit

Permalink
fix: image ref parsing for docker.io registry
Browse files Browse the repository at this point in the history
  • Loading branch information
lucas-jacques committed Dec 3, 2024
1 parent e972cff commit b0e39c0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
6 changes: 3 additions & 3 deletions core/registry/ref.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ func (r *Reference) String() string {
return fmt.Sprintf("%s/%s:%s", r.Domain, r.Repository, tag)
}

func Parse(ref string, options ...name.Option) (Reference, error) {
if t, err := name.NewTag(ref, options...); err == nil {
func Parse(ref string) (Reference, error) {
if t, err := name.NewTag(ref); err == nil {
return Reference{
Domain: t.RegistryStr(),
Repository: t.RepositoryStr(),
Tag: t.TagStr(),
}, nil
}
if d, err := name.NewDigest(ref, options...); err == nil {
if d, err := name.NewDigest(ref); err == nil {
return Reference{
Domain: d.RegistryStr(),
Repository: d.RepositoryStr(),
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ require (
github.com/containerd/errdefs v0.1.0
github.com/coreos/go-iptables v0.7.0
github.com/danielgtaylor/huma/v2 v2.26.0
github.com/distribution/reference v0.5.0
github.com/gammazero/deque v0.2.1
github.com/google/go-containerregistry v0.20.2
github.com/jackc/pgx/v5 v5.6.0
Expand Down Expand Up @@ -49,6 +48,7 @@ require (
github.com/containerd/ttrpc v1.2.3 // indirect
github.com/containerd/typeurl/v2 v2.1.1 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/distribution/reference v0.5.0 // indirect
github.com/docker/cli v27.1.1+incompatible // indirect
github.com/docker/distribution v2.8.2+incompatible // indirect
github.com/docker/docker-credential-helpers v0.7.0 // indirect
Expand Down
9 changes: 1 addition & 8 deletions runtime/images/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (

containerdimages "github.com/containerd/containerd/v2/core/images"
"github.com/containerd/containerd/v2/core/remotes/docker"
distribution "github.com/distribution/reference"
)

type Service struct {
Expand All @@ -30,13 +29,7 @@ func NewService(ctrd *client.Client, snapshotter string) *Service {
}
}

func (s *Service) Pull(ctx context.Context, name string, auth registry.RegistriesConfig) (client.Image, error) {
namedRef, err := distribution.ParseDockerRef(name)
if err != nil {
return nil, fmt.Errorf("failed to parse image reference %q: %w", name, err)
}
ref := namedRef.String()

func (s *Service) Pull(ctx context.Context, ref string, auth registry.RegistriesConfig) (client.Image, error) {
authorizer := docker.NewDockerAuthorizer(
docker.WithAuthCreds(func(host string) (string, string, error) {
return auth.Get(host)
Expand Down

0 comments on commit b0e39c0

Please sign in to comment.