Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cli/command/manifest/annotate.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"path/filepath"

"github.com/containerd/errdefs"
"github.com/docker/cli/cli"
"github.com/docker/cli/cli/command"
"github.com/docker/cli/cli/config"
Expand Down Expand Up @@ -97,7 +98,7 @@ func runManifestAnnotate(dockerCLI command.Cli, opts annotateOptions) error {
manifestStore := newManifestStore(dockerCLI)
imageManifest, err := manifestStore.Get(targetRef, imgRef)
switch {
case store.IsNotFound(err):
case errdefs.IsNotFound(err):
return fmt.Errorf("manifest for image %s does not exist in %s", opts.image, opts.target)
case err != nil:
return err
Expand Down
4 changes: 2 additions & 2 deletions cli/command/manifest/create_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"errors"
"fmt"

"github.com/containerd/errdefs"
"github.com/docker/cli/cli"
"github.com/docker/cli/cli/command"
"github.com/docker/cli/cli/manifest/store"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -45,7 +45,7 @@ func createManifestList(ctx context.Context, dockerCLI command.Cli, args []strin
manifestStore := newManifestStore(dockerCLI)
_, err = manifestStore.GetList(targetRef)
switch {
case store.IsNotFound(err):
case errdefs.IsNotFound(err):
// New manifest list
case err != nil:
return err
Expand Down
4 changes: 2 additions & 2 deletions cli/command/manifest/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package manifest
import (
"context"

"github.com/containerd/errdefs"
"github.com/distribution/reference"
"github.com/docker/cli/cli/command"
"github.com/docker/cli/cli/manifest/store"
"github.com/docker/cli/cli/manifest/types"
)

Expand Down Expand Up @@ -72,7 +72,7 @@ func normalizeReference(ref string) (reference.Named, error) {
func getManifest(ctx context.Context, dockerCLI command.Cli, listRef, namedRef reference.Named, insecure bool) (types.ImageManifest, error) {
data, err := newManifestStore(dockerCLI).Get(listRef, namedRef)
switch {
case store.IsNotFound(err):
case errdefs.IsNotFound(err):
return newRegistryClient(dockerCLI, insecure).GetManifest(ctx, namedRef)
case err != nil:
return types.ImageManifest{}, err
Expand Down
25 changes: 6 additions & 19 deletions cli/manifest/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"path/filepath"
"strings"

"github.com/containerd/errdefs"
"github.com/distribution/reference"
"github.com/docker/cli/cli/manifest/types"
"github.com/docker/distribution/manifest/manifestlist"
Expand Down Expand Up @@ -152,27 +153,13 @@ func makeFilesafeName(ref string) string {
return strings.ReplaceAll(fileName, "/", "_")
}

type notFoundError struct {
object string
func newNotFoundError(ref string) error {
return errdefs.ErrNotFound.WithMessage("No such manifest: " + ref)
}

func newNotFoundError(ref string) *notFoundError {
return &notFoundError{object: ref}
}

func (n *notFoundError) Error() string {
return "No such manifest: " + n.object
}

// NotFound interface
func (*notFoundError) NotFound() {}

// IsNotFound returns true if the error is a not found error
//
// Deprecated: use [errdefs.IsNotFound]. This function will be removed in the next release.
func IsNotFound(err error) bool {
_, ok := err.(notFound)
return ok
}

type notFound interface {
NotFound()
return errdefs.IsNotFound(err)
}
5 changes: 3 additions & 2 deletions cli/manifest/store/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"os"
"testing"

"github.com/containerd/errdefs"
"github.com/distribution/reference"
"github.com/docker/cli/cli/manifest/types"
"github.com/google/go-cmp/cmp"
Expand Down Expand Up @@ -86,7 +87,7 @@ func TestStoreSaveAndGet(t *testing.T) {
actual, err := store.Get(tc.listRef, tc.manifestRef)
if tc.expectedErr != "" {
assert.Error(t, err, tc.expectedErr)
assert.Check(t, IsNotFound(err))
assert.Check(t, errdefs.IsNotFound(err))
return
}
assert.NilError(t, err)
Expand Down Expand Up @@ -117,5 +118,5 @@ func TestStoreGetListDoesNotExist(t *testing.T) {
listRef := ref("list")
_, err := store.GetList(listRef)
assert.Error(t, err, "No such manifest: list")
assert.Check(t, IsNotFound(err))
assert.Check(t, errdefs.IsNotFound(err))
}
Loading