Add suspend/resume button for CronJobs (#1860)

Signed-off-by: vshakirova <vshakirova@mirantis.com>
This commit is contained in:
Violetta authored and GitHub committed 2020-12-29 17:19:23 +02:00
1 parent b7d97e6b5b
commit fd63f2f4e3
3 files changed
+85 -7

No files matched your search

+1 -1
View File
@@ -18,7 +18,7 @@ export class ApiManager {
}
getApiByKind(kind: string, apiVersion: string) {
return Array.from(this.apis.values()).find((api) => api.kind === kind && api.apiVersion === apiVersion);
return Array.from(this.apis.values()).find((api) => api.kind === kind && api.apiVersionWithGroup === apiVersion);
}
registerApi(apiBase: string, api: KubeApi) {
+37 -1
View File
@@ -5,6 +5,38 @@ import { formatDuration } from "../../utils/formatDuration";
import { autobind } from "../../utils";
import { KubeApi } from "../kube-api";
export class CronJobApi extends KubeApi<CronJob> {
suspend(params: { namespace: string; name: string }) {
return this.request.patch(this.getUrl(params), {
data: {
spec: {
suspend: true
}
}
},
{
headers: {
"content-type": "application/strategic-merge-patch+json"
}
});
}
resume(params: { namespace: string; name: string }) {
return this.request.patch(this.getUrl(params), {
data: {
spec: {
suspend: false
}
}
},
{
headers: {
"content-type": "application/strategic-merge-patch+json"
}
});
}
}
@autobind()
export class CronJob extends KubeObject {
static kind = "CronJob";
@@ -90,8 +122,12 @@ export class CronJob extends KubeObject {
return day > daysInMonth[month - 1];
}
isSuspend() {
return this.spec.suspend;
}
}
export const cronJobApi = new KubeApi({
export const cronJobApi = new CronJobApi({
objectConstructor: CronJob,
});