Skip to content

Commit

Permalink
remove duplicated IPAM code
Browse files Browse the repository at this point in the history
Signed-off-by: Ruslan Bayandinov <[email protected]>
  • Loading branch information
wazsone committed Jan 11, 2023
1 parent b98f5a9 commit 0ba5f8a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 18 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/edwarnicke/grpcfd v1.1.2
github.com/kelseyhightower/envconfig v1.4.0
github.com/networkservicemesh/api v1.6.2-0.20221205183940-84c7ff837cdd
github.com/networkservicemesh/sdk v0.5.1-0.20221219152652-beec79b7ec9d
github.com/networkservicemesh/sdk v0.5.1-0.20230109230417-1492e69a650d
github.com/networkservicemesh/sdk-sriov v0.0.0-20221219180322-513bee7f52b7
github.com/pkg/errors v0.9.1
github.com/sirupsen/logrus v1.9.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ github.com/networkservicemesh/api v1.6.2-0.20221205183940-84c7ff837cdd h1:26HR90
github.com/networkservicemesh/api v1.6.2-0.20221205183940-84c7ff837cdd/go.mod h1:hOF2844BSstH1311oDMDgqqXS+kdc77htZNPRKl9mf8=
github.com/networkservicemesh/sdk v0.5.1-0.20221219152652-beec79b7ec9d h1:cx0Z/xWuoW0JS3VmA+5Ckg5g+iirB7RJglGDnJzmGEo=
github.com/networkservicemesh/sdk v0.5.1-0.20221219152652-beec79b7ec9d/go.mod h1:++MSpR2wuFlCpCYoR6lELxJ4ILKd650vDQ8d9CtGAzA=
github.com/networkservicemesh/sdk v0.5.1-0.20230109230417-1492e69a650d h1:1EhczRkzfkutymvDj5XYinD68omLpFk2F2kJdhzYG+U=
github.com/networkservicemesh/sdk v0.5.1-0.20230109230417-1492e69a650d/go.mod h1:++MSpR2wuFlCpCYoR6lELxJ4ILKd650vDQ8d9CtGAzA=
github.com/networkservicemesh/sdk-sriov v0.0.0-20221219180322-513bee7f52b7 h1:warFgkj/xEmiV/KK33MQzOY/D54KHP4duCn+dSQf+0I=
github.com/networkservicemesh/sdk-sriov v0.0.0-20221219180322-513bee7f52b7/go.mod h1:uClz/S+Ty0doAV+ZKL+gg0PBkY9F6vyelPG40K4VVxw=
github.com/open-policy-agent/opa v0.44.0 h1:sEZthsrWBqIN+ShTMJ0Hcz6a3GkYsY4FaB2S/ou2hZk=
Expand Down
18 changes: 4 additions & 14 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) 2020-2022 Doc.ai and/or its affiliates.
// Copyright (c) 2021-2022 Nordix and/or its affiliates.
// Copyright (c) 2020-2023 Doc.ai and/or its affiliates.
// Copyright (c) 2021-2023 Nordix and/or its affiliates.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand All @@ -24,7 +24,6 @@ import (
"context"
"crypto/tls"
"fmt"
"net"
"net/url"
"os"
"os/signal"
Expand Down Expand Up @@ -61,8 +60,7 @@ import (
"github.com/networkservicemesh/sdk/pkg/networkservice/common/onidle"
"github.com/networkservicemesh/sdk/pkg/networkservice/common/policyroute"
"github.com/networkservicemesh/sdk/pkg/networkservice/connectioncontext/dnscontext"
"github.com/networkservicemesh/sdk/pkg/networkservice/core/chain"
"github.com/networkservicemesh/sdk/pkg/networkservice/ipam/point2pointipam"
"github.com/networkservicemesh/sdk/pkg/networkservice/ipam/groupipam"
registryclient "github.com/networkservicemesh/sdk/pkg/registry/chains/client"
registryauthorize "github.com/networkservicemesh/sdk/pkg/registry/common/authorize"
"github.com/networkservicemesh/sdk/pkg/registry/common/clientinfo"
Expand Down Expand Up @@ -200,7 +198,7 @@ func main() {
log.FromContext(ctx).Infof("executing phase 3: creating icmp server ipam")
// ********************************************************************************

ipamChain := getIPAMChain(config.CidrPrefix)
ipamChain := groupipam.NewServer(config.CidrPrefix)

log.FromContext(ctx).Infof("network prefixes parsed successfully")

Expand Down Expand Up @@ -405,11 +403,3 @@ type policyRoutesGetter struct {
ctx context.Context
policyRoutes atomic.Value
}

func getIPAMChain(cIDRGroups [][]*net.IPNet) networkservice.NetworkServiceServer {
var ipamchain []networkservice.NetworkServiceServer
for _, cidrGroup := range cIDRGroups {
ipamchain = append(ipamchain, point2pointipam.NewServer(cidrGroup...))
}
return chain.NewNetworkServiceServer(ipamchain...)
}
6 changes: 3 additions & 3 deletions suite_setup_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) 2020-2022 Doc.ai and/or its affiliates.
// Copyright (c) 2020-2023 Doc.ai and/or its affiliates.
//
// Copyright (c) 2020-2022 Cisco and/or its affiliates.
// Copyright (c) 2020-2023 Cisco and/or its affiliates.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down Expand Up @@ -119,7 +119,7 @@ func (f *TestSuite) SetupSuite() {
registrybegin.NewNetworkServiceEndpointRegistryServer(),
updatepath.NewNetworkServiceEndpointRegistryServer(spiffejwt.TokenGeneratorFunc(source, f.config.MaxTokenLifetime)),
authorize.NewNetworkServiceEndpointRegistryServer(),
expire.NewNetworkServiceEndpointRegistryServer(f.ctx, time.Minute),
expire.NewNetworkServiceEndpointRegistryServer(f.ctx, expire.WithDefaultExpiration(time.Minute)),
registryrecvfd.NewNetworkServiceEndpointRegistryServer(),
memrg,
)
Expand Down

0 comments on commit 0ba5f8a

Please sign in to comment.