Skip to content

Instantly share code, notes, and snippets.

@alpeb
Created March 5, 2020 19:33
Show Gist options
  • Save alpeb/d725640b7c7fc6e0095e87dfb8729c14 to your computer and use it in GitHub Desktop.
Save alpeb/d725640b7c7fc6e0095e87dfb8729c14 to your computer and use it in GitHub Desktop.
diff --git a/controller/api/destination/watcher/endpoints_watcher.go b/controller/api/destination/watcher/endpoints_watcher.go
index 1d04a747..afaa98af 100644
--- a/controller/api/destination/watcher/endpoints_watcher.go
+++ b/controller/api/destination/watcher/endpoints_watcher.go
@@ -46,8 +46,7 @@ type (
// RemoteGatewayAddress is a an address points to a remote gateway
RemoteGatewayAddress struct {
- IP string
- Port Port
+ HeadlessServiceAddress
LocalServiceName string
Namespace string
GatewayIdentity string
@@ -144,21 +143,6 @@ func (pa *PodAddress) SetPort(p Port) {
pa.Port = p
}
-// GetPort gets the target port
-func (rg *RemoteGatewayAddress) GetPort() Port {
- return rg.Port
-}
-
-// GetIP gets the IP
-func (rg *RemoteGatewayAddress) GetIP() string {
- return rg.IP
-}
-
-// SetPort sets the target port
-func (rg *RemoteGatewayAddress) SetPort(p Port) {
- rg.Port = p
-}
-
// GetPort gets the target port
func (hs *HeadlessServiceAddress) GetPort() Port {
return hs.Port
@@ -535,10 +519,12 @@ func (pp *portPublisher) endpointsToAddresses(endpoints *corev1.Endpoints) Addre
fqName, hasFqName := endpoints.Annotations[consts.RemoteServiceFqName]
if hasFqName {
addresses[id] = &RemoteGatewayAddress{
+ HeadlessServiceAddress: HeadlessServiceAddress{
+ IP: endpoint.IP,
+ Port: resolvedPort,
+ },
LocalServiceName: endpoints.Name,
Namespace: endpoints.Namespace,
- IP: endpoint.IP,
- Port: resolvedPort,
GatewayIdentity: endpoints.Annotations[consts.RemoteGatewayIdentity],
FullyQualifiedRemoteName: fqName,
}
diff --git a/controller/api/destination/endpoint_translator_test.go b/controller/api/destination/endpoint_translator_test.go
index d82a426b..979bb4bc 100644
--- a/controller/api/destination/endpoint_translator_test.go
+++ b/controller/api/destination/endpoint_translator_test.go
@@ -96,18 +96,22 @@ var (
}
remoteGatewayWithNoTLS = watcher.RemoteGatewayAddress{
+ HeadlessServiceAddress: watcher.HeadlessServiceAddress{
+ IP: "1.1.1.1",
+ Port: 1,
+ },
LocalServiceName: "gateway-remote",
Namespace: "test-ns",
- IP: "1.1.1.1",
- Port: 1,
FullyQualifiedRemoteName: "full-name-1",
}
remoteGatewayWithTLS = watcher.RemoteGatewayAddress{
+ HeadlessServiceAddress: watcher.HeadlessServiceAddress{
+ IP: "1.1.1.12",
+ Port: 2,
+ },
LocalServiceName: "gateway-2-remote",
Namespace: "test-ns",
- IP: "1.1.1.2",
- Port: 2,
GatewayIdentity: "some-identity",
FullyQualifiedRemoteName: "full-name-2",
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment