Merge pull request #9809 from dereknola/urfave_v2
Migrate Urfave CLI from v1 to v2
This commit is contained in:
		| @@ -26,7 +26,7 @@ import ( | ||||
| 	"github.com/containerd/containerd/v2/pkg/namespaces" | ||||
| 	ptypes "github.com/containerd/containerd/v2/protobuf/types" | ||||
| 	"github.com/containerd/log" | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| ) | ||||
|  | ||||
| // AppContext returns the context for a command. Should only be called once per | ||||
| @@ -37,8 +37,8 @@ import ( | ||||
| func AppContext(context *cli.Context) (gocontext.Context, gocontext.CancelFunc) { | ||||
| 	var ( | ||||
| 		ctx       = gocontext.Background() | ||||
| 		timeout   = context.GlobalDuration("timeout") | ||||
| 		namespace = context.GlobalString("namespace") | ||||
| 		timeout   = context.Duration("timeout") | ||||
| 		namespace = context.String("namespace") | ||||
| 		cancel    gocontext.CancelFunc | ||||
| 	) | ||||
| 	ctx = namespaces.WithNamespace(ctx, namespace) | ||||
| @@ -58,9 +58,9 @@ func AppContext(context *cli.Context) (gocontext.Context, gocontext.CancelFunc) | ||||
|  | ||||
| // NewClient returns a new containerd client | ||||
| func NewClient(context *cli.Context, opts ...containerd.Opt) (*containerd.Client, gocontext.Context, gocontext.CancelFunc, error) { | ||||
| 	timeoutOpt := containerd.WithTimeout(context.GlobalDuration("connect-timeout")) | ||||
| 	timeoutOpt := containerd.WithTimeout(context.Duration("connect-timeout")) | ||||
| 	opts = append(opts, timeoutOpt) | ||||
| 	client, err := containerd.New(context.GlobalString("address"), opts...) | ||||
| 	client, err := containerd.New(context.String("address"), opts...) | ||||
| 	if err != nil { | ||||
| 		return nil, nil, nil, err | ||||
| 	} | ||||
|   | ||||
| @@ -26,71 +26,73 @@ import ( | ||||
| 	"github.com/containerd/containerd/v2/defaults" | ||||
| 	"github.com/containerd/containerd/v2/pkg/atomicfile" | ||||
|  | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| ) | ||||
|  | ||||
| var ( | ||||
| 	// SnapshotterFlags are cli flags specifying snapshotter names | ||||
| 	SnapshotterFlags = []cli.Flag{ | ||||
| 		cli.StringFlag{ | ||||
| 			Name:   "snapshotter", | ||||
| 			Usage:  "Snapshotter name. Empty value stands for the default value.", | ||||
| 			EnvVar: "CONTAINERD_SNAPSHOTTER", | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:    "snapshotter", | ||||
| 			Usage:   "Snapshotter name. Empty value stands for the default value.", | ||||
| 			EnvVars: []string{"CONTAINERD_SNAPSHOTTER"}, | ||||
| 		}, | ||||
| 	} | ||||
|  | ||||
| 	// SnapshotterLabels are cli flags specifying labels which will be added to the new snapshot for container. | ||||
| 	SnapshotterLabels = cli.StringSliceFlag{ | ||||
| 	SnapshotterLabels = &cli.StringSliceFlag{ | ||||
| 		Name:  "snapshotter-label", | ||||
| 		Usage: "Labels added to the new snapshot for this container.", | ||||
| 	} | ||||
|  | ||||
| 	// LabelFlag is a cli flag specifying labels | ||||
| 	LabelFlag = cli.StringSliceFlag{ | ||||
| 	LabelFlag = &cli.StringSliceFlag{ | ||||
| 		Name:  "label", | ||||
| 		Usage: "Labels to attach to the image", | ||||
| 	} | ||||
|  | ||||
| 	// RegistryFlags are cli flags specifying registry options | ||||
| 	RegistryFlags = []cli.Flag{ | ||||
| 		cli.BoolFlag{ | ||||
| 			Name:  "skip-verify,k", | ||||
| 			Usage: "Skip SSL certificate validation", | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:    "skip-verify", | ||||
| 			Aliases: []string{"k"}, | ||||
| 			Usage:   "Skip SSL certificate validation", | ||||
| 		}, | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "plain-http", | ||||
| 			Usage: "Allow connections using plain HTTP", | ||||
| 		}, | ||||
| 		cli.StringFlag{ | ||||
| 			Name:  "user,u", | ||||
| 			Usage: "User[:password] Registry user and password", | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:    "user", | ||||
| 			Aliases: []string{"u"}, | ||||
| 			Usage:   "User[:password] Registry user and password", | ||||
| 		}, | ||||
| 		cli.StringFlag{ | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:  "refresh", | ||||
| 			Usage: "Refresh token for authorization server", | ||||
| 		}, | ||||
| 		cli.StringFlag{ | ||||
| 		&cli.StringFlag{ | ||||
| 			Name: "hosts-dir", | ||||
| 			// compatible with "/etc/docker/certs.d" | ||||
| 			Usage: "Custom hosts configuration directory", | ||||
| 		}, | ||||
| 		cli.StringFlag{ | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:  "tlscacert", | ||||
| 			Usage: "Path to TLS root CA", | ||||
| 		}, | ||||
| 		cli.StringFlag{ | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:  "tlscert", | ||||
| 			Usage: "Path to TLS client certificate", | ||||
| 		}, | ||||
| 		cli.StringFlag{ | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:  "tlskey", | ||||
| 			Usage: "Path to TLS client key", | ||||
| 		}, | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "http-dump", | ||||
| 			Usage: "Dump all HTTP request/responses when interacting with container registry", | ||||
| 		}, | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "http-trace", | ||||
| 			Usage: "Enable HTTP tracing for registry interactions", | ||||
| 		}, | ||||
| @@ -98,12 +100,12 @@ var ( | ||||
|  | ||||
| 	// RuntimeFlags are cli flags specifying runtime | ||||
| 	RuntimeFlags = []cli.Flag{ | ||||
| 		cli.StringFlag{ | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:  "runtime", | ||||
| 			Usage: "Runtime name or absolute path to runtime binary", | ||||
| 			Value: defaults.DefaultRuntime, | ||||
| 		}, | ||||
| 		cli.StringFlag{ | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:  "runtime-config-path", | ||||
| 			Usage: "Optional runtime config path", | ||||
| 		}, | ||||
| @@ -111,117 +113,120 @@ var ( | ||||
|  | ||||
| 	// ContainerFlags are cli flags specifying container options | ||||
| 	ContainerFlags = []cli.Flag{ | ||||
| 		cli.StringFlag{ | ||||
| 			Name:  "config,c", | ||||
| 			Usage: "Path to the runtime-specific spec config file", | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:    "config", | ||||
| 			Aliases: []string{"c"}, | ||||
| 			Usage:   "Path to the runtime-specific spec config file", | ||||
| 		}, | ||||
| 		cli.StringFlag{ | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:  "cwd", | ||||
| 			Usage: "Specify the working directory of the process", | ||||
| 		}, | ||||
| 		cli.StringSliceFlag{ | ||||
| 		&cli.StringSliceFlag{ | ||||
| 			Name:  "env", | ||||
| 			Usage: "Specify additional container environment variables (e.g. FOO=bar)", | ||||
| 		}, | ||||
| 		cli.StringFlag{ | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:  "env-file", | ||||
| 			Usage: "Specify additional container environment variables in a file(e.g. FOO=bar, one per line)", | ||||
| 		}, | ||||
| 		cli.StringSliceFlag{ | ||||
| 		&cli.StringSliceFlag{ | ||||
| 			Name:  "label", | ||||
| 			Usage: "Specify additional labels (e.g. foo=bar)", | ||||
| 		}, | ||||
| 		cli.StringSliceFlag{ | ||||
| 		&cli.StringSliceFlag{ | ||||
| 			Name:  "annotation", | ||||
| 			Usage: "Specify additional OCI annotations (e.g. foo=bar)", | ||||
| 		}, | ||||
| 		cli.StringSliceFlag{ | ||||
| 		&cli.StringSliceFlag{ | ||||
| 			Name:  "mount", | ||||
| 			Usage: "Specify additional container mount (e.g. type=bind,src=/tmp,dst=/host,options=rbind:ro)", | ||||
| 		}, | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "net-host", | ||||
| 			Usage: "Enable host networking for the container", | ||||
| 		}, | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "privileged", | ||||
| 			Usage: "Run privileged container", | ||||
| 		}, | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "read-only", | ||||
| 			Usage: "Set the containers filesystem as readonly", | ||||
| 		}, | ||||
| 		cli.StringFlag{ | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:  "sandbox", | ||||
| 			Usage: "Create the container in the given sandbox", | ||||
| 		}, | ||||
| 		cli.BoolFlag{ | ||||
| 			Name:  "tty,t", | ||||
| 			Usage: "Allocate a TTY for the container", | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:    "tty", | ||||
| 			Aliases: []string{"t"}, | ||||
| 			Usage:   "Allocate a TTY for the container", | ||||
| 		}, | ||||
| 		cli.StringSliceFlag{ | ||||
| 		&cli.StringSliceFlag{ | ||||
| 			Name:  "with-ns", | ||||
| 			Usage: "Specify existing Linux namespaces to join at container runtime (format '<nstype>:<path>')", | ||||
| 		}, | ||||
| 		cli.StringFlag{ | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:  "pid-file", | ||||
| 			Usage: "File path to write the task's pid", | ||||
| 		}, | ||||
| 		cli.IntSliceFlag{ | ||||
| 		&cli.IntSliceFlag{ | ||||
| 			Name:  "gpus", | ||||
| 			Usage: "Add gpus to the container", | ||||
| 		}, | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "allow-new-privs", | ||||
| 			Usage: "Turn off OCI spec's NoNewPrivileges feature flag", | ||||
| 		}, | ||||
| 		cli.Uint64Flag{ | ||||
| 		&cli.Uint64Flag{ | ||||
| 			Name:  "memory-limit", | ||||
| 			Usage: "Memory limit (in bytes) for the container", | ||||
| 		}, | ||||
| 		cli.StringSliceFlag{ | ||||
| 		&cli.StringSliceFlag{ | ||||
| 			Name:  "cap-add", | ||||
| 			Usage: "Add Linux capabilities (Set capabilities with 'CAP_' prefix)", | ||||
| 		}, | ||||
| 		cli.StringSliceFlag{ | ||||
| 		&cli.StringSliceFlag{ | ||||
| 			Name:  "cap-drop", | ||||
| 			Usage: "Drop Linux capabilities (Set capabilities with 'CAP_' prefix)", | ||||
| 		}, | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "seccomp", | ||||
| 			Usage: "Enable the default seccomp profile", | ||||
| 		}, | ||||
| 		cli.StringFlag{ | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:  "seccomp-profile", | ||||
| 			Usage: "File path to custom seccomp profile. seccomp must be set to true, before using seccomp-profile", | ||||
| 		}, | ||||
| 		cli.StringFlag{ | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:  "apparmor-default-profile", | ||||
| 			Usage: "Enable AppArmor with the default profile with the specified name, e.g. \"cri-containerd.apparmor.d\"", | ||||
| 		}, | ||||
| 		cli.StringFlag{ | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:  "apparmor-profile", | ||||
| 			Usage: "Enable AppArmor with an existing custom profile", | ||||
| 		}, | ||||
| 		cli.StringFlag{ | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:  "blockio-config-file", | ||||
| 			Usage: "File path to blockio class definitions. By default class definitions are not loaded.", | ||||
| 		}, | ||||
| 		cli.StringFlag{ | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:  "blockio-class", | ||||
| 			Usage: "Name of the blockio class to associate the container with", | ||||
| 		}, | ||||
| 		cli.StringFlag{ | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:  "rdt-class", | ||||
| 			Usage: "Name of the RDT class to associate the container with. Specifies a Class of Service (CLOS) for cache and memory bandwidth management.", | ||||
| 		}, | ||||
| 		cli.StringFlag{ | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:  "hostname", | ||||
| 			Usage: "Set the container's host name", | ||||
| 		}, | ||||
| 		cli.StringFlag{ | ||||
| 			Name:  "user,u", | ||||
| 			Usage: "Username or user id, group optional (format: <name|uid>[:<group|gid>])", | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:    "user", | ||||
| 			Aliases: []string{"u"}, | ||||
| 			Usage:   "Username or user id, group optional (format: <name|uid>[:<group|gid>])", | ||||
| 		}, | ||||
| 	} | ||||
| ) | ||||
|   | ||||
| @@ -23,37 +23,37 @@ import ( | ||||
|  | ||||
| 	"github.com/containerd/containerd/v2/core/runtime/v2/runc/options" | ||||
| 	runtimeoptions "github.com/containerd/containerd/v2/pkg/runtimeoptions/v1" | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| ) | ||||
|  | ||||
| func init() { | ||||
| 	RuntimeFlags = append(RuntimeFlags, cli.StringFlag{ | ||||
| 	RuntimeFlags = append(RuntimeFlags, &cli.StringFlag{ | ||||
| 		Name:  "runc-binary", | ||||
| 		Usage: "Specify runc-compatible binary", | ||||
| 	}, cli.StringFlag{ | ||||
| 	}, &cli.StringFlag{ | ||||
| 		Name:  "runc-root", | ||||
| 		Usage: "Specify runc-compatible root", | ||||
| 	}, cli.BoolFlag{ | ||||
| 	}, &cli.BoolFlag{ | ||||
| 		Name:  "runc-systemd-cgroup", | ||||
| 		Usage: "Start runc with systemd cgroup manager", | ||||
| 	}) | ||||
| 	ContainerFlags = append(ContainerFlags, cli.BoolFlag{ | ||||
| 	ContainerFlags = append(ContainerFlags, &cli.BoolFlag{ | ||||
| 		Name:  "rootfs", | ||||
| 		Usage: "Use custom rootfs that is not managed by containerd snapshotter", | ||||
| 	}, cli.BoolFlag{ | ||||
| 	}, &cli.BoolFlag{ | ||||
| 		Name:  "no-pivot", | ||||
| 		Usage: "Disable use of pivot-root (linux only)", | ||||
| 	}, cli.Int64Flag{ | ||||
| 	}, &cli.Int64Flag{ | ||||
| 		Name:  "cpu-quota", | ||||
| 		Usage: "Limit CPU CFS quota", | ||||
| 		Value: -1, | ||||
| 	}, cli.Uint64Flag{ | ||||
| 	}, &cli.Uint64Flag{ | ||||
| 		Name:  "cpu-period", | ||||
| 		Usage: "Limit CPU CFS period", | ||||
| 	}, cli.StringFlag{ | ||||
| 	}, &cli.StringFlag{ | ||||
| 		Name:  "rootfs-propagation", | ||||
| 		Usage: "Set the propagation of the container rootfs", | ||||
| 	}, cli.StringSliceFlag{ | ||||
| 	}, &cli.StringSliceFlag{ | ||||
| 		Name:  "device", | ||||
| 		Usage: "File path to a device to add to the container; or a path to a directory tree of devices to add to the container", | ||||
| 	}) | ||||
|   | ||||
| @@ -17,23 +17,21 @@ | ||||
| package commands | ||||
|  | ||||
| import ( | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| ) | ||||
|  | ||||
| func init() { | ||||
| 	ContainerFlags = append(ContainerFlags, | ||||
| 		cli.Uint64Flag{ | ||||
| 		&cli.Uint64Flag{ | ||||
| 			Name:  "cpu-count", | ||||
| 			Usage: "Number of CPUs available to the container", | ||||
| 		}, | ||||
| 		cli.Uint64Flag{ | ||||
| 		}, &cli.Uint64Flag{ | ||||
| 			Name:  "cpu-shares", | ||||
| 			Usage: "The relative number of CPU shares given to the container relative to other workloads. Between 0 and 10,000.", | ||||
| 		}, | ||||
| 		cli.Uint64Flag{ | ||||
| 		}, &cli.Uint64Flag{ | ||||
| 			Name:  "cpu-max", | ||||
| 			Usage: "The number of processor cycles threads in a container can use per 10,000 cycles. Set to a percentage times 100. Between 1 and 10,000", | ||||
| 		}, cli.StringSliceFlag{ | ||||
| 		}, &cli.StringSliceFlag{ | ||||
| 			Name:  "device", | ||||
| 			Usage: "Identifier of a device to add to the container  (e.g. class://5B45201D-F2F2-4F3B-85BB-30FF1F953599)", | ||||
| 		}) | ||||
|   | ||||
| @@ -23,23 +23,23 @@ import ( | ||||
| 	containerd "github.com/containerd/containerd/v2/client" | ||||
| 	"github.com/containerd/containerd/v2/cmd/ctr/commands" | ||||
| 	"github.com/containerd/errdefs" | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| ) | ||||
|  | ||||
| var checkpointCommand = cli.Command{ | ||||
| var checkpointCommand = &cli.Command{ | ||||
| 	Name:      "checkpoint", | ||||
| 	Usage:     "Checkpoint a container", | ||||
| 	ArgsUsage: "CONTAINER REF", | ||||
| 	Flags: []cli.Flag{ | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "rw", | ||||
| 			Usage: "Include the rw layer in the checkpoint", | ||||
| 		}, | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "image", | ||||
| 			Usage: "Include the image in the checkpoint", | ||||
| 		}, | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "task", | ||||
| 			Usage: "Checkpoint container task", | ||||
| 		}, | ||||
|   | ||||
| @@ -31,15 +31,15 @@ import ( | ||||
| 	"github.com/containerd/errdefs" | ||||
| 	"github.com/containerd/log" | ||||
| 	"github.com/containerd/typeurl/v2" | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| ) | ||||
|  | ||||
| // Command is the cli command for managing containers | ||||
| var Command = cli.Command{ | ||||
| var Command = &cli.Command{ | ||||
| 	Name:    "containers", | ||||
| 	Usage:   "Manage containers", | ||||
| 	Aliases: []string{"c", "container"}, | ||||
| 	Subcommands: []cli.Command{ | ||||
| 	Subcommands: []*cli.Command{ | ||||
| 		createCommand, | ||||
| 		deleteCommand, | ||||
| 		infoCommand, | ||||
| @@ -50,12 +50,11 @@ var Command = cli.Command{ | ||||
| 	}, | ||||
| } | ||||
|  | ||||
| var createCommand = cli.Command{ | ||||
| 	Name:           "create", | ||||
| 	Usage:          "Create container", | ||||
| 	ArgsUsage:      "[flags] Image|RootFS CONTAINER [COMMAND] [ARG...]", | ||||
| 	SkipArgReorder: true, | ||||
| 	Flags:          append(commands.RuntimeFlags, append(append(commands.SnapshotterFlags, []cli.Flag{commands.SnapshotterLabels}...), commands.ContainerFlags...)...), | ||||
| var createCommand = &cli.Command{ | ||||
| 	Name:      "create", | ||||
| 	Usage:     "Create container", | ||||
| 	ArgsUsage: "[flags] Image|RootFS CONTAINER [COMMAND] [ARG...]", | ||||
| 	Flags:     append(commands.RuntimeFlags, append(append(commands.SnapshotterFlags, []cli.Flag{commands.SnapshotterLabels}...), commands.ContainerFlags...)...), | ||||
| 	Action: func(context *cli.Context) error { | ||||
| 		var ( | ||||
| 			id     string | ||||
| @@ -91,20 +90,21 @@ var createCommand = cli.Command{ | ||||
| 	}, | ||||
| } | ||||
|  | ||||
| var listCommand = cli.Command{ | ||||
| var listCommand = &cli.Command{ | ||||
| 	Name:      "list", | ||||
| 	Aliases:   []string{"ls"}, | ||||
| 	Usage:     "List containers", | ||||
| 	ArgsUsage: "[flags] [<filter>, ...]", | ||||
| 	Flags: []cli.Flag{ | ||||
| 		cli.BoolFlag{ | ||||
| 			Name:  "quiet, q", | ||||
| 			Usage: "Print only the container id", | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:    "quiet", | ||||
| 			Aliases: []string{"q"}, | ||||
| 			Usage:   "Print only the container id", | ||||
| 		}, | ||||
| 	}, | ||||
| 	Action: func(context *cli.Context) error { | ||||
| 		var ( | ||||
| 			filters = context.Args() | ||||
| 			filters = context.Args().Slice() | ||||
| 			quiet   = context.Bool("quiet") | ||||
| 		) | ||||
| 		client, ctx, cancel, err := commands.NewClient(context) | ||||
| @@ -145,13 +145,13 @@ var listCommand = cli.Command{ | ||||
| 	}, | ||||
| } | ||||
|  | ||||
| var deleteCommand = cli.Command{ | ||||
| var deleteCommand = &cli.Command{ | ||||
| 	Name:      "delete", | ||||
| 	Usage:     "Delete one or more existing containers", | ||||
| 	ArgsUsage: "[flags] CONTAINER [CONTAINER, ...]", | ||||
| 	Aliases:   []string{"del", "remove", "rm"}, | ||||
| 	Flags: []cli.Flag{ | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "keep-snapshot", | ||||
| 			Usage: "Do not clean up snapshot with container", | ||||
| 		}, | ||||
| @@ -171,7 +171,7 @@ var deleteCommand = cli.Command{ | ||||
| 		if context.NArg() == 0 { | ||||
| 			return fmt.Errorf("must specify at least one container to delete: %w", errdefs.ErrInvalidArgument) | ||||
| 		} | ||||
| 		for _, arg := range context.Args() { | ||||
| 		for _, arg := range context.Args().Slice() { | ||||
| 			if err := deleteContainer(ctx, client, arg, deleteOpts...); err != nil { | ||||
| 				if exitErr == nil { | ||||
| 					exitErr = err | ||||
| @@ -206,7 +206,7 @@ func deleteContainer(ctx context.Context, client *containerd.Client, id string, | ||||
|  | ||||
| } | ||||
|  | ||||
| var setLabelsCommand = cli.Command{ | ||||
| var setLabelsCommand = &cli.Command{ | ||||
| 	Name:        "label", | ||||
| 	Usage:       "Set and clear labels for a container", | ||||
| 	ArgsUsage:   "[flags] CONTAINER [<key>=<value>, ...]", | ||||
| @@ -244,12 +244,12 @@ var setLabelsCommand = cli.Command{ | ||||
| 	}, | ||||
| } | ||||
|  | ||||
| var infoCommand = cli.Command{ | ||||
| var infoCommand = &cli.Command{ | ||||
| 	Name:      "info", | ||||
| 	Usage:     "Get info about a container", | ||||
| 	ArgsUsage: "CONTAINER", | ||||
| 	Flags: []cli.Flag{ | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "spec", | ||||
| 			Usage: "Only display the spec", | ||||
| 		}, | ||||
|   | ||||
| @@ -26,19 +26,19 @@ import ( | ||||
| 	"github.com/containerd/containerd/v2/pkg/cio" | ||||
| 	"github.com/containerd/errdefs" | ||||
| 	"github.com/containerd/log" | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| ) | ||||
|  | ||||
| var restoreCommand = cli.Command{ | ||||
| var restoreCommand = &cli.Command{ | ||||
| 	Name:      "restore", | ||||
| 	Usage:     "Restore a container from checkpoint", | ||||
| 	ArgsUsage: "CONTAINER REF", | ||||
| 	Flags: []cli.Flag{ | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "rw", | ||||
| 			Usage: "Restore the rw layer from the checkpoint", | ||||
| 		}, | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "live", | ||||
| 			Usage: "Restore the runtime and memory data from the checkpoint", | ||||
| 		}, | ||||
| @@ -136,7 +136,7 @@ var restoreCommand = cli.Command{ | ||||
| 			return err | ||||
| 		} | ||||
| 		if code != 0 { | ||||
| 			return cli.NewExitError("", int(code)) | ||||
| 			return cli.Exit("", int(code)) | ||||
| 		} | ||||
| 		return nil | ||||
| 	}, | ||||
|   | ||||
| @@ -35,12 +35,12 @@ import ( | ||||
| 	units "github.com/docker/go-units" | ||||
| 	digest "github.com/opencontainers/go-digest" | ||||
| 	ocispec "github.com/opencontainers/image-spec/specs-go/v1" | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| ) | ||||
|  | ||||
| var ( | ||||
| 	// Command is the cli command for managing content | ||||
| 	Command = cli.Command{ | ||||
| 	Command = &cli.Command{ | ||||
| 		Name:  "content", | ||||
| 		Usage: "Manage content", | ||||
| 		Subcommands: cli.Commands{ | ||||
| @@ -59,7 +59,7 @@ var ( | ||||
| 		}, | ||||
| 	} | ||||
|  | ||||
| 	getCommand = cli.Command{ | ||||
| 	getCommand = &cli.Command{ | ||||
| 		Name:        "get", | ||||
| 		Usage:       "Get the data for an object", | ||||
| 		ArgsUsage:   "[<digest>, ...]", | ||||
| @@ -88,17 +88,17 @@ var ( | ||||
| 		}, | ||||
| 	} | ||||
|  | ||||
| 	ingestCommand = cli.Command{ | ||||
| 	ingestCommand = &cli.Command{ | ||||
| 		Name:        "ingest", | ||||
| 		Usage:       "Accept content into the store", | ||||
| 		ArgsUsage:   "[flags] <key>", | ||||
| 		Description: "ingest objects into the local content store", | ||||
| 		Flags: []cli.Flag{ | ||||
| 			cli.Int64Flag{ | ||||
| 			&cli.Int64Flag{ | ||||
| 				Name:  "expected-size", | ||||
| 				Usage: "Validate against provided size", | ||||
| 			}, | ||||
| 			cli.StringFlag{ | ||||
| 			&cli.StringFlag{ | ||||
| 				Name:  "expected-digest", | ||||
| 				Usage: "Verify content against expected digest", | ||||
| 			}, | ||||
| @@ -130,18 +130,19 @@ var ( | ||||
| 		}, | ||||
| 	} | ||||
|  | ||||
| 	activeIngestCommand = cli.Command{ | ||||
| 	activeIngestCommand = &cli.Command{ | ||||
| 		Name:        "active", | ||||
| 		Usage:       "Display active transfers", | ||||
| 		ArgsUsage:   "[flags] [<regexp>]", | ||||
| 		Description: "display the ongoing transfers", | ||||
| 		Flags: []cli.Flag{ | ||||
| 			cli.DurationFlag{ | ||||
| 				Name:   "timeout, t", | ||||
| 				Usage:  "Total timeout for fetch", | ||||
| 				EnvVar: "CONTAINERD_FETCH_TIMEOUT", | ||||
| 			&cli.DurationFlag{ | ||||
| 				Name:    "timeout", | ||||
| 				Aliases: []string{"t"}, | ||||
| 				Usage:   "Total timeout for fetch", | ||||
| 				EnvVars: []string{"CONTAINERD_FETCH_TIMEOUT"}, | ||||
| 			}, | ||||
| 			cli.StringFlag{ | ||||
| 			&cli.StringFlag{ | ||||
| 				Name:  "root", | ||||
| 				Usage: "Path to content store root", | ||||
| 				Value: "/tmp/content", // TODO(stevvooe): for now, just use the PWD/.content | ||||
| @@ -172,22 +173,23 @@ var ( | ||||
| 		}, | ||||
| 	} | ||||
|  | ||||
| 	listCommand = cli.Command{ | ||||
| 	listCommand = &cli.Command{ | ||||
| 		Name:        "list", | ||||
| 		Aliases:     []string{"ls"}, | ||||
| 		Usage:       "List all blobs in the store", | ||||
| 		ArgsUsage:   "[flags]", | ||||
| 		Description: "list blobs in the content store", | ||||
| 		Flags: []cli.Flag{ | ||||
| 			cli.BoolFlag{ | ||||
| 				Name:  "quiet, q", | ||||
| 				Usage: "Print only the blob digest", | ||||
| 			&cli.BoolFlag{ | ||||
| 				Name:    "quiet", | ||||
| 				Aliases: []string{"q"}, | ||||
| 				Usage:   "Print only the blob digest", | ||||
| 			}, | ||||
| 		}, | ||||
| 		Action: func(context *cli.Context) error { | ||||
| 			var ( | ||||
| 				quiet = context.Bool("quiet") | ||||
| 				args  = []string(context.Args()) | ||||
| 				args  = context.Args().Slice() | ||||
| 			) | ||||
| 			client, ctx, cancel, err := commands.NewClient(context) | ||||
| 			if err != nil { | ||||
| @@ -232,7 +234,7 @@ var ( | ||||
| 		}, | ||||
| 	} | ||||
|  | ||||
| 	setLabelsCommand = cli.Command{ | ||||
| 	setLabelsCommand = &cli.Command{ | ||||
| 		Name:        "label", | ||||
| 		Usage:       "Add labels to content", | ||||
| 		ArgsUsage:   "<digest> [<label>=<value> ...]", | ||||
| @@ -286,20 +288,20 @@ var ( | ||||
| 		}, | ||||
| 	} | ||||
|  | ||||
| 	editCommand = cli.Command{ | ||||
| 	editCommand = &cli.Command{ | ||||
| 		Name:        "edit", | ||||
| 		Usage:       "Edit a blob and return a new digest", | ||||
| 		ArgsUsage:   "[flags] <digest>", | ||||
| 		Description: "edit a blob and return a new digest", | ||||
| 		Flags: []cli.Flag{ | ||||
| 			cli.StringFlag{ | ||||
| 			&cli.StringFlag{ | ||||
| 				Name:  "validate", | ||||
| 				Usage: "Validate the result against a format (json, mediatype, etc.)", | ||||
| 			}, | ||||
| 			cli.StringFlag{ | ||||
| 				Name:   "editor", | ||||
| 				Usage:  "Select editor (vim, emacs, etc.)", | ||||
| 				EnvVar: "EDITOR", | ||||
| 			&cli.StringFlag{ | ||||
| 				Name:    "editor", | ||||
| 				Usage:   "Select editor (vim, emacs, etc.)", | ||||
| 				EnvVars: []string{"EDITOR"}, | ||||
| 			}, | ||||
| 		}, | ||||
| 		Action: func(context *cli.Context) error { | ||||
| @@ -355,7 +357,7 @@ var ( | ||||
| 		}, | ||||
| 	} | ||||
|  | ||||
| 	deleteCommand = cli.Command{ | ||||
| 	deleteCommand = &cli.Command{ | ||||
| 		Name:      "delete", | ||||
| 		Aliases:   []string{"del", "remove", "rm"}, | ||||
| 		Usage:     "Permanently delete one or more blobs", | ||||
| @@ -364,7 +366,7 @@ var ( | ||||
| 	blobs are printed to stdout.`, | ||||
| 		Action: func(context *cli.Context) error { | ||||
| 			var ( | ||||
| 				args      = []string(context.Args()) | ||||
| 				args      = context.Args().Slice() | ||||
| 				exitError error | ||||
| 			) | ||||
| 			client, ctx, cancel, err := commands.NewClient(context) | ||||
| @@ -404,7 +406,7 @@ var ( | ||||
| 	// TODO(stevvooe): Create "multi-fetch" mode that just takes a remote | ||||
| 	// then receives object/hint lines on stdin, returning content as | ||||
| 	// needed. | ||||
| 	fetchObjectCommand = cli.Command{ | ||||
| 	fetchObjectCommand = &cli.Command{ | ||||
| 		Name:        "fetch-object", | ||||
| 		Usage:       "Retrieve objects from a remote", | ||||
| 		ArgsUsage:   "[flags] <remote> <object> [<hint>, ...]", | ||||
| @@ -446,13 +448,13 @@ var ( | ||||
| 		}, | ||||
| 	} | ||||
|  | ||||
| 	fetchBlobCommand = cli.Command{ | ||||
| 	fetchBlobCommand = &cli.Command{ | ||||
| 		Name:        "fetch-blob", | ||||
| 		Usage:       "Retrieve blobs from a remote", | ||||
| 		ArgsUsage:   "[flags] <remote> [<digest>, ...]", | ||||
| 		Description: `Fetch blobs by digests from a remote.`, | ||||
| 		Flags: append(commands.RegistryFlags, []cli.Flag{ | ||||
| 			cli.StringFlag{ | ||||
| 			&cli.StringFlag{ | ||||
| 				Name:  "media-type", | ||||
| 				Usage: "Specify target mediatype for request header", | ||||
| 			}, | ||||
| @@ -506,7 +508,7 @@ var ( | ||||
| 		}, | ||||
| 	} | ||||
|  | ||||
| 	pushObjectCommand = cli.Command{ | ||||
| 	pushObjectCommand = &cli.Command{ | ||||
| 		Name:        "push-object", | ||||
| 		Usage:       "Push an object to a remote", | ||||
| 		ArgsUsage:   "[flags] <remote> <object> <type>", | ||||
|   | ||||
| @@ -37,10 +37,10 @@ import ( | ||||
| 	"github.com/containerd/platforms" | ||||
| 	"github.com/opencontainers/go-digest" | ||||
| 	ocispec "github.com/opencontainers/image-spec/specs-go/v1" | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| ) | ||||
|  | ||||
| var fetchCommand = cli.Command{ | ||||
| var fetchCommand = &cli.Command{ | ||||
| 	Name:      "fetch", | ||||
| 	Usage:     "Fetch all content for an image into containerd", | ||||
| 	ArgsUsage: "[flags] <remote> <object>", | ||||
| @@ -59,24 +59,24 @@ content and snapshots ready for a direct use via the 'ctr run'. | ||||
|  | ||||
| Most of this is experimental and there are few leaps to make this work.`, | ||||
| 	Flags: append(commands.RegistryFlags, commands.LabelFlag, | ||||
| 		cli.StringSliceFlag{ | ||||
| 		&cli.StringSliceFlag{ | ||||
| 			Name:  "platform", | ||||
| 			Usage: "Pull content from a specific platform", | ||||
| 		}, | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "all-platforms", | ||||
| 			Usage: "Pull content from all platforms", | ||||
| 		}, | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:   "all-metadata", | ||||
| 			Usage:  "(Deprecated: use skip-metadata) Pull metadata for all platforms", | ||||
| 			Hidden: true, | ||||
| 		}, | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "skip-metadata", | ||||
| 			Usage: "Skips metadata for unused platforms (Image may be unable to be pushed without metadata)", | ||||
| 		}, | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "metadata-only", | ||||
| 			Usage: "Pull all metadata including manifests and configs", | ||||
| 		}, | ||||
| @@ -131,7 +131,7 @@ func NewFetchConfig(ctx context.Context, clicontext *cli.Context) (*FetchConfig, | ||||
| 		Labels:    clicontext.StringSlice("label"), | ||||
| 		TraceHTTP: clicontext.Bool("http-trace"), | ||||
| 	} | ||||
| 	if !clicontext.GlobalBool("debug") { | ||||
| 	if !clicontext.Bool("debug") { | ||||
| 		config.ProgressOutput = os.Stdout | ||||
| 	} | ||||
| 	if !clicontext.Bool("all-platforms") { | ||||
|   | ||||
| @@ -25,7 +25,7 @@ import ( | ||||
| 	"github.com/containerd/containerd/v2/core/content" | ||||
| 	"github.com/containerd/containerd/v2/core/leases" | ||||
| 	"github.com/containerd/log" | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| ) | ||||
|  | ||||
| const ( | ||||
| @@ -34,17 +34,17 @@ const ( | ||||
| ) | ||||
|  | ||||
| var pruneFlags = []cli.Flag{ | ||||
| 	cli.BoolFlag{ | ||||
| 	&cli.BoolFlag{ | ||||
| 		Name:  "async", | ||||
| 		Usage: "Allow garbage collection to cleanup asynchronously", | ||||
| 	}, | ||||
| 	cli.BoolFlag{ | ||||
| 	&cli.BoolFlag{ | ||||
| 		Name:  "dry", | ||||
| 		Usage: "Just show updates without applying (enables debug logging)", | ||||
| 	}, | ||||
| } | ||||
|  | ||||
| var pruneCommand = cli.Command{ | ||||
| var pruneCommand = &cli.Command{ | ||||
| 	Name:  "prune", | ||||
| 	Usage: "Prunes content from the content store", | ||||
| 	Subcommands: cli.Commands{ | ||||
| @@ -52,7 +52,7 @@ var pruneCommand = cli.Command{ | ||||
| 	}, | ||||
| } | ||||
|  | ||||
| var pruneReferencesCommand = cli.Command{ | ||||
| var pruneReferencesCommand = &cli.Command{ | ||||
| 	Name:  "references", | ||||
| 	Usage: "Prunes preference labels from the content store (layers only by default)", | ||||
| 	Flags: pruneFlags, | ||||
|   | ||||
| @@ -22,7 +22,7 @@ import ( | ||||
| 	"text/tabwriter" | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
|  | ||||
| 	api "github.com/containerd/containerd/v2/api/services/introspection/v1" | ||||
| 	"github.com/containerd/containerd/v2/cmd/ctr/commands" | ||||
| @@ -31,17 +31,17 @@ import ( | ||||
| ) | ||||
|  | ||||
| // Command is the parent for all commands under "deprecations" | ||||
| var Command = cli.Command{ | ||||
| var Command = &cli.Command{ | ||||
| 	Name: "deprecations", | ||||
| 	Subcommands: []cli.Command{ | ||||
| 	Subcommands: []*cli.Command{ | ||||
| 		listCommand, | ||||
| 	}, | ||||
| } | ||||
| var listCommand = cli.Command{ | ||||
| var listCommand = &cli.Command{ | ||||
| 	Name:  "list", | ||||
| 	Usage: "Print warnings for deprecations", | ||||
| 	Flags: []cli.Flag{ | ||||
| 		cli.StringFlag{ | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:  "format", | ||||
| 			Usage: "output format to use (Examples: 'default', 'json')", | ||||
| 		}, | ||||
|   | ||||
| @@ -24,14 +24,14 @@ import ( | ||||
| 	"github.com/containerd/containerd/v2/pkg/events" | ||||
| 	"github.com/containerd/log" | ||||
| 	"github.com/containerd/typeurl/v2" | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
|  | ||||
| 	// Register grpc event types | ||||
| 	_ "github.com/containerd/containerd/v2/api/events" | ||||
| ) | ||||
|  | ||||
| // Command is the cli command for displaying containerd events | ||||
| var Command = cli.Command{ | ||||
| var Command = &cli.Command{ | ||||
| 	Name:    "events", | ||||
| 	Aliases: []string{"event"}, | ||||
| 	Usage:   "Display containerd events", | ||||
| @@ -42,7 +42,7 @@ var Command = cli.Command{ | ||||
| 		} | ||||
| 		defer cancel() | ||||
| 		eventsClient := client.EventService() | ||||
| 		eventsCh, errCh := eventsClient.Subscribe(ctx, context.Args()...) | ||||
| 		eventsCh, errCh := eventsClient.Subscribe(ctx, context.Args().Slice()...) | ||||
| 		for { | ||||
| 			var e *events.Envelope | ||||
| 			select { | ||||
|   | ||||
| @@ -24,10 +24,10 @@ import ( | ||||
| 	"github.com/containerd/containerd/v2/core/images/converter" | ||||
| 	"github.com/containerd/containerd/v2/core/images/converter/uncompress" | ||||
| 	"github.com/containerd/platforms" | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| ) | ||||
|  | ||||
| var convertCommand = cli.Command{ | ||||
| var convertCommand = &cli.Command{ | ||||
| 	Name:      "convert", | ||||
| 	Usage:     "Convert an image", | ||||
| 	ArgsUsage: "[flags] <source_ref> <target_ref>", | ||||
| @@ -40,21 +40,21 @@ When '--all-platforms' is given all images in a manifest list must be available. | ||||
| `, | ||||
| 	Flags: []cli.Flag{ | ||||
| 		// generic flags | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "uncompress", | ||||
| 			Usage: "Convert tar.gz layers to uncompressed tar layers", | ||||
| 		}, | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "oci", | ||||
| 			Usage: "Convert Docker media types to OCI media types", | ||||
| 		}, | ||||
| 		// platform flags | ||||
| 		cli.StringSliceFlag{ | ||||
| 		&cli.StringSliceFlag{ | ||||
| 			Name:  "platform", | ||||
| 			Usage: "Pull content from a specific platform", | ||||
| 			Value: &cli.StringSlice{}, | ||||
| 			Value: cli.NewStringSlice(), | ||||
| 		}, | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "all-platforms", | ||||
| 			Usage: "Exports content from all platforms", | ||||
| 		}, | ||||
|   | ||||
| @@ -22,7 +22,7 @@ import ( | ||||
| 	"io" | ||||
| 	"os" | ||||
|  | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
|  | ||||
| 	"github.com/containerd/containerd/v2/cmd/ctr/commands" | ||||
| 	"github.com/containerd/containerd/v2/core/images/archive" | ||||
| @@ -32,7 +32,7 @@ import ( | ||||
| 	"github.com/containerd/platforms" | ||||
| ) | ||||
|  | ||||
| var exportCommand = cli.Command{ | ||||
| var exportCommand = &cli.Command{ | ||||
| 	Name:      "export", | ||||
| 	Usage:     "Export images", | ||||
| 	ArgsUsage: "[flags] <out> <image> ...", | ||||
| @@ -44,24 +44,24 @@ Use '--platform' to define the output platform. | ||||
| When '--all-platforms' is given all images in a manifest list must be available. | ||||
| `, | ||||
| 	Flags: []cli.Flag{ | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "skip-manifest-json", | ||||
| 			Usage: "Do not add Docker compatible manifest.json to archive", | ||||
| 		}, | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "skip-non-distributable", | ||||
| 			Usage: "Do not add non-distributable blobs such as Windows layers to archive", | ||||
| 		}, | ||||
| 		cli.StringSliceFlag{ | ||||
| 		&cli.StringSliceFlag{ | ||||
| 			Name:  "platform", | ||||
| 			Usage: "Pull content from a specific platform", | ||||
| 			Value: &cli.StringSlice{}, | ||||
| 			Value: cli.NewStringSlice(), | ||||
| 		}, | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "all-platforms", | ||||
| 			Usage: "Exports content from all platforms", | ||||
| 		}, | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "local", | ||||
| 			Usage: "Run export locally rather than through transfer API", | ||||
| 		}, | ||||
|   | ||||
| @@ -30,11 +30,11 @@ import ( | ||||
| 	"github.com/containerd/errdefs" | ||||
| 	"github.com/containerd/log" | ||||
| 	"github.com/containerd/platforms" | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| ) | ||||
|  | ||||
| // Command is the cli command for managing images | ||||
| var Command = cli.Command{ | ||||
| var Command = &cli.Command{ | ||||
| 	Name:    "images", | ||||
| 	Aliases: []string{"image", "i"}, | ||||
| 	Usage:   "Manage images", | ||||
| @@ -57,21 +57,22 @@ var Command = cli.Command{ | ||||
| 	}, | ||||
| } | ||||
|  | ||||
| var listCommand = cli.Command{ | ||||
| var listCommand = &cli.Command{ | ||||
| 	Name:        "list", | ||||
| 	Aliases:     []string{"ls"}, | ||||
| 	Usage:       "List images known to containerd", | ||||
| 	ArgsUsage:   "[flags] [<filter>, ...]", | ||||
| 	Description: "list images registered with containerd", | ||||
| 	Flags: []cli.Flag{ | ||||
| 		cli.BoolFlag{ | ||||
| 			Name:  "quiet, q", | ||||
| 			Usage: "Print only the image refs", | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:    "quiet", | ||||
| 			Aliases: []string{"q"}, | ||||
| 			Usage:   "Print only the image refs", | ||||
| 		}, | ||||
| 	}, | ||||
| 	Action: func(context *cli.Context) error { | ||||
| 		var ( | ||||
| 			filters = context.Args() | ||||
| 			filters = context.Args().Slice() | ||||
| 			quiet   = context.Bool("quiet") | ||||
| 		) | ||||
| 		client, ctx, cancel, err := commands.NewClient(context) | ||||
| @@ -141,15 +142,16 @@ var listCommand = cli.Command{ | ||||
| 	}, | ||||
| } | ||||
|  | ||||
| var setLabelsCommand = cli.Command{ | ||||
| var setLabelsCommand = &cli.Command{ | ||||
| 	Name:        "label", | ||||
| 	Usage:       "Set and clear labels for an image", | ||||
| 	ArgsUsage:   "[flags] <name> [<key>=<value>, ...]", | ||||
| 	Description: "set and clear labels for an image", | ||||
| 	Flags: []cli.Flag{ | ||||
| 		cli.BoolFlag{ | ||||
| 			Name:  "replace-all, r", | ||||
| 			Usage: "Replace all labels", | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:    "replace-all", | ||||
| 			Aliases: []string{"r"}, | ||||
| 			Usage:   "Replace all labels", | ||||
| 		}, | ||||
| 	}, | ||||
| 	Action: func(context *cli.Context) error { | ||||
| @@ -200,15 +202,16 @@ var setLabelsCommand = cli.Command{ | ||||
| 	}, | ||||
| } | ||||
|  | ||||
| var checkCommand = cli.Command{ | ||||
| var checkCommand = &cli.Command{ | ||||
| 	Name:        "check", | ||||
| 	Usage:       "Check existing images to ensure all content is available locally", | ||||
| 	ArgsUsage:   "[flags] [<filter>, ...]", | ||||
| 	Description: "check existing images to ensure all content is available locally", | ||||
| 	Flags: append([]cli.Flag{ | ||||
| 		cli.BoolFlag{ | ||||
| 			Name:  "quiet, q", | ||||
| 			Usage: "Print only the ready image refs (fully downloaded and unpacked)", | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:    "quiet", | ||||
| 			Aliases: []string{"q"}, | ||||
| 			Usage:   "Print only the ready image refs (fully downloaded and unpacked)", | ||||
| 		}, | ||||
| 	}, commands.SnapshotterFlags...), | ||||
| 	Action: func(context *cli.Context) error { | ||||
| @@ -224,7 +227,7 @@ var checkCommand = cli.Command{ | ||||
|  | ||||
| 		var contentStore = client.ContentStore() | ||||
|  | ||||
| 		args := []string(context.Args()) | ||||
| 		args := context.Args().Slice() | ||||
| 		imageList, err := client.ListImages(ctx, args...) | ||||
| 		if err != nil { | ||||
| 			return fmt.Errorf("failed listing images: %w", err) | ||||
| @@ -313,14 +316,14 @@ var checkCommand = cli.Command{ | ||||
| 	}, | ||||
| } | ||||
|  | ||||
| var removeCommand = cli.Command{ | ||||
| var removeCommand = &cli.Command{ | ||||
| 	Name:        "delete", | ||||
| 	Aliases:     []string{"del", "remove", "rm"}, | ||||
| 	Usage:       "Remove one or more images by reference", | ||||
| 	ArgsUsage:   "[flags] <ref> [<ref>, ...]", | ||||
| 	Description: "remove one or more images by reference", | ||||
| 	Flags: []cli.Flag{ | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "sync", | ||||
| 			Usage: "Synchronously remove image and all associated resources", | ||||
| 		}, | ||||
| @@ -335,7 +338,7 @@ var removeCommand = cli.Command{ | ||||
| 			exitErr    error | ||||
| 			imageStore = client.ImageService() | ||||
| 		) | ||||
| 		for i, target := range context.Args() { | ||||
| 		for i, target := range context.Args().Slice() { | ||||
| 			var opts []images.DeleteOpt | ||||
| 			if context.Bool("sync") && i == context.NArg()-1 { | ||||
| 				opts = append(opts, images.SynchronousDelete()) | ||||
| @@ -359,11 +362,11 @@ var removeCommand = cli.Command{ | ||||
| 	}, | ||||
| } | ||||
|  | ||||
| var pruneCommand = cli.Command{ | ||||
| var pruneCommand = &cli.Command{ | ||||
| 	Name:  "prune", | ||||
| 	Usage: "Remove unused images", | ||||
| 	Flags: []cli.Flag{ | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "all", // TODO: add more filters | ||||
| 			Usage: "Remove all unused images, not just dangling ones (if all is not specified no images will be pruned)", | ||||
| 		}, | ||||
|   | ||||
| @@ -23,7 +23,7 @@ import ( | ||||
| 	"time" | ||||
|  | ||||
| 	ocispec "github.com/opencontainers/image-spec/specs-go/v1" | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
|  | ||||
| 	containerd "github.com/containerd/containerd/v2/client" | ||||
| 	"github.com/containerd/containerd/v2/cmd/ctr/commands" | ||||
| @@ -35,7 +35,7 @@ import ( | ||||
| 	"github.com/containerd/platforms" | ||||
| ) | ||||
|  | ||||
| var importCommand = cli.Command{ | ||||
| var importCommand = &cli.Command{ | ||||
| 	Name:      "import", | ||||
| 	Usage:     "Import images", | ||||
| 	ArgsUsage: "[flags] <in>", | ||||
| @@ -57,44 +57,44 @@ If foobar.tar contains an OCI ref named "latest" and anonymous ref "sha256:deadb | ||||
| "foo/bar:latest" and "foo/bar@sha256:deadbeef" images in the containerd store. | ||||
| `, | ||||
| 	Flags: append([]cli.Flag{ | ||||
| 		cli.StringFlag{ | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:  "base-name", | ||||
| 			Value: "", | ||||
| 			Usage: "Base image name for added images, when provided only images with this name prefix are imported", | ||||
| 		}, | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "digests", | ||||
| 			Usage: "Whether to create digest images (default: false)", | ||||
| 		}, | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "skip-digest-for-named", | ||||
| 			Usage: "Skip applying --digests option to images named in the importing tar (use it in conjunction with --digests)", | ||||
| 		}, | ||||
| 		cli.StringFlag{ | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:  "index-name", | ||||
| 			Usage: "Image name to keep index as, by default index is discarded", | ||||
| 		}, | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "all-platforms", | ||||
| 			Usage: "Imports content for all platforms, false by default", | ||||
| 		}, | ||||
| 		cli.StringFlag{ | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:  "platform", | ||||
| 			Usage: "Imports content for specific platform", | ||||
| 		}, | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "no-unpack", | ||||
| 			Usage: "Skip unpacking the images, cannot be used with --discard-unpacked-layers, false by default", | ||||
| 		}, | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "local", | ||||
| 			Usage: "Run import locally rather than through transfer API", | ||||
| 		}, | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "compress-blobs", | ||||
| 			Usage: "Compress uncompressed blobs when creating manifest (Docker format only)", | ||||
| 		}, | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "discard-unpacked-layers", | ||||
| 			Usage: "Allow the garbage collector to clean layers up from the content store after unpacking, cannot be used with --no-unpack, false by default", | ||||
| 		}, | ||||
|   | ||||
| @@ -21,17 +21,17 @@ import ( | ||||
|  | ||||
| 	"github.com/containerd/containerd/v2/cmd/ctr/commands" | ||||
| 	"github.com/containerd/containerd/v2/pkg/display" | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| ) | ||||
|  | ||||
| var inspectCommand = cli.Command{ | ||||
| var inspectCommand = &cli.Command{ | ||||
| 	Name:        "inspect", | ||||
| 	Aliases:     []string{"i"}, | ||||
| 	Usage:       "inspect an image", | ||||
| 	ArgsUsage:   "<image> [flags]", | ||||
| 	Description: `Inspect an image`, | ||||
| 	Flags: []cli.Flag{ | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "content", | ||||
| 			Usage: "Show JSON content", | ||||
| 		}, | ||||
|   | ||||
| @@ -28,10 +28,10 @@ import ( | ||||
| 	"github.com/containerd/errdefs" | ||||
| 	"github.com/containerd/platforms" | ||||
| 	"github.com/opencontainers/image-spec/identity" | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| ) | ||||
|  | ||||
| var mountCommand = cli.Command{ | ||||
| var mountCommand = &cli.Command{ | ||||
| 	Name:      "mount", | ||||
| 	Usage:     "Mount an image to a target path", | ||||
| 	ArgsUsage: "[flags] <ref> <target>", | ||||
| @@ -40,11 +40,11 @@ var mountCommand = cli.Command{ | ||||
| When you are done, use the unmount command. | ||||
| `, | ||||
| 	Flags: append(append(commands.RegistryFlags, append(commands.SnapshotterFlags, commands.LabelFlag)...), | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "rw", | ||||
| 			Usage: "Enable write support on the mount", | ||||
| 		}, | ||||
| 		cli.StringFlag{ | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:  "platform", | ||||
| 			Usage: "Mount the image for the specified platform", | ||||
| 			Value: platforms.DefaultString(), | ||||
|   | ||||
| @@ -36,10 +36,10 @@ import ( | ||||
| 	"github.com/containerd/platforms" | ||||
| 	"github.com/opencontainers/image-spec/identity" | ||||
| 	ocispec "github.com/opencontainers/image-spec/specs-go/v1" | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| ) | ||||
|  | ||||
| var pullCommand = cli.Command{ | ||||
| var pullCommand = &cli.Command{ | ||||
| 	Name:      "pull", | ||||
| 	Usage:     "Pull an image from a remote", | ||||
| 	ArgsUsage: "[flags] <ref>", | ||||
| @@ -53,33 +53,33 @@ command. As part of this process, we do the following: | ||||
| 3. Register metadata for the image. | ||||
| `, | ||||
| 	Flags: append(append(commands.RegistryFlags, append(commands.SnapshotterFlags, commands.LabelFlag)...), | ||||
| 		cli.StringSliceFlag{ | ||||
| 		&cli.StringSliceFlag{ | ||||
| 			Name:  "platform", | ||||
| 			Usage: "Pull content from a specific platform", | ||||
| 			Value: &cli.StringSlice{}, | ||||
| 			Value: cli.NewStringSlice(), | ||||
| 		}, | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "all-platforms", | ||||
| 			Usage: "Pull content and metadata from all platforms", | ||||
| 		}, | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:   "all-metadata", | ||||
| 			Usage:  "(Deprecated: use skip-metadata) Pull metadata for all platforms", | ||||
| 			Hidden: true, | ||||
| 		}, | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "skip-metadata", | ||||
| 			Usage: "Skips metadata for unused platforms (Image may be unable to be pushed without metadata)", | ||||
| 		}, | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "print-chainid", | ||||
| 			Usage: "Print the resulting image's chain ID", | ||||
| 		}, | ||||
| 		cli.IntFlag{ | ||||
| 		&cli.IntFlag{ | ||||
| 			Name:  "max-concurrent-downloads", | ||||
| 			Usage: "Set the max concurrent downloads for each pull", | ||||
| 		}, | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "local", | ||||
| 			Usage: "Fetch content from local client rather than using transfer service", | ||||
| 		}, | ||||
|   | ||||
| @@ -40,11 +40,11 @@ import ( | ||||
| 	"github.com/containerd/platforms" | ||||
| 	digest "github.com/opencontainers/go-digest" | ||||
| 	ocispec "github.com/opencontainers/image-spec/specs-go/v1" | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| 	"golang.org/x/sync/errgroup" | ||||
| ) | ||||
|  | ||||
| var pushCommand = cli.Command{ | ||||
| var pushCommand = &cli.Command{ | ||||
| 	Name:      "push", | ||||
| 	Usage:     "Push an image to a remote", | ||||
| 	ArgsUsage: "[flags] <remote> [<local>]", | ||||
| @@ -57,24 +57,24 @@ var pushCommand = cli.Command{ | ||||
| 	creating the associated configuration, and creating the manifest | ||||
| 	which references those resources. | ||||
| `, | ||||
| 	Flags: append(commands.RegistryFlags, cli.StringFlag{ | ||||
| 	Flags: append(commands.RegistryFlags, &cli.StringFlag{ | ||||
| 		Name:  "manifest", | ||||
| 		Usage: "Digest of manifest", | ||||
| 	}, cli.StringFlag{ | ||||
| 	}, &cli.StringFlag{ | ||||
| 		Name:  "manifest-type", | ||||
| 		Usage: "Media type of manifest digest", | ||||
| 		Value: ocispec.MediaTypeImageManifest, | ||||
| 	}, cli.StringSliceFlag{ | ||||
| 	}, &cli.StringSliceFlag{ | ||||
| 		Name:  "platform", | ||||
| 		Usage: "Push content from a specific platform", | ||||
| 		Value: &cli.StringSlice{}, | ||||
| 	}, cli.IntFlag{ | ||||
| 		Value: cli.NewStringSlice(), | ||||
| 	}, &cli.IntFlag{ | ||||
| 		Name:  "max-concurrent-uploaded-layers", | ||||
| 		Usage: "Set the max concurrent uploaded layers for each push", | ||||
| 	}, cli.BoolFlag{ | ||||
| 	}, &cli.BoolFlag{ | ||||
| 		Name:  "local", | ||||
| 		Usage: "Push content from local client rather than using transfer service", | ||||
| 	}, cli.BoolFlag{ | ||||
| 	}, &cli.BoolFlag{ | ||||
| 		Name:  "allow-non-distributable-blobs", | ||||
| 		Usage: "Allow pushing blobs that are marked as non-distributable", | ||||
| 	}), | ||||
| @@ -82,7 +82,7 @@ var pushCommand = cli.Command{ | ||||
| 		var ( | ||||
| 			ref   = context.Args().First() | ||||
| 			local = context.Args().Get(1) | ||||
| 			debug = context.GlobalBool("debug") | ||||
| 			debug = context.Bool("debug") | ||||
| 			desc  ocispec.Descriptor | ||||
| 		) | ||||
| 		if ref == "" { | ||||
|   | ||||
| @@ -19,7 +19,7 @@ package images | ||||
| import ( | ||||
| 	"fmt" | ||||
|  | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
|  | ||||
| 	"github.com/containerd/containerd/v2/cmd/ctr/commands" | ||||
| 	"github.com/containerd/containerd/v2/core/transfer/image" | ||||
| @@ -27,21 +27,21 @@ import ( | ||||
| 	"github.com/distribution/reference" | ||||
| ) | ||||
|  | ||||
| var tagCommand = cli.Command{ | ||||
| var tagCommand = &cli.Command{ | ||||
| 	Name:        "tag", | ||||
| 	Usage:       "Tag an image", | ||||
| 	ArgsUsage:   "[flags] <source_ref> <target_ref> [<target_ref>, ...]", | ||||
| 	Description: `Tag an image for use in containerd.`, | ||||
| 	Flags: []cli.Flag{ | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "force", | ||||
| 			Usage: "Force target_ref to be created, regardless if it already exists", | ||||
| 		}, | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "local", | ||||
| 			Usage: "Run tag locally rather than through transfer API", | ||||
| 		}, | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "skip-reference-check", | ||||
| 			Usage: "Skip the strict check for reference names", | ||||
| 		}, | ||||
| @@ -64,7 +64,7 @@ var tagCommand = cli.Command{ | ||||
| 		defer cancel() | ||||
|  | ||||
| 		if !context.Bool("local") { | ||||
| 			for _, targetRef := range context.Args()[1:] { | ||||
| 			for _, targetRef := range context.Args().Slice()[1:] { | ||||
| 				if !context.Bool("skip-reference-check") { | ||||
| 					if _, err := reference.ParseAnyReference(targetRef); err != nil { | ||||
| 						return fmt.Errorf("error parsing reference: %q is not a valid repository/tag %v", targetRef, err) | ||||
| @@ -91,7 +91,7 @@ var tagCommand = cli.Command{ | ||||
| 			return err | ||||
| 		} | ||||
| 		// Support multiple references for one command run | ||||
| 		for _, targetRef := range context.Args()[1:] { | ||||
| 		for _, targetRef := range context.Args().Slice()[1:] { | ||||
| 			if !context.Bool("skip-reference-check") { | ||||
| 				if _, err := reference.ParseAnyReference(targetRef); err != nil { | ||||
| 					return fmt.Errorf("error parsing reference: %q is not a valid repository/tag %v", targetRef, err) | ||||
|   | ||||
| @@ -23,16 +23,16 @@ import ( | ||||
| 	"github.com/containerd/containerd/v2/core/leases" | ||||
| 	"github.com/containerd/containerd/v2/core/mount" | ||||
| 	"github.com/containerd/errdefs" | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| ) | ||||
|  | ||||
| var unmountCommand = cli.Command{ | ||||
| var unmountCommand = &cli.Command{ | ||||
| 	Name:        "unmount", | ||||
| 	Usage:       "Unmount the image from the target", | ||||
| 	ArgsUsage:   "[flags] <target>", | ||||
| 	Description: "Unmount the image rootfs from the specified target.", | ||||
| 	Flags: append(append(commands.RegistryFlags, append(commands.SnapshotterFlags, commands.LabelFlag)...), | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "rm", | ||||
| 			Usage: "Remove the snapshot after a successful unmount", | ||||
| 		}, | ||||
|   | ||||
| @@ -27,10 +27,10 @@ import ( | ||||
| 	"github.com/containerd/containerd/v2/pkg/progress" | ||||
|  | ||||
| 	"github.com/opencontainers/image-spec/identity" | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| ) | ||||
|  | ||||
| var usageCommand = cli.Command{ | ||||
| var usageCommand = &cli.Command{ | ||||
| 	Name:      "usage", | ||||
| 	Usage:     "Display usage of snapshots for a given image ref", | ||||
| 	ArgsUsage: "[flags] <ref>", | ||||
|   | ||||
| @@ -20,7 +20,7 @@ import ( | ||||
| 	api "github.com/containerd/containerd/v2/api/services/introspection/v1" | ||||
| 	"github.com/containerd/containerd/v2/cmd/ctr/commands" | ||||
| 	ptypes "github.com/containerd/containerd/v2/protobuf/types" | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| ) | ||||
|  | ||||
| type Info struct { | ||||
| @@ -28,7 +28,7 @@ type Info struct { | ||||
| } | ||||
|  | ||||
| // Command is a cli command to output the containerd server info | ||||
| var Command = cli.Command{ | ||||
| var Command = &cli.Command{ | ||||
| 	Name:  "info", | ||||
| 	Usage: "Print the server info", | ||||
| 	Action: func(context *cli.Context) error { | ||||
|   | ||||
| @@ -19,25 +19,27 @@ package install | ||||
| import ( | ||||
| 	containerd "github.com/containerd/containerd/v2/client" | ||||
| 	"github.com/containerd/containerd/v2/cmd/ctr/commands" | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| ) | ||||
|  | ||||
| // Command to install binary packages | ||||
| var Command = cli.Command{ | ||||
| var Command = &cli.Command{ | ||||
| 	Name:        "install", | ||||
| 	Usage:       "Install a new package", | ||||
| 	ArgsUsage:   "<ref>", | ||||
| 	Description: "install a new package", | ||||
| 	Flags: []cli.Flag{ | ||||
| 		cli.BoolFlag{ | ||||
| 			Name:  "libs,l", | ||||
| 			Usage: "Install libs from the image", | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:    "libs", | ||||
| 			Aliases: []string{"l"}, | ||||
| 			Usage:   "Install libs from the image", | ||||
| 		}, | ||||
| 		cli.BoolFlag{ | ||||
| 			Name:  "replace,r", | ||||
| 			Usage: "Replace any binaries or libs in the opt directory", | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:    "replace", | ||||
| 			Aliases: []string{"r"}, | ||||
| 			Usage:   "Replace any binaries or libs in the opt directory", | ||||
| 		}, | ||||
| 		cli.StringFlag{ | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:  "path", | ||||
| 			Usage: "Set an optional install path other than the managed opt directory", | ||||
| 		}, | ||||
|   | ||||
| @@ -26,11 +26,11 @@ import ( | ||||
|  | ||||
| 	"github.com/containerd/containerd/v2/cmd/ctr/commands" | ||||
| 	"github.com/containerd/containerd/v2/core/leases" | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| ) | ||||
|  | ||||
| // Command is the cli command for managing content | ||||
| var Command = cli.Command{ | ||||
| var Command = &cli.Command{ | ||||
| 	Name:  "leases", | ||||
| 	Usage: "Manage leases", | ||||
| 	Subcommands: cli.Commands{ | ||||
| @@ -40,7 +40,7 @@ var Command = cli.Command{ | ||||
| 	}, | ||||
| } | ||||
|  | ||||
| var listCommand = cli.Command{ | ||||
| var listCommand = &cli.Command{ | ||||
|  | ||||
| 	Name:        "list", | ||||
| 	Aliases:     []string{"ls"}, | ||||
| @@ -48,14 +48,15 @@ var listCommand = cli.Command{ | ||||
| 	ArgsUsage:   "[flags] <filter>", | ||||
| 	Description: "list active leases by containerd", | ||||
| 	Flags: []cli.Flag{ | ||||
| 		cli.BoolFlag{ | ||||
| 			Name:  "quiet, q", | ||||
| 			Usage: "Print only the blob digest", | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:    "quiet", | ||||
| 			Aliases: []string{"q"}, | ||||
| 			Usage:   "Print only the blob digest", | ||||
| 		}, | ||||
| 	}, | ||||
| 	Action: func(context *cli.Context) error { | ||||
| 		var ( | ||||
| 			filters = context.Args() | ||||
| 			filters = context.Args().Slice() | ||||
| 			quiet   = context.Bool("quiet") | ||||
| 		) | ||||
| 		client, ctx, cancel, err := commands.NewClient(context) | ||||
| @@ -99,24 +100,25 @@ var listCommand = cli.Command{ | ||||
| 	}, | ||||
| } | ||||
|  | ||||
| var createCommand = cli.Command{ | ||||
| var createCommand = &cli.Command{ | ||||
| 	Name:        "create", | ||||
| 	Usage:       "Create lease", | ||||
| 	ArgsUsage:   "[flags] <label>=<value> ...", | ||||
| 	Description: "create a new lease", | ||||
| 	Flags: []cli.Flag{ | ||||
| 		cli.StringFlag{ | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:  "id", | ||||
| 			Usage: "Set the id for the lease, will be generated by default", | ||||
| 		}, | ||||
| 		cli.DurationFlag{ | ||||
| 			Name:  "expires, x", | ||||
| 			Usage: "Expiration of lease (0 value will not expire)", | ||||
| 			Value: 24 * time.Hour, | ||||
| 		&cli.DurationFlag{ | ||||
| 			Name:    "expires", | ||||
| 			Aliases: []string{"x"}, | ||||
| 			Usage:   "Expiration of lease (0 value will not expire)", | ||||
| 			Value:   24 * time.Hour, | ||||
| 		}, | ||||
| 	}, | ||||
| 	Action: func(context *cli.Context) error { | ||||
| 		var labelstr = context.Args() | ||||
| 		var labelstr = context.Args().Slice() | ||||
| 		client, ctx, cancel, err := commands.NewClient(context) | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| @@ -152,20 +154,20 @@ var createCommand = cli.Command{ | ||||
| 	}, | ||||
| } | ||||
|  | ||||
| var deleteCommand = cli.Command{ | ||||
| var deleteCommand = &cli.Command{ | ||||
| 	Name:        "delete", | ||||
| 	Aliases:     []string{"del", "remove", "rm"}, | ||||
| 	Usage:       "Delete a lease", | ||||
| 	ArgsUsage:   "[flags] <lease id> ...", | ||||
| 	Description: "delete a lease", | ||||
| 	Flags: []cli.Flag{ | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "sync", | ||||
| 			Usage: "Synchronously remove leases and all unreferenced resources", | ||||
| 		}, | ||||
| 	}, | ||||
| 	Action: func(context *cli.Context) error { | ||||
| 		var lids = context.Args() | ||||
| 		var lids = context.Args().Slice() | ||||
| 		if len(lids) == 0 { | ||||
| 			return cli.ShowSubcommandHelp(context) | ||||
| 		} | ||||
|   | ||||
| @@ -27,11 +27,11 @@ import ( | ||||
| 	"github.com/containerd/containerd/v2/cmd/ctr/commands" | ||||
| 	"github.com/containerd/errdefs" | ||||
| 	"github.com/containerd/log" | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| ) | ||||
|  | ||||
| // Command is the cli command for managing namespaces | ||||
| var Command = cli.Command{ | ||||
| var Command = &cli.Command{ | ||||
| 	Name:    "namespaces", | ||||
| 	Aliases: []string{"namespace", "ns"}, | ||||
| 	Usage:   "Manage namespaces", | ||||
| @@ -43,7 +43,7 @@ var Command = cli.Command{ | ||||
| 	}, | ||||
| } | ||||
|  | ||||
| var createCommand = cli.Command{ | ||||
| var createCommand = &cli.Command{ | ||||
| 	Name:        "create", | ||||
| 	Aliases:     []string{"c"}, | ||||
| 	Usage:       "Create a new namespace", | ||||
| @@ -64,7 +64,7 @@ var createCommand = cli.Command{ | ||||
| 	}, | ||||
| } | ||||
|  | ||||
| var setLabelsCommand = cli.Command{ | ||||
| var setLabelsCommand = &cli.Command{ | ||||
| 	Name:        "label", | ||||
| 	Usage:       "Set and clear labels for a namespace", | ||||
| 	ArgsUsage:   "<name> [<key>=<value>, ...]", | ||||
| @@ -89,16 +89,17 @@ var setLabelsCommand = cli.Command{ | ||||
| 	}, | ||||
| } | ||||
|  | ||||
| var listCommand = cli.Command{ | ||||
| var listCommand = &cli.Command{ | ||||
| 	Name:        "list", | ||||
| 	Aliases:     []string{"ls"}, | ||||
| 	Usage:       "List namespaces", | ||||
| 	ArgsUsage:   "[flags]", | ||||
| 	Description: "list namespaces", | ||||
| 	Flags: []cli.Flag{ | ||||
| 		cli.BoolFlag{ | ||||
| 			Name:  "quiet, q", | ||||
| 			Usage: "Print only the namespace name", | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:    "quiet", | ||||
| 			Aliases: []string{"q"}, | ||||
| 			Usage:   "Print only the namespace name", | ||||
| 		}, | ||||
| 	}, | ||||
| 	Action: func(context *cli.Context) error { | ||||
| @@ -141,16 +142,17 @@ var listCommand = cli.Command{ | ||||
| 	}, | ||||
| } | ||||
|  | ||||
| var removeCommand = cli.Command{ | ||||
| var removeCommand = &cli.Command{ | ||||
| 	Name:        "remove", | ||||
| 	Aliases:     []string{"rm"}, | ||||
| 	Usage:       "Remove one or more namespaces", | ||||
| 	ArgsUsage:   "<name> [<name>, ...]", | ||||
| 	Description: "remove one or more namespaces. for now, the namespace must be empty", | ||||
| 	Flags: []cli.Flag{ | ||||
| 		cli.BoolFlag{ | ||||
| 			Name:  "cgroup,c", | ||||
| 			Usage: "Delete the namespace's cgroup", | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:    "cgroup", | ||||
| 			Aliases: []string{"c"}, | ||||
| 			Usage:   "Delete the namespace's cgroup", | ||||
| 		}, | ||||
| 	}, | ||||
| 	Action: func(context *cli.Context) error { | ||||
| @@ -163,7 +165,7 @@ var removeCommand = cli.Command{ | ||||
|  | ||||
| 		opts := deleteOpts(context) | ||||
| 		namespaces := client.NamespaceService() | ||||
| 		for _, target := range context.Args() { | ||||
| 		for _, target := range context.Args().Slice() { | ||||
| 			if err := namespaces.Delete(ctx, target, opts...); err != nil { | ||||
| 				if !errdefs.IsNotFound(err) { | ||||
| 					if exitErr == nil { | ||||
|   | ||||
| @@ -19,7 +19,7 @@ package namespaces | ||||
| import ( | ||||
| 	"github.com/containerd/containerd/v2/core/runtime/opts" | ||||
| 	"github.com/containerd/containerd/v2/pkg/namespaces" | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| ) | ||||
|  | ||||
| func deleteOpts(context *cli.Context) []namespaces.DeleteOpts { | ||||
|   | ||||
| @@ -20,7 +20,7 @@ package namespaces | ||||
|  | ||||
| import ( | ||||
| 	"github.com/containerd/containerd/v2/pkg/namespaces" | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| ) | ||||
|  | ||||
| func deleteOpts(context *cli.Context) []namespaces.DeleteOpts { | ||||
|   | ||||
| @@ -19,7 +19,7 @@ package oci | ||||
| import ( | ||||
| 	"fmt" | ||||
|  | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
|  | ||||
| 	"github.com/containerd/containerd/v2/cmd/ctr/commands" | ||||
| 	"github.com/containerd/containerd/v2/core/containers" | ||||
| @@ -28,19 +28,19 @@ import ( | ||||
| ) | ||||
|  | ||||
| // Command is the parent for all OCI related tools under 'oci' | ||||
| var Command = cli.Command{ | ||||
| var Command = &cli.Command{ | ||||
| 	Name:  "oci", | ||||
| 	Usage: "OCI tools", | ||||
| 	Subcommands: []cli.Command{ | ||||
| 	Subcommands: []*cli.Command{ | ||||
| 		defaultSpecCommand, | ||||
| 	}, | ||||
| } | ||||
|  | ||||
| var defaultSpecCommand = cli.Command{ | ||||
| var defaultSpecCommand = &cli.Command{ | ||||
| 	Name:  "spec", | ||||
| 	Usage: "See the output of the default OCI spec", | ||||
| 	Flags: []cli.Flag{ | ||||
| 		cli.StringFlag{ | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:  "platform", | ||||
| 			Usage: "Platform of the spec to print (Examples: 'linux/arm64', 'windows/amd64')", | ||||
| 		}, | ||||
|   | ||||
| @@ -29,33 +29,35 @@ import ( | ||||
| 	"github.com/containerd/platforms" | ||||
| 	pluginutils "github.com/containerd/plugin" | ||||
| 	v1 "github.com/opencontainers/image-spec/specs-go/v1" | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| 	"google.golang.org/grpc/codes" | ||||
| ) | ||||
|  | ||||
| // Command is a cli command that outputs plugin information | ||||
| var Command = cli.Command{ | ||||
| var Command = &cli.Command{ | ||||
| 	Name:    "plugins", | ||||
| 	Aliases: []string{"plugin"}, | ||||
| 	Usage:   "Provides information about containerd plugins", | ||||
| 	Subcommands: []cli.Command{ | ||||
| 	Subcommands: []*cli.Command{ | ||||
| 		listCommand, | ||||
| 		inspectRuntimeCommand, | ||||
| 	}, | ||||
| } | ||||
|  | ||||
| var listCommand = cli.Command{ | ||||
| var listCommand = &cli.Command{ | ||||
| 	Name:    "list", | ||||
| 	Aliases: []string{"ls"}, | ||||
| 	Usage:   "Lists containerd plugins", | ||||
| 	Flags: []cli.Flag{ | ||||
| 		cli.BoolFlag{ | ||||
| 			Name:  "quiet,q", | ||||
| 			Usage: "Print only the plugin ids", | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:    "quiet", | ||||
| 			Aliases: []string{"q"}, | ||||
| 			Usage:   "Print only the plugin ids", | ||||
| 		}, | ||||
| 		cli.BoolFlag{ | ||||
| 			Name:  "detailed,d", | ||||
| 			Usage: "Print detailed information about each plugin", | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:    "detailed", | ||||
| 			Aliases: []string{"d"}, | ||||
| 			Usage:   "Print detailed information about each plugin", | ||||
| 		}, | ||||
| 	}, | ||||
| 	Action: func(context *cli.Context) error { | ||||
| @@ -69,7 +71,7 @@ var listCommand = cli.Command{ | ||||
| 		} | ||||
| 		defer cancel() | ||||
| 		ps := client.IntrospectionService() | ||||
| 		response, err := ps.Plugins(ctx, context.Args()) | ||||
| 		response, err := ps.Plugins(ctx, context.Args().Slice()) | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| 		} | ||||
| @@ -165,7 +167,7 @@ func prettyPlatforms(pspb []*types.Platform) string { | ||||
| 	return strings.Join(ps, ",") | ||||
| } | ||||
|  | ||||
| var inspectRuntimeCommand = cli.Command{ | ||||
| var inspectRuntimeCommand = &cli.Command{ | ||||
| 	Name:      "inspect-runtime", | ||||
| 	Usage:     "Display runtime info", | ||||
| 	ArgsUsage: "[flags]", | ||||
|   | ||||
| @@ -24,7 +24,7 @@ import ( | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/containerd/containerd/v2/defaults" | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| ) | ||||
|  | ||||
| type pprofDialer struct { | ||||
| @@ -33,17 +33,18 @@ type pprofDialer struct { | ||||
| } | ||||
|  | ||||
| // Command is the cli command for providing golang pprof outputs for containerd | ||||
| var Command = cli.Command{ | ||||
| var Command = &cli.Command{ | ||||
| 	Name:  "pprof", | ||||
| 	Usage: "Provide golang pprof outputs for containerd", | ||||
| 	Flags: []cli.Flag{ | ||||
| 		cli.StringFlag{ | ||||
| 			Name:  "debug-socket, d", | ||||
| 			Usage: "Socket path for containerd's debug server", | ||||
| 			Value: defaults.DefaultDebugAddress, | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:    "debug-socket", | ||||
| 			Aliases: []string{"d"}, | ||||
| 			Usage:   "Socket path for containerd's debug server", | ||||
| 			Value:   defaults.DefaultDebugAddress, | ||||
| 		}, | ||||
| 	}, | ||||
| 	Subcommands: []cli.Command{ | ||||
| 	Subcommands: []*cli.Command{ | ||||
| 		pprofBlockCommand, | ||||
| 		pprofGoroutinesCommand, | ||||
| 		pprofHeapCommand, | ||||
| @@ -53,11 +54,11 @@ var Command = cli.Command{ | ||||
| 	}, | ||||
| } | ||||
|  | ||||
| var pprofGoroutinesCommand = cli.Command{ | ||||
| var pprofGoroutinesCommand = &cli.Command{ | ||||
| 	Name:  "goroutines", | ||||
| 	Usage: "Dump goroutine stack dump", | ||||
| 	Flags: []cli.Flag{ | ||||
| 		cli.UintFlag{ | ||||
| 		&cli.UintFlag{ | ||||
| 			Name:  "debug", | ||||
| 			Usage: "Debug pprof args", | ||||
| 			Value: 2, | ||||
| @@ -77,11 +78,11 @@ var pprofGoroutinesCommand = cli.Command{ | ||||
| 	}, | ||||
| } | ||||
|  | ||||
| var pprofHeapCommand = cli.Command{ | ||||
| var pprofHeapCommand = &cli.Command{ | ||||
| 	Name:  "heap", | ||||
| 	Usage: "Dump heap profile", | ||||
| 	Flags: []cli.Flag{ | ||||
| 		cli.UintFlag{ | ||||
| 		&cli.UintFlag{ | ||||
| 			Name:  "debug", | ||||
| 			Usage: "Debug pprof args", | ||||
| 			Value: 0, | ||||
| @@ -101,16 +102,17 @@ var pprofHeapCommand = cli.Command{ | ||||
| 	}, | ||||
| } | ||||
|  | ||||
| var pprofProfileCommand = cli.Command{ | ||||
| var pprofProfileCommand = &cli.Command{ | ||||
| 	Name:  "profile", | ||||
| 	Usage: "CPU profile", | ||||
| 	Flags: []cli.Flag{ | ||||
| 		cli.DurationFlag{ | ||||
| 			Name:  "seconds,s", | ||||
| 			Usage: "Duration for collection (seconds)", | ||||
| 			Value: 30 * time.Second, | ||||
| 		&cli.DurationFlag{ | ||||
| 			Name:    "seconds", | ||||
| 			Aliases: []string{"s"}, | ||||
| 			Usage:   "Duration for collection (seconds)", | ||||
| 			Value:   30 * time.Second, | ||||
| 		}, | ||||
| 		cli.UintFlag{ | ||||
| 		&cli.UintFlag{ | ||||
| 			Name:  "debug", | ||||
| 			Usage: "Debug pprof args", | ||||
| 			Value: 0, | ||||
| @@ -131,16 +133,17 @@ var pprofProfileCommand = cli.Command{ | ||||
| 	}, | ||||
| } | ||||
|  | ||||
| var pprofTraceCommand = cli.Command{ | ||||
| var pprofTraceCommand = &cli.Command{ | ||||
| 	Name:  "trace", | ||||
| 	Usage: "Collect execution trace", | ||||
| 	Flags: []cli.Flag{ | ||||
| 		cli.DurationFlag{ | ||||
| 			Name:  "seconds,s", | ||||
| 			Usage: "Trace time (seconds)", | ||||
| 			Value: 5 * time.Second, | ||||
| 		&cli.DurationFlag{ | ||||
| 			Name:    "seconds", | ||||
| 			Aliases: []string{"s"}, | ||||
| 			Usage:   "Trace time (seconds)", | ||||
| 			Value:   5 * time.Second, | ||||
| 		}, | ||||
| 		cli.UintFlag{ | ||||
| 		&cli.UintFlag{ | ||||
| 			Name:  "debug", | ||||
| 			Usage: "Debug pprof args", | ||||
| 			Value: 0, | ||||
| @@ -162,11 +165,11 @@ var pprofTraceCommand = cli.Command{ | ||||
| 	}, | ||||
| } | ||||
|  | ||||
| var pprofBlockCommand = cli.Command{ | ||||
| var pprofBlockCommand = &cli.Command{ | ||||
| 	Name:  "block", | ||||
| 	Usage: "Goroutine blocking profile", | ||||
| 	Flags: []cli.Flag{ | ||||
| 		cli.UintFlag{ | ||||
| 		&cli.UintFlag{ | ||||
| 			Name:  "debug", | ||||
| 			Usage: "Debug pprof args", | ||||
| 			Value: 0, | ||||
| @@ -186,11 +189,11 @@ var pprofBlockCommand = cli.Command{ | ||||
| 	}, | ||||
| } | ||||
|  | ||||
| var pprofThreadcreateCommand = cli.Command{ | ||||
| var pprofThreadcreateCommand = &cli.Command{ | ||||
| 	Name:  "threadcreate", | ||||
| 	Usage: "Goroutine thread creating profile", | ||||
| 	Flags: []cli.Flag{ | ||||
| 		cli.UintFlag{ | ||||
| 		&cli.UintFlag{ | ||||
| 			Name:  "debug", | ||||
| 			Usage: "Debug pprof args", | ||||
| 			Value: 0, | ||||
| @@ -211,7 +214,7 @@ var pprofThreadcreateCommand = cli.Command{ | ||||
| } | ||||
|  | ||||
| func getPProfClient(context *cli.Context) *http.Client { | ||||
| 	dialer := getPProfDialer(context.GlobalString("debug-socket")) | ||||
| 	dialer := getPProfDialer(context.String("debug-socket")) | ||||
|  | ||||
| 	tr := &http.Transport{ | ||||
| 		Dial: dialer.pprofDial, | ||||
|   | ||||
| @@ -36,7 +36,7 @@ import ( | ||||
| 	"github.com/containerd/containerd/v2/core/remotes/docker/config" | ||||
| 	"github.com/containerd/containerd/v2/core/transfer/registry" | ||||
| 	"github.com/containerd/log" | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| ) | ||||
|  | ||||
| // PushTracker returns a new InMemoryTracker which tracks the ref status | ||||
|   | ||||
| @@ -26,7 +26,7 @@ import ( | ||||
| 	"github.com/containerd/console" | ||||
| 	gocni "github.com/containerd/go-cni" | ||||
| 	specs "github.com/opencontainers/runtime-spec/specs-go" | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
|  | ||||
| 	containerd "github.com/containerd/containerd/v2/client" | ||||
| 	"github.com/containerd/containerd/v2/cmd/ctr/commands" | ||||
| @@ -89,41 +89,41 @@ func parseMountFlag(m string) (specs.Mount, error) { | ||||
| } | ||||
|  | ||||
| // Command runs a container | ||||
| var Command = cli.Command{ | ||||
| 	Name:           "run", | ||||
| 	Usage:          "Run a container", | ||||
| 	ArgsUsage:      "[flags] Image|RootFS ID [COMMAND] [ARG...]", | ||||
| 	SkipArgReorder: true, | ||||
| var Command = &cli.Command{ | ||||
| 	Name:      "run", | ||||
| 	Usage:     "Run a container", | ||||
| 	ArgsUsage: "[flags] Image|RootFS ID [COMMAND] [ARG...]", | ||||
| 	Flags: append([]cli.Flag{ | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "rm", | ||||
| 			Usage: "Remove the container after running, cannot be used with --detach", | ||||
| 		}, | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "null-io", | ||||
| 			Usage: "Send all IO to /dev/null", | ||||
| 		}, | ||||
| 		cli.StringFlag{ | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:  "log-uri", | ||||
| 			Usage: "Log uri", | ||||
| 		}, | ||||
| 		cli.BoolFlag{ | ||||
| 			Name:  "detach,d", | ||||
| 			Usage: "Detach from the task after it has started execution, cannot be used with --rm", | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:    "detach", | ||||
| 			Aliases: []string{"d"}, | ||||
| 			Usage:   "Detach from the task after it has started execution, cannot be used with --rm", | ||||
| 		}, | ||||
| 		cli.StringFlag{ | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:  "fifo-dir", | ||||
| 			Usage: "Directory used for storing IO FIFOs", | ||||
| 		}, | ||||
| 		cli.StringFlag{ | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:  "cgroup", | ||||
| 			Usage: "Cgroup path (To disable use of cgroup, set to \"\" explicitly)", | ||||
| 		}, | ||||
| 		cli.StringFlag{ | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:  "platform", | ||||
| 			Usage: "Run image for specific platform", | ||||
| 		}, | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "cni", | ||||
| 			Usage: "Enable cni networking for the container", | ||||
| 		}, | ||||
| @@ -259,7 +259,7 @@ var Command = cli.Command{ | ||||
| 			return err | ||||
| 		} | ||||
| 		if code != 0 { | ||||
| 			return cli.NewExitError("", int(code)) | ||||
| 			return cli.Exit("", int(code)) | ||||
| 		} | ||||
| 		return nil | ||||
| 	}, | ||||
|   | ||||
| @@ -39,43 +39,43 @@ import ( | ||||
| 	"github.com/containerd/platforms" | ||||
| 	"github.com/intel/goresctrl/pkg/blockio" | ||||
| 	"github.com/opencontainers/runtime-spec/specs-go" | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| 	"tags.cncf.io/container-device-interface/pkg/cdi" | ||||
| 	"tags.cncf.io/container-device-interface/pkg/parser" | ||||
| ) | ||||
|  | ||||
| var platformRunFlags = []cli.Flag{ | ||||
| 	cli.StringFlag{ | ||||
| 	&cli.StringFlag{ | ||||
| 		Name:  "uidmap", | ||||
| 		Usage: "Run inside a user namespace with the specified UID mapping range; specified with the format `container-uid:host-uid:length`", | ||||
| 	}, | ||||
| 	cli.StringFlag{ | ||||
| 	&cli.StringFlag{ | ||||
| 		Name:  "gidmap", | ||||
| 		Usage: "Run inside a user namespace with the specified GID mapping range; specified with the format `container-gid:host-gid:length`", | ||||
| 	}, | ||||
| 	cli.BoolFlag{ | ||||
| 	&cli.BoolFlag{ | ||||
| 		Name:  "remap-labels", | ||||
| 		Usage: "Provide the user namespace ID remapping to the snapshotter via label options; requires snapshotter support", | ||||
| 	}, | ||||
| 	cli.BoolFlag{ | ||||
| 	&cli.BoolFlag{ | ||||
| 		Name:  "privileged-without-host-devices", | ||||
| 		Usage: "Don't pass all host devices to privileged container", | ||||
| 	}, | ||||
| 	cli.Float64Flag{ | ||||
| 	&cli.Float64Flag{ | ||||
| 		Name:  "cpus", | ||||
| 		Usage: "Set the CFS cpu quota", | ||||
| 		Value: 0.0, | ||||
| 	}, | ||||
| 	cli.IntFlag{ | ||||
| 	&cli.IntFlag{ | ||||
| 		Name:  "cpu-shares", | ||||
| 		Usage: "Set the cpu shares", | ||||
| 		Value: 1024, | ||||
| 	}, | ||||
| 	cli.StringFlag{ | ||||
| 	&cli.StringFlag{ | ||||
| 		Name:  "cpuset-cpus", | ||||
| 		Usage: "Set the CPUs the container will run in (e.g., 1-2,4)", | ||||
| 	}, | ||||
| 	cli.StringFlag{ | ||||
| 	&cli.StringFlag{ | ||||
| 		Name:  "cpuset-mems", | ||||
| 		Usage: "Set the memory nodes the container will run in (e.g., 1-2,4)", | ||||
| 	}, | ||||
| @@ -110,7 +110,7 @@ func NewContainer(ctx gocontext.Context, client *containerd.Client, context *cli | ||||
| 		var ( | ||||
| 			ref = context.Args().First() | ||||
| 			// for container's id is Args[1] | ||||
| 			args = context.Args()[2:] | ||||
| 			args = context.Args().Slice()[2:] | ||||
| 		) | ||||
| 		opts = append(opts, oci.WithDefaultSpec(), oci.WithDefaultUnixDevices) | ||||
| 		if ef := context.String("env-file"); ef != "" { | ||||
|   | ||||
| @@ -30,11 +30,11 @@ import ( | ||||
| 	"github.com/containerd/containerd/v2/pkg/oci" | ||||
| 	"github.com/containerd/log" | ||||
| 	specs "github.com/opencontainers/runtime-spec/specs-go" | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| ) | ||||
|  | ||||
| var platformRunFlags = []cli.Flag{ | ||||
| 	cli.BoolFlag{ | ||||
| 	&cli.BoolFlag{ | ||||
| 		Name:  "isolated", | ||||
| 		Usage: "Run the container with vm isolation", | ||||
| 	}, | ||||
| @@ -62,7 +62,7 @@ func NewContainer(ctx gocontext.Context, client *containerd.Client, context *cli | ||||
| 	} else { | ||||
| 		var ( | ||||
| 			ref  = context.Args().First() | ||||
| 			args = context.Args()[2:] | ||||
| 			args = context.Args().Slice()[2:] | ||||
| 		) | ||||
|  | ||||
| 		id = context.Args().Get(1) | ||||
| @@ -176,7 +176,7 @@ func NewContainer(ctx gocontext.Context, client *containerd.Client, context *cli | ||||
| 	var runtimeOpts interface{} | ||||
| 	if runtime == "io.containerd.runhcs.v1" { | ||||
| 		runtimeOpts = &options.Options{ | ||||
| 			Debug: context.GlobalBool("debug"), | ||||
| 			Debug: context.Bool("debug"), | ||||
| 		} | ||||
| 	} | ||||
| 	cOpts = append(cOpts, containerd.WithRuntime(runtime, runtimeOpts)) | ||||
|   | ||||
| @@ -27,11 +27,11 @@ import ( | ||||
| 	"github.com/containerd/containerd/v2/defaults" | ||||
| 	"github.com/containerd/containerd/v2/pkg/oci" | ||||
| 	"github.com/containerd/log" | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| ) | ||||
|  | ||||
| // Command is a set of subcommands to manage runtimes with sandbox support | ||||
| var Command = cli.Command{ | ||||
| var Command = &cli.Command{ | ||||
| 	Name:    "sandboxes", | ||||
| 	Aliases: []string{"sandbox", "sb", "s"}, | ||||
| 	Usage:   "Manage sandboxes", | ||||
| @@ -42,13 +42,13 @@ var Command = cli.Command{ | ||||
| 	}, | ||||
| } | ||||
|  | ||||
| var runCommand = cli.Command{ | ||||
| var runCommand = &cli.Command{ | ||||
| 	Name:      "run", | ||||
| 	Aliases:   []string{"create", "c", "r"}, | ||||
| 	Usage:     "Run a new sandbox", | ||||
| 	ArgsUsage: "[flags] <pod-config.json> <sandbox-id>", | ||||
| 	Flags: []cli.Flag{ | ||||
| 		cli.StringFlag{ | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:  "runtime", | ||||
| 			Usage: "Runtime name", | ||||
| 			Value: defaults.DefaultRuntime, | ||||
| @@ -97,12 +97,12 @@ var runCommand = cli.Command{ | ||||
| 	}, | ||||
| } | ||||
|  | ||||
| var listCommand = cli.Command{ | ||||
| var listCommand = &cli.Command{ | ||||
| 	Name:    "list", | ||||
| 	Aliases: []string{"ls"}, | ||||
| 	Usage:   "List sandboxes", | ||||
| 	Flags: []cli.Flag{ | ||||
| 		cli.StringSliceFlag{ | ||||
| 		&cli.StringSliceFlag{ | ||||
| 			Name:  "filters", | ||||
| 			Usage: "The list of filters to apply when querying sandboxes from the store", | ||||
| 		}, | ||||
| @@ -143,15 +143,16 @@ var listCommand = cli.Command{ | ||||
| 	}, | ||||
| } | ||||
|  | ||||
| var removeCommand = cli.Command{ | ||||
| var removeCommand = &cli.Command{ | ||||
| 	Name:      "remove", | ||||
| 	Aliases:   []string{"rm"}, | ||||
| 	ArgsUsage: "<id> [<id>, ...]", | ||||
| 	Usage:     "Remove sandboxes", | ||||
| 	Flags: []cli.Flag{ | ||||
| 		cli.BoolFlag{ | ||||
| 			Name:  "force, f", | ||||
| 			Usage: "Ignore shutdown errors when removing sandbox", | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:    "force", | ||||
| 			Aliases: []string{"f"}, | ||||
| 			Usage:   "Ignore shutdown errors when removing sandbox", | ||||
| 		}, | ||||
| 	}, | ||||
| 	Action: func(context *cli.Context) error { | ||||
| @@ -163,7 +164,7 @@ var removeCommand = cli.Command{ | ||||
|  | ||||
| 		force := context.Bool("force") | ||||
|  | ||||
| 		for _, id := range context.Args() { | ||||
| 		for _, id := range context.Args().Slice() { | ||||
| 			sandbox, err := client.LoadSandbox(ctx, id) | ||||
| 			if err != nil { | ||||
| 				log.G(ctx).WithError(err).Errorf("failed to load sandbox %s", id) | ||||
|   | ||||
| @@ -37,39 +37,40 @@ import ( | ||||
| 	"github.com/containerd/ttrpc" | ||||
| 	"github.com/containerd/typeurl/v2" | ||||
| 	"github.com/opencontainers/runtime-spec/specs-go" | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| ) | ||||
|  | ||||
| var fifoFlags = []cli.Flag{ | ||||
| 	cli.StringFlag{ | ||||
| 	&cli.StringFlag{ | ||||
| 		Name:  "stdin", | ||||
| 		Usage: "Specify the path to the stdin fifo", | ||||
| 	}, | ||||
| 	cli.StringFlag{ | ||||
| 	&cli.StringFlag{ | ||||
| 		Name:  "stdout", | ||||
| 		Usage: "Specify the path to the stdout fifo", | ||||
| 	}, | ||||
| 	cli.StringFlag{ | ||||
| 	&cli.StringFlag{ | ||||
| 		Name:  "stderr", | ||||
| 		Usage: "Specify the path to the stderr fifo", | ||||
| 	}, | ||||
| 	cli.BoolFlag{ | ||||
| 		Name:  "tty,t", | ||||
| 		Usage: "Enable tty support", | ||||
| 	&cli.BoolFlag{ | ||||
| 		Name:    "tty", | ||||
| 		Aliases: []string{"t"}, | ||||
| 		Usage:   "Enable tty support", | ||||
| 	}, | ||||
| } | ||||
|  | ||||
| // Command is the cli command for interacting with a task | ||||
| var Command = cli.Command{ | ||||
| var Command = &cli.Command{ | ||||
| 	Name:  "shim", | ||||
| 	Usage: "Interact with a shim directly", | ||||
| 	Flags: []cli.Flag{ | ||||
| 		cli.StringFlag{ | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:  "id", | ||||
| 			Usage: "Container id", | ||||
| 		}, | ||||
| 	}, | ||||
| 	Subcommands: []cli.Command{ | ||||
| 	Subcommands: []*cli.Command{ | ||||
| 		deleteCommand, | ||||
| 		execCommand, | ||||
| 		startCommand, | ||||
| @@ -77,7 +78,7 @@ var Command = cli.Command{ | ||||
| 	}, | ||||
| } | ||||
|  | ||||
| var startCommand = cli.Command{ | ||||
| var startCommand = &cli.Command{ | ||||
| 	Name:  "start", | ||||
| 	Usage: "Start a container with a task", | ||||
| 	Action: func(context *cli.Context) error { | ||||
| @@ -92,7 +93,7 @@ var startCommand = cli.Command{ | ||||
| 	}, | ||||
| } | ||||
|  | ||||
| var deleteCommand = cli.Command{ | ||||
| var deleteCommand = &cli.Command{ | ||||
| 	Name:  "delete", | ||||
| 	Usage: "Delete a container with a task", | ||||
| 	Action: func(context *cli.Context) error { | ||||
| @@ -111,7 +112,7 @@ var deleteCommand = cli.Command{ | ||||
| 	}, | ||||
| } | ||||
|  | ||||
| var stateCommand = cli.Command{ | ||||
| var stateCommand = &cli.Command{ | ||||
| 	Name:  "state", | ||||
| 	Usage: "Get the state of all the processes of the task", | ||||
| 	Action: func(context *cli.Context) error { | ||||
| @@ -120,7 +121,7 @@ var stateCommand = cli.Command{ | ||||
| 			return err | ||||
| 		} | ||||
| 		r, err := service.State(gocontext.Background(), &task.StateRequest{ | ||||
| 			ID: context.GlobalString("id"), | ||||
| 			ID: context.String("id"), | ||||
| 		}) | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| @@ -130,24 +131,26 @@ var stateCommand = cli.Command{ | ||||
| 	}, | ||||
| } | ||||
|  | ||||
| var execCommand = cli.Command{ | ||||
| var execCommand = &cli.Command{ | ||||
| 	Name:  "exec", | ||||
| 	Usage: "Exec a new process in the task's container", | ||||
| 	Flags: append(fifoFlags, | ||||
| 		cli.BoolFlag{ | ||||
| 			Name:  "attach,a", | ||||
| 			Usage: "Stay attached to the container and open the fifos", | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:    "attach", | ||||
| 			Aliases: []string{"a"}, | ||||
| 			Usage:   "Stay attached to the container and open the fifos", | ||||
| 		}, | ||||
| 		cli.StringSliceFlag{ | ||||
| 			Name:  "env,e", | ||||
| 			Usage: "Add environment vars", | ||||
| 			Value: &cli.StringSlice{}, | ||||
| 		&cli.StringSliceFlag{ | ||||
| 			Name:    "env", | ||||
| 			Aliases: []string{"e"}, | ||||
| 			Usage:   "Add environment vars", | ||||
| 			Value:   cli.NewStringSlice(), | ||||
| 		}, | ||||
| 		cli.StringFlag{ | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:  "cwd", | ||||
| 			Usage: "Current working directory", | ||||
| 		}, | ||||
| 		cli.StringFlag{ | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:  "spec", | ||||
| 			Usage: "Runtime spec", | ||||
| 		}, | ||||
| @@ -230,18 +233,18 @@ var execCommand = cli.Command{ | ||||
| } | ||||
|  | ||||
| func getTaskService(context *cli.Context) (task.TaskService, error) { | ||||
| 	id := context.GlobalString("id") | ||||
| 	id := context.String("id") | ||||
| 	if id == "" { | ||||
| 		return nil, fmt.Errorf("container id must be specified") | ||||
| 	} | ||||
| 	ns := context.GlobalString("namespace") | ||||
| 	ns := context.String("namespace") | ||||
|  | ||||
| 	// /containerd-shim/ns/id/shim.sock is the old way to generate shim socket, | ||||
| 	// compatible it | ||||
| 	s1 := filepath.Join(string(filepath.Separator), "containerd-shim", ns, id, "shim.sock") | ||||
| 	// this should not error, ctr always get a default ns | ||||
| 	ctx := namespaces.WithNamespace(gocontext.Background(), ns) | ||||
| 	s2, _ := shim.SocketAddress(ctx, context.GlobalString("address"), id) | ||||
| 	s2, _ := shim.SocketAddress(ctx, context.String("address"), id) | ||||
| 	s2 = strings.TrimPrefix(s2, "unix://") | ||||
|  | ||||
| 	for _, socket := range []string{s2, "\x00" + s1} { | ||||
|   | ||||
| @@ -38,11 +38,11 @@ import ( | ||||
| 	"github.com/containerd/log" | ||||
| 	digest "github.com/opencontainers/go-digest" | ||||
| 	ocispec "github.com/opencontainers/image-spec/specs-go/v1" | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| ) | ||||
|  | ||||
| // Command is the cli command for managing snapshots | ||||
| var Command = cli.Command{ | ||||
| var Command = &cli.Command{ | ||||
| 	Name:    "snapshots", | ||||
| 	Aliases: []string{"snapshot"}, | ||||
| 	Usage:   "Manage snapshots", | ||||
| @@ -63,7 +63,7 @@ var Command = cli.Command{ | ||||
| 	}, | ||||
| } | ||||
|  | ||||
| var listCommand = cli.Command{ | ||||
| var listCommand = &cli.Command{ | ||||
| 	Name:    "list", | ||||
| 	Aliases: []string{"ls"}, | ||||
| 	Usage:   "List snapshots", | ||||
| @@ -74,7 +74,7 @@ var listCommand = cli.Command{ | ||||
| 		} | ||||
| 		defer cancel() | ||||
| 		var ( | ||||
| 			snapshotter = client.SnapshotService(context.GlobalString("snapshotter")) | ||||
| 			snapshotter = client.SnapshotService(context.String("snapshotter")) | ||||
| 			tw          = tabwriter.NewWriter(os.Stdout, 1, 8, 1, ' ', 0) | ||||
| 		) | ||||
| 		fmt.Fprintln(tw, "KEY\tPARENT\tKIND\t") | ||||
| @@ -92,21 +92,21 @@ var listCommand = cli.Command{ | ||||
| 	}, | ||||
| } | ||||
|  | ||||
| var diffCommand = cli.Command{ | ||||
| var diffCommand = &cli.Command{ | ||||
| 	Name:      "diff", | ||||
| 	Usage:     "Get the diff of two snapshots. the default second snapshot is the first snapshot's parent.", | ||||
| 	ArgsUsage: "[flags] <idA> [<idB>]", | ||||
| 	Flags: append([]cli.Flag{ | ||||
| 		cli.StringFlag{ | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:  "media-type", | ||||
| 			Usage: "Media type to use for creating diff", | ||||
| 			Value: ocispec.MediaTypeImageLayerGzip, | ||||
| 		}, | ||||
| 		cli.StringFlag{ | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:  "ref", | ||||
| 			Usage: "Content upload reference to use", | ||||
| 		}, | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "keep", | ||||
| 			Usage: "Keep diff content. up to creator to delete it.", | ||||
| 		}, | ||||
| @@ -133,7 +133,7 @@ var diffCommand = cli.Command{ | ||||
|  | ||||
| 		var desc ocispec.Descriptor | ||||
| 		labels := commands.LabelArgs(context.StringSlice("label")) | ||||
| 		snapshotter := client.SnapshotService(context.GlobalString("snapshotter")) | ||||
| 		snapshotter := client.SnapshotService(context.String("snapshotter")) | ||||
|  | ||||
| 		if context.Bool("keep") { | ||||
| 			labels["containerd.io/gc.root"] = time.Now().UTC().Format(time.RFC3339) | ||||
| @@ -194,12 +194,12 @@ func withMounts(ctx gocontext.Context, id string, sn snapshots.Snapshotter, f fu | ||||
| 	return f(mounts) | ||||
| } | ||||
|  | ||||
| var usageCommand = cli.Command{ | ||||
| var usageCommand = &cli.Command{ | ||||
| 	Name:      "usage", | ||||
| 	Usage:     "Usage snapshots", | ||||
| 	ArgsUsage: "[flags] [<key>, ...]", | ||||
| 	Flags: []cli.Flag{ | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "b", | ||||
| 			Usage: "Display size in bytes", | ||||
| 		}, | ||||
| @@ -221,7 +221,7 @@ var usageCommand = cli.Command{ | ||||
| 		} | ||||
| 		defer cancel() | ||||
| 		var ( | ||||
| 			snapshotter = client.SnapshotService(context.GlobalString("snapshotter")) | ||||
| 			snapshotter = client.SnapshotService(context.String("snapshotter")) | ||||
| 			tw          = tabwriter.NewWriter(os.Stdout, 1, 8, 1, ' ', 0) | ||||
| 		) | ||||
| 		fmt.Fprintln(tw, "KEY\tSIZE\tINODES\t") | ||||
| @@ -237,7 +237,7 @@ var usageCommand = cli.Command{ | ||||
| 				return err | ||||
| 			} | ||||
| 		} else { | ||||
| 			for _, id := range context.Args() { | ||||
| 			for _, id := range context.Args().Slice() { | ||||
| 				usage, err := snapshotter.Usage(ctx, id) | ||||
| 				if err != nil { | ||||
| 					return err | ||||
| @@ -250,7 +250,7 @@ var usageCommand = cli.Command{ | ||||
| 	}, | ||||
| } | ||||
|  | ||||
| var removeCommand = cli.Command{ | ||||
| var removeCommand = &cli.Command{ | ||||
| 	Name:      "delete", | ||||
| 	Aliases:   []string{"del", "remove", "rm"}, | ||||
| 	ArgsUsage: "<key> [<key>, ...]", | ||||
| @@ -261,8 +261,8 @@ var removeCommand = cli.Command{ | ||||
| 			return err | ||||
| 		} | ||||
| 		defer cancel() | ||||
| 		snapshotter := client.SnapshotService(context.GlobalString("snapshotter")) | ||||
| 		for _, key := range context.Args() { | ||||
| 		snapshotter := client.SnapshotService(context.String("snapshotter")) | ||||
| 		for _, key := range context.Args().Slice() { | ||||
| 			err = snapshotter.Remove(ctx, key) | ||||
| 			if err != nil { | ||||
| 				return fmt.Errorf("failed to remove %q: %w", key, err) | ||||
| @@ -273,16 +273,17 @@ var removeCommand = cli.Command{ | ||||
| 	}, | ||||
| } | ||||
|  | ||||
| var prepareCommand = cli.Command{ | ||||
| var prepareCommand = &cli.Command{ | ||||
| 	Name:      "prepare", | ||||
| 	Usage:     "Prepare a snapshot from a committed snapshot", | ||||
| 	ArgsUsage: "[flags] <key> [<parent>]", | ||||
| 	Flags: []cli.Flag{ | ||||
| 		cli.StringFlag{ | ||||
| 			Name:  "target, t", | ||||
| 			Usage: "Mount target path, will print mount, if provided", | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:    "target", | ||||
| 			Aliases: []string{"t"}, | ||||
| 			Usage:   "Mount target path, will print mount, if provided", | ||||
| 		}, | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "mounts", | ||||
| 			Usage: "Print out snapshot mounts as JSON", | ||||
| 		}, | ||||
| @@ -302,7 +303,7 @@ var prepareCommand = cli.Command{ | ||||
| 		} | ||||
| 		defer cancel() | ||||
|  | ||||
| 		snapshotter := client.SnapshotService(context.GlobalString("snapshotter")) | ||||
| 		snapshotter := client.SnapshotService(context.String("snapshotter")) | ||||
| 		labels := map[string]string{ | ||||
| 			"containerd.io/gc.root": time.Now().UTC().Format(time.RFC3339), | ||||
| 		} | ||||
| @@ -324,16 +325,17 @@ var prepareCommand = cli.Command{ | ||||
| 	}, | ||||
| } | ||||
|  | ||||
| var viewCommand = cli.Command{ | ||||
| var viewCommand = &cli.Command{ | ||||
| 	Name:      "view", | ||||
| 	Usage:     "Create a read-only snapshot from a committed snapshot", | ||||
| 	ArgsUsage: "[flags] <key> [<parent>]", | ||||
| 	Flags: []cli.Flag{ | ||||
| 		cli.StringFlag{ | ||||
| 			Name:  "target, t", | ||||
| 			Usage: "Mount target path, will print mount, if provided", | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:    "target", | ||||
| 			Aliases: []string{"t"}, | ||||
| 			Usage:   "Mount target path, will print mount, if provided", | ||||
| 		}, | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "mounts", | ||||
| 			Usage: "Print out snapshot mounts as JSON", | ||||
| 		}, | ||||
| @@ -353,7 +355,7 @@ var viewCommand = cli.Command{ | ||||
| 		} | ||||
| 		defer cancel() | ||||
|  | ||||
| 		snapshotter := client.SnapshotService(context.GlobalString("snapshotter")) | ||||
| 		snapshotter := client.SnapshotService(context.String("snapshotter")) | ||||
| 		mounts, err := snapshotter.View(ctx, key, parent) | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| @@ -371,7 +373,7 @@ var viewCommand = cli.Command{ | ||||
| 	}, | ||||
| } | ||||
|  | ||||
| var mountCommand = cli.Command{ | ||||
| var mountCommand = &cli.Command{ | ||||
| 	Name:      "mounts", | ||||
| 	Aliases:   []string{"m", "mount"}, | ||||
| 	Usage:     "Mount gets mount commands for the snapshots", | ||||
| @@ -389,7 +391,7 @@ var mountCommand = cli.Command{ | ||||
| 			return err | ||||
| 		} | ||||
| 		defer cancel() | ||||
| 		snapshotter := client.SnapshotService(context.GlobalString("snapshotter")) | ||||
| 		snapshotter := client.SnapshotService(context.String("snapshotter")) | ||||
| 		mounts, err := snapshotter.Mounts(ctx, key) | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| @@ -401,7 +403,7 @@ var mountCommand = cli.Command{ | ||||
| 	}, | ||||
| } | ||||
|  | ||||
| var commitCommand = cli.Command{ | ||||
| var commitCommand = &cli.Command{ | ||||
| 	Name:      "commit", | ||||
| 	Usage:     "Commit an active snapshot into the provided name", | ||||
| 	ArgsUsage: "<key> <active>", | ||||
| @@ -418,7 +420,7 @@ var commitCommand = cli.Command{ | ||||
| 			return err | ||||
| 		} | ||||
| 		defer cancel() | ||||
| 		snapshotter := client.SnapshotService(context.GlobalString("snapshotter")) | ||||
| 		snapshotter := client.SnapshotService(context.String("snapshotter")) | ||||
| 		labels := map[string]string{ | ||||
| 			"containerd.io/gc.root": time.Now().UTC().Format(time.RFC3339), | ||||
| 		} | ||||
| @@ -426,7 +428,7 @@ var commitCommand = cli.Command{ | ||||
| 	}, | ||||
| } | ||||
|  | ||||
| var treeCommand = cli.Command{ | ||||
| var treeCommand = &cli.Command{ | ||||
| 	Name:  "tree", | ||||
| 	Usage: "Display tree view of snapshot branches", | ||||
| 	Action: func(context *cli.Context) error { | ||||
| @@ -436,7 +438,7 @@ var treeCommand = cli.Command{ | ||||
| 		} | ||||
| 		defer cancel() | ||||
| 		var ( | ||||
| 			snapshotter = client.SnapshotService(context.GlobalString("snapshotter")) | ||||
| 			snapshotter = client.SnapshotService(context.String("snapshotter")) | ||||
| 			tree        = newSnapshotTree() | ||||
| 		) | ||||
|  | ||||
| @@ -454,7 +456,7 @@ var treeCommand = cli.Command{ | ||||
| 	}, | ||||
| } | ||||
|  | ||||
| var infoCommand = cli.Command{ | ||||
| var infoCommand = &cli.Command{ | ||||
| 	Name:      "info", | ||||
| 	Usage:     "Get info about a snapshot", | ||||
| 	ArgsUsage: "<key>", | ||||
| @@ -469,7 +471,7 @@ var infoCommand = cli.Command{ | ||||
| 			return err | ||||
| 		} | ||||
| 		defer cancel() | ||||
| 		snapshotter := client.SnapshotService(context.GlobalString("snapshotter")) | ||||
| 		snapshotter := client.SnapshotService(context.String("snapshotter")) | ||||
| 		info, err := snapshotter.Stat(ctx, key) | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| @@ -481,7 +483,7 @@ var infoCommand = cli.Command{ | ||||
| 	}, | ||||
| } | ||||
|  | ||||
| var setLabelCommand = cli.Command{ | ||||
| var setLabelCommand = &cli.Command{ | ||||
| 	Name:        "label", | ||||
| 	Usage:       "Add labels to content", | ||||
| 	ArgsUsage:   "<name> [<label>=<value> ...]", | ||||
| @@ -494,7 +496,7 @@ var setLabelCommand = cli.Command{ | ||||
| 		} | ||||
| 		defer cancel() | ||||
|  | ||||
| 		snapshotter := client.SnapshotService(context.GlobalString("snapshotter")) | ||||
| 		snapshotter := client.SnapshotService(context.String("snapshotter")) | ||||
|  | ||||
| 		info := snapshots.Info{ | ||||
| 			Name:   key, | ||||
| @@ -530,7 +532,7 @@ var setLabelCommand = cli.Command{ | ||||
| 	}, | ||||
| } | ||||
|  | ||||
| var unpackCommand = cli.Command{ | ||||
| var unpackCommand = &cli.Command{ | ||||
| 	Name:      "unpack", | ||||
| 	Usage:     "Unpack applies layers from a manifest to a snapshot", | ||||
| 	ArgsUsage: "[flags] <digest>", | ||||
|   | ||||
| @@ -21,10 +21,10 @@ import ( | ||||
| 	"github.com/containerd/containerd/v2/cmd/ctr/commands" | ||||
| 	"github.com/containerd/containerd/v2/pkg/cio" | ||||
| 	"github.com/containerd/log" | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| ) | ||||
|  | ||||
| var attachCommand = cli.Command{ | ||||
| var attachCommand = &cli.Command{ | ||||
| 	Name:      "attach", | ||||
| 	Usage:     "Attach to the IO of a running container", | ||||
| 	ArgsUsage: "CONTAINER", | ||||
| @@ -79,7 +79,7 @@ var attachCommand = cli.Command{ | ||||
| 			return err | ||||
| 		} | ||||
| 		if code != 0 { | ||||
| 			return cli.NewExitError("", int(code)) | ||||
| 			return cli.Exit("", int(code)) | ||||
| 		} | ||||
| 		return nil | ||||
| 	}, | ||||
|   | ||||
| @@ -23,23 +23,23 @@ import ( | ||||
| 	containerd "github.com/containerd/containerd/v2/client" | ||||
| 	"github.com/containerd/containerd/v2/cmd/ctr/commands" | ||||
| 	"github.com/containerd/containerd/v2/core/runtime/v2/runc/options" | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| ) | ||||
|  | ||||
| var checkpointCommand = cli.Command{ | ||||
| var checkpointCommand = &cli.Command{ | ||||
| 	Name:      "checkpoint", | ||||
| 	Usage:     "Checkpoint a container", | ||||
| 	ArgsUsage: "[flags] CONTAINER", | ||||
| 	Flags: []cli.Flag{ | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "exit", | ||||
| 			Usage: "Stop the container after the checkpoint", | ||||
| 		}, | ||||
| 		cli.StringFlag{ | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:  "image-path", | ||||
| 			Usage: "Path to criu image files", | ||||
| 		}, | ||||
| 		cli.StringFlag{ | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:  "work-path", | ||||
| 			Usage: "Path to criu work files and logs", | ||||
| 		}, | ||||
|   | ||||
| @@ -23,20 +23,21 @@ import ( | ||||
| 	"github.com/containerd/containerd/v2/cmd/ctr/commands" | ||||
| 	"github.com/containerd/containerd/v2/pkg/cio" | ||||
| 	"github.com/containerd/log" | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| ) | ||||
|  | ||||
| var deleteCommand = cli.Command{ | ||||
| var deleteCommand = &cli.Command{ | ||||
| 	Name:      "delete", | ||||
| 	Usage:     "Delete one or more tasks", | ||||
| 	ArgsUsage: "CONTAINER [CONTAINER, ...]", | ||||
| 	Aliases:   []string{"del", "remove", "rm"}, | ||||
| 	Flags: []cli.Flag{ | ||||
| 		cli.BoolFlag{ | ||||
| 			Name:  "force, f", | ||||
| 			Usage: "Force delete task process", | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:    "force", | ||||
| 			Aliases: []string{"f"}, | ||||
| 			Usage:   "Force delete task process", | ||||
| 		}, | ||||
| 		cli.StringFlag{ | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:  "exec-id", | ||||
| 			Usage: "Process ID to kill", | ||||
| 		}, | ||||
| @@ -70,10 +71,10 @@ var deleteCommand = cli.Command{ | ||||
| 				return err | ||||
| 			} | ||||
| 			if ec := status.ExitCode(); ec != 0 { | ||||
| 				return cli.NewExitError("", int(ec)) | ||||
| 				return cli.Exit("", int(ec)) | ||||
| 			} | ||||
| 		} else { | ||||
| 			for _, target := range context.Args() { | ||||
| 			for _, target := range context.Args().Slice() { | ||||
| 				task, err := loadTask(ctx, client, target) | ||||
| 				if err != nil { | ||||
| 					if exitErr == nil { | ||||
|   | ||||
| @@ -28,41 +28,42 @@ import ( | ||||
| 	"github.com/containerd/containerd/v2/pkg/cio" | ||||
| 	"github.com/containerd/containerd/v2/pkg/oci" | ||||
| 	"github.com/containerd/log" | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| ) | ||||
|  | ||||
| var execCommand = cli.Command{ | ||||
| 	Name:           "exec", | ||||
| 	Usage:          "Execute additional processes in an existing container", | ||||
| 	ArgsUsage:      "[flags] CONTAINER CMD [ARG...]", | ||||
| 	SkipArgReorder: true, | ||||
| var execCommand = &cli.Command{ | ||||
| 	Name:      "exec", | ||||
| 	Usage:     "Execute additional processes in an existing container", | ||||
| 	ArgsUsage: "[flags] CONTAINER CMD [ARG...]", | ||||
| 	Flags: []cli.Flag{ | ||||
| 		cli.StringFlag{ | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:  "cwd", | ||||
| 			Usage: "Working directory of the new process", | ||||
| 		}, | ||||
| 		cli.BoolFlag{ | ||||
| 			Name:  "tty,t", | ||||
| 			Usage: "Allocate a TTY for the container", | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:    "tty", | ||||
| 			Aliases: []string{"t"}, | ||||
| 			Usage:   "Allocate a TTY for the container", | ||||
| 		}, | ||||
| 		cli.BoolFlag{ | ||||
| 			Name:  "detach,d", | ||||
| 			Usage: "Detach from the task after it has started execution", | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:    "detach", | ||||
| 			Aliases: []string{"d"}, | ||||
| 			Usage:   "Detach from the task after it has started execution", | ||||
| 		}, | ||||
| 		cli.StringFlag{ | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:     "exec-id", | ||||
| 			Required: true, | ||||
| 			Usage:    "Exec specific id for the process", | ||||
| 		}, | ||||
| 		cli.StringFlag{ | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:  "fifo-dir", | ||||
| 			Usage: "Directory used for storing IO FIFOs", | ||||
| 		}, | ||||
| 		cli.StringFlag{ | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:  "log-uri", | ||||
| 			Usage: "Log uri for custom shim logging", | ||||
| 		}, | ||||
| 		cli.StringFlag{ | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:  "user", | ||||
| 			Usage: "User id or name", | ||||
| 		}, | ||||
| @@ -186,7 +187,7 @@ var execCommand = cli.Command{ | ||||
| 			return err | ||||
| 		} | ||||
| 		if code != 0 { | ||||
| 			return cli.NewExitError("", int(code)) | ||||
| 			return cli.Exit("", int(code)) | ||||
| 		} | ||||
| 		return nil | ||||
| 	}, | ||||
|   | ||||
| @@ -27,7 +27,7 @@ import ( | ||||
| 	"github.com/containerd/log" | ||||
| 	"github.com/containerd/typeurl/v2" | ||||
| 	"github.com/moby/sys/signal" | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| ) | ||||
|  | ||||
| const defaultSignal = "SIGTERM" | ||||
| @@ -61,23 +61,25 @@ func RemoveCniNetworkIfExist(ctx context.Context, container containerd.Container | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| var killCommand = cli.Command{ | ||||
| var killCommand = &cli.Command{ | ||||
| 	Name:      "kill", | ||||
| 	Usage:     "Signal a container (default: SIGTERM)", | ||||
| 	ArgsUsage: "[flags] CONTAINER", | ||||
| 	Flags: []cli.Flag{ | ||||
| 		cli.StringFlag{ | ||||
| 			Name:  "signal, s", | ||||
| 			Value: "", | ||||
| 			Usage: "Signal to send to the container", | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:    "signal", | ||||
| 			Aliases: []string{"s"}, | ||||
| 			Value:   "", | ||||
| 			Usage:   "Signal to send to the container", | ||||
| 		}, | ||||
| 		cli.StringFlag{ | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:  "exec-id", | ||||
| 			Usage: "Process ID to kill", | ||||
| 		}, | ||||
| 		cli.BoolFlag{ | ||||
| 			Name:  "all, a", | ||||
| 			Usage: "Send signal to all processes inside the container", | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:    "all", | ||||
| 			Aliases: []string{"a"}, | ||||
| 			Usage:   "Send signal to all processes inside the container", | ||||
| 		}, | ||||
| 	}, | ||||
| 	Action: func(context *cli.Context) error { | ||||
|   | ||||
| @@ -23,18 +23,19 @@ import ( | ||||
|  | ||||
| 	tasks "github.com/containerd/containerd/v2/api/services/tasks/v1" | ||||
| 	"github.com/containerd/containerd/v2/cmd/ctr/commands" | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| ) | ||||
|  | ||||
| var listCommand = cli.Command{ | ||||
| var listCommand = &cli.Command{ | ||||
| 	Name:      "list", | ||||
| 	Usage:     "List tasks", | ||||
| 	Aliases:   []string{"ls"}, | ||||
| 	ArgsUsage: "[flags]", | ||||
| 	Flags: []cli.Flag{ | ||||
| 		cli.BoolFlag{ | ||||
| 			Name:  "quiet, q", | ||||
| 			Usage: "Print only the task id", | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:    "quiet", | ||||
| 			Aliases: []string{"q"}, | ||||
| 			Usage:   "Print only the task id", | ||||
| 		}, | ||||
| 	}, | ||||
| 	Action: func(context *cli.Context) error { | ||||
|   | ||||
| @@ -28,7 +28,7 @@ import ( | ||||
| 	v2 "github.com/containerd/cgroups/v3/cgroup2/stats" | ||||
| 	"github.com/containerd/containerd/v2/cmd/ctr/commands" | ||||
| 	"github.com/containerd/typeurl/v2" | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| ) | ||||
|  | ||||
| const ( | ||||
| @@ -37,13 +37,13 @@ const ( | ||||
| 	formatJSON  = "json" | ||||
| ) | ||||
|  | ||||
| var metricsCommand = cli.Command{ | ||||
| var metricsCommand = &cli.Command{ | ||||
| 	Name:      "metrics", | ||||
| 	Usage:     "Get a single data point of metrics for a task with the built-in Linux runtime", | ||||
| 	ArgsUsage: "CONTAINER", | ||||
| 	Aliases:   []string{"metric"}, | ||||
| 	Flags: []cli.Flag{ | ||||
| 		cli.StringFlag{ | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:  formatFlag, | ||||
| 			Usage: `"table" or "json"`, | ||||
| 			Value: formatTable, | ||||
|   | ||||
| @@ -18,10 +18,10 @@ package tasks | ||||
|  | ||||
| import ( | ||||
| 	"github.com/containerd/containerd/v2/cmd/ctr/commands" | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| ) | ||||
|  | ||||
| var pauseCommand = cli.Command{ | ||||
| var pauseCommand = &cli.Command{ | ||||
| 	Name:      "pause", | ||||
| 	Usage:     "Pause an existing container", | ||||
| 	ArgsUsage: "CONTAINER", | ||||
|   | ||||
| @@ -24,10 +24,10 @@ import ( | ||||
|  | ||||
| 	"github.com/containerd/containerd/v2/cmd/ctr/commands" | ||||
| 	"github.com/containerd/typeurl/v2" | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| ) | ||||
|  | ||||
| var psCommand = cli.Command{ | ||||
| var psCommand = &cli.Command{ | ||||
| 	Name:      "ps", | ||||
| 	Usage:     "List processes for container", | ||||
| 	ArgsUsage: "CONTAINER", | ||||
|   | ||||
| @@ -18,10 +18,10 @@ package tasks | ||||
|  | ||||
| import ( | ||||
| 	"github.com/containerd/containerd/v2/cmd/ctr/commands" | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| ) | ||||
|  | ||||
| var resumeCommand = cli.Command{ | ||||
| var resumeCommand = &cli.Command{ | ||||
| 	Name:      "resume", | ||||
| 	Usage:     "Resume a paused container", | ||||
| 	ArgsUsage: "CONTAINER", | ||||
|   | ||||
| @@ -25,33 +25,34 @@ import ( | ||||
| 	"github.com/containerd/containerd/v2/pkg/cio" | ||||
| 	"github.com/containerd/errdefs" | ||||
| 	"github.com/containerd/log" | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| ) | ||||
|  | ||||
| var startCommand = cli.Command{ | ||||
| var startCommand = &cli.Command{ | ||||
| 	Name:      "start", | ||||
| 	Usage:     "Start a container that has been created", | ||||
| 	ArgsUsage: "CONTAINER", | ||||
| 	Flags: append(platformStartFlags, []cli.Flag{ | ||||
| 		cli.BoolFlag{ | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:  "null-io", | ||||
| 			Usage: "Send all IO to /dev/null", | ||||
| 		}, | ||||
| 		cli.StringFlag{ | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:  "log-uri", | ||||
| 			Usage: "Log uri", | ||||
| 		}, | ||||
| 		cli.StringFlag{ | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:  "fifo-dir", | ||||
| 			Usage: "Directory used for storing IO FIFOs", | ||||
| 		}, | ||||
| 		cli.StringFlag{ | ||||
| 		&cli.StringFlag{ | ||||
| 			Name:  "pid-file", | ||||
| 			Usage: "File path to write the task's pid", | ||||
| 		}, | ||||
| 		cli.BoolFlag{ | ||||
| 			Name:  "detach,d", | ||||
| 			Usage: "Detach from the task after it has started execution", | ||||
| 		&cli.BoolFlag{ | ||||
| 			Name:    "detach", | ||||
| 			Aliases: []string{"d"}, | ||||
| 			Usage:   "Detach from the task after it has started execution", | ||||
| 		}, | ||||
| 	}...), | ||||
| 	Action: func(context *cli.Context) error { | ||||
| @@ -137,7 +138,7 @@ var startCommand = cli.Command{ | ||||
| 			return err | ||||
| 		} | ||||
| 		if code != 0 { | ||||
| 			return cli.NewExitError("", int(code)) | ||||
| 			return cli.Exit("", int(code)) | ||||
| 		} | ||||
| 		return nil | ||||
| 	}, | ||||
|   | ||||
| @@ -19,7 +19,7 @@ package tasks | ||||
| import ( | ||||
| 	gocontext "context" | ||||
|  | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| ) | ||||
|  | ||||
| type resizer interface { | ||||
| @@ -27,11 +27,11 @@ type resizer interface { | ||||
| } | ||||
|  | ||||
| // Command is the cli command for managing tasks | ||||
| var Command = cli.Command{ | ||||
| var Command = &cli.Command{ | ||||
| 	Name:    "tasks", | ||||
| 	Usage:   "Manage tasks", | ||||
| 	Aliases: []string{"t", "task"}, | ||||
| 	Subcommands: []cli.Command{ | ||||
| 	Subcommands: []*cli.Command{ | ||||
| 		attachCommand, | ||||
| 		checkpointCommand, | ||||
| 		deleteCommand, | ||||
|   | ||||
| @@ -29,12 +29,12 @@ import ( | ||||
| 	containerd "github.com/containerd/containerd/v2/client" | ||||
| 	"github.com/containerd/containerd/v2/pkg/cio" | ||||
| 	"github.com/containerd/log" | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| 	"golang.org/x/sys/unix" | ||||
| ) | ||||
|  | ||||
| var platformStartFlags = []cli.Flag{ | ||||
| 	cli.BoolFlag{ | ||||
| 	&cli.BoolFlag{ | ||||
| 		Name:  "no-pivot", | ||||
| 		Usage: "Disable use of pivot-root (linux only)", | ||||
| 	}, | ||||
|   | ||||
| @@ -26,7 +26,7 @@ import ( | ||||
| 	containerd "github.com/containerd/containerd/v2/client" | ||||
| 	"github.com/containerd/containerd/v2/pkg/cio" | ||||
| 	"github.com/containerd/log" | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| ) | ||||
|  | ||||
| var platformStartFlags = []cli.Flag{} | ||||
|   | ||||
| @@ -22,11 +22,11 @@ import ( | ||||
|  | ||||
| 	"github.com/containerd/containerd/v2/cmd/ctr/commands" | ||||
| 	"github.com/containerd/containerd/v2/version" | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| ) | ||||
|  | ||||
| // Command is a cli command to output the client and containerd server version | ||||
| var Command = cli.Command{ | ||||
| var Command = &cli.Command{ | ||||
| 	Name:  "version", | ||||
| 	Usage: "Print the client and server versions", | ||||
| 	Action: func(context *cli.Context) error { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Phil Estes
					Phil Estes