mirror of
https://github.com/alibaba/higress.git
synced 2026-06-08 20:27:31 +08:00
fix mcp service port protocol name (#1383)
This commit is contained in:
@@ -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 {
|
func (w *watcher) generateServiceEntry(host string) *v1alpha3.ServiceEntry {
|
||||||
endpoints := make([]*v1alpha3.WorkloadEntry, 0)
|
endpoints := make([]*v1alpha3.WorkloadEntry, 0)
|
||||||
|
protocol := string(common.ParseProtocol(w.Protocol))
|
||||||
for _, ep := range strings.Split(w.Domain, common.CommaSeparator) {
|
for _, ep := range strings.Split(w.Domain, common.CommaSeparator) {
|
||||||
var endpoint *v1alpha3.WorkloadEntry
|
var endpoint *v1alpha3.WorkloadEntry
|
||||||
if w.Type == string(registry.Static) {
|
if w.Type == string(registry.Static) {
|
||||||
@@ -152,7 +153,7 @@ func (w *watcher) generateServiceEntry(host string) *v1alpha3.ServiceEntry {
|
|||||||
}
|
}
|
||||||
endpoint = &v1alpha3.WorkloadEntry{
|
endpoint = &v1alpha3.WorkloadEntry{
|
||||||
Address: pair[0],
|
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) {
|
} else if w.Type == string(registry.DNS) {
|
||||||
if !domainRegex.MatchString(ep) {
|
if !domainRegex.MatchString(ep) {
|
||||||
@@ -175,8 +176,8 @@ func (w *watcher) generateServiceEntry(host string) *v1alpha3.ServiceEntry {
|
|||||||
var ports []*v1alpha3.ServicePort
|
var ports []*v1alpha3.ServicePort
|
||||||
ports = append(ports, &v1alpha3.ServicePort{
|
ports = append(ports, &v1alpha3.ServicePort{
|
||||||
Number: w.Port,
|
Number: w.Port,
|
||||||
Name: w.Protocol,
|
Name: protocol,
|
||||||
Protocol: string(common.ParseProtocol(w.Protocol)),
|
Protocol: protocol,
|
||||||
})
|
})
|
||||||
se := &v1alpha3.ServiceEntry{
|
se := &v1alpha3.ServiceEntry{
|
||||||
Hosts: []string{host},
|
Hosts: []string{host},
|
||||||
|
|||||||
Reference in New Issue
Block a user