Skip to content

refactor(cli): extract resolveLocalInput + connectIngestTarget from runDataIngest - #321

Merged
saadqbal merged 1 commit into
developfrom
refactor/283-rundataingest-extract
Jul 14, 2026
Merged

refactor(cli): extract resolveLocalInput + connectIngestTarget from runDataIngest#321
saadqbal merged 1 commit into
developfrom
refactor/283-rundataingest-extract

Conversation

@saadqbal

@saadqbalsaadqbal commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

Recreation of #309, which was auto-closed during the #300#317 merge batch when its base branch (#303's) was deleted on squash-merge — GitHub closes a PR whose base ref is gone, and it can't be reopened. Same work, rebased cleanly onto develop (the #303 data.go split it stacked on is already merged).

Extracts resolveLocalInput + connectIngestTarget from runDataIngest:

  • Both take *runDataIngestArgs so the in-place a.Spec/a.Overwrite mutations thread through; explicit (cancelled, err) returns preserve the interactive-cancel + error paths; err feeds the named return so the reclaim defer still fires.

Diff vs develop is exactly the extraction (data.go −483, +cluster/+local). Previously reviewed + approved on #309.

🤖 Generated with Claude Code


Note

Low Risk
Pure move/refactor of existing ingest preflight logic with explicit cancel wiring; no new ingest semantics or cluster APIs.

Overview
runDataIngest is slimmed down to orchestration: it calls resolveLocalInput for all pre-cluster work and connectIngestTarget for kube discovery plus the destination-table guard, then continues with dry-run, teardown, staging, and runIngestionRun unchanged.

resolveLocalInput (data_ingest_local.go) holds the former inline steps 0–4 and P3 preflight (banner, interactive prompts, validation, layout walk, spec build/schema check, local preflight/summary). connectIngestTarget (data_ingest_cluster.go) holds steps 5–8a (cluster target resolution, verbose summary, existing-table prompt/a.Overwrite). Both take *runDataIngestArgs so in-place spec/path/overwrite updates still flow to the JSON error defer and later steps; cancelled plus err preserve interactive cancel (exit 0) vs real failures.

Imports and helpers that only served the moved blocks shift with the code (yaml, filepath, strings, schema on the local file). No intended behavior, exit-code, or UX change—mechanical split for readability and follow-on testing.

Reviewed by Cursor Bugbot for commit e04bc04. Bugbot is set up for automated code reviews on this repo. Configure here.

…unDataIngest
runDataIngest was 586 lines; every pre-cluster step and the cluster
pre-flight now live in two named stanza functions, moved verbatim:
- resolveLocalInput (data_ingest_local.go) — steps 0–4 + the P3 content
preflight: flag guard, banner, guided prompts, ~-expansion +
existence-first check, table-name/category/misapplied-flag validation,
layout walk, per-category spec resolution, spec synthesis + schema
validation, local summary. Mutates a in place (via *runDataIngestArgs)
so the --output-json defer and the cluster steps see the resolved spec
exactly as before.
- connectIngestTarget (data_ingest_cluster.go) — steps 5–8a: kubeconfig
resolve, release + PVC discovery, verbose cluster summary, and the
destination-table guard (incl. the folded interactive replace decision,
which still flips a.Overwrite).
The jsonEmitted/named-return defer dance stays INSIDE runDataIngest,
next to the err it reads — both extracted functions feed that named
return, so the error-JSON contract is unchanged. The dry-run stop (which
sets jsonEmitted) also stays inside.
Only in-stanza edits are what the new signatures force: multi-value
returns on error paths, := to = where a named result already exists, and
&a -> a where a is already a pointer. Step order, output order, and exit
codes are untouched.
data.go: 693 -> 240 lines; runDataIngest: 586 -> 138.
Safety net: the #187 outcome-matrix table test + #264 mutation pins pass
untouched; full suite green under -race; coverage floors hold (82.7%).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@LukasWodka

Copy link
Copy Markdown
Contributor

👋 Heads-up — Code review queue is at 42 / 30

Above the WIP limit. The team convention is to review existing PRs before opening new work.

Open PRs currently in Code review (oldest first):

Pull from review before opening new work. (This is a nudge from the kanban WIP check, not a block.)

@saadqbal
saadqbal requested a review from LukasWodkaJuly 14, 2026 14:48
@saadqbal
saadqbal merged commit d718682 into developJul 14, 2026
23 checks passed
@saadqbal
saadqbal deleted the refactor/283-rundataingest-extract branch July 14, 2026 15:52
Sign up for freeto 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.

2 participants

@saadqbal@LukasWodka