diff --git a/cmd/ctr/commands/content/content.go b/cmd/ctr/commands/content/content.go index 38d1a4b4c..d7d1bfb6a 100644 --- a/cmd/ctr/commands/content/content.go +++ b/cmd/ctr/commands/content/content.go @@ -581,7 +581,7 @@ var ( func edit(context *cli.Context, rd io.Reader) (_ io.ReadCloser, retErr error) { editor := context.String("editor") if editor == "" { - return nil, fmt.Errorf("editor is required") + return nil, errors.New("editor is required") } tmp, err := os.CreateTemp(os.Getenv("XDG_RUNTIME_DIR"), "edit-") diff --git a/cmd/ctr/commands/images/import.go b/cmd/ctr/commands/images/import.go index a5fb00174..89976094c 100644 --- a/cmd/ctr/commands/images/import.go +++ b/cmd/ctr/commands/images/import.go @@ -17,6 +17,7 @@ package images import ( + "errors" "fmt" "io" "os" @@ -211,7 +212,7 @@ If foobar.tar contains an OCI ref named "latest" and anonymous ref "sha256:deadb } if context.Bool("skip-digest-for-named") { if !context.Bool("digests") { - return fmt.Errorf("--skip-digest-for-named must be specified with --digests option") + return errors.New("--skip-digest-for-named must be specified with --digests option") } opts = append(opts, containerd.WithSkipDigestRef(func(name string) bool { return name != "" })) } @@ -237,7 +238,7 @@ If foobar.tar contains an OCI ref named "latest" and anonymous ref "sha256:deadb if context.Bool("discard-unpacked-layers") { if context.Bool("no-unpack") { - return fmt.Errorf("--discard-unpacked-layers and --no-unpack are incompatible options") + return errors.New("--discard-unpacked-layers and --no-unpack are incompatible options") } opts = append(opts, containerd.WithDiscardUnpackedLayers()) } diff --git a/cmd/ctr/commands/images/mount.go b/cmd/ctr/commands/images/mount.go index 6367bceef..5b95f500c 100644 --- a/cmd/ctr/commands/images/mount.go +++ b/cmd/ctr/commands/images/mount.go @@ -17,6 +17,7 @@ package images import ( + "errors" "fmt" "time" @@ -56,10 +57,10 @@ When you are done, use the unmount command. target = context.Args().Get(1) ) if ref == "" { - return fmt.Errorf("please provide an image reference to mount") + return errors.New("please provide an image reference to mount") } if target == "" { - return fmt.Errorf("please provide a target path to mount to") + return errors.New("please provide a target path to mount to") } client, ctx, cancel, err := commands.NewClient(context) diff --git a/cmd/ctr/commands/images/pull.go b/cmd/ctr/commands/images/pull.go index 0e5ba205a..6d8d8ea5a 100644 --- a/cmd/ctr/commands/images/pull.go +++ b/cmd/ctr/commands/images/pull.go @@ -18,6 +18,7 @@ package images import ( "context" + "errors" "fmt" "io" "os" @@ -89,7 +90,7 @@ command. As part of this process, we do the following: ref = context.Args().First() ) if ref == "" { - return fmt.Errorf("please provide an image reference to pull") + return errors.New("please provide an image reference to pull") } client, ctx, cancel, err := commands.NewClient(context) diff --git a/cmd/ctr/commands/images/tag.go b/cmd/ctr/commands/images/tag.go index c9382f933..762e0d0e2 100644 --- a/cmd/ctr/commands/images/tag.go +++ b/cmd/ctr/commands/images/tag.go @@ -17,6 +17,7 @@ package images import ( + "errors" "fmt" "github.com/urfave/cli/v2" @@ -51,10 +52,10 @@ var tagCommand = &cli.Command{ ref = context.Args().First() ) if ref == "" { - return fmt.Errorf("please provide an image reference to tag from") + return errors.New("please provide an image reference to tag from") } if context.NArg() <= 1 { - return fmt.Errorf("please provide an image reference to tag to") + return errors.New("please provide an image reference to tag to") } client, ctx, cancel, err := commands.NewClient(context) diff --git a/cmd/ctr/commands/images/unmount.go b/cmd/ctr/commands/images/unmount.go index 248f813cf..2784f8057 100644 --- a/cmd/ctr/commands/images/unmount.go +++ b/cmd/ctr/commands/images/unmount.go @@ -17,6 +17,7 @@ package images import ( + "errors" "fmt" "github.com/containerd/containerd/v2/cmd/ctr/commands" @@ -42,7 +43,7 @@ var unmountCommand = &cli.Command{ target = context.Args().First() ) if target == "" { - return fmt.Errorf("please provide a target path to unmount from") + return errors.New("please provide a target path to unmount from") } client, ctx, cancel, err := commands.NewClient(context) diff --git a/cmd/ctr/commands/images/usage.go b/cmd/ctr/commands/images/usage.go index be00fee26..be7d1d4a3 100644 --- a/cmd/ctr/commands/images/usage.go +++ b/cmd/ctr/commands/images/usage.go @@ -17,6 +17,7 @@ package images import ( + "errors" "fmt" "os" "text/tabwriter" @@ -38,7 +39,7 @@ var usageCommand = &cli.Command{ Action: func(context *cli.Context) error { var ref = context.Args().First() if ref == "" { - return fmt.Errorf("please provide an image reference to mount") + return errors.New("please provide an image reference to mount") } client, ctx, cancel, err := commands.NewClient(context) diff --git a/cmd/ctr/commands/run/run.go b/cmd/ctr/commands/run/run.go index 5118dc274..96e6be8ad 100644 --- a/cmd/ctr/commands/run/run.go +++ b/cmd/ctr/commands/run/run.go @@ -68,7 +68,7 @@ func parseMountFlag(m string) (specs.Mount, error) { for _, field := range fields { key, val, ok := strings.Cut(field, "=") if !ok { - return mount, fmt.Errorf("invalid mount specification: expected key=val") + return mount, errors.New("invalid mount specification: expected key=val") } switch key { diff --git a/cmd/ctr/commands/run/run_unix.go b/cmd/ctr/commands/run/run_unix.go index c7929906c..3d54257c7 100644 --- a/cmd/ctr/commands/run/run_unix.go +++ b/cmd/ctr/commands/run/run_unix.go @@ -210,7 +210,7 @@ func NewContainer(ctx gocontext.Context, client *containerd.Client, context *cli privileged := context.Bool("privileged") privilegedWithoutHostDevices := context.Bool("privileged-without-host-devices") if privilegedWithoutHostDevices && !privileged { - return nil, fmt.Errorf("can't use 'privileged-without-host-devices' without 'privileged' specified") + return nil, errors.New("can't use 'privileged-without-host-devices' without 'privileged' specified") } if privileged { if privilegedWithoutHostDevices { @@ -243,7 +243,7 @@ func NewContainer(ctx gocontext.Context, client *containerd.Client, context *cli if caps := context.StringSlice("cap-add"); len(caps) > 0 { for _, cap := range caps { if !strings.HasPrefix(cap, "CAP_") { - return nil, fmt.Errorf("capabilities must be specified with 'CAP_' prefix") + return nil, errors.New("capabilities must be specified with 'CAP_' prefix") } } opts = append(opts, oci.WithAddedCapabilities(caps)) @@ -252,7 +252,7 @@ func NewContainer(ctx gocontext.Context, client *containerd.Client, context *cli if caps := context.StringSlice("cap-drop"); len(caps) > 0 { for _, cap := range caps { if !strings.HasPrefix(cap, "CAP_") { - return nil, fmt.Errorf("capabilities must be specified with 'CAP_' prefix") + return nil, errors.New("capabilities must be specified with 'CAP_' prefix") } } opts = append(opts, oci.WithDroppedCapabilities(caps)) @@ -261,7 +261,7 @@ func NewContainer(ctx gocontext.Context, client *containerd.Client, context *cli seccompProfile := context.String("seccomp-profile") if !context.Bool("seccomp") && seccompProfile != "" { - return nil, fmt.Errorf("seccomp must be set to true, if using a custom seccomp-profile") + return nil, errors.New("seccomp must be set to true, if using a custom seccomp-profile") } if context.Bool("seccomp") { @@ -278,7 +278,7 @@ func NewContainer(ctx gocontext.Context, client *containerd.Client, context *cli if s := context.String("apparmor-profile"); len(s) > 0 { if len(context.String("apparmor-default-profile")) > 0 { - return nil, fmt.Errorf("apparmor-profile conflicts with apparmor-default-profile") + return nil, errors.New("apparmor-profile conflicts with apparmor-default-profile") } opts = append(opts, apparmor.WithProfile(s)) }