tokers commented on code in PR #1040:
URL:
https://github.com/apache/apisix-ingress-controller/pull/1040#discussion_r879971391
##########
pkg/kube/translation/ingress.go:
##########
@@ -393,6 +428,29 @@ func (t *translator) translateIngressExtensionsV1beta1(ing
*extensionsv1beta1.In
return ctx, nil
}
+func (t *translator) translateDefaultUpstreamFromIngressV1beta1(namespace
string, svcName string, svcPort intstr.IntOrString) *apisixv1.Upstream {
+ var portNumber int32
+ if svcPort.Type == intstr.String {
+ svc, err := t.ServiceLister.Services(namespace).Get(svcName)
+ if err != nil {
Review Comment:
Ditto.
##########
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 {
Review Comment:
Should not use the `svc` variable when `err` is not `nil`, this might cause
the program panic.
##########
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:
Leave an empty there.
--
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]