kubeconfighook

package
v5.95.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 8, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

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

func IsTokenExpired(kubeconfigPath string) bool

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

func MaybeRefreshOmniKubeconfig(cmd *cobra.Command)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL