Skip to content

Commit

Permalink
switch to github.com/distribution/reference module
Browse files Browse the repository at this point in the history
containerd 1.7.19 and up alias the reference/docker package to the new module,
and deprecate the package.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
  • Loading branch information
thaJeztah committed Jul 31, 2024
1 parent 1dedd40 commit a37c158
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 26 deletions.
8 changes: 4 additions & 4 deletions cmd/optimizer-nri-plugin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ import (
"time"

"github.com/containerd/log"
distribution "github.com/distribution/reference"
"github.com/pkg/errors"
"github.com/urfave/cli/v2"

"github.com/containerd/containerd/reference/docker"
"github.com/containerd/nri/pkg/api"
"github.com/containerd/nri/pkg/stub"
"github.com/containerd/nydus-snapshotter/pkg/errdefs"
Expand Down Expand Up @@ -201,12 +201,12 @@ func (p *plugin) StopContainer(_ context.Context, _ *api.PodSandbox, container *
}

func GetImageName(annotations map[string]string) (string, string, error) {
named, err := docker.ParseDockerRef(annotations[imageNameLabel])
named, err := distribution.ParseDockerRef(annotations[imageNameLabel])
if err != nil {
return "", "", err
}
nameTagged := named.(docker.NamedTagged)
repo := docker.Path(nameTagged)
nameTagged := named.(distribution.NamedTagged)
repo := distribution.Path(nameTagged)

dir := filepath.Dir(repo)
image := filepath.Base(repo)
Expand Down
2 changes: 1 addition & 1 deletion pkg/auth/image_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import (
"github.com/containerd/containerd/defaults"
"github.com/containerd/containerd/pkg/dialer"
"github.com/containerd/containerd/reference"
distribution "github.com/containerd/containerd/reference/docker"
runtime_alpha "github.com/containerd/containerd/third_party/k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
"github.com/containerd/log"
"github.com/containerd/stargz-snapshotter/service/keychain/cri"
"github.com/containerd/stargz-snapshotter/service/keychain/crialpha"
"github.com/containerd/stargz-snapshotter/service/resolver"
distribution "github.com/distribution/reference"
"github.com/pkg/errors"
"google.golang.org/grpc"
"google.golang.org/grpc/backoff"
Expand Down
6 changes: 3 additions & 3 deletions pkg/auth/keychain.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (

"github.com/pkg/errors"

"github.com/containerd/containerd/reference/docker"
"github.com/containerd/nydus-snapshotter/pkg/label"
distribution "github.com/distribution/reference"
"github.com/google/go-containerregistry/pkg/authn"
)

Expand Down Expand Up @@ -106,12 +106,12 @@ func GetRegistryKeyChain(host, ref string, labels map[string]string) *PassKeyCha
}

func GetKeyChainByRef(ref string, labels map[string]string) (*PassKeyChain, error) {
named, err := docker.ParseDockerRef(ref)
named, err := distribution.ParseDockerRef(ref)
if err != nil {
return nil, errors.Wrapf(err, "parse ref %s", ref)
}

host := docker.Domain(named)
host := distribution.Domain(named)
keychain := GetRegistryKeyChain(host, ref, labels)

return keychain, nil
Expand Down
4 changes: 2 additions & 2 deletions pkg/remote/remotes/docker/fetcher_fuzz.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"net/http/httptest"
"net/url"

refDocker "github.com/containerd/containerd/reference/docker"
distribution "github.com/distribution/reference"
)

func FuzzFetcher(data []byte) int {
Expand Down Expand Up @@ -76,6 +76,6 @@ func FuzzFetcher(data []byte) int {
}

func FuzzParseDockerRef(data []byte) int {
_, _ = refDocker.ParseDockerRef(string(data))
_, _ = distribution.ParseDockerRef(string(data))
return 1
}
8 changes: 4 additions & 4 deletions pkg/resolve/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (
"io"
"net/http"

"github.com/containerd/containerd/reference/docker"
"github.com/containerd/nydus-snapshotter/pkg/auth"
"github.com/containerd/nydus-snapshotter/pkg/utils/transport"
distribution "github.com/distribution/reference"
"github.com/google/go-containerregistry/pkg/name"
retryablehttp "github.com/hashicorp/go-retryablehttp"
"github.com/pkg/errors"
Expand All @@ -32,12 +32,12 @@ func NewResolver() *Resolver {
}

func (r *Resolver) Resolve(ref, digest string, labels map[string]string) (io.ReadCloser, error) {
named, err := docker.ParseDockerRef(ref)
named, err := distribution.ParseDockerRef(ref)
if err != nil {
return nil, errors.Wrapf(err, "failed parse docker ref %s", ref)
}
host := docker.Domain(named)
sref := fmt.Sprintf("%s/%s", host, docker.Path(named))
host := distribution.Domain(named)
sref := fmt.Sprintf("%s/%s", host, distribution.Path(named))
nref, err := name.ParseReference(sref)
if err != nil {
return nil, errors.Wrapf(err, "failed to parse ref %q (%q)", sref, digest)
Expand Down
14 changes: 6 additions & 8 deletions pkg/stargz/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@ import (
"strings"
"time"

"github.com/pkg/errors"

"github.com/containerd/containerd/reference/docker"
"github.com/containerd/log"
"github.com/containerd/nydus-snapshotter/pkg/utils/transport"
"github.com/containerd/stargz-snapshotter/estargz"
distribution "github.com/distribution/reference"
"github.com/google/go-containerregistry/pkg/authn"
"github.com/google/go-containerregistry/pkg/name"

"github.com/containerd/stargz-snapshotter/estargz"
"github.com/pkg/errors"
)

const httpTimeout = 15 * time.Second
Expand Down Expand Up @@ -152,12 +150,12 @@ func parseFooter(p []byte) (tocOffset int64, ok bool) {
}

func (r *Resolver) resolve(ref, digest string, keychain authn.Keychain) (*io.SectionReader, error) {
named, err := docker.ParseDockerRef(ref)
named, err := distribution.ParseDockerRef(ref)
if err != nil {
return nil, err
}
host := docker.Domain(named)
sref := fmt.Sprintf("%s/%s", host, docker.Path(named))
host := distribution.Domain(named)
sref := fmt.Sprintf("%s/%s", host, distribution.Path(named))
nref, err := name.ParseReference(sref)
if err != nil {
return nil, errors.Wrapf(err, "failed to parse ref %q (%q)", sref, digest)
Expand Down
8 changes: 4 additions & 4 deletions pkg/utils/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"time"

snpkg "github.com/containerd/containerd/pkg/snapshotters"
"github.com/containerd/containerd/reference/docker"
distribution "github.com/distribution/reference"
"github.com/google/go-containerregistry/pkg/authn"
"github.com/google/go-containerregistry/pkg/name"
"github.com/google/go-containerregistry/pkg/v1/remote/transport"
Expand All @@ -37,12 +37,12 @@ func ConvertToVPCHost(registryHost string) string {
}

func ParseImage(imageID string) (Image, error) {
named, err := docker.ParseDockerRef(imageID)
named, err := distribution.ParseDockerRef(imageID)
if err != nil {
return Image{}, err
}
host := docker.Domain(named)
repo := docker.Path(named)
host := distribution.Domain(named)
repo := distribution.Path(named)
return Image{
Host: host,
Repo: repo,
Expand Down

0 comments on commit a37c158

Please sign in to comment.