mirror of
https://github.com/minio/minio.git
synced 2025-01-11 23:13:23 -05:00
Allow querying a single target in config get API (#15587)
This commit is contained in:
parent
edba7c987b
commit
18dffb26e7
@ -177,6 +177,11 @@ func (a adminAPIHandlers) SetConfigKVHandler(w http.ResponseWriter, r *http.Requ
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetConfigKVHandler - GET /minio/admin/v3/get-config-kv?key={key}
|
// GetConfigKVHandler - GET /minio/admin/v3/get-config-kv?key={key}
|
||||||
|
//
|
||||||
|
// `key` can be one of three forms:
|
||||||
|
// 1. `subsys:target` -> request for config of a single subsystem and target pair.
|
||||||
|
// 2. `subsys:` -> request for config of a single subsystem and the default target.
|
||||||
|
// 3. `subsys` -> request for config of all targets for the given subsystem.
|
||||||
func (a adminAPIHandlers) GetConfigKVHandler(w http.ResponseWriter, r *http.Request) {
|
func (a adminAPIHandlers) GetConfigKVHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
ctx := newContext(r, w, "GetConfigKV")
|
ctx := newContext(r, w, "GetConfigKV")
|
||||||
|
|
||||||
@ -189,8 +194,22 @@ func (a adminAPIHandlers) GetConfigKVHandler(w http.ResponseWriter, r *http.Requ
|
|||||||
|
|
||||||
cfg := globalServerConfig.Clone()
|
cfg := globalServerConfig.Clone()
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
subSys := vars["key"]
|
key := vars["key"]
|
||||||
subSysConfigs, err := cfg.GetSubsysInfo(subSys)
|
|
||||||
|
var subSys, target string
|
||||||
|
{
|
||||||
|
ws := strings.SplitN(key, madmin.SubSystemSeparator, 2)
|
||||||
|
subSys = ws[0]
|
||||||
|
if len(ws) == 2 {
|
||||||
|
if ws[1] == "" {
|
||||||
|
target = madmin.Default
|
||||||
|
} else {
|
||||||
|
target = ws[1]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
subSysConfigs, err := cfg.GetSubsysInfo(subSys, target)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
||||||
return
|
return
|
||||||
@ -433,7 +452,7 @@ func (a adminAPIHandlers) GetConfigHandler(w http.ResponseWriter, r *http.Reques
|
|||||||
}
|
}
|
||||||
for _, hkv := range hkvs {
|
for _, hkv := range hkvs {
|
||||||
// We ignore the error below, as we cannot get one.
|
// We ignore the error below, as we cannot get one.
|
||||||
cfgSubsysItems, _ := cfg.GetSubsysInfo(hkv.Key)
|
cfgSubsysItems, _ := cfg.GetSubsysInfo(hkv.Key, "")
|
||||||
|
|
||||||
for _, item := range cfgSubsysItems {
|
for _, item := range cfgSubsysItems {
|
||||||
off := item.Config.Get(config.Enable) == config.EnableOff
|
off := item.Config.Get(config.Enable) == config.EnableOff
|
||||||
|
2
go.mod
2
go.mod
@ -48,7 +48,7 @@ require (
|
|||||||
github.com/minio/dperf v0.4.2
|
github.com/minio/dperf v0.4.2
|
||||||
github.com/minio/highwayhash v1.0.2
|
github.com/minio/highwayhash v1.0.2
|
||||||
github.com/minio/kes v0.20.0
|
github.com/minio/kes v0.20.0
|
||||||
github.com/minio/madmin-go v1.4.24
|
github.com/minio/madmin-go v1.4.25
|
||||||
github.com/minio/minio-go/v7 v7.0.34
|
github.com/minio/minio-go/v7 v7.0.34
|
||||||
github.com/minio/pkg v1.3.0
|
github.com/minio/pkg v1.3.0
|
||||||
github.com/minio/selfupdate v0.5.0
|
github.com/minio/selfupdate v0.5.0
|
||||||
|
4
go.sum
4
go.sum
@ -623,8 +623,8 @@ github.com/minio/highwayhash v1.0.2/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLT
|
|||||||
github.com/minio/kes v0.20.0 h1:1tyC51Rr8zTregTESuT/QN/iebNMX7B9t7d3xLNMEpE=
|
github.com/minio/kes v0.20.0 h1:1tyC51Rr8zTregTESuT/QN/iebNMX7B9t7d3xLNMEpE=
|
||||||
github.com/minio/kes v0.20.0/go.mod h1:3FW1BQkMGQW78yhy+69tUq5bdcf5rnXJizyeKB9a/tc=
|
github.com/minio/kes v0.20.0/go.mod h1:3FW1BQkMGQW78yhy+69tUq5bdcf5rnXJizyeKB9a/tc=
|
||||||
github.com/minio/madmin-go v1.3.5/go.mod h1:vGKGboQgGIWx4DuDUaXixjlIEZOCIp6ivJkQoiVaACc=
|
github.com/minio/madmin-go v1.3.5/go.mod h1:vGKGboQgGIWx4DuDUaXixjlIEZOCIp6ivJkQoiVaACc=
|
||||||
github.com/minio/madmin-go v1.4.24 h1:AFn8/N/E64RUXV4ztGwQcmsKb2uTlwSwiGyk6B37PWY=
|
github.com/minio/madmin-go v1.4.25 h1:IEJpsTXlHz18/yRI5HxY84KaJdDjUUYdMiC5f8fId4g=
|
||||||
github.com/minio/madmin-go v1.4.24/go.mod h1:ez87VmMtsxP7DRxjKJKD4RDNW+nhO2QF9KSzwxBDQ98=
|
github.com/minio/madmin-go v1.4.25/go.mod h1:ez87VmMtsxP7DRxjKJKD4RDNW+nhO2QF9KSzwxBDQ98=
|
||||||
github.com/minio/mc v0.0.0-20220818165341-8c239d16aa37 h1:UE9kHgdza2HB4DDx0nIn0jHRl6YASUomVoKjciMfqjM=
|
github.com/minio/mc v0.0.0-20220818165341-8c239d16aa37 h1:UE9kHgdza2HB4DDx0nIn0jHRl6YASUomVoKjciMfqjM=
|
||||||
github.com/minio/mc v0.0.0-20220818165341-8c239d16aa37/go.mod h1:O3pvs5/n57bZ0mpcG/skBuD4pHX6m+wVbW7lw8LO5go=
|
github.com/minio/mc v0.0.0-20220818165341-8c239d16aa37/go.mod h1:O3pvs5/n57bZ0mpcG/skBuD4pHX6m+wVbW7lw8LO5go=
|
||||||
github.com/minio/md5-simd v1.1.0/go.mod h1:XpBqgZULrMYD3R+M28PcmP0CkI7PEMzB3U77ZrKZ0Gw=
|
github.com/minio/md5-simd v1.1.0/go.mod h1:XpBqgZULrMYD3R+M28PcmP0CkI7PEMzB3U77ZrKZ0Gw=
|
||||||
|
@ -1221,8 +1221,10 @@ type SubsysInfo struct {
|
|||||||
EnvMap map[string]EnvPair
|
EnvMap map[string]EnvPair
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetSubsysInfo returns `SubsysInfo`s for all targets for the subsystem.
|
// GetSubsysInfo returns `SubsysInfo`s for all targets for the subsystem, when
|
||||||
func (c Config) GetSubsysInfo(subSys string) ([]SubsysInfo, error) {
|
// target is empty. Otherwise returns `SubsysInfo` for the desired target only.
|
||||||
|
// To request the default target only, target must be set to `Default`.
|
||||||
|
func (c Config) GetSubsysInfo(subSys, target string) ([]SubsysInfo, error) {
|
||||||
// Check if config param requested is valid.
|
// Check if config param requested is valid.
|
||||||
defKVS1, ok := DefaultKVS[subSys]
|
defKVS1, ok := DefaultKVS[subSys]
|
||||||
if !ok {
|
if !ok {
|
||||||
@ -1234,6 +1236,20 @@ func (c Config) GetSubsysInfo(subSys string) ([]SubsysInfo, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if target != "" {
|
||||||
|
found := false
|
||||||
|
for _, t := range targets {
|
||||||
|
if t == target {
|
||||||
|
found = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !found {
|
||||||
|
return nil, Errorf("there is no target `%s` for subsystem `%s`", target, subSys)
|
||||||
|
}
|
||||||
|
targets = []string{target}
|
||||||
|
}
|
||||||
|
|
||||||
// The `Comment` configuration variable is optional but is available to be
|
// The `Comment` configuration variable is optional but is available to be
|
||||||
// set for all sub-systems. It is not present in the `DefaultKVS` map's
|
// set for all sub-systems. It is not present in the `DefaultKVS` map's
|
||||||
// values. To enable fetching a configured comment value from the
|
// values. To enable fetching a configured comment value from the
|
||||||
|
Loading…
Reference in New Issue
Block a user