mirror of
https://github.com/semaphoreui/semaphore.git
synced 2024-11-23 20:35:24 +01:00
fix(config): check value by zero for init default
This commit is contained in:
parent
f553def7f2
commit
175d629518
@ -189,9 +189,9 @@ func (conf *ConfigType) ToJSON() ([]byte, error) {
|
||||
// ConfigInit reads in cli flags, and switches actions appropriately on them
|
||||
func ConfigInit(configPath string) {
|
||||
fmt.Println("Loading config")
|
||||
loadConfigDefaults()
|
||||
loadConfigFile(configPath)
|
||||
loadConfigEnvironment()
|
||||
loadConfigDefaults()
|
||||
|
||||
fmt.Println("Validating config")
|
||||
validateConfig()
|
||||
@ -256,14 +256,14 @@ func loadDefaultsToObject(obj interface{}) error {
|
||||
v = reflect.Indirect(v)
|
||||
}
|
||||
|
||||
if v.Type().Kind() != reflect.Struct {
|
||||
return nil
|
||||
}
|
||||
|
||||
for i := 0; i < t.NumField(); i++ {
|
||||
fieldType := t.Field(i)
|
||||
fieldValue := v.Field(i)
|
||||
|
||||
if !fieldValue.IsZero() {
|
||||
continue
|
||||
}
|
||||
|
||||
if fieldType.Type.Kind() == reflect.Struct {
|
||||
err := loadDefaultsToObject(fieldValue.Addr())
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user