From afaef4e8a1a9bfb1856831a0b036aaa003944e34 Mon Sep 17 00:00:00 2001 From: 0xPatrick Date: Thu, 31 Oct 2024 05:12:28 -0400 Subject: [PATCH] feat(client): expose `restartThreshold` via `StarshipContext` (#577) - allow api consumers to specify restartThreshold > 3 Co-authored-by: Anmol --- clients/js/packages/client/src/client.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/clients/js/packages/client/src/client.ts b/clients/js/packages/client/src/client.ts index cc59bb37..60e9e44f 100644 --- a/clients/js/packages/client/src/client.ts +++ b/clients/js/packages/client/src/client.ts @@ -23,6 +23,7 @@ export interface StarshipContext { verbose?: boolean; curdir?: string; timeout?: string; + restartThreshold?: number; } export const defaultStarshipContext: Partial = { @@ -32,7 +33,8 @@ export const defaultStarshipContext: Partial = { chart: 'starship/devnet', namespace: '', version: '', - timeout: '10m' + timeout: '10m', + restartThreshold: 3 }; export interface PodPorts { @@ -128,9 +130,6 @@ export class StarshipClient implements StarshipClientI { private podStatuses = new Map(); // To keep track of pod statuses - // Define a constant for the restart threshold - private readonly RESTART_THRESHOLD = 3; - constructor(ctx: StarshipContext) { this.ctx = deepmerge(defaultStarshipContext, ctx); // TODO add semver check against net @@ -547,9 +546,9 @@ export class StarshipClient implements StarshipClientI { reason }); - if (restarts > this.RESTART_THRESHOLD) { + if (restarts > this.ctx.restartThreshold) { this.log( - `${chalk.red('Error:')} Pod ${podName} has restarted more than ${this.RESTART_THRESHOLD} times.` + `${chalk.red('Error:')} Pod ${podName} has restarted more than ${this.ctx.restartThreshold} times.` ); this.exit(1); }