mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 10:51:29 +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:
commit
e71e284b74
@ -2556,7 +2556,11 @@ func (i *IngressDescriber) describeBackendV1(ns string, backend *networkingv1.In
|
|||||||
}
|
}
|
||||||
if backend.Resource != nil {
|
if backend.Resource != nil {
|
||||||
ic := backend.Resource
|
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 ""
|
return ""
|
||||||
}
|
}
|
||||||
|
@ -2213,6 +2213,12 @@ func TestDescribeIngress(t *testing.T) {
|
|||||||
Name: "bar",
|
Name: "bar",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
backendResourceNoAPIGroup := networkingv1.IngressBackend{
|
||||||
|
Resource: &corev1.TypedLocalObjectReference{
|
||||||
|
Kind: "foo",
|
||||||
|
Name: "bar",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
tests := map[string]struct {
|
tests := map[string]struct {
|
||||||
input *fake.Clientset
|
input *fake.Clientset
|
||||||
@ -2280,6 +2286,42 @@ Rules:
|
|||||||
foo.bar.com
|
foo.bar.com
|
||||||
/foo APIGroup: example.com, Kind: foo, Name: bar
|
/foo APIGroup: example.com, Kind: foo, Name: bar
|
||||||
Annotations: <none>
|
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",
|
Events: <none>` + "\n",
|
||||||
},
|
},
|
||||||
"Spec.DefaultBackend.Service & IngressRule.HTTP.Paths.Backend.Service v1": {
|
"Spec.DefaultBackend.Service & IngressRule.HTTP.Paths.Backend.Service v1": {
|
||||||
|
Loading…
Reference in New Issue
Block a user