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