From 0a112d1a1e22a2b5122d65ab85c792f540c4cbb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BE=84=E6=BD=AD?= Date: Tue, 15 Oct 2024 11:50:43 +0800 Subject: [PATCH] fix mcp service port protocol name (#1383) --- registry/direct/watcher.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/registry/direct/watcher.go b/registry/direct/watcher.go index 8ad5f858c..533c80d63 100644 --- a/registry/direct/watcher.go +++ b/registry/direct/watcher.go @@ -133,6 +133,7 @@ var domainRegex = regexp.MustCompile(`^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA- func (w *watcher) generateServiceEntry(host string) *v1alpha3.ServiceEntry { endpoints := make([]*v1alpha3.WorkloadEntry, 0) + protocol := string(common.ParseProtocol(w.Protocol)) for _, ep := range strings.Split(w.Domain, common.CommaSeparator) { var endpoint *v1alpha3.WorkloadEntry if w.Type == string(registry.Static) { @@ -152,7 +153,7 @@ func (w *watcher) generateServiceEntry(host string) *v1alpha3.ServiceEntry { } endpoint = &v1alpha3.WorkloadEntry{ Address: pair[0], - Ports: map[string]uint32{w.Protocol: uint32(port)}, + Ports: map[string]uint32{protocol: uint32(port)}, } } else if w.Type == string(registry.DNS) { if !domainRegex.MatchString(ep) { @@ -175,8 +176,8 @@ func (w *watcher) generateServiceEntry(host string) *v1alpha3.ServiceEntry { var ports []*v1alpha3.ServicePort ports = append(ports, &v1alpha3.ServicePort{ Number: w.Port, - Name: w.Protocol, - Protocol: string(common.ParseProtocol(w.Protocol)), + Name: protocol, + Protocol: protocol, }) se := &v1alpha3.ServiceEntry{ Hosts: []string{host},