Convert CLI to urfave v2
Followed the Migration Guide at https://cli.urfave.org/migrate-v1-to-v2/ The major changes not pointed out in the migration guide are: - context.Args() no longer produces a []slice, so context.Args().Slice() in substitued - All cli.Global***** are deprecated (the migration guide is somewhat unclear on this) Signed-off-by: Derek Nola <derek.nola@suse.com> Vendor in urfave cli/v2 Signed-off-by: Derek Nola <derek.nola@suse.com> Fix NewStringSlice calls Signed-off-by: Derek Nola <derek.nola@suse.com>
This commit is contained in:
@@ -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>])",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
Reference in New Issue
Block a user