ikatlinsky opened a new issue, #2818:
URL: https://github.com/apache/apisix-dashboard/issues/2818
# Feature request
## Please describe your feature
We need a way to dynamically configure dashboard users based on the
environment variables. The current implementation of config parsing using Viper
does not support such an ability, all values are read as they are, without
mapping to the values of the corresponding environment variables.
## Describe the solution you'd like
Allow using environment variables in `config.yaml` in the following format
```
authentication:
users:
- username: $ADMIN_USERNAME_ENV_KEY
password: $ADMIN_PASSWORD_ENV_KEY
```
This can be achieved by using Viper decoder hooks
Decoder:
```
func substituteEnvironmentVariables() mapstructure.DecodeHookFuncKind {
return func(
f reflect.Kind,
t reflect.Kind,
data interface{}) (interface{}, error) {
if f != reflect.String || t != reflect.String {
return data, nil
}
return os.ExpandEnv(data.(string)), nil
}
}
```
Using a decoder in Viper
```
viper.Unmarshal(&config, viper.DecodeHook(substituteEnvironmentVariables()))
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]