Skip to content

Commit 38b1ead

Browse files
committed
Fix credential expirability check
Fixes a bug introduced during the refactor in e92213c, which incorrectly inverted the previous credential expirability checking logic. This caused errors about being unable to cache otherwise cachable credentials. Also changes the error log around the previous expirability check site to no longer log the error that previously came from the `ExpiresAt()` check; since this is now the wrong `err`, it's always `nil`. Addresses #776
1 parent b115902 commit 38b1ead

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

pkg/filecache/converter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func (p *v2) Retrieve(ctx context.Context) (aws.Credentials, error) {
2727
// Don't have account ID
2828
}
2929

30-
if expiration, err := p.creds.ExpiresAt(); err != nil {
30+
if expiration, err := p.creds.ExpiresAt(); err == nil {
3131
resp.CanExpire = true
3232
resp.Expires = expiration
3333
}

pkg/filecache/filecache.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ func (f *FileCacheProvider) RetrieveWithContext(ctx context.Context) (credential
251251
}
252252
} else {
253253
// credential doesn't support expiration time, so can't cache, but still return the credential
254-
_, _ = fmt.Fprintf(os.Stderr, "Unable to cache credential: %v\n", err)
254+
_, _ = fmt.Fprint(os.Stderr, "Unable to cache credential: credential doesn't support expiration\n")
255255
err = nil
256256
}
257257
return V2CredentialToV1Value(credential), err

0 commit comments

Comments
 (0)