mirror of
https://github.com/minio/minio.git
synced 2025-11-22 02:35:30 -05:00
Enhance config restore to carry previous set content as well (#8483)
This PR brings support for `history` list to list in the following agreed format ``` ~ mc admin config history list -n 2 myminio RestoreId: df0ebb1e-69b0-4043-b9dd-ab54508f2897 Date: Mon, 04 Nov 2019 17:27:27 GMT region name="us-east-1" state="on" region name="us-east-1" state="on" region name="us-east-1" state="on" region name="us-east-1" state="on" RestoreId: ecc6873a-0ed3-41f9-b03e-a2a1bab48b5f Date: Mon, 04 Nov 2019 17:28:23 GMT region name=us-east-1 state=off ``` This PR also moves the help templating and coloring to fully `mc` side instead than `madmin` API.
This commit is contained in:
committed by
kannappanr
parent
26ed9e81b1
commit
1e457dda7e
@@ -19,42 +19,12 @@ package madmin
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
"text/tabwriter"
|
||||
"text/template"
|
||||
|
||||
"github.com/minio/minio/pkg/color"
|
||||
)
|
||||
|
||||
// Help template used by all sub-systems
|
||||
const Help = `{{colorBlueBold "Key"}}{{"\t"}}{{colorBlueBold "Description"}}
|
||||
{{colorYellowBold "----"}}{{"\t"}}{{colorYellowBold "----"}}
|
||||
{{range $key, $value := .}}{{colorCyanBold $key}}{{ "\t" }}{{$value}}
|
||||
{{end}}`
|
||||
|
||||
// HelpEnv template used by all sub-systems
|
||||
const HelpEnv = `{{colorBlueBold "KeyEnv"}}{{"\t"}}{{colorBlueBold "Description"}}
|
||||
{{colorYellowBold "----"}}{{"\t"}}{{colorYellowBold "----"}}
|
||||
{{range $key, $value := .}}{{colorCyanBold $key}}{{ "\t" }}{{$value}}
|
||||
{{end}}`
|
||||
|
||||
var funcMap = template.FuncMap{
|
||||
"colorBlueBold": color.BlueBold,
|
||||
"colorYellowBold": color.YellowBold,
|
||||
"colorCyanBold": color.CyanBold,
|
||||
}
|
||||
|
||||
// HelpTemplate - captures config help template
|
||||
var HelpTemplate = template.Must(template.New("config-help").Funcs(funcMap).Parse(Help))
|
||||
|
||||
// HelpEnvTemplate - captures config help template
|
||||
var HelpEnvTemplate = template.Must(template.New("config-help-env").Funcs(funcMap).Parse(HelpEnv))
|
||||
|
||||
// HelpConfigKV - return help for a given sub-system.
|
||||
func (adm *AdminClient) HelpConfigKV(subSys, key string, envOnly bool) (io.Reader, error) {
|
||||
func (adm *AdminClient) HelpConfigKV(subSys, key string, envOnly bool) (map[string]string, error) {
|
||||
v := url.Values{}
|
||||
v.Set("subSys", subSys)
|
||||
v.Set("key", key)
|
||||
@@ -84,17 +54,5 @@ func (adm *AdminClient) HelpConfigKV(subSys, key string, envOnly bool) (io.Reade
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var s strings.Builder
|
||||
w := tabwriter.NewWriter(&s, 1, 8, 2, ' ', 0)
|
||||
if !envOnly {
|
||||
err = HelpTemplate.Execute(w, help)
|
||||
} else {
|
||||
err = HelpEnvTemplate.Execute(w, help)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
w.Flush()
|
||||
return strings.NewReader(s.String()), nil
|
||||
return help, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user