1
0
mirror of https://github.com/minio/mc.git synced 2025-12-10 10:22:47 +03:00

Fix incorrect bool parsing (#4991)

For example `--json=false` would still print JSON.

Went through all usage, and I think I covered them all.
This commit is contained in:
Klaus Post
2024-07-18 09:08:30 -07:00
committed by GitHub
parent ded36374e8
commit f6df01d750
8 changed files with 18 additions and 18 deletions

View File

@@ -127,7 +127,7 @@ func mainAdminConfigHistory(ctx *cli.Context) error {
client, err := newAdminClient(aliasedURL)
fatalIf(err, "Unable to initialize admin connection.")
if ctx.IsSet("clear") {
if ctx.Bool("clear") {
fatalIf(probe.NewError(client.ClearConfigHistoryKV(globalContext, "all")), "Unable to clear server configuration.")
// Print

View File

@@ -116,13 +116,13 @@ func mainAdminConfigReset(ctx *cli.Context) error {
if len(ctx.Args()) == 1 {
// Call get config API
hr, e := client.HelpConfigKV(globalContext, "", "", ctx.IsSet("env"))
hr, e := client.HelpConfigKV(globalContext, "", "", ctx.Bool("env"))
fatalIf(probe.NewError(e), "Unable to get help for the sub-system")
// Print
printMsg(configHelpMessage{
Value: hr,
envOnly: ctx.IsSet("env"),
envOnly: ctx.Bool("env"),
})
return nil

View File

@@ -112,13 +112,13 @@ func mainAdminConfigSet(ctx *cli.Context) error {
if !strings.Contains(input, madmin.KvSeparator) {
// Call get config API
hr, e := client.HelpConfigKV(globalContext, args.Get(1), args.Get(2), ctx.IsSet("env"))
hr, e := client.HelpConfigKV(globalContext, args.Get(1), args.Get(2), ctx.Bool("env"))
fatalIf(probe.NewError(e), "Unable to get help for the sub-system")
// Print
printMsg(configHelpMessage{
Value: hr,
envOnly: ctx.IsSet("env"),
envOnly: ctx.Bool("env"),
})
return nil

View File

@@ -95,15 +95,15 @@ func (i srRemoveStatus) String() string {
func checkAdminReplicateRemoveSyntax(ctx *cli.Context) {
// Check argument count
argsNr := len(ctx.Args())
if ctx.IsSet("all") && argsNr > 1 {
if ctx.Bool("all") && argsNr > 1 {
fatalIf(errInvalidArgument().Trace(ctx.Args().Tail()...),
"")
}
if argsNr < 2 && !ctx.IsSet("all") {
if argsNr < 2 && !ctx.Bool("all") {
fatalIf(errInvalidArgument().Trace(ctx.Args().Tail()...),
"Need at least two arguments to remove command.")
}
if !ctx.IsSet("force") {
if !ctx.Bool("force") {
fatalIf(errDummy().Trace(),
"Site removal requires --force flag. This operation is *IRREVERSIBLE*. Please review carefully before performing this *DANGEROUS* operation.")
}

View File

@@ -251,7 +251,7 @@ func mainAdminServiceRestart(ctx *cli.Context) error {
fatalIf(err, "Unable to initialize admin connection.")
rowCount := 2
toWait := ctx.IsSet("wait")
toWait := ctx.Bool("wait")
if toWait {
rowCount = 3
}

View File

@@ -112,13 +112,13 @@ func parsePagerDisableFlag(args []string) {
// Set global states. NOTE: It is deliberately kept monolithic to ensure we dont miss out any flags.
func setGlobalsFromContext(ctx *cli.Context) error {
quiet := ctx.IsSet("quiet") || ctx.GlobalIsSet("quiet")
debug := ctx.IsSet("debug") || ctx.GlobalIsSet("debug")
json := ctx.IsSet("json") || ctx.GlobalIsSet("json")
noColor := ctx.IsSet("no-color") || ctx.GlobalIsSet("no-color")
insecure := ctx.IsSet("insecure") || ctx.GlobalIsSet("insecure")
devMode := ctx.IsSet("dev") || ctx.GlobalIsSet("dev")
airgapped := ctx.IsSet("airgap") || ctx.GlobalIsSet("airgap")
quiet := ctx.Bool("quiet") || ctx.GlobalBool("quiet")
debug := ctx.Bool("debug") || ctx.GlobalBool("debug")
json := ctx.Bool("json") || ctx.GlobalBool("json")
noColor := ctx.Bool("no-color") || ctx.GlobalBool("no-color")
insecure := ctx.Bool("insecure") || ctx.GlobalBool("insecure")
devMode := ctx.Bool("dev") || ctx.GlobalBool("dev")
airgapped := ctx.Bool("airgap") || ctx.GlobalBool("airgap")
globalQuiet = globalQuiet || quiet
globalDebug = globalDebug || debug

View File

@@ -191,7 +191,7 @@ func mainPipe(ctx *cli.Context) error {
fatalIf(err, "Unable to parse encryption keys.")
// globalQuiet is true for no window size to get. We just need --quiet here.
quiet := ctx.IsSet("quiet")
quiet := ctx.Bool("quiet")
meta := map[string]string{}
if attr := ctx.String("attr"); attr != "" {

View File

@@ -519,7 +519,7 @@ func mainReplicateBacklog(cliCtx *cli.Context) error {
// Create a new MinIO Admin Client
client, cerr := newAdminClient(aliasedURL)
fatalIf(cerr, "Unable to initialize admin connection.")
if !cliCtx.IsSet("full") {
if !cliCtx.Bool("full") {
mrfCh := client.BucketReplicationMRF(ctx, bucket, cliCtx.String("nodes"))
if globalJSON {
for mrf := range mrfCh {