diff --git a/cmd/context.go b/cmd/context.go index a464d7eab..cba8210e4 100644 --- a/cmd/context.go +++ b/cmd/context.go @@ -29,7 +29,7 @@ package main import ( "github.com/pkg/errors" - "github.com/urfave/cli" + "github.com/urfave/cli/v2" ) var contextCommand = cli.Command{ diff --git a/cmd/example.go b/cmd/example.go index d519f7412..371cb32db 100644 --- a/cmd/example.go +++ b/cmd/example.go @@ -37,7 +37,7 @@ import ( "github.com/docker/api/client" "github.com/golang/protobuf/ptypes/empty" "github.com/pkg/errors" - "github.com/urfave/cli" + "github.com/urfave/cli/v2" ) var exampleCommand = cli.Command{ diff --git a/cmd/main.go b/cmd/main.go index f6a3ea11f..e81370d65 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -38,7 +38,7 @@ import ( "github.com/docker/api/context" "github.com/sirupsen/logrus" - "github.com/urfave/cli" + "github.com/urfave/cli/v2" ) func init() { @@ -61,12 +61,12 @@ func main() { app.UseShortOptionHandling = true app.EnableBashCompletion = true app.Flags = []cli.Flag{ - cli.BoolFlag{ + &cli.BoolFlag{ Name: "debug", Usage: "enable debug output in the logs", }, - context.ConfigFlag, - context.ContextFlag, + &context.ConfigFlag, + &context.ContextFlag, } // Make a copy of the default HelpPrinter function @@ -87,7 +87,7 @@ func main() { } app.Before = func(clix *cli.Context) error { - if clix.GlobalBool("debug") { + if clix.Bool("debug") { logrus.SetLevel(logrus.DebugLevel) } ctx, err := context.GetContext() @@ -100,9 +100,9 @@ func main() { // TODO select backend based on context.Metadata.Type return nil } - app.Commands = []cli.Command{ - contextCommand, - exampleCommand, + app.Commands = []*cli.Command{ + &contextCommand, + &exampleCommand, } sort.Sort(cli.FlagsByName(app.Flags)) diff --git a/context/flags.go b/context/flags.go index 0456704f7..f875a9fc9 100644 --- a/context/flags.go +++ b/context/flags.go @@ -4,7 +4,7 @@ import ( "path/filepath" "github.com/mitchellh/go-homedir" - "github.com/urfave/cli" + "github.com/urfave/cli/v2" ) const ( @@ -19,15 +19,16 @@ var ( ConfigFlag = cli.StringFlag{ Name: "config", Usage: "Location of client config files `DIRECTORY`", - EnvVar: "DOCKER_CONFIG", + EnvVars: []string{"DOCKER_CONFIG"}, Value: filepath.Join(home(), configFileDir), Destination: &ConfigDir, } ContextFlag = cli.StringFlag{ - Name: "context, c", + Name: "context", + Aliases: []string{"c"}, Usage: "Name of the context `CONTEXT` to use to connect to the daemon (overrides DOCKER_HOST env var and default context set with \"docker context use\")", - EnvVar: "DOCKER_CONTEXT", + EnvVars: []string{"DOCKER_CONTEXT"}, Destination: &ContextName, } ) diff --git a/example/backend/main.go b/example/backend/main.go index cbba0ce44..ee3f25678 100644 --- a/example/backend/main.go +++ b/example/backend/main.go @@ -39,7 +39,7 @@ import ( "github.com/golang/protobuf/ptypes/empty" "github.com/pkg/errors" "github.com/sirupsen/logrus" - "github.com/urfave/cli" + "github.com/urfave/cli/v2" ) func main() { @@ -50,17 +50,17 @@ func main() { app.UseShortOptionHandling = true app.EnableBashCompletion = true app.Flags = []cli.Flag{ - cli.BoolFlag{ + &cli.BoolFlag{ Name: "debug", Usage: "enable debug output in the logs", }, - cli.StringFlag{ + &cli.StringFlag{ Name: "address,a", Usage: "address of the server", }, } app.Before = func(clix *cli.Context) error { - if clix.GlobalBool("debug") { + if clix.Bool("debug") { logrus.SetLevel(logrus.DebugLevel) } return nil @@ -73,7 +73,7 @@ func main() { s := server.New() // listen on a socket to accept connects - l, err := net.Listen("unix", clix.GlobalString("address")) + l, err := net.Listen("unix", clix.String("address")) if err != nil { return errors.Wrap(err, "listen unix socket") } @@ -93,7 +93,7 @@ func main() { s.Stop() }() - logrus.WithField("address", clix.GlobalString("address")).Info("serving daemon API") + logrus.WithField("address", clix.String("address")).Info("serving daemon API") // start the GRPC server to serve on the listener return s.Serve(l) } diff --git a/go.mod b/go.mod index 123d3e0a4..cf47268c5 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.5.1 // indirect github.com/sirupsen/logrus v1.5.0 - github.com/urfave/cli v1.22.4 + github.com/urfave/cli/v2 v2.2.0 google.golang.org/grpc v1.28.1 google.golang.org/protobuf v1.21.0 ) diff --git a/go.sum b/go.sum index 5786c13cf..f2dee35bb 100644 --- a/go.sum +++ b/go.sum @@ -105,8 +105,8 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/urfave/cli v1.22.4 h1:u7tSpNPPswAFymm8IehJhy4uJMlUuU/GmqSkvJ1InXA= -github.com/urfave/cli v1.22.4/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= +github.com/urfave/cli/v2 v2.2.0 h1:JTTnM6wKzdA0Jqodd966MVj4vWbbquZykeX1sKbe2C4= +github.com/urfave/cli/v2 v2.2.0/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=