diff --git a/internal/config/config.go b/internal/config/config.go index 0cda4220a..080734d63 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -1091,6 +1091,8 @@ func (c Config) GetAvailableTargets(subSys string) ([]string, error) { seen.Add(k) } + // env:prefix + filterMap := map[string]string{} // Add targets that are configured via environment variables. for _, param := range defKVS { envVarPrefix := getEnvVarName(subSys, Default, param.Key) + Default @@ -1098,11 +1100,21 @@ func (c Config) GetAvailableTargets(subSys string) ([]string, error) { for _, k := range envsWithPrefix { tgtName := strings.TrimPrefix(k, envVarPrefix) if tgtName != "" { - seen.Add(tgtName) + if v, ok := filterMap[k]; ok { + if strings.HasPrefix(envVarPrefix, v) { + filterMap[k] = envVarPrefix + } + } else { + filterMap[k] = envVarPrefix + } } } } + for k, v := range filterMap { + seen.Add(strings.TrimPrefix(k, v)) + } + seen.Remove(Default) targets := seen.ToSlice() sort.Strings(targets)