Skip to content

Commit 0a112d1

Browse files
authored
fix mcp service port protocol name (#1383)
1 parent 04ce776 commit 0a112d1

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

registry/direct/watcher.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ var domainRegex = regexp.MustCompile(`^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-
133133

134134
func (w *watcher) generateServiceEntry(host string) *v1alpha3.ServiceEntry {
135135
endpoints := make([]*v1alpha3.WorkloadEntry, 0)
136+
protocol := string(common.ParseProtocol(w.Protocol))
136137
for _, ep := range strings.Split(w.Domain, common.CommaSeparator) {
137138
var endpoint *v1alpha3.WorkloadEntry
138139
if w.Type == string(registry.Static) {
@@ -152,7 +153,7 @@ func (w *watcher) generateServiceEntry(host string) *v1alpha3.ServiceEntry {
152153
}
153154
endpoint = &v1alpha3.WorkloadEntry{
154155
Address: pair[0],
155-
Ports: map[string]uint32{w.Protocol: uint32(port)},
156+
Ports: map[string]uint32{protocol: uint32(port)},
156157
}
157158
} else if w.Type == string(registry.DNS) {
158159
if !domainRegex.MatchString(ep) {
@@ -175,8 +176,8 @@ func (w *watcher) generateServiceEntry(host string) *v1alpha3.ServiceEntry {
175176
var ports []*v1alpha3.ServicePort
176177
ports = append(ports, &v1alpha3.ServicePort{
177178
Number: w.Port,
178-
Name: w.Protocol,
179-
Protocol: string(common.ParseProtocol(w.Protocol)),
179+
Name: protocol,
180+
Protocol: protocol,
180181
})
181182
se := &v1alpha3.ServiceEntry{
182183
Hosts: []string{host},

0 commit comments

Comments
 (0)