Skip to content

Commit afaef4e

Browse files
feat(client): expose restartThreshold via StarshipContext (#577)
- allow api consumers to specify restartThreshold > 3 Co-authored-by: Anmol <anmol1696@gmail.com>
1 parent 027a459 commit afaef4e

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

clients/js/packages/client/src/client.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export interface StarshipContext {
2323
verbose?: boolean;
2424
curdir?: string;
2525
timeout?: string;
26+
restartThreshold?: number;
2627
}
2728

2829
export const defaultStarshipContext: Partial<StarshipContext> = {
@@ -32,7 +33,8 @@ export const defaultStarshipContext: Partial<StarshipContext> = {
3233
chart: 'starship/devnet',
3334
namespace: '',
3435
version: '',
35-
timeout: '10m'
36+
timeout: '10m',
37+
restartThreshold: 3
3638
};
3739

3840
export interface PodPorts {
@@ -128,9 +130,6 @@ export class StarshipClient implements StarshipClientI {
128130

129131
private podStatuses = new Map<string, PodStatus>(); // To keep track of pod statuses
130132

131-
// Define a constant for the restart threshold
132-
private readonly RESTART_THRESHOLD = 3;
133-
134133
constructor(ctx: StarshipContext) {
135134
this.ctx = deepmerge(defaultStarshipContext, ctx);
136135
// TODO add semver check against net
@@ -547,9 +546,9 @@ export class StarshipClient implements StarshipClientI {
547546
reason
548547
});
549548

550-
if (restarts > this.RESTART_THRESHOLD) {
549+
if (restarts > this.ctx.restartThreshold) {
551550
this.log(
552-
`${chalk.red('Error:')} Pod ${podName} has restarted more than ${this.RESTART_THRESHOLD} times.`
551+
`${chalk.red('Error:')} Pod ${podName} has restarted more than ${this.ctx.restartThreshold} times.`
553552
);
554553
this.exit(1);
555554
}

0 commit comments

Comments
 (0)