diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2018-10-28 20:49:10 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2018-10-28 21:41:11 +0900 |
commit | 3e950780fedccacdd1e1267343b5b9baae204566 (patch) | |
tree | 9ce9e5c038fba363b10763a23f96c08aaf8fd702 /internal/pkg/table | |
parent | 5d7ecf5a9e68bcd1a71bc6468e0075f1f9d028ba (diff) |
move NewAPIRoutingPolicyFromConfigStruct() from server/
The config is an internal package so it should not be exported.
NewAPIPolicyAssignmentFromTableStruct() is approprate for config/.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'internal/pkg/table')
-rw-r--r-- | internal/pkg/table/policy.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/internal/pkg/table/policy.go b/internal/pkg/table/policy.go index b06da47d..73bfac75 100644 --- a/internal/pkg/table/policy.go +++ b/internal/pkg/table/policy.go @@ -4117,3 +4117,19 @@ func NewAPIPolicyAssignmentFromTableStruct(t *PolicyAssignment) *api.PolicyAssig }(), } } + +func NewAPIRoutingPolicyFromConfigStruct(c *config.RoutingPolicy) (*api.RoutingPolicy, error) { + definedSets, err := config.NewAPIDefinedSetsFromConfigStruct(&c.DefinedSets) + if err != nil { + return nil, err + } + policies := make([]*api.Policy, 0, len(c.PolicyDefinitions)) + for _, policy := range c.PolicyDefinitions { + policies = append(policies, ToPolicyApi(&policy)) + } + + return &api.RoutingPolicy{ + DefinedSets: definedSets, + Policies: policies, + }, nil +} |