Skip to content

refactor(k8s): decouple store from kubernetes.io dependencies#74

Merged
rbaliyan merged 3 commits into
mainfrom
refactor/k8s-decouple-from-kubernetes
May 8, 2026
Merged

refactor(k8s): decouple store from kubernetes.io dependencies#74
rbaliyan merged 3 commits into
mainfrom
refactor/k8s-decouple-from-kubernetes

Conversation

@rbaliyan
Copy link
Copy Markdown
Owner

@rbaliyan rbaliyan commented May 8, 2026

Summary

  • Replace kubernetes.Interface with a narrow Client interface (Get/Upsert/Watch/Health); the k8s package no longer imports k8s.io/*.
  • Drop the informer cache. Reads call straight through to the Client and rely on Manager-level caching for repeats, matching the postgres/mongodb stores.
  • Move k8s into the main config module (delete k8s/go.mod); kubernetes-versioned bits move to k8s/example/ with its own go.mod and a reference Adapter over kubernetes.Interface.

Why

Releasing config previously required a second release of config/k8s to pick up the new version. With this refactor a single release covers the store, and the example adapter follows the kubernetes client release cadence independently.

Test plan

  • go test ./k8s/... (new fake-Client suite covers set/get/delete, secret routing, find+cursor, watch, health, lifecycle states)
  • go test ./... in main module
  • go build ./... + golangci-lint run ./... in k8s/example/ (verifies the adapter compiles against real k8s.io/*)
  • golangci-lint run ./k8s/... clean
  • CI green

rbaliyan added 3 commits May 8, 2026 15:09
Replace the direct dependency on k8s.io/* with a narrow Client interface
(Get/Upsert/Watch/Health) and remove the informer-based local cache. Reads
go straight through to the Client and rely on the Manager-level cache for
repeats, matching how the postgres and mongodb stores behave.

The k8s package now lives in the main config module so a single release
covers it. A reference Adapter wrapping kubernetes.Interface lives at
k8s/example/ in its own go.mod, kept on the kubernetes client release
cadence rather than the config one.
Address review feedback on PR #74:

- Clarify Find behavior: Keys mode resolves secret-prefixed keys; Prefix mode
  scans the namespace ConfigMap only.
- Document Store.Watch drop-on-full-buffer behavior and connection precondition.
- Note that Connect's watch lifetime is bounded by Close, not by ctx.
- Soften Client.Watch reconnect requirement to "recommended" so the bundled
  reference adapter does not violate its own contract; document NewRetryWatcher
  as the standard way to add resilience.
- Mark Event.Old as best-effort; describe Store fallback when Old is nil.
- Expand WithK8sNamespace doc with the empty-config-namespace fallback.
- Update README ctx declaration so the snippet compiles as written.
The k8s package no longer has its own go.mod (it's part of the main module
now), so the previous "k8s submodule" gosec step failed with no go.sum.
Drop the exclude-dir for k8s and add a parallel step that scans the
k8s/example adapter from its own module.
@github-advanced-security
Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

@rbaliyan rbaliyan merged commit a60f614 into main May 8, 2026
10 checks passed
@rbaliyan rbaliyan deleted the refactor/k8s-decouple-from-kubernetes branch May 8, 2026 10:13
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.

2 participants