mirror of
https://git.sr.ht/~phw/scotty
synced 2025-04-16 10:09:28 +02:00
Use nested map for service configs
This commit is contained in:
parent
c8146355c1
commit
36f8f3e311
1 changed files with 5 additions and 1 deletions
|
@ -30,7 +30,11 @@ import (
|
||||||
|
|
||||||
func getConfigFromFlag(cmd *cobra.Command, flagName string) (string, *viper.Viper) {
|
func getConfigFromFlag(cmd *cobra.Command, flagName string) (string, *viper.Viper) {
|
||||||
configName := cmd.Flag(flagName).Value.String()
|
configName := cmd.Flag(flagName).Value.String()
|
||||||
config := viper.Sub(configName)
|
var config *viper.Viper
|
||||||
|
servicesConfig := viper.Sub("service")
|
||||||
|
if servicesConfig != nil {
|
||||||
|
config = servicesConfig.Sub(configName)
|
||||||
|
}
|
||||||
if config == nil {
|
if config == nil {
|
||||||
cobra.CheckErr(fmt.Sprintf("Invalid source configuration \"%s\"", configName))
|
cobra.CheckErr(fmt.Sprintf("Invalid source configuration \"%s\"", configName))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue