feat: replace github.com/pkg/errors to errors
Signed-off-by: haoyun <yun.hao@daocloud.io> Co-authored-by: zounengren <zouyee1989@gmail.com>
This commit is contained in:
@@ -45,7 +45,6 @@ import (
|
||||
"github.com/containerd/ttrpc"
|
||||
"github.com/containerd/typeurl"
|
||||
ptypes "github.com/gogo/protobuf/types"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
exec "golang.org/x/sys/execabs"
|
||||
"golang.org/x/sys/unix"
|
||||
@@ -154,7 +153,7 @@ func executeShim() error {
|
||||
}
|
||||
server, err := newServer()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed creating server")
|
||||
return fmt.Errorf("failed creating server: %w", err)
|
||||
}
|
||||
sv, err := shim.NewService(
|
||||
shim.Config{
|
||||
@@ -212,7 +211,7 @@ func serve(ctx context.Context, server *ttrpc.Server, path string) error {
|
||||
p = abstractSocketPrefix + p
|
||||
}
|
||||
if len(p) > socketPathLimit {
|
||||
return errors.Errorf("%q: unix socket path too long (> %d)", p, socketPathLimit)
|
||||
return fmt.Errorf("%q: unix socket path too long (> %d)", p, socketPathLimit)
|
||||
}
|
||||
l, err = net.Listen("unix", p)
|
||||
}
|
||||
@@ -310,10 +309,10 @@ func (l *remoteEventsPublisher) Publish(ctx context.Context, topic string, event
|
||||
}
|
||||
status, err := reaper.Default.WaitTimeout(cmd, c, 30*time.Second)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to publish event: %s", b.String())
|
||||
return fmt.Errorf("failed to publish event: %s: %w", b.String(), err)
|
||||
}
|
||||
if status != 0 {
|
||||
return errors.Errorf("failed to publish event: %s", b.String())
|
||||
return fmt.Errorf("failed to publish event: %s", b.String())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -37,7 +37,6 @@ import (
|
||||
"github.com/containerd/containerd/sys"
|
||||
"github.com/containerd/containerd/tracing"
|
||||
"github.com/containerd/containerd/version"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli"
|
||||
"google.golang.org/grpc/grpclog"
|
||||
@@ -155,7 +154,7 @@ can be used and modified as necessary as a custom configuration.`
|
||||
|
||||
// cleanup temp mounts
|
||||
if err := mount.SetTempMountLocation(filepath.Join(config.Root, "tmpmounts")); err != nil {
|
||||
return errors.Wrap(err, "creating temp mount location")
|
||||
return fmt.Errorf("creating temp mount location: %w", err)
|
||||
}
|
||||
// unmount all temp mounts on boot for the server
|
||||
warnings, err := mount.CleanupTempMounts(0)
|
||||
@@ -167,7 +166,7 @@ can be used and modified as necessary as a custom configuration.`
|
||||
}
|
||||
|
||||
if config.GRPC.Address == "" {
|
||||
return errors.Wrap(errdefs.ErrInvalidArgument, "grpc address cannot be empty")
|
||||
return fmt.Errorf("grpc address cannot be empty: %w", errdefs.ErrInvalidArgument)
|
||||
}
|
||||
if config.TTRPC.Address == "" {
|
||||
// If TTRPC was not explicitly configured, use defaults based on GRPC.
|
||||
@@ -235,11 +234,11 @@ can be used and modified as necessary as a custom configuration.`
|
||||
var l net.Listener
|
||||
if isLocalAddress(config.Debug.Address) {
|
||||
if l, err = sys.GetLocalListener(config.Debug.Address, config.Debug.UID, config.Debug.GID); err != nil {
|
||||
return errors.Wrapf(err, "failed to get listener for debug endpoint")
|
||||
return fmt.Errorf("failed to get listener for debug endpoint: %w", err)
|
||||
}
|
||||
} else {
|
||||
if l, err = net.Listen("tcp", config.Debug.Address); err != nil {
|
||||
return errors.Wrapf(err, "failed to get listener for debug endpoint")
|
||||
return fmt.Errorf("failed to get listener for debug endpoint: %w", err)
|
||||
}
|
||||
}
|
||||
serve(ctx, l, server.ServeDebug)
|
||||
@@ -247,28 +246,28 @@ can be used and modified as necessary as a custom configuration.`
|
||||
if config.Metrics.Address != "" {
|
||||
l, err := net.Listen("tcp", config.Metrics.Address)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to get listener for metrics endpoint")
|
||||
return fmt.Errorf("failed to get listener for metrics endpoint: %w", err)
|
||||
}
|
||||
serve(ctx, l, server.ServeMetrics)
|
||||
}
|
||||
// setup the ttrpc endpoint
|
||||
tl, err := sys.GetLocalListener(config.TTRPC.Address, config.TTRPC.UID, config.TTRPC.GID)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to get listener for main ttrpc endpoint")
|
||||
return fmt.Errorf("failed to get listener for main ttrpc endpoint: %w", err)
|
||||
}
|
||||
serve(ctx, tl, server.ServeTTRPC)
|
||||
|
||||
if config.GRPC.TCPAddress != "" {
|
||||
l, err := net.Listen("tcp", config.GRPC.TCPAddress)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to get listener for TCP grpc endpoint")
|
||||
return fmt.Errorf("failed to get listener for TCP grpc endpoint: %w", err)
|
||||
}
|
||||
serve(ctx, l, server.ServeTCP)
|
||||
}
|
||||
// setup the main grpc endpoint
|
||||
l, err := sys.GetLocalListener(config.GRPC.Address, config.GRPC.UID, config.GRPC.GID)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to get listener for main endpoint")
|
||||
return fmt.Errorf("failed to get listener for main endpoint: %w", err)
|
||||
}
|
||||
serve(ctx, l, server.ServeGRPC)
|
||||
|
||||
@@ -364,7 +363,7 @@ func setLogFormat(config *srvconfig.Config) error {
|
||||
TimestampFormat: log.RFC3339NanoFixed,
|
||||
})
|
||||
default:
|
||||
return errors.Errorf("unknown log format: %s", f)
|
||||
return fmt.Errorf("unknown log format: %s", f)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -18,6 +18,7 @@ package command
|
||||
|
||||
import (
|
||||
gocontext "context"
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
"os"
|
||||
@@ -28,7 +29,6 @@ import (
|
||||
"github.com/containerd/containerd/namespaces"
|
||||
"github.com/containerd/containerd/pkg/dialer"
|
||||
"github.com/gogo/protobuf/types"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/urfave/cli"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/backoff"
|
||||
@@ -52,7 +52,7 @@ var publishCommand = cli.Command{
|
||||
ctx := namespaces.WithNamespace(gocontext.Background(), context.String("namespace"))
|
||||
topic := context.String("topic")
|
||||
if topic == "" {
|
||||
return errors.Wrap(errdefs.ErrInvalidArgument, "topic required to publish event")
|
||||
return fmt.Errorf("topic required to publish event: %w", errdefs.ErrInvalidArgument)
|
||||
}
|
||||
payload, err := getEventPayload(os.Stdin)
|
||||
if err != nil {
|
||||
@@ -87,7 +87,7 @@ func getEventPayload(r io.Reader) (*types.Any, error) {
|
||||
func connectEvents(address string) (eventsapi.EventsClient, error) {
|
||||
conn, err := connect(address, dialer.ContextDialer)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to dial %q", address)
|
||||
return nil, fmt.Errorf("failed to dial %q: %w", address, err)
|
||||
}
|
||||
return eventsapi.NewEventsClient(conn), nil
|
||||
}
|
||||
@@ -109,7 +109,7 @@ func connect(address string, d func(gocontext.Context, string) (net.Conn, error)
|
||||
defer cancel()
|
||||
conn, err := grpc.DialContext(ctx, dialer.DialAddress(address), gopts...)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to dial %q", address)
|
||||
return nil, fmt.Errorf("failed to dial %q: %w", address, err)
|
||||
}
|
||||
return conn, nil
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ import (
|
||||
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/containerd/containerd/services/server"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli"
|
||||
exec "golang.org/x/sys/execabs"
|
||||
@@ -218,7 +217,7 @@ func registerUnregisterService(root string) (bool, error) {
|
||||
|
||||
if unregisterServiceFlag {
|
||||
if registerServiceFlag {
|
||||
return true, errors.Wrap(errdefs.ErrInvalidArgument, "--register-service and --unregister-service cannot be used together")
|
||||
return true, fmt.Errorf("--register-service and --unregister-service cannot be used together: %w", errdefs.ErrInvalidArgument)
|
||||
}
|
||||
return true, unregisterService()
|
||||
}
|
||||
@@ -242,7 +241,7 @@ func registerUnregisterService(root string) (bool, error) {
|
||||
// and we want to make sure stderr goes to the panic file.
|
||||
r, _, err := allocConsole.Call()
|
||||
if r == 0 && err != nil {
|
||||
return true, fmt.Errorf("error allocating conhost: %s", err)
|
||||
return true, fmt.Errorf("error allocating conhost: %w", err)
|
||||
}
|
||||
|
||||
if err := initPanicFile(filepath.Join(root, "panic.log")); err != nil {
|
||||
@@ -253,7 +252,7 @@ func registerUnregisterService(root string) (bool, error) {
|
||||
if logFileFlag != "" {
|
||||
f, err := os.OpenFile(logFileFlag, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
|
||||
if err != nil {
|
||||
return true, errors.Wrapf(err, "open log file %q", logFileFlag)
|
||||
return true, fmt.Errorf("open log file %q: %w", logFileFlag, err)
|
||||
}
|
||||
logOutput = f
|
||||
}
|
||||
|
||||
@@ -17,12 +17,12 @@
|
||||
package containers
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/containerd/containerd"
|
||||
"github.com/containerd/containerd/cmd/ctr/commands"
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
@@ -88,7 +88,7 @@ var checkpointCommand = cli.Command{
|
||||
}
|
||||
defer func() {
|
||||
if err := task.Resume(ctx); err != nil {
|
||||
fmt.Println(errors.Wrap(err, "error resuming task"))
|
||||
fmt.Println(fmt.Errorf("error resuming task: %w", err))
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@ import (
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/containerd/typeurl"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
@@ -66,17 +65,17 @@ var createCommand = cli.Command{
|
||||
if config {
|
||||
id = context.Args().First()
|
||||
if context.NArg() > 1 {
|
||||
return errors.Wrap(errdefs.ErrInvalidArgument, "with spec config file, only container id should be provided")
|
||||
return fmt.Errorf("with spec config file, only container id should be provided: %w", errdefs.ErrInvalidArgument)
|
||||
}
|
||||
} else {
|
||||
id = context.Args().Get(1)
|
||||
ref = context.Args().First()
|
||||
if ref == "" {
|
||||
return errors.Wrap(errdefs.ErrInvalidArgument, "image ref must be provided")
|
||||
return fmt.Errorf("image ref must be provided: %w", errdefs.ErrInvalidArgument)
|
||||
}
|
||||
}
|
||||
if id == "" {
|
||||
return errors.Wrap(errdefs.ErrInvalidArgument, "container id must be provided")
|
||||
return fmt.Errorf("container id must be provided: %w", errdefs.ErrInvalidArgument)
|
||||
}
|
||||
client, ctx, cancel, err := commands.NewClient(context)
|
||||
if err != nil {
|
||||
@@ -169,7 +168,7 @@ var deleteCommand = cli.Command{
|
||||
}
|
||||
|
||||
if context.NArg() == 0 {
|
||||
return errors.Wrap(errdefs.ErrInvalidArgument, "must specify at least one container to delete")
|
||||
return fmt.Errorf("must specify at least one container to delete: %w", errdefs.ErrInvalidArgument)
|
||||
}
|
||||
for _, arg := range context.Args() {
|
||||
if err := deleteContainer(ctx, client, arg, deleteOpts...); err != nil {
|
||||
@@ -215,7 +214,7 @@ var setLabelsCommand = cli.Command{
|
||||
Action: func(context *cli.Context) error {
|
||||
containerID, labels := commands.ObjectWithLabelArgs(context)
|
||||
if containerID == "" {
|
||||
return errors.Wrap(errdefs.ErrInvalidArgument, "container id must be provided")
|
||||
return fmt.Errorf("container id must be provided: %w", errdefs.ErrInvalidArgument)
|
||||
}
|
||||
client, ctx, cancel, err := commands.NewClient(context)
|
||||
if err != nil {
|
||||
@@ -257,7 +256,7 @@ var infoCommand = cli.Command{
|
||||
Action: func(context *cli.Context) error {
|
||||
id := context.Args().First()
|
||||
if id == "" {
|
||||
return errors.Wrap(errdefs.ErrInvalidArgument, "container id must be provided")
|
||||
return fmt.Errorf("container id must be provided: %w", errdefs.ErrInvalidArgument)
|
||||
}
|
||||
client, ctx, cancel, err := commands.NewClient(context)
|
||||
if err != nil {
|
||||
|
||||
@@ -17,11 +17,12 @@
|
||||
package containers
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/containerd/containerd"
|
||||
"github.com/containerd/containerd/cio"
|
||||
"github.com/containerd/containerd/cmd/ctr/commands"
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package content
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
@@ -31,7 +32,6 @@ import (
|
||||
units "github.com/docker/go-units"
|
||||
digest "github.com/opencontainers/go-digest"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/urfave/cli"
|
||||
exec "golang.org/x/sys/execabs"
|
||||
)
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package images
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/containerd/containerd/cmd/ctr/commands"
|
||||
@@ -24,7 +25,6 @@ import (
|
||||
"github.com/containerd/containerd/images/converter/uncompress"
|
||||
"github.com/containerd/containerd/platforms"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
@@ -74,7 +74,7 @@ When '--all-platforms' is given all images in a manifest list must be available.
|
||||
for _, ps := range pss {
|
||||
p, err := platforms.Parse(ps)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "invalid platform %q", ps)
|
||||
return fmt.Errorf("invalid platform %q: %w", ps, err)
|
||||
}
|
||||
all = append(all, p)
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
package images
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
|
||||
@@ -24,7 +26,6 @@ import (
|
||||
"github.com/containerd/containerd/images/archive"
|
||||
"github.com/containerd/containerd/platforms"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
@@ -73,7 +74,7 @@ When '--all-platforms' is given all images in a manifest list must be available.
|
||||
for _, ps := range pss {
|
||||
p, err := platforms.Parse(ps)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "invalid platform %q", ps)
|
||||
return fmt.Errorf("invalid platform %q: %w", ps, err)
|
||||
}
|
||||
all = append(all, p)
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package images
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"sort"
|
||||
@@ -29,7 +30,6 @@ import (
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/containerd/containerd/pkg/progress"
|
||||
"github.com/containerd/containerd/platforms"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
@@ -82,7 +82,7 @@ var listCommand = cli.Command{
|
||||
)
|
||||
imageList, err := imageStore.List(ctx, filters...)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to list images")
|
||||
return fmt.Errorf("failed to list images: %w", err)
|
||||
}
|
||||
if quiet {
|
||||
for _, image := range imageList {
|
||||
@@ -224,7 +224,7 @@ var checkCommand = cli.Command{
|
||||
args := []string(context.Args())
|
||||
imageList, err := client.ListImages(ctx, args...)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed listing images")
|
||||
return fmt.Errorf("failed listing images: %w", err)
|
||||
}
|
||||
if len(imageList) == 0 {
|
||||
log.G(ctx).Debugf("no images found")
|
||||
@@ -248,7 +248,7 @@ var checkCommand = cli.Command{
|
||||
available, required, present, missing, err := images.Check(ctx, contentStore, image.Target(), platforms.Default())
|
||||
if err != nil {
|
||||
if exitErr == nil {
|
||||
exitErr = errors.Wrapf(err, "unable to check %v", image.Name())
|
||||
exitErr = fmt.Errorf("unable to check %v: %w", image.Name(), err)
|
||||
}
|
||||
log.G(ctx).WithError(err).Errorf("unable to check %v", image.Name())
|
||||
status = "error"
|
||||
@@ -284,7 +284,7 @@ var checkCommand = cli.Command{
|
||||
unpacked, err := image.IsUnpacked(ctx, context.String("snapshotter"))
|
||||
if err != nil {
|
||||
if exitErr == nil {
|
||||
exitErr = errors.Wrapf(err, "unable to check unpack for %v", image.Name())
|
||||
exitErr = fmt.Errorf("unable to check unpack for %v: %w", image.Name(), err)
|
||||
}
|
||||
log.G(ctx).WithError(err).Errorf("unable to check unpack for %v", image.Name())
|
||||
}
|
||||
@@ -340,7 +340,7 @@ var removeCommand = cli.Command{
|
||||
if err := imageStore.Delete(ctx, target, opts...); err != nil {
|
||||
if !errdefs.IsNotFound(err) {
|
||||
if exitErr == nil {
|
||||
exitErr = errors.Wrapf(err, "unable to delete %v", target)
|
||||
exitErr = fmt.Errorf("unable to delete %v: %w", target, err)
|
||||
}
|
||||
log.G(ctx).WithError(err).Errorf("unable to delete %v", target)
|
||||
continue
|
||||
|
||||
@@ -27,7 +27,6 @@ import (
|
||||
"github.com/containerd/containerd/mount"
|
||||
"github.com/containerd/containerd/platforms"
|
||||
"github.com/opencontainers/image-spec/identity"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
@@ -93,7 +92,7 @@ When you are done, use the unmount command.
|
||||
ps := context.String("platform")
|
||||
p, err := platforms.Parse(ps)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "unable to parse platform %s", ps)
|
||||
return fmt.Errorf("unable to parse platform %s: %w", ps, err)
|
||||
}
|
||||
|
||||
img, err := client.ImageService().Get(ctx, ref)
|
||||
@@ -103,7 +102,7 @@ When you are done, use the unmount command.
|
||||
|
||||
i := containerd.NewImageWithPlatform(client, img, platforms.Only(p))
|
||||
if err := i.Unpack(ctx, snapshotter); err != nil {
|
||||
return errors.Wrap(err, "error unpacking image")
|
||||
return fmt.Errorf("error unpacking image: %w", err)
|
||||
}
|
||||
|
||||
diffIDs, err := i.RootFS(ctx)
|
||||
|
||||
@@ -28,7 +28,6 @@ import (
|
||||
"github.com/containerd/containerd/platforms"
|
||||
"github.com/opencontainers/image-spec/identity"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
@@ -106,13 +105,13 @@ command. As part of this process, we do the following:
|
||||
if context.Bool("all-platforms") {
|
||||
p, err = images.Platforms(ctx, client.ContentStore(), img.Target)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "unable to resolve image platforms")
|
||||
return fmt.Errorf("unable to resolve image platforms: %w", err)
|
||||
}
|
||||
} else {
|
||||
for _, s := range context.StringSlice("platform") {
|
||||
ps, err := platforms.Parse(s)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "unable to parse platform %s", s)
|
||||
return fmt.Errorf("unable to parse platform %s: %w", s, err)
|
||||
}
|
||||
p = append(p, ps)
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@ package images
|
||||
|
||||
import (
|
||||
gocontext "context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http/httptrace"
|
||||
"os"
|
||||
"sync"
|
||||
@@ -35,7 +37,6 @@ import (
|
||||
"github.com/containerd/containerd/remotes/docker"
|
||||
digest "github.com/opencontainers/go-digest"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/urfave/cli"
|
||||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
@@ -88,7 +89,7 @@ var pushCommand = cli.Command{
|
||||
if manifest := context.String("manifest"); manifest != "" {
|
||||
desc.Digest, err = digest.Parse(manifest)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "invalid manifest digest")
|
||||
return fmt.Errorf("invalid manifest digest: %w", err)
|
||||
}
|
||||
desc.MediaType = context.String("manifest-type")
|
||||
} else {
|
||||
@@ -97,14 +98,14 @@ var pushCommand = cli.Command{
|
||||
}
|
||||
img, err := client.ImageService().Get(ctx, local)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "unable to resolve image to manifest")
|
||||
return fmt.Errorf("unable to resolve image to manifest: %w", err)
|
||||
}
|
||||
desc = img.Target
|
||||
|
||||
if pss := context.StringSlice("platform"); len(pss) == 1 {
|
||||
p, err := platforms.Parse(pss[0])
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "invalid platform %q", pss[0])
|
||||
return fmt.Errorf("invalid platform %q: %w", pss[0], err)
|
||||
}
|
||||
|
||||
cs := client.ContentStore()
|
||||
@@ -113,7 +114,7 @@ var pushCommand = cli.Command{
|
||||
for _, manifest := range manifests {
|
||||
if manifest.Platform != nil && matcher.Match(*manifest.Platform) {
|
||||
if _, err := images.Children(ctx, cs, manifest); err != nil {
|
||||
return errors.Wrap(err, "no matching manifest")
|
||||
return fmt.Errorf("no matching manifest: %w", err)
|
||||
}
|
||||
desc = manifest
|
||||
break
|
||||
|
||||
@@ -23,7 +23,6 @@ import (
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/containerd/containerd/leases"
|
||||
"github.com/containerd/containerd/mount"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
@@ -60,10 +59,10 @@ var unmountCommand = cli.Command{
|
||||
snapshotter := context.String("snapshotter")
|
||||
s := client.SnapshotService(snapshotter)
|
||||
if err := client.LeasesService().Delete(ctx, leases.Lease{ID: target}); err != nil && !errdefs.IsNotFound(err) {
|
||||
return errors.Wrap(err, "error deleting lease")
|
||||
return fmt.Errorf("error deleting lease: %w", err)
|
||||
}
|
||||
if err := s.Remove(ctx, target); err != nil && !errdefs.IsNotFound(err) {
|
||||
return errors.Wrap(err, "error removing snapshot")
|
||||
return fmt.Errorf("error removing snapshot: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ import (
|
||||
|
||||
"github.com/containerd/containerd/cmd/ctr/commands"
|
||||
"github.com/containerd/containerd/leases"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
@@ -69,7 +68,7 @@ var listCommand = cli.Command{
|
||||
|
||||
leaseList, err := ls.List(ctx, filters...)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to list leases")
|
||||
return fmt.Errorf("failed to list leases: %w", err)
|
||||
}
|
||||
if quiet {
|
||||
for _, l := range leaseList {
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package namespaces
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"sort"
|
||||
@@ -26,7 +27,6 @@ import (
|
||||
"github.com/containerd/containerd/cmd/ctr/commands"
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
@@ -167,7 +167,7 @@ var removeCommand = cli.Command{
|
||||
if err := namespaces.Delete(ctx, target, opts...); err != nil {
|
||||
if !errdefs.IsNotFound(err) {
|
||||
if exitErr == nil {
|
||||
exitErr = errors.Wrapf(err, "unable to delete %v", target)
|
||||
exitErr = fmt.Errorf("unable to delete %v: %w", target, err)
|
||||
}
|
||||
log.G(ctx).WithError(err).Errorf("unable to delete %v", target)
|
||||
continue
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
package oci
|
||||
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/urfave/cli"
|
||||
|
||||
"github.com/containerd/containerd/cmd/ctr/commands"
|
||||
@@ -43,7 +44,7 @@ var defaultSpecCommand = cli.Command{
|
||||
|
||||
spec, err := oci.GenerateSpec(ctx, nil, &containers.Container{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to generate spec")
|
||||
return fmt.Errorf("failed to generate spec: %w", err)
|
||||
}
|
||||
|
||||
commands.PrintAsJSON(spec)
|
||||
|
||||
@@ -24,7 +24,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/containerd/containerd/defaults"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
@@ -183,7 +182,7 @@ func httpGetRequest(client *http.Client, request string) (io.ReadCloser, error)
|
||||
return nil, err
|
||||
}
|
||||
if resp.StatusCode != 200 {
|
||||
return nil, errors.Errorf("http get failed with status: %s", resp.Status)
|
||||
return nil, fmt.Errorf("http get failed with status: %s", resp.Status)
|
||||
}
|
||||
return resp.Body, nil
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import (
|
||||
gocontext "context"
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
@@ -34,7 +35,6 @@ import (
|
||||
"github.com/containerd/containerd/remotes"
|
||||
"github.com/containerd/containerd/remotes/docker"
|
||||
"github.com/containerd/containerd/remotes/docker/config"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
@@ -46,12 +46,12 @@ func passwordPrompt() (string, error) {
|
||||
defer c.Reset()
|
||||
|
||||
if err := c.DisableEcho(); err != nil {
|
||||
return "", errors.Wrap(err, "failed to disable echo")
|
||||
return "", fmt.Errorf("failed to disable echo: %w", err)
|
||||
}
|
||||
|
||||
line, _, err := bufio.NewReader(c).ReadLine()
|
||||
if err != nil {
|
||||
return "", errors.Wrap(err, "failed to read line")
|
||||
return "", fmt.Errorf("failed to read line: %w", err)
|
||||
}
|
||||
return string(line), nil
|
||||
}
|
||||
@@ -126,7 +126,7 @@ func resolverDefaultTLS(clicontext *cli.Context) (*tls.Config, error) {
|
||||
if tlsRootPath := clicontext.String("tlscacert"); tlsRootPath != "" {
|
||||
tlsRootData, err := os.ReadFile(tlsRootPath)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to read %q", tlsRootPath)
|
||||
return nil, fmt.Errorf("failed to read %q: %w", tlsRootPath, err)
|
||||
}
|
||||
|
||||
config.RootCAs = x509.NewCertPool()
|
||||
@@ -143,7 +143,7 @@ func resolverDefaultTLS(clicontext *cli.Context) (*tls.Config, error) {
|
||||
}
|
||||
keyPair, err := tls.LoadX509KeyPair(tlsCertPath, tlsKeyPath)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to load TLS client credentials (cert=%q, key=%q)", tlsCertPath, tlsKeyPath)
|
||||
return nil, fmt.Errorf("failed to load TLS client credentials (cert=%q, key=%q): %w", tlsCertPath, tlsKeyPath, err)
|
||||
}
|
||||
config.Certificates = []tls.Certificate{keyPair}
|
||||
}
|
||||
@@ -161,7 +161,7 @@ type DebugTransport struct {
|
||||
func (t DebugTransport) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||
in, err := httputil.DumpRequest(req, true)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to dump request")
|
||||
return nil, fmt.Errorf("failed to dump request: %w", err)
|
||||
}
|
||||
|
||||
if _, err := t.writer.Write(in); err != nil {
|
||||
@@ -175,7 +175,7 @@ func (t DebugTransport) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||
|
||||
out, err := httputil.DumpResponse(resp, true)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to dump response")
|
||||
return nil, fmt.Errorf("failed to dump response: %w", err)
|
||||
}
|
||||
|
||||
if _, err := t.writer.Write(out); err != nil {
|
||||
|
||||
@@ -20,6 +20,7 @@ import (
|
||||
"context"
|
||||
gocontext "context"
|
||||
"encoding/csv"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
@@ -34,7 +35,6 @@ import (
|
||||
"github.com/containerd/containerd/oci"
|
||||
gocni "github.com/containerd/go-cni"
|
||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
@@ -21,6 +21,7 @@ package run
|
||||
|
||||
import (
|
||||
gocontext "context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -39,7 +40,6 @@ import (
|
||||
"github.com/containerd/containerd/runtime/v2/runc/options"
|
||||
"github.com/containerd/containerd/snapshots"
|
||||
"github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
@@ -204,7 +204,7 @@ func NewContainer(ctx gocontext.Context, client *containerd.Client, context *cli
|
||||
if context.Bool("net-host") {
|
||||
hostname, err := os.Hostname()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "get hostname")
|
||||
return nil, fmt.Errorf("get hostname: %w", err)
|
||||
}
|
||||
opts = append(opts,
|
||||
oci.WithHostNamespace(specs.NetworkNamespace),
|
||||
@@ -417,15 +417,15 @@ func parseIDMapping(mapping string) (specs.LinuxIDMapping, error) {
|
||||
}
|
||||
cID, err := strconv.ParseUint(parts[0], 0, 32)
|
||||
if err != nil {
|
||||
return specs.LinuxIDMapping{}, errors.Wrapf(err, "invalid container id for user namespace remapping")
|
||||
return specs.LinuxIDMapping{}, fmt.Errorf("invalid container id for user namespace remapping: %w", err)
|
||||
}
|
||||
hID, err := strconv.ParseUint(parts[1], 0, 32)
|
||||
if err != nil {
|
||||
return specs.LinuxIDMapping{}, errors.Wrapf(err, "invalid host id for user namespace remapping")
|
||||
return specs.LinuxIDMapping{}, fmt.Errorf("invalid host id for user namespace remapping: %w", err)
|
||||
}
|
||||
size, err := strconv.ParseUint(parts[2], 0, 32)
|
||||
if err != nil {
|
||||
return specs.LinuxIDMapping{}, errors.Wrapf(err, "invalid size for user namespace remapping")
|
||||
return specs.LinuxIDMapping{}, fmt.Errorf("invalid size for user namespace remapping: %w", err)
|
||||
}
|
||||
return specs.LinuxIDMapping{
|
||||
ContainerID: uint32(cID),
|
||||
|
||||
@@ -18,6 +18,7 @@ package run
|
||||
|
||||
import (
|
||||
gocontext "context"
|
||||
"errors"
|
||||
|
||||
"github.com/Microsoft/hcsshim/cmd/containerd-shim-runhcs-v1/options"
|
||||
"github.com/containerd/console"
|
||||
@@ -26,7 +27,6 @@ import (
|
||||
"github.com/containerd/containerd/oci"
|
||||
"github.com/containerd/containerd/pkg/netns"
|
||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
@@ -21,6 +21,7 @@ package shim
|
||||
|
||||
import (
|
||||
gocontext "context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"os"
|
||||
@@ -36,7 +37,6 @@ import (
|
||||
"github.com/containerd/typeurl"
|
||||
ptypes "github.com/gogo/protobuf/types"
|
||||
"github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
@@ -18,6 +18,7 @@ package snapshots
|
||||
|
||||
import (
|
||||
gocontext "context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
@@ -35,7 +36,6 @@ import (
|
||||
"github.com/containerd/containerd/snapshots"
|
||||
digest "github.com/opencontainers/go-digest"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
@@ -262,7 +262,7 @@ var removeCommand = cli.Command{
|
||||
for _, key := range context.Args() {
|
||||
err = snapshotter.Remove(ctx, key)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to remove %q", key)
|
||||
return fmt.Errorf("failed to remove %q: %w", key, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package tasks
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/containerd/containerd"
|
||||
@@ -24,7 +25,6 @@ import (
|
||||
"github.com/containerd/containerd/plugin"
|
||||
"github.com/containerd/containerd/runtime/linux/runctypes"
|
||||
"github.com/containerd/containerd/runtime/v2/runc/options"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
|
||||
@@ -17,10 +17,11 @@
|
||||
package tasks
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/containerd/containerd"
|
||||
"github.com/containerd/containerd/cmd/ctr/commands"
|
||||
"github.com/moby/sys/signal"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
package tasks
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"text/tabwriter"
|
||||
|
||||
"github.com/containerd/containerd/cmd/ctr/commands"
|
||||
"github.com/containerd/typeurl"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
|
||||
@@ -17,11 +17,12 @@
|
||||
package tasks
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/containerd/console"
|
||||
"github.com/containerd/containerd"
|
||||
"github.com/containerd/containerd/cio"
|
||||
"github.com/containerd/containerd/cmd/ctr/commands"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
@@ -21,6 +21,7 @@ package tasks
|
||||
|
||||
import (
|
||||
gocontext "context"
|
||||
"errors"
|
||||
"net/url"
|
||||
"os"
|
||||
"os/signal"
|
||||
@@ -29,7 +30,6 @@ import (
|
||||
"github.com/containerd/containerd"
|
||||
"github.com/containerd/containerd/cio"
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/urfave/cli"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
@@ -18,6 +18,7 @@ package tasks
|
||||
|
||||
import (
|
||||
gocontext "context"
|
||||
"errors"
|
||||
"net/url"
|
||||
"time"
|
||||
|
||||
@@ -25,7 +26,6 @@ import (
|
||||
"github.com/containerd/containerd"
|
||||
"github.com/containerd/containerd/cio"
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user