Add getStatus to CronJob

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton committed 2023-03-09 14:58:30 -05:00
1 parent 01164ed732
commit 87cbfd1e39
1 file changed
+13
@@ -66,6 +66,11 @@ export interface CronJobStatus {
active?: ObjectReference[];
}
export enum CronJobStatusPhase {
SUSPENDED = "Suspended",
SCHEDULED = "Scheduled",
}
export class CronJob extends KubeObject<
NamespaceScopedMetadata,
CronJobStatus,
@@ -90,6 +95,14 @@ export class CronJob extends KubeObject<
return this.spec.schedule;
}
getStatus() {
if (this.isSuspend()) {
return CronJobStatusPhase.SUSPENDED;
}
return CronJobStatusPhase.SCHEDULED;
}
isNeverRun() {
const schedule = this.getSchedule();
const daysInMonth = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];