Skip to content

Commit

Permalink
fix: check if expiration date is nil before logging
Browse files Browse the repository at this point in the history
  • Loading branch information
reubenmiller committed Jun 13, 2024
1 parent e780324 commit 465ebff
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions pkg/cmd/sessions/set/set.manual.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,15 @@ func (n *CmdSet) RunE(cmd *cobra.Command, args []string) error {
shouldBeValidFor := cfg.TokenValidFor()
expiresSoon, expiresAt := ShouldRenewToken(tok, shouldBeValidFor)

if expiresSoon {
log.Warnf("Ignoring existing token as it will expire soon. minimumValidFor=%s, tokenExpiresAt=%s", shouldBeValidFor, expiresAt.Format(time.RFC3339))
client.SetToken("")
} else if expiresAt != nil {
log.Infof("Token expiresAt: %s", expiresAt.Format(time.RFC3339))
if expiresAt != nil {
if expiresSoon {
log.Warnf("Ignoring existing token as it will expire soon. minimumValidFor=%s, tokenExpiresAt=%s", shouldBeValidFor, expiresAt.Format(time.RFC3339))
client.SetToken("")
} else {
log.Infof("Token expiresAt: %s", expiresAt.Format(time.RFC3339))
}
} else {
log.Infof("Ignoring invalid token")
}
}
}
Expand Down

0 comments on commit 465ebff

Please sign in to comment.