Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
protected makeContextConfig(
job: JobConfig,
assetDir: string = process.cwd()
): ExecutionContextConfig {
const assetIds = job.assets ? [...job.assets, '.'] : ['.'];
const resolvedAssetDir = resolveAssetDir(assetDir);
this.context.sysconfig.teraslice.assets_directory = resolvedAssetDir;
job.assets = assetIds;
const jobValidator = new JobValidator(this.context);
const executionConfig = jobValidator.validateConfig(job) as ExecutionConfig;
return {
context: this.context,
executionConfig,
assetIds
};
}
}
async function validateJob(context, jobSpec) {
const jobValidator = new JobValidator(context, {
terasliceOpPath,
assetPath: get(context, 'sysconfig.teraslice.assets_directory'),
});
try {
return await jobValidator.validateConfig(jobSpec);
} catch (error) {
throw new Error(`validating job: ${error}`);
}
}
module.exports = function jobsService(context) {
let executionService;
let exStore;
let jobStore;
const logger = makeLogger(context, 'jobs_service');
const jobValidator = new JobValidator(context, {
terasliceOpPath,
assetPath: get(context, 'sysconfig.teraslice.assets_directory'),
});
/**
* Validate the job spec
*
* @returns {Promise}
*/
async function _validateJobSpec(jobSpec) {
const parsedAssetJob = await _ensureAssets(cloneDeep(jobSpec));
const validJob = await jobValidator.validateConfig(parsedAssetJob);
return validJob;
}
async function submitJob(jobSpec, shouldRun) {