mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 11:21:47 +00:00
Print ServiceAccount attached to the Pod
This commit is contained in:
parent
35940b707c
commit
b938cdabd0
@ -766,6 +766,9 @@ func describePod(pod *corev1.Pod, events *corev1.EventList) (string, error) {
|
||||
if len(pod.Spec.PriorityClassName) > 0 {
|
||||
w.Write(LEVEL_0, "Priority Class Name:\t%s\n", stringOrNone(pod.Spec.PriorityClassName))
|
||||
}
|
||||
if len(pod.Spec.ServiceAccountName) > 0 {
|
||||
w.Write(LEVEL_0, "Service Account:\t%s\n", pod.Spec.ServiceAccountName)
|
||||
}
|
||||
if pod.Spec.NodeName == "" {
|
||||
w.Write(LEVEL_0, "Node:\t<none>\n")
|
||||
} else {
|
||||
|
@ -102,6 +102,30 @@ func TestDescribePod(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDescribePodServiceAccount(t *testing.T) {
|
||||
fake := fake.NewSimpleClientset(&corev1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "bar",
|
||||
Namespace: "foo",
|
||||
},
|
||||
Spec: corev1.PodSpec{
|
||||
ServiceAccountName: "fooaccount",
|
||||
},
|
||||
})
|
||||
c := &describeClient{T: t, Namespace: "foo", Interface: fake}
|
||||
d := PodDescriber{c}
|
||||
out, err := d.Describe("foo", "bar", DescriberSettings{ShowEvents: true})
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
if !strings.Contains(out, "Service Account:") {
|
||||
t.Errorf("unexpected out: %s", out)
|
||||
}
|
||||
if !strings.Contains(out, "fooaccount") {
|
||||
t.Errorf("unexpected out: %s", out)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDescribePodEphemeralContainers(t *testing.T) {
|
||||
fake := fake.NewSimpleClientset(&corev1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
|
Loading…
Reference in New Issue
Block a user