From ebb6c246ca013a3f788a402365d3a7f43817c214 Mon Sep 17 00:00:00 2001 From: Olof Mattsson <14146601+omattsson@users.noreply.github.com> Date: Mon, 19 Oct 2026 08:15:55 +0200 Subject: [PATCH] feat(stack): stack follow/unfollow, preview, pods, recent (#154, #156) - stack follow and stack unfollow: get or stop the in-app notifications of a stack (POST and DELETE /api/v1/stack-instances/:id/follow). stack get shows Following and Followers when the server sends them. - stack preview: the merged Helm values that the next deploy uses (deploy-preview). YAML on stdout, one document for each chart; --chart gives plain YAML of one chart. The values-drift warning goes to stderr. -q lists the charts that changed since the last deploy. - stack pods: the live pods with READY (containers), RESTARTS, AGE and the container REASON, and the Warning events of the namespace (--all-events also shows Normal events). Event fields are sanitized. - stack recent: your 5 most recently updated stacks. - Tests: resetListFlags resets before the test too, and a stack list test no longer leaves --page Changed. go test -shuffle=on failed on main for some seeds. Closes #154 Closes #156 Co-Authored-By: Claude Opus 5.5 --- .github/copilot-instructions.md | 2 +- CLAUDE.md | 2 + README.md | 17 +- cli/cmd/paging_test.go | 7 +- cli/cmd/stack.go | 53 ++-- cli/cmd/stack_followers.go | 129 ++++++++++ cli/cmd/stack_inspect.go | 311 +++++++++++++++++++++++ cli/cmd/stack_inspect_test.go | 360 +++++++++++++++++++++++++++ cli/cmd/stack_test.go | 4 +- cli/pkg/client/client.go | 50 ++++ cli/pkg/client/stack_inspect_test.go | 64 +++++ cli/pkg/types/types.go | 30 +++ 12 files changed, 1002 insertions(+), 27 deletions(-) create mode 100644 cli/cmd/stack_followers.go create mode 100644 cli/cmd/stack_inspect.go create mode 100644 cli/cmd/stack_inspect_test.go create mode 100644 cli/pkg/client/stack_inspect_test.go diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 29bb69b..2782321 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -22,7 +22,7 @@ stackctl is a Go CLI tool (Cobra) for managing Kubernetes stack deployments. It | `config` | set, get, list, use-context, current-context, delete-context | config.go | | `login`/`logout`/`whoami` | top-level; supports password + OIDC loopback flow | login.go | | `auth` | register | login.go | -| `stack` | list, get, create, update, deploy, stop, clean, delete, status, logs, clone, extend, values, compare, history, rollback, history-values, watch | stack.go (TTL and stop-time helpers: ttl.go) | +| `stack` | list, get, create, update, deploy, stop, clean, delete, status, logs, clone, extend, values, compare, history, rollback, history-values, watch, preview, pods, recent, follow, unfollow | stack.go; preview/pods/recent: stack_inspect.go; follow/unfollow: stack_followers.go; TTL and stop-time helpers: ttl.go | | `template` | list, get, create, update, delete, clone, instantiate, quick-deploy, publish, unpublish, update-chart, versions (list, get, diff) | template.go | | `definition` | list, get, create, update, delete, export, import, update-chart | definition.go | | `override` | list, get, set, unset, delete, branch (list/set/delete), quota (get/set/delete) | override.go | diff --git a/CLAUDE.md b/CLAUDE.md index 91a0fa3..d218058 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -28,6 +28,8 @@ cli/ # Go module root (github.com/omattsson/stackctl/cl login.go # login, logout, whoami, auth register token.go # Token helpers (save/load/delete session, fresh token for plugins) stack.go # stack list/get/create/update/deploy/stop/clean/delete/status/logs/clone/extend/values/compare/history/rollback/history-values/watch + stack_inspect.go # stack preview/pods/recent (deploy-preview, live pods and events, recent) + stack_followers.go # stack follow/unfollow (in-app notifications; not the --follow log flag) ttl.go # --ttl/--stop-at/--until parsing, TTL limit check (GET /api/v1/ui-config, 30-day fallback), expiry text server.go # server info (ping, ui-config; public routes, no credentials) template.go # template list/get/create/update/clone/publish/unpublish/versions/instantiate/quick-deploy/delete diff --git a/README.md b/README.md index 6197b77..21c54c3 100644 --- a/README.md +++ b/README.md @@ -230,7 +230,17 @@ stackctl stack update my-app --ttl 0 # clear the expiry # Monitor stackctl stack status my-app +stackctl stack pods my-app # live pods, container reasons (CrashLoopBackOff) and Warning events stackctl stack logs my-app +stackctl stack recent # your 5 most recently updated stacks + +# Helm values that the next deploy uses (YAML on stdout, warnings on stderr) +stackctl stack preview my-app +stackctl stack preview my-app --chart backend > backend-values.yaml + +# Get the in-app notifications of a stack (not the --follow flag, which streams a log) +stackctl stack follow my-app +stackctl stack unfollow my-app stackctl stack watch --id 6a1d2c3b-4e5f-4a6b-8c7d-9e0f1a2b3c4d # watch uses --id, not a name argument # Lifecycle @@ -268,6 +278,8 @@ stackctl stack rollback my-app --target-log `--stop-at` (`stack create`, `clone`, `update`, `template quick-deploy`) sets a fixed stop time: the TTL becomes 0 and the stack stops at that time. `--stop-at` and `--until` accept RFC 3339 (`2026-10-17T18:00:00+02:00`) or a local time without a zone (`2026-10-17 18:00`). stackctl sends the time in UTC. `stack create --ttl 0` now sends 0 (no expiry); without `--ttl` the server applies its default TTL. `--ttl` and `--stop-at` together, a stop time in the past or a bad format are usage errors; stackctl sends no request. Before the request, stackctl also refuses a `--ttl`, a `--stop-at` or an `--until` above the TTL limit of the server (`max_instance_ttl_days` of `GET /api/v1/ui-config`; 30 days for an older server). `stack list` (column `EXPIRES`) and `stack get` show a fixed stop time as `stops at