Update export command to print disabled sub-sys as comments (#2978)

This commit is contained in:
Harshavardhana
2019-12-03 12:10:12 -08:00
committed by kannappanr
parent 1e1480f408
commit 3f426ff7e0
4 changed files with 34 additions and 18 deletions
+19 -1
View File
@@ -18,6 +18,7 @@ package cmd
import (
"encoding/json"
"strings"
"github.com/minio/cli"
"github.com/minio/mc/pkg/probe"
@@ -53,7 +54,24 @@ type configExportMessage struct {
// String colorized service status message.
func (u configExportMessage) String() string {
return u.Value.String()
var s strings.Builder
count := u.Value.Count()
// Print all "on" states entries
for _, targetKV := range u.Value {
kv := targetKV.KVS
count--
if kv.Get(madmin.StateKey) == madmin.StateOff {
s.WriteString(madmin.KvComment)
s.WriteString(madmin.KvSpaceSeparator)
}
s.WriteString(targetKV.SubSystem)
s.WriteString(madmin.KvSpaceSeparator)
s.WriteString(kv.String())
if len(u.Value) > 1 && count > 0 {
s.WriteString(madmin.KvNewline)
}
}
return s.String()
}
// JSON jsonified service status Message message.
+2 -2
View File
@@ -124,7 +124,7 @@ func getModTime(path string) (t time.Time, err *probe.Error) {
var e error
path, e = filepath.EvalSymlinks(path)
if e != nil {
return t, probe.NewError(fmt.Errorf("Unable to get absolute path of %s. %s", path, e))
return t, probe.NewError(fmt.Errorf("Unable to get absolute path of %s. %w", path, e))
}
// Version is mc non-standard, we will use mc binary's
@@ -132,7 +132,7 @@ func getModTime(path string) (t time.Time, err *probe.Error) {
var fi os.FileInfo
fi, e = os.Stat(path)
if e != nil {
return t, probe.NewError(fmt.Errorf("Unable to get ModTime of %s. %s", path, e))
return t, probe.NewError(fmt.Errorf("Unable to get ModTime of %s. %w", path, e))
}
// Return the ModTime