diff --git a/pkg/describe/describe.go b/pkg/describe/describe.go index 1c92d65b..b40a9b6b 100644 --- a/pkg/describe/describe.go +++ b/pkg/describe/describe.go @@ -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 := "" + 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 "" } diff --git a/pkg/describe/describe_test.go b/pkg/describe/describe_test.go index 73124205..01e7d656 100644 --- a/pkg/describe/describe_test.go +++ b/pkg/describe/describe_test.go @@ -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: +Events: ` + "\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 () +Rules: + Host Path Backends + ---- ---- -------- + foo.bar.com + /foo APIGroup: , Kind: foo, Name: bar +Annotations: Events: ` + "\n", }, "Spec.DefaultBackend.Service & IngressRule.HTTP.Paths.Backend.Service v1": {