Fix `kubectl describe ingress` format
Fixes https://github.com/kubernetes/kubernetes/issues/94980 Fixes two formatting issues: * Un-opened parenthesis (`10.244.0.6:8080)`) * Bad format string and spacing Before this PR: ``` Name: example-ingress Namespace: default Address: Default backend: istio-ingressgateway:80 (<error: endpoints "istio-ingressgateway" not found>) Rules: Host Path Backends ---- ---- -------- * * %!(EXTRA string=istio-ingressgateway:80 (<error: endpoints "istio-ingressgateway" not found>))Annotations: <none> Events: <none> ``` After this PR: ``` Name: example-ingress Namespace: default Address: Default backend: istio-ingressgateway:80 (<error: endpoints "istio-ingressgateway" not found>) Rules: Host Path Backends ---- ---- -------- * * istio-ingressgateway:80 (<error: endpoints "istio-ingressgateway" not found>) Annotations: <none> Events: <none> ``` Compare to an old kubectl without the bug: ``` Name: example-ingress Namespace: default Address: Default backend: istio-ingressgateway:80 (<none>) Rules: Host Path Backends ---- ---- -------- * * istio-ingressgateway:80 (<none>) Annotations: kubectl.kubernetes.io/last-applied-configuration: ... Events: <none> ``` Kubernetes-commit: 6d9d0d0a4d1fef5ef63a05a298967db2b5f9a698
This commit is contained in:
parent
28d699c230
commit
56d89052f2
|
@ -2465,7 +2465,7 @@ func (i *IngressDescriber) describeBackendV1(ns string, backend *networkingv1.In
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ep := formatEndpoints(endpoints, sets.NewString(spName))
|
ep := formatEndpoints(endpoints, sets.NewString(spName))
|
||||||
return fmt.Sprintf("%s\t %s)", sb, ep)
|
return fmt.Sprintf("%s (%s)", sb, ep)
|
||||||
}
|
}
|
||||||
if backend.Resource != nil {
|
if backend.Resource != nil {
|
||||||
ic := backend.Resource
|
ic := backend.Resource
|
||||||
|
@ -2518,7 +2518,7 @@ func (i *IngressDescriber) describeIngressV1(ing *networkingv1.Ingress, events *
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if count == 0 {
|
if count == 0 {
|
||||||
w.Write(LEVEL_1, "\t%s %s\n", "*", "*", i.describeBackendV1(ns, def))
|
w.Write(LEVEL_1, "%s\t%s\t%s\n", "*", "*", i.describeBackendV1(ns, def))
|
||||||
}
|
}
|
||||||
printAnnotationsMultiline(w, "Annotations", ing.Annotations)
|
printAnnotationsMultiline(w, "Annotations", ing.Annotations)
|
||||||
|
|
||||||
|
|
|
@ -1924,6 +1924,28 @@ Rules:
|
||||||
Annotations: <none>
|
Annotations: <none>
|
||||||
Events: <none>` + "\n",
|
Events: <none>` + "\n",
|
||||||
},
|
},
|
||||||
|
"DefaultBackend": {
|
||||||
|
input: fake.NewSimpleClientset(&networkingv1.Ingress{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: "bar",
|
||||||
|
Namespace: "foo",
|
||||||
|
},
|
||||||
|
Spec: networkingv1.IngressSpec{
|
||||||
|
DefaultBackend: &backendV1,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
output: `Name: bar
|
||||||
|
Namespace: foo
|
||||||
|
Address:
|
||||||
|
Default backend: default-backend:80 (<error: endpoints "default-backend" not found>)
|
||||||
|
Rules:
|
||||||
|
Host Path Backends
|
||||||
|
---- ---- --------
|
||||||
|
* * default-backend:80 (<error: endpoints "default-backend" not found>)
|
||||||
|
Annotations: <none>
|
||||||
|
Events: <none>
|
||||||
|
`,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for name, test := range tests {
|
for name, test := range tests {
|
||||||
|
|
Loading…
Reference in New Issue