diff options
Diffstat (limited to 'config/default.go')
-rw-r--r-- | config/default.go | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/config/default.go b/config/default.go index 05fe2db8..fc15f046 100644 --- a/config/default.go +++ b/config/default.go @@ -216,6 +216,23 @@ func SetDefaultConfigValues(b *BgpConfigSet) error { return setDefaultConfigValuesWithViper(nil, b) } +func setDefaultPolicyConfigValuesWithViper(v *viper.Viper, p *PolicyDefinition) error { + stmts, err := extractArray(v.Get("policy.statements")) + if err != nil { + return err + } + for i, _ := range p.Statements { + vv := viper.New() + if len(stmts) > i { + vv.Set("statement", stmts[i]) + } + if !vv.IsSet("statement.actions.route-disposition") { + p.Statements[i].Actions.RouteDisposition = ROUTE_DISPOSITION_NONE + } + } + return nil +} + func setDefaultConfigValuesWithViper(v *viper.Viper, b *BgpConfigSet) error { if v == nil { v = viper.New() @@ -258,5 +275,21 @@ func setDefaultConfigValuesWithViper(v *viper.Viper, b *BgpConfigSet) error { } } + list, err = extractArray(v.Get("policy-definitions")) + if err != nil { + return err + } + + for idx, p := range b.PolicyDefinitions { + vv := viper.New() + if len(list) > idx { + vv.Set("policy", list[idx]) + } + if err := setDefaultPolicyConfigValuesWithViper(vv, &p); err != nil { + return err + } + b.PolicyDefinitions[idx] = p + } + return nil } |