diff --git a/pkg/printers/internalversion/describe.go b/pkg/printers/internalversion/describe.go index f9d4fe352be..2bc95dd969d 100644 --- a/pkg/printers/internalversion/describe.go +++ b/pkg/printers/internalversion/describe.go @@ -2225,7 +2225,6 @@ func describeServiceAccount(serviceAccount *api.ServiceAccount, tokens []api.Sec w.Write(LEVEL_0, "Namespace:\t%s\n", serviceAccount.Namespace) printLabelsMultiline(w, "Labels", serviceAccount.Labels) printAnnotationsMultiline(w, "Annotations", serviceAccount.Annotations) - w.WriteLine() var ( emptyHeader = " " @@ -2267,7 +2266,6 @@ func describeServiceAccount(serviceAccount *api.ServiceAccount, tokens []api.Sec prefix = emptyHeader } } - w.WriteLine() } if events != nil { diff --git a/pkg/printers/internalversion/describe_test.go b/pkg/printers/internalversion/describe_test.go index 8df36736c7f..6a29c08c89a 100644 --- a/pkg/printers/internalversion/describe_test.go +++ b/pkg/printers/internalversion/describe_test.go @@ -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: +Annotations: +Image pull secrets: test-local-ref (not found) +Mountable secrets: test-objectref (not found) +Tokens: +Events: ` + "\n" + if out != expectedOut { + t.Errorf("expected : %q\n but got output:\n %q", expectedOut, out) + } + +} + // boolPtr returns a pointer to a bool func boolPtr(b bool) *bool { o := b