Merge pull request #9809 from dereknola/urfave_v2

Migrate Urfave CLI from v1 to v2
This commit is contained in:
Phil Estes
2024-02-16 16:13:37 +00:00
committed by GitHub
149 changed files with 11041 additions and 4693 deletions

View File

@@ -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
}