mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-10-31 10:18:13 +00:00 
			
		
		
		
	Merge pull request #100505 from lauchokyip/fixDescribe
Fixed kubectl describe ingress causing SEGFAULT if API Group is not specified
This commit is contained in:
		| @@ -2556,7 +2556,11 @@ func (i *IngressDescriber) describeBackendV1(ns string, backend *networkingv1.In | ||||
| 	} | ||||
| 	if backend.Resource != nil { | ||||
| 		ic := backend.Resource | ||||
| 		return fmt.Sprintf("APIGroup: %v, Kind: %v, Name: %v", *ic.APIGroup, ic.Kind, ic.Name) | ||||
| 		apiGroup := "<none>" | ||||
| 		if ic.APIGroup != nil { | ||||
| 			apiGroup = fmt.Sprintf("%v", *ic.APIGroup) | ||||
| 		} | ||||
| 		return fmt.Sprintf("APIGroup: %v, Kind: %v, Name: %v", apiGroup, ic.Kind, ic.Name) | ||||
| 	} | ||||
| 	return "" | ||||
| } | ||||
|   | ||||
| @@ -2213,6 +2213,12 @@ func TestDescribeIngress(t *testing.T) { | ||||
| 			Name:     "bar", | ||||
| 		}, | ||||
| 	} | ||||
| 	backendResourceNoAPIGroup := networkingv1.IngressBackend{ | ||||
| 		Resource: &corev1.TypedLocalObjectReference{ | ||||
| 			Kind: "foo", | ||||
| 			Name: "bar", | ||||
| 		}, | ||||
| 	} | ||||
|  | ||||
| 	tests := map[string]struct { | ||||
| 		input  *fake.Clientset | ||||
| @@ -2280,6 +2286,42 @@ Rules: | ||||
|   foo.bar.com   | ||||
|                /foo   APIGroup: example.com, Kind: foo, Name: bar | ||||
| Annotations:   <none> | ||||
| Events:        <none>` + "\n", | ||||
| 		}, | ||||
| 		"IngressRule.HTTP.Paths.Backend.Resource v1 Without APIGroup": { | ||||
| 			input: fake.NewSimpleClientset(&networkingv1.Ingress{ | ||||
| 				ObjectMeta: metav1.ObjectMeta{ | ||||
| 					Name:      "bar", | ||||
| 					Namespace: "foo", | ||||
| 				}, | ||||
| 				Spec: networkingv1.IngressSpec{ | ||||
| 					Rules: []networkingv1.IngressRule{ | ||||
| 						{ | ||||
| 							Host: "foo.bar.com", | ||||
| 							IngressRuleValue: networkingv1.IngressRuleValue{ | ||||
| 								HTTP: &networkingv1.HTTPIngressRuleValue{ | ||||
| 									Paths: []networkingv1.HTTPIngressPath{ | ||||
| 										{ | ||||
| 											Path:    "/foo", | ||||
| 											Backend: backendResourceNoAPIGroup, | ||||
| 										}, | ||||
| 									}, | ||||
| 								}, | ||||
| 							}, | ||||
| 						}, | ||||
| 					}, | ||||
| 				}, | ||||
| 			}), | ||||
| 			output: `Name:             bar | ||||
| Namespace:        foo | ||||
| Address:           | ||||
| Default backend:  default-http-backend:80 (<error: endpoints "default-http-backend" not found>) | ||||
| Rules: | ||||
|   Host         Path  Backends | ||||
|   ----         ----  -------- | ||||
|   foo.bar.com   | ||||
|                /foo   APIGroup: <none>, Kind: foo, Name: bar | ||||
| Annotations:   <none> | ||||
| Events:        <none>` + "\n", | ||||
| 		}, | ||||
| 		"Spec.DefaultBackend.Service & IngressRule.HTTP.Paths.Backend.Service v1": { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Kubernetes Prow Robot
					Kubernetes Prow Robot