fix mcp service port protocol name (#1383)

This commit is contained in:
澄潭
2024-10-15 11:50:43 +08:00
committed by GitHub
parent 04ce776f14
commit 0a112d1a1e

View File

@@ -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},