Skip to content

Commit

Permalink
Modify gateway to use endpoint.Local
Browse files Browse the repository at this point in the history
Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
  • Loading branch information
tpantelis committed Jan 5, 2024
1 parent 350145d commit 2bdccb4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
11 changes: 6 additions & 5 deletions pkg/gateway/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ type Config struct {
SubmarinerClient submclientset.Interface
KubeClient kubernetes.Interface
LeaderElectionClient kubernetes.Interface
NewCableEngine func(localCluster *types.SubmarinerCluster, localEndpoint *types.SubmarinerEndpoint) cableengine.Engine
NewNATDiscovery func(localEndpoint *types.SubmarinerEndpoint) (natdiscovery.Interface, error)
NewCableEngine func(localCluster *types.SubmarinerCluster, localEndpoint *endpoint.Local) cableengine.Engine
NewNATDiscovery func(localEndpoint *endpoint.Local) (natdiscovery.Interface, error)
}

type gatewayType struct {
Expand All @@ -95,7 +95,7 @@ type gatewayType struct {
natDiscovery natdiscovery.Interface
gatewayPod *pod.GatewayPod
hostName string
localEndpoint *types.SubmarinerEndpoint
localEndpoint *endpoint.Local
fatalError chan error
leaderComponentsStarted *sync.WaitGroup
recorder record.EventRecorder
Expand Down Expand Up @@ -148,6 +148,8 @@ func New(config *Config) (Interface, error) {
return nil, errors.Wrap(err, "error creating local endpoint object")
}

g.localEndpoint = endpoint.NewLocal(localEndpointSpec, g.SyncerConfig.LocalClient, g.Spec.Namespace)

g.cableEngine = g.NewCableEngine(localCluster, g.localEndpoint)

g.natDiscovery, err = g.NewNATDiscovery(g.localEndpoint)
Expand Down Expand Up @@ -351,8 +353,7 @@ func (g *gatewayType) initPublicIPWatcher() {
publicIPConfig := &endpoint.PublicIPWatcherConfig{
SubmSpec: &g.Spec,
K8sClient: g.KubeClient,
Endpoints: g.SubmarinerClient.SubmarinerV1().Endpoints(g.Spec.Namespace),
LocalEndpoint: *g.localEndpoint,
LocalEndpoint: g.localEndpoint,
}

g.publicIPWatcher = endpoint.NewPublicIPWatcher(publicIPConfig)
Expand Down
7 changes: 4 additions & 3 deletions pkg/gateway/gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import (
"github.com/submariner-io/submariner/pkg/cableengine"
enginefake "github.com/submariner-io/submariner/pkg/cableengine/fake"
submfake "github.com/submariner-io/submariner/pkg/client/clientset/versioned/fake"
submendpoint "github.com/submariner-io/submariner/pkg/endpoint"
"github.com/submariner-io/submariner/pkg/gateway"
"github.com/submariner-io/submariner/pkg/natdiscovery"
"github.com/submariner-io/submariner/pkg/types"
Expand Down Expand Up @@ -263,11 +264,11 @@ func newTestDriver() *testDriver {
SubmarinerClient: submfake.NewSimpleClientset(),
KubeClient: t.kubeClient,
LeaderElectionClient: t.kubeClient,
NewCableEngine: func(_ *types.SubmarinerCluster, ep *types.SubmarinerEndpoint) cableengine.Engine {
t.cableEngine.LocalEndPoint = ep
NewCableEngine: func(_ *types.SubmarinerCluster, lep *submendpoint.Local) cableengine.Engine {
t.cableEngine.LocalEndPoint = &types.SubmarinerEndpoint{Spec: *lep.Spec()}
return t.cableEngine
},
NewNATDiscovery: func(_ *types.SubmarinerEndpoint) (natdiscovery.Interface, error) {
NewNATDiscovery: func(_ *submendpoint.Local) (natdiscovery.Interface, error) {
return &fakeNATDiscovery{}, nil
},
}
Expand Down

0 comments on commit 2bdccb4

Please sign in to comment.