@@ -65,14 +65,25 @@ func SelectSession(sessions credentials.Sessions) (string, string, error) {
65
65
p .WithMaxHeight (MaxItemsToShow )
66
66
p .WithEmptyMessage ("No SSO Sessions Found" )
67
67
p .WithTitle ("Pick SSO Session" )
68
- p .WithHeaders ("SSO Session" , "Region" , "SSO Start URL" , "Expires In" )
68
+ p .WithHeaders ("SSO Session" , "Region" , "SSO Start URL" , "Refreshable" , " Expires In" )
69
69
p .AddAction (keys .Tab , "tab" , "view cached" )
70
70
for _ , session := range sessions {
71
71
expires := "-"
72
+ refreshable := "-"
72
73
if session .ClientToken != nil && ! session .ClientToken .IsExpired () {
73
74
expires = fmt .Sprintf ("%.f mins" , session .ClientToken .ExpiresAt .Sub (now ).Minutes ())
74
75
}
75
- p .AddOption (session .Name , session .Name , session .Region , session .StartUrl , expires )
76
+ if session .ClientCredentials != nil && ! session .ClientCredentials .IsExpired () {
77
+ hours := session .ClientCredentials .ExpiresAt .Sub (now ).Hours ()
78
+ if hours < 1 {
79
+ refreshable = fmt .Sprintf ("%.f mins" , hours * 60 )
80
+ } else if hours < 24 {
81
+ refreshable = fmt .Sprintf ("%.f hours" , hours )
82
+ } else {
83
+ refreshable = fmt .Sprintf ("%.f days" , hours / 24 )
84
+ }
85
+ }
86
+ p .AddOption (session .Name , session .Name , session .Region , session .StartUrl , refreshable , expires )
76
87
}
77
88
selection , firedKeyCode := p .Pick ()
78
89
if firedKeyCode != nil && * firedKeyCode == keys .Tab {
0 commit comments