Skip to content

Commit

Permalink
Improve the tsh prompt re: access list reviews (#36046)
Browse files Browse the repository at this point in the history
- Show the access list title instead of an arbitrary GUID
- Improve formatting for lists whose "next review" date is
  in the past

Closes #35427
  • Loading branch information
zmb3 committed Dec 26, 2023
1 parent 3ff6c3a commit e29442d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions tool/tsh/common/tsh.go
Expand Up @@ -4227,10 +4227,15 @@ func printLoginInformation(cf *CLIConf, profile *client.ProfileStatus, profiles

if len(accessListsToReview) > 0 {
fmt.Printf("Access lists that need to be reviewed:\n")
now := time.Now()

for _, accessList := range accessListsToReview {
fmt.Printf("\t%s (%s left to review)\n", accessList.GetName(), accessList.Spec.Audit.NextAuditDate.Sub(now).Round(time.Second).String())
d := time.Until(accessList.Spec.Audit.NextAuditDate).Round(time.Minute)
var msg string
if d > 0 {
msg = fmt.Sprintf("%v left to review", d.String())
} else {
msg = fmt.Sprintf("review was required %v ago", (-d).String())
}
fmt.Printf("\t%s (%v)\n", accessList.Spec.Title, msg)
}
fmt.Println()
}
Expand Down

0 comments on commit e29442d

Please sign in to comment.