8000 fix(library): vendor the sunsingerus mergo fork so the operator imports as a Go module by sks · Pull Request #2158 · Altinity/clickhouse-operator · GitHub
[go: up one dir, main page]

Skip to content

fix(library): vendor the sunsingerus mergo fork so the operator imports as a Go module - #2158

Closed
sks wants to merge 1 commit into
Altinity:masterfrom
sks:vendor-mergo-for-library-consumption
Closed

sks wants to merge 1 commit into
Altinity:masterfrom
sks:vendor-mergo-for-library-consumption

Conversation

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

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 a replace directive:

replace github.com/imdario/mergo => github.com/sunsingerus/mergo v0.0.0-20230507185449-fc6fffa94450

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.)

The fix

Vendor the sunsingerus fork's stdlib-only sources at pkg/util/mergo (BSD-3-Clause, LICENSE included, provenance pinned to fc6fffa94450 in provenance.go) and swap the four API packages' imports to it. The non-propagating replace and the imdario/mergo 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

Verified with a scratch consumer module (require, import pkg/apis/clickhouse.altinity.com/v1, exercise the mergo.WithSliceDeepMerge path) 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)

  • Splitting the pkg/chop config accessors (Config(), the Access/Username reads) from the k8s.io/client-go client wiring — today importing pkg/chop for config drags the whole k8s client surface into a non-k8s consumer's tree.

Happy to adjust (path, naming, docs) to fit your conventions.

…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>
@sks
sks commented Nov 16, 2026
Copy link
Copy Markdown
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.

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