Skip to content

feat(cache): add an optional ttl to the filesystem kubeconfig cache - #297

Open
ZeikoFr wants to merge 1 commit into
MichaelSp:mainfrom
ZeikoFr:feat/filesystem-cache-ttl
Open

feat(cache): add an optional ttl to the filesystem kubeconfig cache#297
ZeikoFr wants to merge 1 commit into
MichaelSp:mainfrom
ZeikoFr:feat/filesystem-cache-ttl

Conversation

@ZeikoFr

@ZeikoFr ZeikoFr commented Aug 30, 2026

Copy link
Copy Markdown

Independent of #295 and #296, can be merged in any order.

The filesystem cache serves a cached kubeconfig until kswitch clean removes it.
Kubeconfigs from the cloud providers embed credentials that expire, so a
long-lived cache eventually hands out a kubeconfig that no longer authenticates,
and the failure gives no hint that the cache is at fault.

cache:
  kind: filesystem
  config:
    path: ~/.kube/cache
    ttl: 8h

Once the cached file is older than ttl, the kubeconfig is fetched from the
store again. Leaving ttl unset keeps the current behaviour exactly.

Verification

gofmt, go build, go vet, golangci-lint run (0 issues) and
go test -race -count=1 ./... are clean. Tests cover both the expiry and the
unset-ttl path.

🤖 Generated with Claude Code

The filesystem cache served a cached kubeconfig until "kswitch clean" removed
it. Kubeconfigs of the cloud providers embed credentials that expire, so a
long lived cache eventually hands out a kubeconfig that no longer
authenticates and the user has to work out that the cache is at fault.

The new optional ttl refetches a cached kubeconfig from the store once the
cached file is older than the given duration. Leaving ttl unset keeps the
previous behaviour.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@ZeikoFr
ZeikoFr force-pushed the feat/filesystem-cache-ttl branch from 45d9243 to ba51e3d Compare August 30, 2026 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant