cli: closurejvm instrument (Go CLI, first command) - #29
Conversation
A thin Go CLI over the operator's CRDs — reuses api/v1alpha1 + a controller-runtime client to apply real typed custom resources, so launching work isn't hand-written YAML + kubectl. First command: `instrument`. - operator/cmd/closurejvm/: main (subcommand dispatch) + instrument (build a ClosureJVMTarget from flags, apply create-or-update, optional --wait for Injected printing phase transitions + coverageEndpoint). Pure buildTarget + validateInstrument are unit-tested; no new module deps (client-go/clientcmd + controller-runtime client were already vendored). - `make -C operator cli` → operator/bin/closurejvm. - docs/OPERATOR-USAGE.md §3: a CLI alternative to the target YAML. Validated against the kind cluster: instrumented a fresh Deployment to Injected with the coverage Service, idempotent re-apply, and the validation errors (missing --deployment; --coverage-service without --coverage-includes). Scope is instrument-only by design; run/status/dashboard are the next CLI PRs. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JuGqspSB9zpA5AyvHJBiDK
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JuGqspSB9zpA5AyvHJBiDK
|
@claude please review this CLI PR. Focus: (1) buildTarget correctness vs the CRD (coverage-enabled-iff-includes; JVMOptsVar-empty-lets-CRD-default; ThreadTracker omitempty behavior); (2) applyTarget create-or-update + waitForInjected loop (error/timeout/Error-phase); (3) kubeconfig/context/namespace resolution via clientcmd; (4) client-side validation gaps. Unit-tested + validated against kind (instrument→Injected, idempotent re-apply, validation errors). |
|
Claude finished @ianp94's task in 4m 47s —— View job Review:
|
…eneration (review #29) Two review fixes: - **ThreadTracker un-disableable (high):** AgentsSpec.ThreadTracker was a plain bool + omitempty + default=true, so --thread-tracker=false marshalled as unset and admission re-defaulted it to true — the flag could never disable it. Make it a *bool (nil = default on); the CLI sends an explicit pointer, injection reads nil-or-true. Verified live: --thread-tracker=false stores false, omitted stores true. Regenerated CRD/deepcopy + synced the chart's CRD copy. - **--wait stale-status race (medium):** waitForInjected now gates the terminal Injected/Error checks on status.observedGeneration >= metadata.generation, so a re-apply that changed the spec can't read the pre-update Injected status and return early. Also retry transient Get errors until the deadline instead of aborting the whole wait. Plus polish: client-side enum validation for --jvm-opts-var and --invariant-mode (clean CLI error vs a raw server CEL error), and clean -h/--help handling (flag.ErrHelp no longer prints as an error). Tests added for all. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JuGqspSB9zpA5AyvHJBiDK
|
Both real — fixed in `db2a7f4`. #1 #2 Minor items: added client-side enum validation for On the non-blocking notes: |
The first slice of the CLI to launch tests — a thin Go binary over the operator's CRDs, so instrumenting an app isn't hand-written YAML + kubectl. Scope:
instrumentonly (by design;run/status/dashboardare the next CLI PRs).What's here (
operator/cmd/closurejvm/)api/v1alpha1types + a controller-runtime client to apply real typedClosureJVMTargetCRs (not templated YAML).instrument: builds a target from flags (--deployment,--container,--jvm-opts-var,--coverage-includes/--coverage-port/--coverage-service,--invariant-mode/--latency-max-ms/--heap-delta-max-kb,--thread-tracker), applies create-or-update (idempotent re-apply), and with--waitblocks untilInjected, printing phase transitions + thecoverageEndpoint.--context/-n; namespace defaults to the context's.stdlib flag+ subcommand dispatch — no new module deps (client-go/clientcmd + controller-runtime client were already vendored).make -C operator cli→operator/bin/closurejvm.Tests + validation
buildTarget+validateInstrument(coverage on iff includes set; port default; the reject cases).Injected ✓with the coverage Service, idempotent re-apply, and both validation errors (--deploymentrequired;--coverage-serviceneeds--coverage-includes).docs/OPERATOR-USAGE.md§3 gains a CLI alternative to the target YAML.@claude please review — focus on: (1)
buildTargetcorrectness vs the CRD (coverage-enabled-iff-includes, the JVMOptsVar-empty-lets-CRD-default choice, ThreadTracker withomitempty); (2) the apply create-or-update +waitForInjectedloop (error/timeout/Error-phase handling); (3) kubeconfig/context/namespace resolution; (4) anything that should be validated client-side but isn't.🤖 Generated with Claude Code