Skip to content

Commit

Permalink
fix restart counts, print readyness and restart in cli
Browse files Browse the repository at this point in the history
  • Loading branch information
Anmol1696 committed Jun 17, 2024
1 parent cf04ae0 commit 11e81c3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion clients/js/packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"copy": "copyfiles -f ../../LICENSE README.md package.json dist",
"clean": "del dist/**",
"prepare": "npm run build",
"build": "npm run clean; tsc; tsc -p tsconfig.esm.json; npm run copy",
"build": "npm run clean; tsc; tsc -p tsconfig.esm.json; npm run copy; npm run chmod",
"chmod": "chmod +x dist/index.js",
"dev": "ts-node src/index",
"test": "jest",
"test:watch": "jest --watch"
Expand Down
8 changes: 4 additions & 4 deletions clients/js/packages/client/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export class StarshipClient implements StarshipClientI {
private podStatuses = new Map<string, PodStatus>(); // To keep track of pod statuses

// Define a constant for the restart threshold
private readonly RESTART_THRESHOLD = 5;
private readonly RESTART_THRESHOLD = 4;

constructor(ctx: StarshipContext) {
this.ctx = deepmerge(defaultStarshipContext, ctx);
Expand Down Expand Up @@ -380,9 +380,9 @@ export class StarshipClient implements StarshipClientI {
...this.getArgs(),
], false, true).trim();

const [phase, readyList, restartCount, reason] = result.split(/\s+/);
const [phase, readyList, restartCountList, reason] = result.split(/\s+/);
const ready = readyList.split(',').every(state => state === 'true');
const restarts = parseInt(restartCount, 10);
const restarts = restartCountList.split(',').reduce((acc, count) => acc + parseInt(count, 10), 0);

this.podStatuses.set(podName, { phase, ready, restartCount: restarts, reason });

Expand Down Expand Up @@ -426,7 +426,7 @@ export class StarshipClient implements StarshipClientI {
statusColor = chalk.red(status.phase);
}

console.log(`[${chalk.blue(podName)}]: ${statusColor}`);
console.log(`[${chalk.blue(podName)}]: ${statusColor}, ${chalk.gray(`Ready: ${status.ready}, Restarts: ${status.restartCount}`)}`);
});
}

Expand Down

0 comments on commit 11e81c3

Please sign in to comment.