Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: migrate from urfave/cli/v1 to urfave/cli/v2 #263

Merged
merged 1 commit into from
Dec 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ require (
github.com/sirupsen/logrus v1.8.1
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635
github.com/ulikunitz/xz v0.5.7 // indirect
github.com/urfave/cli v1.22.4
github.com/urfave/cli/v2 v2.3.0
go.opencensus.io v0.23.0 // indirect
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110
golang.org/x/sys v0.0.0-20210921065528-437939a70204
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -687,9 +687,10 @@ github.com/ulyssessouza/godotenv v1.3.1-0.20210806120901-e417b721114e/go.mod h1:
github.com/urfave/cli v0.0.0-20171014202726-7bc6a0acffa5/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
github.com/urfave/cli v1.22.2 h1:gsqYFH8bb9ekPA12kRo0hfjngWQjkJPlN9R0N78BoUo=
github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
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.3.0 h1:qph92Y649prgesehzOrQjdWyxFOp/QVM+6imKHad91M=
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
github.com/vishvananda/netlink v0.0.0-20181108222139-023a6dafdcdf/go.mod h1:+SR5DhBJrl6ZM7CoCKvpw5BKroDKQ+PJqOg65H/2ktk=
github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE=
github.com/vishvananda/netlink v1.1.1-0.20201029203352-d40f9887b852/go.mod h1:twkDnbuQxJYemMlGd4JFIcuhgX83tXhKS2B/PRMpOho=
Expand Down Expand Up @@ -1034,6 +1035,7 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWD
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
Expand Down
14 changes: 7 additions & 7 deletions pkg/app/master/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
v "github.com/docker-slim/docker-slim/pkg/version"

log "github.com/sirupsen/logrus"
"github.com/urfave/cli"
"github.com/urfave/cli/v2"
)

// DockerSlim app CLI constants
Expand Down Expand Up @@ -73,18 +73,18 @@ func newCLI() *cli.App {
cliApp.Flags = commands.GlobalFlags()

cliApp.Before = func(ctx *cli.Context) error {
if ctx.GlobalBool(commands.FlagNoColor) {
if ctx.Bool(commands.FlagNoColor) {
app.NoColor()
}

if ctx.GlobalBool(commands.FlagDebug) {
if ctx.Bool(commands.FlagDebug) {
log.SetLevel(log.DebugLevel)
} else {
if ctx.GlobalBool(commands.FlagVerbose) {
if ctx.Bool(commands.FlagVerbose) {
log.SetLevel(log.InfoLevel)
} else {
logLevel := log.WarnLevel
logLevelName := ctx.GlobalString(commands.FlagLogLevel)
logLevelName := ctx.String(commands.FlagLogLevel)
switch logLevelName {
case "trace":
logLevel = log.TraceLevel
Expand All @@ -108,15 +108,15 @@ func newCLI() *cli.App {
}
}

if path := ctx.GlobalString(commands.FlagLog); path != "" {
if path := ctx.String(commands.FlagLog); path != "" {
f, err := os.Create(path)
if err != nil {
return err
}
log.SetOutput(f)
}

logFormat := ctx.GlobalString(commands.FlagLogFormat)
logFormat := ctx.String(commands.FlagLogFormat)
switch logFormat {
case "text":
log.SetFormatter(&log.TextFormatter{DisableColors: true})
Expand Down
16 changes: 8 additions & 8 deletions pkg/app/master/commands/build/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/docker-slim/docker-slim/pkg/app/master/config"
"github.com/docker-slim/docker-slim/pkg/util/errutil"

"github.com/urfave/cli"
"github.com/urfave/cli/v2"
)

const (
Expand All @@ -19,7 +19,7 @@ const (
Alias = "b"
)

var CLI = cli.Command{
var CLI = &cli.Command{
Name: Name,
Aliases: []string{Alias},
Usage: Usage,
Expand Down Expand Up @@ -198,7 +198,7 @@ var CLI = cli.Command{
targetRef = ctx.String(commands.FlagTarget)

if targetRef == "" {
if len(ctx.Args()) < 1 {
if ctx.Args().Len() < 1 {
xc.Out.Error("param.target", "missing image ID/name")
cli.ShowCommandHelp(ctx, Name)
return nil
Expand All @@ -209,7 +209,7 @@ var CLI = cli.Command{
} else {
targetRef = cbOpts.DockerfileContext
if targetRef == "" {
if len(ctx.Args()) < 1 {
if ctx.Args().Len() < 1 {
xc.Out.Error("param.target", "missing Dockerfile build context directory")
cli.ShowCommandHelp(ctx, Name)
return nil
Expand Down Expand Up @@ -502,7 +502,7 @@ var CLI = cli.Command{

doKeepTmpArtifacts := ctx.Bool(FlagKeepTmpArtifacts)

doExcludeMounts := ctx.BoolT(commands.FlagExcludeMounts)
doExcludeMounts := ctx.Bool(commands.FlagExcludeMounts)
if doExcludeMounts {
for mpath := range volumeMounts {
excludePatterns[mpath] = nil
Expand Down Expand Up @@ -603,7 +603,7 @@ var CLI = cli.Command{
})
}

commandReport := ctx.GlobalString(commands.FlagCommandReport)
commandReport := ctx.String(commands.FlagCommandReport)
if commandReport == "off" {
commandReport = ""
}
Expand Down Expand Up @@ -684,8 +684,8 @@ var CLI = cli.Command{
execCmd,
string(execFileCmd),
deleteFatImage,
ctx.GlobalString(commands.FlagLogLevel),
ctx.GlobalString(commands.FlagLogFormat))
ctx.String(commands.FlagLogLevel),
ctx.String(commands.FlagLogFormat))

return nil
},
Expand Down