@@ -18,7 +18,6 @@ package route
1818
1919import (
2020 "context"
21- "fmt"
2221 "strings"
2322 "sync"
2423 "time"
@@ -38,8 +37,6 @@ import (
3837)
3938
4039type HubInterface interface {
41- GetService (hubName string , namespace , name string ) (* corev1.Service , bool )
42- ListServices (name string ) []* corev1.Service
4340 GetHub (name string ) * v1alpha2.Hub
4441 GetHubGateway (hubName string , forHub string ) v1alpha2.HubSpecGateway
4542 GetAuthorized (name string ) string
@@ -420,15 +417,7 @@ func (m *MappingController) Close() {
420417}
421418
422419func (m * MappingController ) updatePort (f * v1alpha2.Route ) error {
423- svc , ok := m .hubInterface .GetService (f .Spec .Export .HubName , f .Spec .Export .Service .Namespace , f .Spec .Export .Service .Name )
424- if ! ok {
425- return fmt .Errorf ("not found export service" )
426- }
427-
428- for _ , port := range svc .Spec .Ports {
429- if port .Protocol != corev1 .ProtocolTCP {
430- continue
431- }
420+ for _ , port := range f .Spec .Import .Ports {
432421 _ , err := m .hubInterface .GetPortPeer (f .Spec .Import .HubName ,
433422 f .Spec .Export .HubName , f .Spec .Export .Service .Namespace , f .Spec .Export .Service .Name , port .Port )
434423 if err != nil {
@@ -439,14 +428,7 @@ func (m *MappingController) updatePort(f *v1alpha2.Route) error {
439428}
440429
441430func (m * MappingController ) deletePort (f * v1alpha2.Route ) error {
442- svc , ok := m .hubInterface .GetService (f .Spec .Export .HubName , f .Spec .Export .Service .Namespace , f .Spec .Export .Service .Name )
443- if ! ok {
444- return fmt .Errorf ("not found export service" )
445- }
446- for _ , port := range svc .Spec .Ports {
447- if port .Protocol != corev1 .ProtocolTCP {
448- continue
449- }
431+ for _ , port := range f .Spec .Import .Ports {
450432 _ , err := m .hubInterface .DeletePortPeer (f .Spec .Import .HubName ,
451433 f .Spec .Export .HubName , f .Spec .Export .Service .Namespace , f .Spec .Export .Service .Name , port .Port )
452434 if err == nil {
0 commit comments