feat(cli): add karta workload CLI with release plumbing#64
Conversation
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: Alon Lavian <alavian@nvidia.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: Alon Lavian <alavian@nvidia.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: Alon Lavian <alavian@nvidia.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: Alon Lavian <alavian@nvidia.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: Alon Lavian <alavian@nvidia.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: Alon Lavian <alavian@nvidia.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: Alon Lavian <alavian@nvidia.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: Alon Lavian <alavian@nvidia.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: Alon Lavian <alavian@nvidia.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: Alon Lavian <alavian@nvidia.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: Alon Lavian <alavian@nvidia.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: Alon Lavian <alavian@nvidia.com>
# Conflicts: # go.mod # go.sum
| k8s.io/cli-runtime v0.36.1 | ||
| k8s.io/client-go v0.36.1 | ||
| k8s.io/utils v0.0.0-20260210185600-b8788abfbbc2 | ||
| sigs.k8s.io/controller-runtime v0.24.1 |
There was a problem hiding this comment.
it cant be part of the karta lib ,
it should be under /karta-cli folder or something with diffrent go.mod/go.sum
we can't bind between karta lib and controller runtime
There was a problem hiding this comment.
Fixed in f475c5e — cmd/karta/ is now its own Go module with its own go.mod/go.sum. Root karta library no longer pulls in cobra, cli-runtime, client-go, or any CLI dependency. pkg/tree's use of client.Object was already replaced with resource.KubernetesObject in a7bc745 so controller-runtime stayed dropped. See the PR-level review I just left for the full breakdown.
lavianalon
left a comment
There was a problem hiding this comment.
Good catch, addressed in f475c5e. The karta CLI is now its own Go module at cmd/karta/ with its own go.mod / go.sum. The root karta library no longer carries cobra, cli-runtime, client-go, or any other CLI-specific dependency.
What changed:
cmd/karta/go.moddeclaresgithub.com/run-ai/karta/cmd/karta, withreplace github.com/run-ai/karta => ../..for local development.- Root
go.modslimmed back to library deps only —controller-runtimestayed gone (earlier commita7bc745had already removedpkg/tree's use ofclient.Objectin favor ofresource.KubernetesObject). .goreleaser.yamlmoved tocmd/karta/; LICENSE staged via before-hook (sh -c 'cp ../../LICENSE LICENSE') and gitignored.- Release workflow now runs goreleaser with
workdir: cmd/karta;gh release createuploads fromcmd/karta/dist/. make release-snapshotcd's intocmd/kartafirst.
Verified locally: make release-snapshot produces 5 archives (darwin amd64/arm64, linux amd64/arm64, windows amd64), each containing karta + LICENSE + README.md. Root go build ./... and go test ./... pass with no CLI deps.
Open question for you: I left the path as cmd/karta/ rather than your suggested /karta-cli since the existing files were already there and cmd/... is the standard Go monorepo pattern. Happy to rename if you'd prefer the literal karta-cli/ top-level directory.
Summary
pkg/treelibrary that walks any Karta definition into a structuredWorkloadTree.kartabinary withworkload listandworkload treecommands, ANSI-aware colored output,--color {auto,always,never}flag, and-A/--all-namespacesflag.//go:embed.make sync-cli-definitions(wired intomake validate) keeps the bundle in sync with the canonicaldocs/examples/..goreleaser.yaml+.github/workflows/release-cli.yamlpublish cross-platform binaries (darwin amd64/arm64, linux amd64/arm64, windows amd64) to GitHub Releases onkartacli-v*tags. Namespace-isolated from existing helm chart releases.17 commits on branch
feat/cli-poc.What changed
pkg/tree/**cmd/karta/cmd/{root,workload,workload_list,workload_tree,version}.gogenericclioptionscmd/karta/internal/render/{table,tree,view,style}.gocmd/karta/internal/kube/client.gocmd/karta/internal/loader/workload.gocmd/karta/internal/definitions/community/*.yaml(11),cmd/karta/internal/definitions/registry.goMakefile(sync-cli-definitions),docs/examples/mpijob.yaml(newline fix)make validateruns sync +git diff --exit-code.goreleaser.yaml,.github/workflows/release-cli.yaml,cmd/karta/README.md,Makefile(release-snapshot)kartacli-v*.gh release create --latest=false --prerelease.How to cut a release
git tag -s kartacli-v0.1.0-alpha.1 -m "karta CLI v0.1.0-alpha.1" git push origin kartacli-v0.1.0-alpha.1Workflow strips the
kartacli-prefix viaGORELEASER_CURRENT_TAG, builds 5 archives, publishes to the original prefixed tag with--prerelease --latest=false --generate-notes. Existingv[0-9].[0-9].[0-9]workflow (helm chart) is untouched.Locally verified
go build -o bin/karta ./cmd/kartaclean;go test ./cmd/karta/...passes../bin/karta --context master-1705 workload list -A --color always: all rows align to identical visible width (118 chars)../bin/karta workload tree rag-dynamo-deploy -n runai-alon: tree view renders correctly../bin/karta versionreturns expected output with and without ldflags injection.goreleaser check .goreleaser.yaml: clean, no deprecations.make release-snapshot: 5 archives indist/, each containingkarta+LICENSE+README.md.GORELEASER_CURRENT_TAG=v0.1.0-alpha.1 goreleaser release --skip=publish,validate: archives correctly named,dist/CHANGELOG.mdgenerated.Commit summary
Commits
006a9e389bd383457833f4b8d2e0c8a6d8503997a46d8bc55d8a4309229f0880b86d9f927383ba46ed4c5dc94057c6ce5a06a2ff77c2ecf961b2fc8Commit
006a9e3-- feat(cli): publish CLI to GitHub Releases via goreleaser:.goreleaser.yamlbuilding darwin/linux amd64+arm64, windows amd64..github/workflows/release-cli.yamltriggered onkartacli-v*tag push.cmd/karta/README.mdshipped inside each archive (alpha banner, install, usage, supported kinds, bug-reporting link).cmd/karta/cmd/version.go+ ldflags-injectedversion/commit/datevars; registerversionsubcommand in root.release-snapshotMakefile target for local goreleaser dry-runs.Commit
89bd383-- feat(cli): bundle all Karta definitions and add sync target:jobset,knative-serving,kserve,milvus,mpijob,nimservice,raycluster,rayjob) fromdocs/examples/intocmd/karta/internal/definitions/community/so the embed-FS picks them up.KARTA_DEFINITIONS_DIR+CLI_DEFINITIONS_DIRMakefile vars.sync-cli-definitionsMakefile target (rm + cp from canonical) and wire it intovalidateso CI fails on drift.Commit
457833f-- fix(examples): correct malformed mpijob.yaml status mappings:docs/examples/mpijob.yamlhad YAML keys glued onto value lines (status: "False" running:). Split into proper key/value pairs sokubectl apply -fand the embedded loader both succeed.Commit
4b8d2e0-- feat(cli): add --all-namespaces / -A flag to workload list:workload list. When set, passes empty namespace toloader.ListWorkloadsso the dynamic client and pods client list cluster-wide.(namespace, name)so multi-namespace output stays readable.Commit
c8a6d85-- fix(cli): align list columns with ANSI-aware padding:text/tabwriterfrom the list table. Escape brackets in tabwriter do not exclude inner content from cell-width math, so ANSI color codes were being counted as visible chars and columns drifted. Compute visible width via regex strip, pad cells manually.Commits
03997a4/6d8bc55/d8a4309/229f088/0b86d9f-- tree rendering polish:Commit
927383b-- fix(render): per-replica desired counts in replica wrappers:Commits
a46ed4c/5dc9405/7c6ce5a-- tree-builder semantics:replicaSelectorsplits per-replica subtrees so each replica gets its own branch.Commit
06a2ff7-- feat(cli): colorize tree and list output with --color flag:Styleabstraction with auto/always/never modes (auto = TTY check +NO_COLORenv honored).Commit
7c2ecf9-- feat(cli): add karta workload CLI with tree and list:cmd/karta/binary using cobra +cli-runtime/genericclioptions.workload listandworkload treecommands.Commit
61b2fc8-- feat(tree): add WorkloadTree builder:pkg/treelibrary that walks any Karta definition into a structuredWorkloadTreeready for rendering.Checklist
🤖 Generated with Claude Code