Skip to content

Commit

Permalink
Display the config in correct format when json flag is used
Browse files Browse the repository at this point in the history
Fixes #2530
  • Loading branch information
kannappanr committed Sep 19, 2018
1 parent 044a95b commit 1bb4f17
Showing 1 changed file with 6 additions and 4 deletions.
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
}

0 comments on commit 1bb4f17

Please sign in to comment.