mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-10 21:53:57 +08:00
chore(deps): upgrade urfave/cli from v1 to v3
Migrate from urfave/cli v1 (maintenance mode) to v3 to benefit from active development, improved features, and long-term support. Signed-off-by: lifubang <lifubang@acmcoder.com>
This commit is contained in:
@@ -1,17 +1,18 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/opencontainers/runc/libcontainer"
|
||||
"github.com/urfave/cli"
|
||||
"github.com/urfave/cli/v3"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
var killCommand = cli.Command{
|
||||
var killCommand = &cli.Command{
|
||||
Name: "kill",
|
||||
Usage: "kill sends the specified signal (default: SIGTERM) to the container's init process",
|
||||
ArgsUsage: `<container-id> [signal]
|
||||
@@ -24,26 +25,31 @@ For example, if the container id is "ubuntu01" the following will send a "KILL"
|
||||
signal to the init process of the "ubuntu01" container:
|
||||
|
||||
# runc kill ubuntu01 KILL`,
|
||||
// Stop parsing flags after the first positional argument (container ID).
|
||||
StopOnNthArg: mkPtr(1),
|
||||
// Disable comma as separator for slice flags.
|
||||
DisableSliceFlagSeparator: true,
|
||||
Flags: []cli.Flag{
|
||||
cli.BoolFlag{
|
||||
Name: "all, a",
|
||||
Usage: "(obsoleted, do not use)",
|
||||
Hidden: true,
|
||||
&cli.BoolFlag{
|
||||
Name: "all",
|
||||
Aliases: []string{"a"},
|
||||
Usage: "(obsoleted, do not use)",
|
||||
Hidden: true,
|
||||
},
|
||||
},
|
||||
Action: func(context *cli.Context) error {
|
||||
if err := checkArgs(context, 1, minArgs); err != nil {
|
||||
Action: func(_ context.Context, cmd *cli.Command) error {
|
||||
if err := checkArgs(cmd, 1, minArgs); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := checkArgs(context, 2, maxArgs); err != nil {
|
||||
if err := checkArgs(cmd, 2, maxArgs); err != nil {
|
||||
return err
|
||||
}
|
||||
container, err := getContainer(context)
|
||||
container, err := getContainer(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
sigstr := context.Args().Get(1)
|
||||
sigstr := cmd.Args().Get(1)
|
||||
if sigstr == "" {
|
||||
sigstr = "SIGTERM"
|
||||
}
|
||||
@@ -53,7 +59,7 @@ signal to the init process of the "ubuntu01" container:
|
||||
return err
|
||||
}
|
||||
err = container.Signal(signal)
|
||||
if errors.Is(err, libcontainer.ErrNotRunning) && context.Bool("all") {
|
||||
if errors.Is(err, libcontainer.ErrNotRunning) && cmd.Bool("all") {
|
||||
err = nil
|
||||
}
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user