Repository navigation
Conversation
…ts as a Go module
Upstream wires mergo.WithSliceDeepMerge (used by the exported API
packages - type_chi.go, type_templates.go, type_configuration_chop.go,
type_chk.go) through a replace directive:
replace github.com/imdario/mergo => github.com/sunsingerus/mergo
Go replace directives do not propagate to consumers importing this
repository as a library module. Any downstream require of
clickhouse-operator fails at compile with:
undefined: mergo.WithSliceDeepMerge
(Raised as Altinity#2150, closed without a fix.)
This vendors the sunsingerus fork's stdlib-only sources at
pkg/util/mergo (BSD-3-Clause, LICENSE included, provenance pinned to
fc6fffa94450) and swaps the four API packages' imports to it. The
non-propagating replace and the imdario require are gone from go.mod.
Net effect: a clean module consumer builds the exported API packages
with zero consumer-side replaces:
require github.com/altinity/clickhouse-operator v0.27.4
No behavior change - the vendored sources are byte-identical to the
fork at the pinned commit (provenance.go documents the pin; do not
modify, re-vendor wholesale).
Context: chinit (the cloud-adaptive node bootstrapper for stateful
ClickHouse fleets on VMs) consumes the operator's config generation,
keeper machinery and API types as a library. The k8s-client wiring
stays upstream; the mergo vendoring is what makes that possible
without a fork.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…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>
This branch has not been deployed
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.
What
Library consumers import the operator for its config generation, and today that drags the entire
k8s.io/client-gosurface throughpkg/chop: theConfigManagerheld*kube.Clientsetand*chopclientset.Clientsetfields, so any import ofchop.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:ConfigManagermoves topkg/chop/configbehind two narrow function seams (thesecretDataGetterpattern 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/chopkeepsNew(),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)ProvisionIPCTokenstays exported frompkg/chop(thin wrapper over the config package's implementation)Net effect
A consumer importing only
pkg/chop/confighas zerok8s.io/client-gomodules in its dependency tree — verified with a scratch consumer (require→import→ build;go list -depsshows 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. 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.)