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 #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>
Author
|
Moving the head to stackgenhq/clickhouse-operator (this fork's tree is being retired; the work continues from the org fork). Reopening shortly from stackgenhq:vendor-mergo-for-library-consumption — same commits, same diff. |
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
Upstream wires
mergo.WithSliceDeepMerge— used by the exported API packages (type_chi.go,type_templates.go,type_configuration_chop.go,type_chk.go) — through areplacedirective:Go
replacedirectives do not propagate to consumers importing this repository as a library module. Any downstreamrequireof clickhouse-operator fails at compile with:(Raised as #2150, closed without a fix.)
The fix
Vendor the sunsingerus fork's stdlib-only sources at
pkg/util/mergo(BSD-3-Clause, LICENSE included, provenance pinned tofc6fffa94450inprovenance.go) and swap the four API packages' imports to it. The non-propagatingreplaceand theimdario/mergorequire are gone fromgo.mod.Net effect
A clean module consumer builds the exported API packages with zero consumer-side replaces:
Verified with a scratch consumer module (require, import
pkg/apis/clickhouse.altinity.com/v1, exercise themergo.WithSliceDeepMergepath) before and after: fails on stock upstream, passes with this patch.No behavior change — the vendored sources are byte-identical to the fork at the pinned commit.
Why we care
stackgenhq/chinit — the cloud-adaptive node bootstrapper for stateful ClickHouse fleets on VMs (EC2 ASGs, Azure VMSS) — consumes the operator's config generation, keeper/chk machinery, and API types as a plain Go library. Today that requires carrying a fork of this repository solely for this vendoring. Landing this patch would let us drop the fork and require upstream directly, and we believe it unblocks library consumption for anyone else embedding the operator's model/config layer outside Kubernetes.
Follow-up we would like to explore (separate PRs)
pkg/chopconfig accessors (Config(), the Access/Username reads) from thek8s.io/client-goclient wiring — today importingpkg/chopfor config drags the whole k8s client surface into a non-k8s consumer's tree.Happy to adjust (path, naming, docs) to fit your conventions.