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:
@@ -127,7 +127,7 @@ func mainAdminConfigHistory(ctx *cli.Context) error {
|
|||||||
client, err := newAdminClient(aliasedURL)
|
client, err := newAdminClient(aliasedURL)
|
||||||
fatalIf(err, "Unable to initialize admin connection.")
|
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.")
|
fatalIf(probe.NewError(client.ClearConfigHistoryKV(globalContext, "all")), "Unable to clear server configuration.")
|
||||||
|
|
||||||
// Print
|
// Print
|
||||||
|
|||||||
@@ -116,13 +116,13 @@ func mainAdminConfigReset(ctx *cli.Context) error {
|
|||||||
|
|
||||||
if len(ctx.Args()) == 1 {
|
if len(ctx.Args()) == 1 {
|
||||||
// Call get config API
|
// 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")
|
fatalIf(probe.NewError(e), "Unable to get help for the sub-system")
|
||||||
|
|
||||||
// Print
|
// Print
|
||||||
printMsg(configHelpMessage{
|
printMsg(configHelpMessage{
|
||||||
Value: hr,
|
Value: hr,
|
||||||
envOnly: ctx.IsSet("env"),
|
envOnly: ctx.Bool("env"),
|
||||||
})
|
})
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -112,13 +112,13 @@ func mainAdminConfigSet(ctx *cli.Context) error {
|
|||||||
|
|
||||||
if !strings.Contains(input, madmin.KvSeparator) {
|
if !strings.Contains(input, madmin.KvSeparator) {
|
||||||
// Call get config API
|
// 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")
|
fatalIf(probe.NewError(e), "Unable to get help for the sub-system")
|
||||||
|
|
||||||
// Print
|
// Print
|
||||||
printMsg(configHelpMessage{
|
printMsg(configHelpMessage{
|
||||||
Value: hr,
|
Value: hr,
|
||||||
envOnly: ctx.IsSet("env"),
|
envOnly: ctx.Bool("env"),
|
||||||
})
|
})
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -95,15 +95,15 @@ func (i srRemoveStatus) String() string {
|
|||||||
func checkAdminReplicateRemoveSyntax(ctx *cli.Context) {
|
func checkAdminReplicateRemoveSyntax(ctx *cli.Context) {
|
||||||
// Check argument count
|
// Check argument count
|
||||||
argsNr := len(ctx.Args())
|
argsNr := len(ctx.Args())
|
||||||
if ctx.IsSet("all") && argsNr > 1 {
|
if ctx.Bool("all") && argsNr > 1 {
|
||||||
fatalIf(errInvalidArgument().Trace(ctx.Args().Tail()...),
|
fatalIf(errInvalidArgument().Trace(ctx.Args().Tail()...),
|
||||||
"")
|
"")
|
||||||
}
|
}
|
||||||
if argsNr < 2 && !ctx.IsSet("all") {
|
if argsNr < 2 && !ctx.Bool("all") {
|
||||||
fatalIf(errInvalidArgument().Trace(ctx.Args().Tail()...),
|
fatalIf(errInvalidArgument().Trace(ctx.Args().Tail()...),
|
||||||
"Need at least two arguments to remove command.")
|
"Need at least two arguments to remove command.")
|
||||||
}
|
}
|
||||||
if !ctx.IsSet("force") {
|
if !ctx.Bool("force") {
|
||||||
fatalIf(errDummy().Trace(),
|
fatalIf(errDummy().Trace(),
|
||||||
"Site removal requires --force flag. This operation is *IRREVERSIBLE*. Please review carefully before performing this *DANGEROUS* operation.")
|
"Site removal requires --force flag. This operation is *IRREVERSIBLE*. Please review carefully before performing this *DANGEROUS* operation.")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -251,7 +251,7 @@ func mainAdminServiceRestart(ctx *cli.Context) error {
|
|||||||
fatalIf(err, "Unable to initialize admin connection.")
|
fatalIf(err, "Unable to initialize admin connection.")
|
||||||
|
|
||||||
rowCount := 2
|
rowCount := 2
|
||||||
toWait := ctx.IsSet("wait")
|
toWait := ctx.Bool("wait")
|
||||||
if toWait {
|
if toWait {
|
||||||
rowCount = 3
|
rowCount = 3
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.
|
// Set global states. NOTE: It is deliberately kept monolithic to ensure we dont miss out any flags.
|
||||||
func setGlobalsFromContext(ctx *cli.Context) error {
|
func setGlobalsFromContext(ctx *cli.Context) error {
|
||||||
quiet := ctx.IsSet("quiet") || ctx.GlobalIsSet("quiet")
|
quiet := ctx.Bool("quiet") || ctx.GlobalBool("quiet")
|
||||||
debug := ctx.IsSet("debug") || ctx.GlobalIsSet("debug")
|
debug := ctx.Bool("debug") || ctx.GlobalBool("debug")
|
||||||
json := ctx.IsSet("json") || ctx.GlobalIsSet("json")
|
json := ctx.Bool("json") || ctx.GlobalBool("json")
|
||||||
noColor := ctx.IsSet("no-color") || ctx.GlobalIsSet("no-color")
|
noColor := ctx.Bool("no-color") || ctx.GlobalBool("no-color")
|
||||||
insecure := ctx.IsSet("insecure") || ctx.GlobalIsSet("insecure")
|
insecure := ctx.Bool("insecure") || ctx.GlobalBool("insecure")
|
||||||
devMode := ctx.IsSet("dev") || ctx.GlobalIsSet("dev")
|
devMode := ctx.Bool("dev") || ctx.GlobalBool("dev")
|
||||||
airgapped := ctx.IsSet("airgap") || ctx.GlobalIsSet("airgap")
|
airgapped := ctx.Bool("airgap") || ctx.GlobalBool("airgap")
|
||||||
|
|
||||||
globalQuiet = globalQuiet || quiet
|
globalQuiet = globalQuiet || quiet
|
||||||
globalDebug = globalDebug || debug
|
globalDebug = globalDebug || debug
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ func mainPipe(ctx *cli.Context) error {
|
|||||||
fatalIf(err, "Unable to parse encryption keys.")
|
fatalIf(err, "Unable to parse encryption keys.")
|
||||||
|
|
||||||
// globalQuiet is true for no window size to get. We just need --quiet here.
|
// 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{}
|
meta := map[string]string{}
|
||||||
if attr := ctx.String("attr"); attr != "" {
|
if attr := ctx.String("attr"); attr != "" {
|
||||||
|
|||||||
@@ -519,7 +519,7 @@ func mainReplicateBacklog(cliCtx *cli.Context) error {
|
|||||||
// Create a new MinIO Admin Client
|
// Create a new MinIO Admin Client
|
||||||
client, cerr := newAdminClient(aliasedURL)
|
client, cerr := newAdminClient(aliasedURL)
|
||||||
fatalIf(cerr, "Unable to initialize admin connection.")
|
fatalIf(cerr, "Unable to initialize admin connection.")
|
||||||
if !cliCtx.IsSet("full") {
|
if !cliCtx.Bool("full") {
|
||||||
mrfCh := client.BucketReplicationMRF(ctx, bucket, cliCtx.String("nodes"))
|
mrfCh := client.BucketReplicationMRF(ctx, bucket, cliCtx.String("nodes"))
|
||||||
if globalJSON {
|
if globalJSON {
|
||||||
for mrf := range mrfCh {
|
for mrf := range mrfCh {
|
||||||
|
|||||||
Reference in New Issue
Block a user