Repository navigation
Make sdtab.T work with interfaces again, and stretch to terminal width - #2
scott-cotton wants to merge 2 commits into
Conversation
Using interface, we can avoid copying the struct at the call-site, and more easily make adaptors for different types just by wrapping them. At the definition site, it is slightly more verbose but at the call site of AddRow, it is less verbose. This PR however keeps the pure struct tag based approach. Also, modified the calculation of table widths to stretch to terminal width.
I don't think we need to worry about that in a CLI. I wouldn't mind if there's a way to avoid copying without adding more concepts to the package, but I don't think it's worth adding things for the sake for performance in this context.
If the goal is to make the AddRow call site less verbose, we could just break out a subroutine like this: func newTableRow(sbinfo *models.SandboxInfo, status string) tableRow {
return tableRow{
Name: sbinfo.Name,
Description: sbinfo.Description,
Cluster: sbinfo.ClusterName,
Created: sbinfo.CreatedAt,
Status: status,
}
}That achieves a similar effect without having to add new concepts (custom column adapters) to the sdtab package.
Personally, I wouldn't want that to happen. In my experience with other CLIs like kubectl, it's common for some tables to be naturally narrow and I think they would be harder to read if they're stretched. |
|
Closing this, please reopen if this work is continued. |
## What Extends `signadot logs` with a **sandbox** log source, over the sandbox-scoped endpoint added in signadot/signadot#7229 (ENG-1110). Previously `logs` only served jobs. ``` signadot logs --sandbox <sb> --workload <fork> [-c <container>] [--since 10m | --since-time <rfc3339>] [-o json|yaml] signadot logs --sandbox <sb> --resource <name> [--step <step>] [...] ``` ## Flags - `--sandbox` — sandbox name (no short form; `-s` is `--stream`). - `--workload` — sandboxed workload (fork) name. Mutually exclusive with `--resource`. - `--resource` [`--step`] — sandbox resource; `--step` selects one plugin step (resource-only). - `-c/--container` — defaults to all containers. - `--since` (relative duration, converted client-side) / `--since-time` (RFC3339). - `-o json|yaml` — structured `[]ContainerLogs`; default prints raw lines, `[container]`-prefixed when there is more than one source. - `--job`/`--sandbox` mutually exclusive; `--stream` is job-only (both enforced). The job path is unchanged/backward-compatible. ## Dependency note Pins `go-sdk` to the pre-merge revision that carries `Sandboxes.GetSandboxLogs` (pushed branch `davido/eng-1111-sandbox-logs-client`). The go-sdk is auto-generated from the monorepo spec, so once #7229 merges and the SDK regenerates, re-pin to that official revision. (ENG-1112 is blocked-by ENG-1111.) ## Testing Built the binary and ran it against a local minikube control plane + operator with the endpoint deployed, over real fork and resource sandboxes: | # | Case | Result | |---|------|--------| | 1 | `--workload logger` | fork pod log lines | | 2 | `--since 6s` | only recent lines | | 3 | `--since-time <future>` | empty | | 4 | `-o yaml` / `-o json` | structured output | | 5 | `--resource prres` | all steps, `[main]`-prefixed | | 6 | `--resource prres --step step2` | only that step | | 7-9 | unknown workload / resource / step | `400` surfaced with the available list | | 10 | `--workload` + `--resource` | client-side error | | 11 | `--step` without `--resource` | client-side error | | 12 | neither `--workload` nor `--resource` | client-side error | | 13 | `--job` + `--sandbox` | mutually-exclusive error | | 14 | `--stream` + `--sandbox` | mutually-exclusive error | | 15 | `--job <missing>` (job path) | still routes (404 from API) | ## Examples (run against a local cluster) Point the CLI at your API (`SIGNADOT_API_URL` / `SIGNADOT_ORG` / `SIGNADOT_API_KEY`, or `~/.signadot/config.yaml`), then: ```console $ signadot logs --sandbox demo-fork --workload web web request handled #0 web request handled #1 web request handled #2 # only recent lines (relative duration, converted to sinceTime client-side) $ signadot logs --sandbox demo-fork --workload web --since 6s web request handled #358 web request handled #359 web request handled #360 # --since (relative duration) and --since-time (absolute RFC3339) select the # same window; they are mutually exclusive. $ signadot logs --sandbox demo-fork --workload web --since 10s web request handled #470 web request handled #471 web request handled #472 web request handled #473 web request handled #474 $ signadot logs --sandbox demo-fork --workload web --since-time 2026-07-14T22:58:59Z web request handled #470 web request handled #471 web request handled #472 web request handled #473 web request handled #474 $ signadot logs --sandbox demo-fork --workload web --since 10s --since-time 2026-07-14T22:58:59Z Error: --since and --since-time are mutually exclusive # structured output $ signadot logs --sandbox demo-fork --workload web -o json [ { "container": "busybox", "logs": [ { "message": "web request handled #0", "time": "2026-07-14T22:43:19.481195046Z" }, ... ] } ] # resource logs — all create steps (per-container prefix when >1 source) $ signadot logs --sandbox demo-res --resource db [main] provision: creating demo resource [signadot-execunit-output-manager] {"level":"INFO","msg":"storing output in ICS","output":"out","key":"out.provision"} [main] seed: loading fixtures [signadot-execunit-output-manager] {"level":"INFO","msg":"storing output in ICS","output":"out","key":"out.seed"} # a single resource step $ signadot logs --sandbox demo-res --resource db --step provision [main] provision: creating demo resource $ signadot logs --sandbox demo-res --resource db --step seed [main] seed: loading fixtures # a specific container $ signadot logs --sandbox demo-fork --workload web -c busybox # error / validation behavior $ signadot logs --sandbox demo-fork --workload nope Error: 400 Bad Request: workload "nope" not found in sandbox "demo-fork"; loggable workloads: web $ signadot logs --sandbox demo-res --resource db --step bogus Error: 400 Bad Request: step "bogus" not found in resource "db"; steps: provision, seed $ signadot logs --sandbox demo-fork --workload web --job x Error: if any flags in the group [job sandbox] are set none of the others can be; [job sandbox] were all set ``` The job path is unchanged: `signadot logs --job <job> [--stream stdout|stderr] [--tail N]`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Using interface, we can avoid copying the struct at the call-site,
and more easily make adaptors for different types just by wrapping them.
At the definition site, it is slightly more verbose but at the call site
of AddRow, it is less verbose.
This PR however keeps the pure struct tag based approach.
Also, modified the calculation of table widths to stretch to terminal
width.