feat(ssh): add --instance option to target a running instance by ID - #1123
Conversation
5898785 to
ff49a42
Compare
davlgd
left a comment
There was a problem hiding this comment.
Thanks for this! Just a nitpick here
| }), | ||
| instance: defineOption({ | ||
| name: 'instance', | ||
| schema: z.string().optional(), |
There was a problem hiding this comment.
z.string() accepts the empty string, so a missing value reaches the handler and reports Instance is not a running instance of this application, with a gap where the ID should be. It happens with --instance alone, and with --instance --command "hostname", where the flag takes no value and the command still runs.
| schema: z.string().optional(), | |
| schema: z.string().min(1).optional(), |
Both are then rejected at parse time instead. if (instance != null) stays as it is: cliparse passes null when the option is absent, and the loose check already covers that.
There was a problem hiding this comment.
Good catch, thanks! Pushed z.string().min(1).optional() so an empty --instance fails at parse time.
With several instances running, `clever ssh` could only pick one through an interactive prompt and failed in non-interactive mode, so scripts had no way to reach a given instance. Selection uses the instance ID because instance numbers change across deployments. Selecting by number, `any` or `all`, as suggested in CleverCloud#1067, is left for a follow-up.
ff74ffe to
764b5b0
Compare
|
Thanks a lot @mehdi653 for this contribution! To keep the history clean before merging, we squashed your commits into a single one and reworked the commit message wording (you're still the author). We also replaced |
Summary
When several instances are running, clever ssh currently requires an interactive prompt and fails in non-interactive mode. This adds --instance instance-id so users and scripts can target a specific running instance without a prompt.
Instance IDs are used rather than instance numbers, which are not stable across deployments (per hsablonniere feedback on #1067). Support for number / any / all selection is left for a follow-up (judu).
Refs #1067
Change
Spec notes
Test plan
E2E results (2026-08-13)
Tested against a real Clever Cloud Node app with the local CLI from this PR checkout (HOME/.local/bin clever, which exposes --instance).
App: ssh-instance-e2e-1123 (app_99596987-df36-4925-8bab-26f50b2e1ba5), scaled to 2 instances, dedicated ed25519 key registered on the account.
-> OK, exit 0, no prompt
-> clear error: Instance bogus is not a running instance of this application, exit 1
-> OK, exit 0
-> clear error: Multiple instances are running. Cannot select in non-interactive mode., exit 1
Also: validate passed on 5898785 (lint, prettier, typecheck, docs:check). Working tree clean; no docs rewrite and no force-push needed.
Test app and temporary SSH key were deleted after the run.