Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli): Fixes bug with command 'ps -x' (sudo) #3051

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions packages/cli/src/commands/ps/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,16 @@ function printExtended(dynos: DynoExtended[]) {
ID: {get: (dyno: DynoExtended) => dyno.id},
Process: {get: (dyno: DynoExtended) => dyno.name},
State: {get: (dyno: DynoExtended) => `${dyno.state} ${ago(new Date(dyno.updated_at))}`},
Region: {get: (dyno: DynoExtended) => dyno.extended ? dyno.extended.region : ''},
'Execution Plane': {get: (dyno: DynoExtended) => dyno.extended ? dyno.extended.execution_plane : ''},
Fleet: {get: (dyno: DynoExtended) => dyno.extended ? dyno.extended.fleet : ''},
Instance: {get: (dyno: DynoExtended) => dyno.extended ? dyno.extended.instance : ''},
IP: {get: (dyno: DynoExtended) => dyno.extended ? dyno.extended.ip : ''},
Port: {get: (dyno: DynoExtended) => dyno.extended ? dyno.extended.port.toString() : ''},
AZ: {get: (dyno: DynoExtended) => dyno.extended ? dyno.extended.az : ''},
Region: {get: (dyno: DynoExtended) => dyno.extended?.region ? dyno.extended.region : ''},
'Execution Plane': {get: (dyno: DynoExtended) => dyno.extended?.execution_plane ? dyno.extended.execution_plane : ''},
Fleet: {get: (dyno: DynoExtended) => dyno.extended?.fleet ? dyno.extended.fleet : ''},
Instance: {get: (dyno: DynoExtended) => dyno.extended?.instance ? dyno.extended.instance : ''},
IP: {get: (dyno: DynoExtended) => dyno.extended?.ip ? dyno.extended.ip : ''},
Port: {get: (dyno: DynoExtended) => dyno.extended?.port ? dyno.extended.port.toString() : ''},
AZ: {get: (dyno: DynoExtended) => dyno.extended?.az ? dyno.extended.az : ''},
Release: {get: (dyno: DynoExtended) => dyno.release.version},
Command: {get: (dyno: DynoExtended) => truncate(dyno.command)},
Route: {get: (dyno: DynoExtended) => dyno.extended ? dyno.extended.route : ''},
Route: {get: (dyno: DynoExtended) => dyno.extended?.route ? dyno.extended.route : ''},
Size: {get: (dyno: DynoExtended) => dyno.size},
},
{
Expand Down
16 changes: 8 additions & 8 deletions packages/cli/src/lib/types/dyno_extended.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ export interface DynoExtended extends Required<Dyno> {
* Extended information.
*/
extended?: {
az: string,
execution_plane: string,
fleet: string,
instance: string,
ip: string,
port: number,
region: string,
route: string,
az: string | null,
execution_plane: string | null,
fleet: string | null,
instance: string | null,
ip: string | null,
port: number | null,
region: string | null,
route: string | null,
}
}
64 changes: 64 additions & 0 deletions packages/cli/test/unit/commands/ps/index.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,70 @@ describe('ps', function () {
expect(stderr.output).to.equal('')
})

it('shows extended info for Private Space app', async function () {
const api = nock('https://api.heroku.com')
.get('/account')
.reply(200, {id: '1234'})
.get('/apps/myapp')
.reply(200, {name: 'myapp'})
.get('/apps/myapp/dynos?extended=true')
.reply(200, [{
id: '100',
command: 'npm start',
size: 'Eco',
name: 'web.1',
type: 'web',
updated_at: hourAgo,
state: 'up',
release: {id: '10', version: '40'},
extended: {
az: null,
execution_plane: null,
fleet: null,
instance: 'instance',
ip: '10.0.0.1',
port: null,
region: 'us',
route: null,
},
}, {
id: '101',
command: 'bash',
size: 'Eco',
name: 'run.1',
type: 'run',
updated_at: hourAgo,
state: 'up',
release: {id: '10', version: '40'},
extended: {
az: null,
execution_plane: null,
fleet: null,
instance: 'instance',
ip: '10.0.0.1',
port: null,
region: 'us',
route: null,
},
}])

await runCommand(Cmd, [
'--app',
'myapp',
'--extended',
])

api.done()

expect(heredoc(stdout.output)).to.equal(heredoc`
Id Process State Region Execution plane Fleet Instance Ip Port Az Release Command Route Size
─── ─────── ─────────────────────────────────────── ────── ─────────────── ───── ──────── ──────── ──── ── ─────── ───────── ───── ────
101 run.1 up ${hourAgoStr} (~ 1h ago) us instance 10.0.0.1 40 bash Eco
100 web.1 up ${hourAgoStr} (~ 1h ago) us instance 10.0.0.1 40 npm start Eco
`)
expect(stderr.output).to.equal('')
})

it('shows shield dynos in extended info if app is in a shielded private space', async function () {
const api = nock('https://api.heroku.com')
.get('/account')
Expand Down
Loading