mirror of
https://github.com/semaphoreui/semaphore.git
synced 2024-12-03 14:51:05 +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
|
// ConfigInit reads in cli flags, and switches actions appropriately on them
|
||||||
func ConfigInit(configPath string) {
|
func ConfigInit(configPath string) {
|
||||||
fmt.Println("Loading config")
|
fmt.Println("Loading config")
|
||||||
loadConfigDefaults()
|
|
||||||
loadConfigFile(configPath)
|
loadConfigFile(configPath)
|
||||||
loadConfigEnvironment()
|
loadConfigEnvironment()
|
||||||
|
loadConfigDefaults()
|
||||||
|
|
||||||
fmt.Println("Validating config")
|
fmt.Println("Validating config")
|
||||||
validateConfig()
|
validateConfig()
|
||||||
@ -256,14 +256,14 @@ func loadDefaultsToObject(obj interface{}) error {
|
|||||||
v = reflect.Indirect(v)
|
v = reflect.Indirect(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
if v.Type().Kind() != reflect.Struct {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
for i := 0; i < t.NumField(); i++ {
|
for i := 0; i < t.NumField(); i++ {
|
||||||
fieldType := t.Field(i)
|
fieldType := t.Field(i)
|
||||||
fieldValue := v.Field(i)
|
fieldValue := v.Field(i)
|
||||||
|
|
||||||
|
if !fieldValue.IsZero() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if fieldType.Type.Kind() == reflect.Struct {
|
if fieldType.Type.Kind() == reflect.Struct {
|
||||||
err := loadDefaultsToObject(fieldValue.Addr())
|
err := loadDefaultsToObject(fieldValue.Addr())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user