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

Display config in correct format when json flag is used #2544

Merged
merged 1 commit into from
Sep 19, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions cmd/admin-config-get.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package cmd

import (
"encoding/json"
"strings"

"github.com/minio/cli"
"github.com/minio/mc/pkg/probe"
Expand Down Expand Up @@ -48,7 +49,7 @@ EXAMPLES:
// configGetMessage container to hold locks information.
type configGetMessage struct {
Status string `json:"status"`
Config []byte `json:"config"`
Config string `json:"config"`
}

// String colorized service status message.
Expand All @@ -59,10 +60,11 @@ func (u configGetMessage) String() string {
// JSON jsonified service status Message message.
func (u configGetMessage) JSON() string {
u.Status = "success"
statusJSONBytes, e := json.Marshal(u)
statusJSONBytes, e := json.MarshalIndent(u, "", "\t")
fatalIf(probe.NewError(e), "Unable to marshal into JSON.")

return string(statusJSONBytes)
// Remove \n and \t from u.Config which holds the config data
return strings.NewReplacer(`\n`, "", `\t`, "").Replace(string(statusJSONBytes))
}

// checkAdminConfigGetSyntax - validate all the passed arguments
Expand All @@ -89,7 +91,7 @@ func mainAdminConfigGet(ctx *cli.Context) error {
fatalIf(probe.NewError(e), "Cannot get server configuration file.")

// Print
printMsg(configGetMessage{Config: c})
printMsg(configGetMessage{Config: string(c)})

return nil
}