mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-17 23:57:49 +00:00
fix issue(#52244)kubectl describe serviceaccount have redundance null line, we should keep accordance for kubectl describe command
This commit is contained in:
parent
e821e531db
commit
23a05f6c23
@ -2225,7 +2225,6 @@ func describeServiceAccount(serviceAccount *api.ServiceAccount, tokens []api.Sec
|
|||||||
w.Write(LEVEL_0, "Namespace:\t%s\n", serviceAccount.Namespace)
|
w.Write(LEVEL_0, "Namespace:\t%s\n", serviceAccount.Namespace)
|
||||||
printLabelsMultiline(w, "Labels", serviceAccount.Labels)
|
printLabelsMultiline(w, "Labels", serviceAccount.Labels)
|
||||||
printAnnotationsMultiline(w, "Annotations", serviceAccount.Annotations)
|
printAnnotationsMultiline(w, "Annotations", serviceAccount.Annotations)
|
||||||
w.WriteLine()
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
emptyHeader = " "
|
emptyHeader = " "
|
||||||
@ -2267,7 +2266,6 @@ func describeServiceAccount(serviceAccount *api.ServiceAccount, tokens []api.Sec
|
|||||||
prefix = emptyHeader
|
prefix = emptyHeader
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
w.WriteLine()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if events != nil {
|
if events != nil {
|
||||||
|
@ -1593,6 +1593,43 @@ func TestDescribeResourceQuota(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestDescribeServiceAccount(t *testing.T) {
|
||||||
|
fake := fake.NewSimpleClientset(&api.ServiceAccount{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: "bar",
|
||||||
|
Namespace: "foo",
|
||||||
|
},
|
||||||
|
Secrets: []api.ObjectReference{
|
||||||
|
{
|
||||||
|
Name: "test-objectref",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
ImagePullSecrets: []api.LocalObjectReference{
|
||||||
|
{
|
||||||
|
Name: "test-local-ref",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
c := &describeClient{T: t, Namespace: "foo", Interface: fake}
|
||||||
|
d := ServiceAccountDescriber{c}
|
||||||
|
out, err := d.Describe("foo", "bar", printers.DescriberSettings{ShowEvents: true})
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("unexpected error: %v", err)
|
||||||
|
}
|
||||||
|
expectedOut := `Name: bar
|
||||||
|
Namespace: foo
|
||||||
|
Labels: <none>
|
||||||
|
Annotations: <none>
|
||||||
|
Image pull secrets: test-local-ref (not found)
|
||||||
|
Mountable secrets: test-objectref (not found)
|
||||||
|
Tokens: <none>
|
||||||
|
Events: <none>` + "\n"
|
||||||
|
if out != expectedOut {
|
||||||
|
t.Errorf("expected : %q\n but got output:\n %q", expectedOut, out)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// boolPtr returns a pointer to a bool
|
// boolPtr returns a pointer to a bool
|
||||||
func boolPtr(b bool) *bool {
|
func boolPtr(b bool) *bool {
|
||||||
o := b
|
o := b
|
||||||
|
Loading…
Reference in New Issue
Block a user