summaryrefslogtreecommitdiffhomepage
path: root/table/policy.go
diff options
context:
space:
mode:
authorISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2016-01-08 11:52:07 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-01-09 05:17:57 -0800
commitb0fbcc6b1b18d2c9fe67437fe6432914b67c5508 (patch)
treeeb453913e7612460cdea586050d616cf2b91312e /table/policy.go
parent26c03bb779fbb59bb3de1c98a2c9d65e192b50bb (diff)
config: change enum value type to string for ease of configuration
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'table/policy.go')
-rw-r--r--table/policy.go14
1 files changed, 8 insertions, 6 deletions
diff --git a/table/policy.go b/table/policy.go
index c9e65300..e556ec1d 100644
--- a/table/policy.go
+++ b/table/policy.go
@@ -172,9 +172,10 @@ const (
)
func NewMatchOption(c interface{}) (MatchOption, error) {
- switch c.(type) {
+ switch t := c.(type) {
case config.MatchSetOptionsType:
- switch c.(config.MatchSetOptionsType) {
+ t = t.DefaultAsNeeded()
+ switch t {
case config.MATCH_SET_OPTIONS_TYPE_ANY:
return MATCH_OPTION_ANY, nil
case config.MATCH_SET_OPTIONS_TYPE_ALL:
@@ -183,7 +184,8 @@ func NewMatchOption(c interface{}) (MatchOption, error) {
return MATCH_OPTION_INVERT, nil
}
case config.MatchSetOptionsRestrictedType:
- switch c.(config.MatchSetOptionsRestrictedType) {
+ t = t.DefaultAsNeeded()
+ switch t {
case config.MATCH_SET_OPTIONS_RESTRICTED_TYPE_ANY:
return MATCH_OPTION_ANY, nil
case config.MATCH_SET_OPTIONS_RESTRICTED_TYPE_INVERT:
@@ -1696,7 +1698,7 @@ func (a *CommunityAction) ToApiStruct() *api.CommunityAction {
cs = append(cs, exp.String())
}
return &api.CommunityAction{
- Type: api.CommunityActionType(a.action),
+ Type: api.CommunityActionType(a.action.ToInt()),
Communities: cs,
}
}
@@ -1814,7 +1816,7 @@ func (a *ExtCommunityAction) ToApiStruct() *api.CommunityAction {
cs = append(cs, f(idx, exp.String()))
}
return &api.CommunityAction{
- Type: api.CommunityActionType(a.action),
+ Type: api.CommunityActionType(a.action.ToInt()),
Communities: cs,
}
}
@@ -2108,7 +2110,7 @@ func (s *Statement) ToApiStruct() *api.Statement {
case *ExtCommunityCondition:
cs.ExtCommunitySet = c.(*ExtCommunityCondition).ToApiStruct()
case *RpkiValidationCondition:
- cs.RpkiResult = int32(c.(*RpkiValidationCondition).result)
+ cs.RpkiResult = int32(c.(*RpkiValidationCondition).result.ToInt())
}
}
as := &api.Actions{}