hahayyum commented on code in PR #1040:
URL: 
https://github.com/apache/apisix-ingress-controller/pull/1040#discussion_r879983617


##########
pkg/kube/translation/ingress.go:
##########
@@ -273,6 +281,29 @@ func (t *translator) translateIngressV1beta1(ing 
*networkingv1beta1.Ingress) (*T
        return ctx, nil
 }
 
+func (t *translator) translateDefaultUpstreamFromIngressV1(namespace string, 
backend *networkingv1.IngressServiceBackend) *apisixv1.Upstream {
+       var portNumber int32
+       if backend.Port.Name != "" {
+               svc, err := 
t.ServiceLister.Services(namespace).Get(backend.Name)
+               if err != nil {
+                       for _, port := range svc.Spec.Ports {
+                               if port.Name == backend.Port.Name {
+                                       portNumber = port.Port
+                                       break
+                               }
+                       }
+               } else {
+                       portNumber = 0
+               }
+
+       } else {
+               portNumber = backend.Port.Number
+       }
+       ups := apisixv1.NewDefaultUpstream()
+       ups.Name = apisixv1.ComposeUpstreamName(namespace, backend.Name, "", 
portNumber)
+       ups.ID = id.GenID(ups.Name)
+       return ups
+}

Review Comment:
   In fact, only one ID needs to be returned here to ensure that the original 
data can be updated or deleted



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to