Skip to content

Commit

Permalink
feat(client): expose restartThreshold via StarshipContext (#577)
Browse files Browse the repository at this point in the history
- allow api consumers to specify restartThreshold > 3

Co-authored-by: Anmol <[email protected]>
  • Loading branch information
0xpatrickdev and Anmol1696 authored Oct 31, 2024
1 parent 027a459 commit afaef4e
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions clients/js/packages/client/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export interface StarshipContext {
verbose?: boolean;
curdir?: string;
timeout?: string;
restartThreshold?: number;
}

export const defaultStarshipContext: Partial<StarshipContext> = {
Expand All @@ -32,7 +33,8 @@ export const defaultStarshipContext: Partial<StarshipContext> = {
chart: 'starship/devnet',
namespace: '',
version: '',
timeout: '10m'
timeout: '10m',
restartThreshold: 3
};

export interface PodPorts {
Expand Down Expand Up @@ -128,9 +130,6 @@ 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 = 3;

constructor(ctx: StarshipContext) {
this.ctx = deepmerge(defaultStarshipContext, ctx);
// TODO add semver check against net
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit afaef4e

Please sign in to comment.