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
```
This commit is contained in:
Kubernetes Submit Queue 2017-08-24 02:32:06 -07:00 committed by GitHub
commit 737ded5aeb

View File

@ -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 {
w := NewPrefixWriter(out)
w.Write(LEVEL_0, "Name:\t%s\n", serviceAccount.Name)
@ -2228,6 +2233,10 @@ func describeServiceAccount(serviceAccount *api.ServiceAccount, tokens []api.Sec
w.WriteLine()
}
if events != nil {
DescribeEvents(events, w)
}
return nil
})
}