mirror of
https://github.com/minio/minio.git
synced 2025-11-07 21:02:58 -05:00
Allow querying a single target in config get API (#15587)
This commit is contained in:
committed by
GitHub
parent
edba7c987b
commit
18dffb26e7
@@ -1221,8 +1221,10 @@ type SubsysInfo struct {
|
||||
EnvMap map[string]EnvPair
|
||||
}
|
||||
|
||||
// GetSubsysInfo returns `SubsysInfo`s for all targets for the subsystem.
|
||||
func (c Config) GetSubsysInfo(subSys string) ([]SubsysInfo, error) {
|
||||
// GetSubsysInfo returns `SubsysInfo`s for all targets for the subsystem, when
|
||||
// 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.
|
||||
defKVS1, ok := DefaultKVS[subSys]
|
||||
if !ok {
|
||||
@@ -1234,6 +1236,20 @@ func (c Config) GetSubsysInfo(subSys string) ([]SubsysInfo, error) {
|
||||
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
|
||||
// set for all sub-systems. It is not present in the `DefaultKVS` map's
|
||||
// values. To enable fetching a configured comment value from the
|
||||
|
||||
Reference in New Issue
Block a user