Renew token from token file before it expires#49
Merged
Conversation
Member
|
@t089 Hey there, thank you for the PR. Nice addition. Lots of things going on right now but I'll definitely try to merge this as soon as possible. |
Contributor
Author
|
Note, that this PR contains a some unrelated linter fixes to make the CI happy. If you prefer, we can split this out. |
t089
commented
Mar 24, 2026
| /// Bearer token authentication scheme via a valid API token. | ||
| case bearer(token: String) | ||
| /// File-backed bearer token with a cached token source that re-reads from disk periodically. | ||
| case tokenFile(source: CachedFileTokenSource) |
Contributor
Author
There was a problem hiding this comment.
adding a new case to a public enum is strictly speaking a SemVer major breaking change. Since this lib has no tagged 1.0 version, I think we are fine.
Member
Hey, no need to split. I've skimmed through and all the changes look good. Will merge probably tomorrow after work. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently the client reads the token from the service account only once when the client is created. When the service account token is short-lived, the client will fail to execute any request with a
401error once the token has expired. The only current workaround is to re-create the entire client.This fix adds a new
KubernetesClientAuthentication.tokenFileand aCachedFileTokenSourcewhich reads the token from the token file and caches it for 1 minute. If the client needs a token after it expired, theCachedFileTokenSourcewill read it again and cache it. This follows roughly the strategy used byclient-go.