Documentation
¶
Overview ¶
Package kubeconfighook provides a centralized hook that transparently refreshes Omni kubeconfig tokens before they expire. The hook is wired into Cobra's PersistentPreRunE so that every CLI command automatically gets a fresh token when needed.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsTokenExpired ¶
IsTokenExpired checks whether the bearer token in the kubeconfig's current context has expired (or will expire within the expiryBuffer).
Returns false (not expired) when the kubeconfig cannot be parsed, has no token, or the token is not a JWT — erring on the side of not refreshing unnecessarily.
func MaybeRefreshOmniKubeconfig ¶
MaybeRefreshOmniKubeconfig checks whether the current kubeconfig's service-account token is expired for Omni-managed clusters and transparently refreshes it.
This function is designed to be called from Cobra PersistentPreRunE hooks. It is a fast no-op (~1ms) when:
- No KSail config is found or the provider is not Omni
- The kubeconfig file does not exist yet (e.g., before cluster create)
- The token is still valid
On refresh failure, a warning is logged but the error is not propagated — the command proceeds with the existing kubeconfig.
Types ¶
This section is empty.