8000 feat(library): split pkg/chop config machinery from the kube client wiring by sks · Pull Request #2161 · Altinity/clickhouse-operator · GitHub
[go: up one dir, main page]

Skip to content

feat(library): split pkg/chop config machinery from the kube client wiring - #2161

Open
sks wants to merge 1 commit into
Altinity:0.28.0from
stackgenhq:chop-config-without-kube-client
Open

sks wants to merge 1 commit into
Altinity:0.28.0from
stackgenhq:chop-config-without-kube-client

Conversation

@sks
@sks sks commented Nov 16, 2026 •
Copy link
Copy Markdown

Stacked on #2160 ("fix(library): vendor the sunsingerus mergo fork so the operator imports as a Go module", merged into 0.28.0). Rebased onto Altinity:0.28.0 as a single-commit diff (2df3f93).

What

Library consumers import the operator for its config generation, and today that drags the entire k8s.io/client-go surface through pkg/chop: the ConfigManager held *kube.Clientset and *chopclientset.Clientset fields, so any import of chop.Config() — the one accessor every consumer reads — compiled the full Kubernetes client machinery in.

The fix

Split the config machinery into pkg/chop/config, kube-free:

  • ConfigManager moves to pkg/chop/config behind two narrow function seams (the secretDataGetter pattern this codebase already established for the RootCA tests):
    • CRConfigLister — reads operator-configuration Custom Resources, answering specs + ResourceVersions (nil seam = file/env-only config, the library-consumer shape)
    • secretDataGetter — Kubernetes Secret reads (nil seam = secret refs log a warning and stay unresolved)
  • pkg/chop keeps New(), GetClientset, and the kube machinery, and adapts its clientsets to the seams — the operator binary's path is unchanged (same signature, same behavior, same logs)
  • ProvisionIPCToken stays exported from pkg/chop (thin wrapper over the config package's implementation)

Net effect

A consumer importing only pkg/chop/config has zero k8s.io/client-go modules in its dependency tree — verified with a scratch consumer (require → import → build; go list -deps shows only apimachinery types):

config manager built without any kube client: true
client-go modules in the consumer's tree: 0

Consumers of the operator outside Kubernetes — VM bootstrappers embedding the config/keeper model layer — no longer inherit the client surface they never call. Together with #2160, the operator's config machinery becomes consumable as a plain Go library.

Behavior

No behavior change: the CR listing, secret fetches, insecure-kube gate, and TLS min-version floor all run through the same logic — only the client boundary moved behind function seams. The in-tree package suite passes (pkg/chop, pkg/chop/config, pkg/apis/..., pkg/model/...); the only failing tests locally are pre-existing (macOS toolchain linker + vet warnings, identical on the base branch).

Happy to restructure (seam shapes, package name) to fit your review preferences.

Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

(Supersedes the closed #2159 — same commits, moved to the org fork.)

@sks sks changed the title feat(library): split pkg/chop config machinery from the kube client wiring [stacked on #2160] feat(library): split pkg/chop config machinery from the kube client wiring Dec 1, 2026
…iring

Library consumers import the operator for its config generation, and
today that drags the entire k8s.io/client-go surface through pkg/chop:
the ConfigManager held *kube.Clientset and *chopclientset.Clientset
fields, so any import of chop.Config() - the one accessor every
consumer reads - compiled the full Kubernetes client machinery in.

This splits the config machinery into pkg/chop/config, kube-free:

- ConfigManager moves to pkg/chop/config with two narrow seams
  (the secretDataGetter pattern already established for the RootCA
  tests):
  - CRConfigLister - reads operator-configuration Custom Resources,
    answering specs + ResourceVersions (nil = file/env-only config,
    the library-consumer shape)
  - secretDataGetter - Kubernetes Secret reads (nil = secret refs
    log a warning and stay unresolved)
- pkg/chop keeps New(), GetClientset, and the kube machinery, and
  adapts its clientsets to the seams - the operator binary's path
  is unchanged (same signature, same behavior, same logs)
- ProvisionIPCToken stays exported from pkg/chop (wrapper over the
  config package's implementation)

Net effect: a consumer importing only pkg/chop/config has ZERO
k8s.io/client-go modules in its dependency tree (verified with a
scratch consumer: require -> import -> build; go list -deps shows
only apimachinery types). Consumers of the operator outside
Kubernetes (VM bootstrappers embedding the config/keeper model
layer) no longer inherit the client surface they never call.

No behavior change: the CR listing, secret fetches, insecure-kube
gate, and TLS min-version floor all run through the same logic -
only the client boundary moved behind function seams.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@sks
sks force-pushed the chop-config-without-kube-client branch from 1608ba4 to 2df3f93 Compare December 1, 2026 16:53
@sks
sks changed the base branch from master to 0.28.0 December 1, 2026 16:53

This branch has not been deployed

No deployments
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

0