Skip to content

Commit

Permalink
Calculate expiresAt from ttl, if not present (#148)
Browse files Browse the repository at this point in the history
Signed-off-by: Arnob kumar saha <[email protected]>
  • Loading branch information
ArnobKumarSaha authored Nov 8, 2024
1 parent 2bd13b4 commit a163de2
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pkg/rancherutil/rancher.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,15 @@ func decodeToken(opts clientbase.ClientOpts) (*rancher.Client, *RancherToken, er
if err != nil {
return nil, nil, err
}
expiresAt, err := time.Parse(time.RFC3339, token.ExpiresAt)
if err != nil {
return nil, nil, err

var expiresAt time.Time
if token.ExpiresAt != "" {
expiresAt, err = time.Parse(time.RFC3339, token.ExpiresAt)
if err != nil {
return nil, nil, err
}
} else {
expiresAt = time.Now().Add(time.Duration(token.TTLMillis) * time.Millisecond)
}

return rc, &RancherToken{
Expand Down

0 comments on commit a163de2

Please sign in to comment.