Skip to content

feat: add manage:list-backends command with cleanup verdicts - #111

Merged
jirkasemmler merged 4 commits into
mainfrom
jirka/manage-list-backends
Aug 12, 2026
Merged

feat: add manage:list-backends command with cleanup verdicts#111
jirkasemmler merged 4 commits into
mainfrom
jirka/manage-list-backends

Conversation

@jirkasemmler

Copy link
Copy Markdown
Contributor

Changes:

  • New manage:list-backends command — read-only inventory of a stack's storage backends with a cleanup verdict per backend (DELETE_UNSUPPORTED_UNUSED / DELETE_UNUSED / REVIEW_UNSUPPORTED_IN_USE / REVIEW_MAINTAINER_ONLY / KEEP). Prints comma-separated ID lists ready to paste into manage:delete-backend.
  • Fetches the detail of every backend (GET /manage/storage-backend/{id}) to add columns missing from the list response: loginType, keyRotated, dynBackends, useSso, ssoEnabled, ssoConfigured.
  • --format=table|csv (CSV keeps stdout parseable, summary goes to stderr), --verdict=X and --unsupported filters; summary is always computed over the whole stack.
  • Registered in cli.php, documented in README.

Used for the DMD-1638 prod backend cleanup — drove the inventory and keypair review of all 14 prod stacks.


Additional notes

⚠️ Don't forget to release new version after merge

🤖 Generated with Claude Code

@jirkasemmler
jirkasemmler marked this pull request as ready for review August 11, 2026 07:21
@jirkasemmler
jirkasemmler requested a balanced review from Copilot August 11, 2026 07:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds read-only backend inventory and cleanup verdicts for stack maintenance.

Changes:

  • Adds table/CSV backend reporting with filters and summaries.
  • Registers the new CLI command.
  • Documents usage, verdicts, and output fields.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/Keboola/Console/Command/ListStorageBackends.php Implements inventory and cleanup verdicts.
cli.php Registers the command.
README.md Documents command usage and behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/Keboola/Console/Command/ListStorageBackends.php
@jirkasemmler
jirkasemmler requested review from a team and romanbracinik and removed request for a team August 11, 2026 07:32
Comment thread src/Keboola/Console/Command/ListStorageBackends.php Outdated
$this->renderTable($output, $visibleRows);
}

$this->renderSummary($output, $rows, $format === self::FORMAT_CSV);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: renderSummary() receives the unfiltered $rows, so with --verdict/--unsupported the summary counts and the paste-ready "Delete candidates" ID lists ignore the filter — the table above shows filtered rows, but the ID list still covers all backends. Since this output is meant to be pasted into manage:delete-backend, an operator can end up deleting backends outside the scope they filtered for. Total backends: N also contradicts the number of rows shown. Pass $visibleRows to renderSummary() (or apply the same filter inside).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opraveno v e9d0fca — summary i paste-ready ID listy se počítají z viditelných (filtrovaných) řádků; při aktivním filtru hlavička říká Backends shown: X of Y (filters active — summary and ID lists cover the shown rows only). Regresní test testSummarizeOnFilteredRowsCoversOnlyThoseRows.

Comment thread src/Keboola/Console/Command/ListStorageBackends.php
Comment thread src/Keboola/Console/Command/ListStorageBackends.php Outdated
Comment thread src/Keboola/Console/Command/ListStorageBackends.php Outdated
Comment thread src/Keboola/Console/Command/ListStorageBackends.php Outdated
Comment thread src/Keboola/Console/Command/ListStorageBackends.php Outdated
Comment thread src/Keboola/Console/Command/ListStorageBackends.php Outdated
Comment thread src/Keboola/Console/Command/ListStorageBackends.php
Comment thread src/Keboola/Console/Command/ListStorageBackends.php
jirkasemmler and others added 4 commits August 12, 2026 08:25
Read-only inventory of a stack's storage backends. Fetches the detail of
every backend to include loginType, keyPairLastRotatedAt, SSO and dynamic
backend flags, assigns a cleanup verdict per backend and prints ID lists
ready for manage:delete-backend. Used for the DMD-1638 prod cleanup.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
A failed per-backend detail call previously degraded silently — the
detail-added columns (loginType, keyRotated, SSO, dynBackends) rendered
empty with no signal to the operator. Now the affected backend IDs are
printed as a stderr warning. Counts and verdicts are unaffected: they
come from the list response.

Also adds timeout/connect_timeout to the Guzzle client so one
unresponsive backend cannot hang the whole scan.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
… bugs

- Extract row/verdict/filter/summary logic into StorageBackendInventory
  (plain class, unit-tested — 24 new tests) so the command does I/O only.
- Fix: summary and paste-ready delete ID lists now cover the displayed
  (filtered) rows only; header shows 'Backends shown: X of Y'.
- Fix: --verdict is validated against the known verdicts instead of
  silently matching nothing.
- Fix: CSV output uses fputcsv and OUTPUT_RAW so cell values cannot be
  mangled by the console formatter.
- Skip list entries without a usable numeric id (stderr warning) instead
  of coercing them to id 0.
- Fetch detail only for displayed rows, with retry middleware
  (3 attempts, 429/5xx/connect) on the Guzzle client; declare
  guzzlehttp/guzzle as a direct dependency.

The raw Guzzle detail call stays for now: Client::getStorageBackend()
exists only since manage-api client v9 and this repo locks ^7 — bumping
to v10 raises repo-wide phpstan errors from 8 to 236 (typed signatures
across ~20 commands), which belongs in a separate PR.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Replaces the raw Guzzle detail workaround with the SDK method (added in
client v9) — the client brings its own exponential backoff, so the
custom retry middleware and HTTP plumbing are gone.

The typed v10 signatures surface 234 pre-existing phpstan findings in
legacy commands (offset access / casts on now-explicit mixed). Those are
captured in phpstan-baseline.neon so new code stays checked at level 9
while cleaning up 22 operator commands stays out of this PR's scope.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@jirkasemmler
jirkasemmler force-pushed the jirka/manage-list-backends branch from 50d8fec to 9497c67 Compare August 12, 2026 06:26
Comment thread phpstan-baseline.neon

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:eyes_bleeding:

@jirkasemmler
jirkasemmler merged commit c4ef6b4 into main Aug 12, 2026
1 check passed
@jirkasemmler
jirkasemmler deleted the jirka/manage-list-backends branch August 12, 2026 16:10
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.

3 participants