Skip to content

Commit f9db9e1

Browse files
Sergey Klyausfujita
Sergey Klyaus
authored andcommitted
Fix overwriteConfig if field order mismatches
1 parent 16ea4f9 commit f9db9e1

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

pkg/config/oc/bgp_configs.go

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/config/oc/default.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -517,13 +517,12 @@ func OverwriteNeighborConfigWithPeerGroup(c *Neighbor, pg *PeerGroup) error {
517517

518518
func overwriteConfig(c, pg interface{}, tagPrefix string, v *viper.Viper) {
519519
nValue := reflect.Indirect(reflect.ValueOf(c))
520-
nType := reflect.Indirect(nValue).Type()
521520
pgValue := reflect.Indirect(reflect.ValueOf(pg))
522521
pgType := reflect.Indirect(pgValue).Type()
523522

524523
for i := 0; i < pgType.NumField(); i++ {
525524
field := pgType.Field(i).Name
526-
tag := tagPrefix + "." + nType.Field(i).Tag.Get("mapstructure")
525+
tag := tagPrefix + "." + pgType.Field(i).Tag.Get("mapstructure")
527526
if func() bool {
528527
for _, t := range forcedOverwrittenConfig {
529528
if t == tag {
@@ -532,7 +531,9 @@ func overwriteConfig(c, pg interface{}, tagPrefix string, v *viper.Viper) {
532531
}
533532
return false
534533
}() || !v.IsSet(tag) {
535-
nValue.FieldByName(field).Set(pgValue.FieldByName(field))
534+
if nField := nValue.FieldByName(field); nField.IsValid() {
535+
nField.Set(pgValue.FieldByName(field))
536+
}
536537
}
537538
}
538539
}

0 commit comments

Comments
 (0)