Skip to content

Commit

Permalink
migrate from urfave/cli/v1 to urfave/cli/v2 (#263)
Browse files Browse the repository at this point in the history
Signed-off-by: Mritunjay Sharma <mritunjaysharma394@gmail.com>
  • Loading branch information
mritunjaysharma394 committed Dec 26, 2021
1 parent 88e906a commit 0d357a9
Show file tree
Hide file tree
Showing 74 changed files with 3,227 additions and 2,972 deletions.
2 changes: 1 addition & 1 deletion go.mod
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
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
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
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

0 comments on commit 0d357a9

Please sign in to comment.