refactor(k8s): decouple store from kubernetes.io dependencies#74
Merged
Conversation
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.
|
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:
For more information about GitHub Code Scanning, check out the documentation. |
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.
Summary
kubernetes.Interfacewith a narrowClientinterface (Get/Upsert/Watch/Health); thek8spackage no longer importsk8s.io/*.Clientand rely on Manager-level caching for repeats, matching the postgres/mongodb stores.k8sinto the main config module (deletek8s/go.mod); kubernetes-versioned bits move tok8s/example/with its owngo.modand a referenceAdapteroverkubernetes.Interface.Why
Releasing
configpreviously required a second release ofconfig/k8sto 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 modulego build ./...+golangci-lint run ./...ink8s/example/(verifies the adapter compiles against realk8s.io/*)golangci-lint run ./k8s/...clean