17 lines
492 B
JavaScript
17 lines
492 B
JavaScript
|
import cp from "node:child_process";
|
||
|
import { jobBuilder, createFile, deleteFile } from "./k8s-common.js";
|
||
|
|
||
|
const applyFile = async (filePath) => {
|
||
|
const command = `${kubCmd} ${filePath}`;
|
||
|
return new Promise((res, rej) =>
|
||
|
cp.exec(command, (err, stdout, stderr) => (err && rej(err)) || res(stdout))
|
||
|
);
|
||
|
};
|
||
|
|
||
|
export default async function createJob(jobRequest) {
|
||
|
const job = jobBuilder(jobRequest);
|
||
|
const filePath = createFile(job);
|
||
|
applyFile(filePath);
|
||
|
deleteFile(filePath);
|
||
|
}
|