mirror of
https://github.com/minio/minio.git
synced 2025-11-22 18:47:43 -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
@@ -21,6 +21,7 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -80,14 +81,27 @@ func (adm *AdminClient) RestoreConfigHistoryKV(restoreID string) (err error) {
|
||||
type ConfigHistoryEntry struct {
|
||||
RestoreID string `json:"restoreId"`
|
||||
CreateTime time.Time `json:"createTime"`
|
||||
Data string `json:"data"`
|
||||
}
|
||||
|
||||
// CreateTimeFormatted is used to print formatted time for CreateTime.
|
||||
func (ch ConfigHistoryEntry) CreateTimeFormatted() string {
|
||||
return ch.CreateTime.Format(http.TimeFormat)
|
||||
}
|
||||
|
||||
// ListConfigHistoryKV - lists a slice of ConfigHistoryEntries sorted by createTime.
|
||||
func (adm *AdminClient) ListConfigHistoryKV() ([]ConfigHistoryEntry, error) {
|
||||
func (adm *AdminClient) ListConfigHistoryKV(count int) ([]ConfigHistoryEntry, error) {
|
||||
if count == 0 {
|
||||
count = 10
|
||||
}
|
||||
v := url.Values{}
|
||||
v.Set("count", strconv.Itoa(count))
|
||||
|
||||
// Execute GET on /minio/admin/v2/list-config-history-kv
|
||||
resp, err := adm.executeMethod(http.MethodGet,
|
||||
requestData{
|
||||
relPath: adminAPIPrefix + "/list-config-history-kv",
|
||||
relPath: adminAPIPrefix + "/list-config-history-kv",
|
||||
queryValues: v,
|
||||
})
|
||||
defer closeResponse(resp)
|
||||
if err != nil {
|
||||
@@ -97,11 +111,15 @@ func (adm *AdminClient) ListConfigHistoryKV() ([]ConfigHistoryEntry, error) {
|
||||
return nil, httpRespToErrorResponse(resp)
|
||||
}
|
||||
|
||||
data, err := DecryptData(adm.secretAccessKey, resp.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var chEntries []ConfigHistoryEntry
|
||||
d := json.NewDecoder(resp.Body)
|
||||
d.DisallowUnknownFields()
|
||||
if err = d.Decode(&chEntries); err != nil {
|
||||
if err = json.Unmarshal(data, &chEntries); err != nil {
|
||||
return chEntries, err
|
||||
}
|
||||
|
||||
return chEntries, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user