Commit 737ded5a authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #51035 from mrogers950/sa-desc-event

Automatic merge from submit-queue (batch tested with PRs 51108, 51035, 50539, 51160, 50947) Show events when describing service accounts **What this PR does / why we need it**: Any events associated with service accounts should appear in the describe output. **Which issue this PR fixes**: **Special notes for your reviewer**: **Release note**: ```release-note Show events when describing service accounts ```
parents 915371cf c42c43a1
...@@ -2173,10 +2173,15 @@ func (d *ServiceAccountDescriber) Describe(namespace, name string, describerSett ...@@ -2173,10 +2173,15 @@ func (d *ServiceAccountDescriber) Describe(namespace, name string, describerSett
} }
} }
return describeServiceAccount(serviceAccount, tokens, missingSecrets) var events *api.EventList
if describerSettings.ShowEvents {
events, _ = d.Core().Events(namespace).Search(api.Scheme, serviceAccount)
}
return describeServiceAccount(serviceAccount, tokens, missingSecrets, events)
} }
func describeServiceAccount(serviceAccount *api.ServiceAccount, tokens []api.Secret, missingSecrets sets.String) (string, error) { func describeServiceAccount(serviceAccount *api.ServiceAccount, tokens []api.Secret, missingSecrets sets.String, events *api.EventList) (string, error) {
return tabbedString(func(out io.Writer) error { return tabbedString(func(out io.Writer) error {
w := NewPrefixWriter(out) w := NewPrefixWriter(out)
w.Write(LEVEL_0, "Name:\t%s\n", serviceAccount.Name) w.Write(LEVEL_0, "Name:\t%s\n", serviceAccount.Name)
...@@ -2228,6 +2233,10 @@ func describeServiceAccount(serviceAccount *api.ServiceAccount, tokens []api.Sec ...@@ -2228,6 +2233,10 @@ func describeServiceAccount(serviceAccount *api.ServiceAccount, tokens []api.Sec
w.WriteLine() w.WriteLine()
} }
if events != nil {
DescribeEvents(events, w)
}
return nil return nil
}) })
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment