diff options
author | FUJITA Tomonori <fujita.tomonori@gmail.com> | 2020-10-20 14:49:08 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@gmail.com> | 2020-11-09 23:10:34 +0900 |
commit | 3df131c6ba76626ebd223f512e1308193ca5e37c (patch) | |
tree | 339b20948fe7f077b0aebbb9ca031ecbbf137a66 /pkg | |
parent | 3d51923e3c33da286a4242627d00933aaad19eec (diff) |
server: fix conversion from api.RouteAction to config.DefaultPolicyType
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/server/grpc_server.go | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/pkg/server/grpc_server.go b/pkg/server/grpc_server.go index 3a7121f7..06425dfa 100644 --- a/pkg/server/grpc_server.go +++ b/pkg/server/grpc_server.go @@ -504,20 +504,29 @@ func readApplyPolicyFromAPIStruct(c *config.ApplyPolicy, a *api.ApplyPolicy) { if c == nil || a == nil { return } + f := func(a api.RouteAction) config.DefaultPolicyType { + if a == api.RouteAction_ACCEPT { + return config.DEFAULT_POLICY_TYPE_ACCEPT_ROUTE + } else if a == api.RouteAction_REJECT { + return config.DEFAULT_POLICY_TYPE_REJECT_ROUTE + } + return "" + } + if a.ImportPolicy != nil { - c.Config.DefaultImportPolicy = config.IntToDefaultPolicyTypeMap[int(a.ImportPolicy.DefaultAction)] + c.Config.DefaultImportPolicy = f(a.ImportPolicy.DefaultAction) for _, p := range a.ImportPolicy.Policies { c.Config.ImportPolicyList = append(c.Config.ImportPolicyList, p.Name) } } if a.ExportPolicy != nil { - c.Config.DefaultExportPolicy = config.IntToDefaultPolicyTypeMap[int(a.ExportPolicy.DefaultAction)] + c.Config.DefaultExportPolicy = f(a.ExportPolicy.DefaultAction) for _, p := range a.ExportPolicy.Policies { c.Config.ExportPolicyList = append(c.Config.ExportPolicyList, p.Name) } } if a.InPolicy != nil { - c.Config.DefaultInPolicy = config.IntToDefaultPolicyTypeMap[int(a.InPolicy.DefaultAction)] + c.Config.DefaultInPolicy = f(a.InPolicy.DefaultAction) for _, p := range a.InPolicy.Policies { c.Config.InPolicyList = append(c.Config.InPolicyList, p.Name) } |