From c319567430a69608efee2677b2af4b418461e7ef Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Mon, 19 Jul 2021 08:29:20 -0700 Subject: [PATCH] do not print config values in base64 (#3757) fixes #3696 --- .golangci.yml | 2 +- Makefile | 4 ++-- cmd/admin-config-get.go | 33 +++++++++++++++++++++++++-------- cmd/admin-heal.go | 26 +++++++++++++------------- cmd/ilm/options.go | 2 +- 5 files changed, 42 insertions(+), 25 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 99e06b20..ef0fc09f 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -8,11 +8,11 @@ linters-settings: linters: disable-all: true enable: + - revive - typecheck - goimports - misspell - govet - - golint - ineffassign - gosimple - deadcode diff --git a/Makefile b/Makefile index bec49e82..8b18373f 100644 --- a/Makefile +++ b/Makefile @@ -18,8 +18,8 @@ checks: getdeps: @mkdir -p ${GOPATH}/bin - @which golangci-lint 1>/dev/null || (echo "Installing golangci-lint" && curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin v1.27.0) - @which stringer 1>/dev/null || (echo "Installing stringer" && go get golang.org/x/tools/cmd/stringer) + @echo "Installing golangci-lint" && curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin v1.40.1 + @which stringer 1>/dev/null || (echo "Installing stringer" && go install -v golang.org/x/tools/cmd/stringer@v0.1.5) crosscompile: @(env bash $(PWD)/buildscripts/cross-compile.sh) diff --git a/cmd/admin-config-get.go b/cmd/admin-config-get.go index b5f7714d..d4ae6ed4 100644 --- a/cmd/admin-config-get.go +++ b/cmd/admin-config-get.go @@ -22,6 +22,7 @@ import ( "github.com/minio/cli" json "github.com/minio/colorjson" + "github.com/minio/madmin-go" "github.com/minio/mc/pkg/probe" ) @@ -58,13 +59,14 @@ EXAMPLES: // configGetMessage container to hold locks information. type configGetMessage struct { - Status string `json:"status"` - Value []byte `json:"value"` + Status string `json:"status"` + Value *madmin.Target `json:"value"` + value []byte } // String colorized service status message. func (u configGetMessage) String() string { - return string(u.Value) + return string(u.value) } // JSON jsonified service status Message message. @@ -109,14 +111,29 @@ func mainAdminConfigGet(ctx *cli.Context) error { return nil } + subSys := strings.Join(args.Tail(), " ") + // Call get config API - buf, e := client.GetConfigKV(globalContext, strings.Join(args.Tail(), " ")) + buf, e := client.GetConfigKV(globalContext, subSys) fatalIf(probe.NewError(e), "Unable to get server '%s' config", args.Tail()) - // Print - printMsg(configGetMessage{ - Value: buf, - }) + if globalJSON { + hr, e := client.HelpConfigKV(globalContext, subSys, "", false) + fatalIf(probe.NewError(e), "Unable to get help for "+subSys+" the sub-system") + + tgt, e := madmin.ParseSubSysTarget(buf, hr) + fatalIf(probe.NewError(e), "Unable to parse sub-system target "+subSys) + + printMsg(configGetMessage{ + Value: tgt, + value: buf, + }) + } else { + // Print + printMsg(configGetMessage{ + value: buf, + }) + } return nil } diff --git a/cmd/admin-heal.go b/cmd/admin-heal.go index 29e4e59c..fc8ca148 100644 --- a/cmd/admin-heal.go +++ b/cmd/admin-heal.go @@ -40,34 +40,34 @@ const ( var adminHealFlags = []cli.Flag{ cli.StringFlag{ Name: "scan", - Usage: "[DEPRECATED] select the healing scan mode (normal/deep)", + Usage: "select the healing scan mode (normal/deep)", Value: scanNormalMode, }, cli.BoolFlag{ Name: "recursive, r", - Usage: "[DEPRECATED] heal recursively", + Usage: "heal recursively", }, cli.BoolFlag{ Name: "dry-run, n", - Usage: "[DEPRECATED] only inspect data, but do not mutate", + Usage: "only inspect data, but do not mutate", }, cli.BoolFlag{ Name: "force-start, f", - Usage: "[DEPRECATED] force start a new heal sequence", + Usage: "force start a new heal sequence", }, cli.BoolFlag{ Name: "force-stop, s", - Usage: "[DEPRECATED] force stop a running heal sequence", + Usage: "force stop a running heal sequence", }, cli.BoolFlag{ Name: "remove", - Usage: "[DEPRECATED] remove dangling objects in heal sequence", + Usage: "remove dangling objects in heal sequence", }, } var adminHealCmd = cli.Command{ Name: "heal", - Usage: "[DEPRECATED] heal disks, buckets and objects on MinIO server", + Usage: "heal disks, buckets and objects on MinIO server", Action: mainAdminHeal, OnUsageError: onUsageError, Before: setGlobalsFromContext, @@ -82,12 +82,12 @@ USAGE: FLAGS: {{range .VisibleFlags}}{{.}} {{end}} -SCAN MODES: - normal (default): Heal objects which are missing on one or more disks. - deep : Heal objects which are missing or with silent data corruption on one or more disks. - -DEPRECATED: - MinIO server now supports auto-heal, this command will be removed in future. +EXAMPLES: + 1. Monitor healing status on a running server at alias 'myminio': + {{.Prompt}} {{.HelpName}} myminio/ + Objects Healed: 7/27 (25.9%), 31 MB/110 MB (0%) + Heal rate: 3 obj/s, 10 MB/s + Estimated Completion: 11 seconds `, } diff --git a/cmd/ilm/options.go b/cmd/ilm/options.go index c3be70ec..6fad8dd8 100644 --- a/cmd/ilm/options.go +++ b/cmd/ilm/options.go @@ -185,7 +185,7 @@ func (opts LifecycleOptions) ToConfig(config *lifecycle.Configuration) (*lifecyc // GetLifecycleOptions create LifeCycleOptions based on cli inputs func GetLifecycleOptions(ctx *cli.Context) LifecycleOptions { - var id string = ctx.String("id") + id := ctx.String("id") if id == "" { id = xid.New().String() }