Skip to content

list sandboxes using sdk and terminal aware table writer - #1

Merged
enisoc merged 1 commit into
mainfrom
listsb
May 5, 2022
Merged

enisoc merged 1 commit into
mainfrom
listsb

Conversation

@scott-cotton

Copy link
Copy Markdown
Member

example use of sdk with list sandboxes.

  • adds an auth package to help with using the sdk
  • adds sdtab terminal aware table.

@scott-cotton
scott-cotton requested a review from enisoc May 5, 2022 14:31
@enisoc
enisoc merged commit fbba351 into main May 5, 2022
@enisoc
enisoc deleted the listsb branch May 5, 2022 16:45
davixcky added a commit that referenced this pull request Jul 21, 2026
## 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]>
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.

2 participants