1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { ContainerRequestResource } from "./container-request";
6 import { MountType, MountKind } from 'models/mount-types';
7 import { WorkflowResource, parseWorkflowDefinition, getWorkflow, CwlSecrets } from 'models/workflow';
8 import { WorkflowInputsData } from './workflow';
10 export type ProcessResource = ContainerRequestResource;
12 export const MOUNT_PATH_CWL_WORKFLOW = '/var/lib/cwl/workflow.json';
13 export const MOUNT_PATH_CWL_INPUT = '/var/lib/cwl/cwl.input.json';
16 export const createWorkflowMounts = (workflow: WorkflowResource, inputs: WorkflowInputsData): { [path: string]: MountType } => {
18 const wfdef = parseWorkflowDefinition(workflow);
19 const mounts: {[path: string]: MountType} = {
21 kind: MountKind.COLLECTION,
25 kind: MountKind.MOUNTED_FILE,
26 path: '/var/spool/cwl/cwl.output.json',
28 '/var/lib/cwl/workflow.json': {
32 '/var/lib/cwl/cwl.input.json': {
41 export const createWorkflowSecretMounts = (workflow: WorkflowResource, inputs: WorkflowInputsData): { [path: string]: MountType } => {
43 const wfdef = parseWorkflowDefinition(workflow);
44 const secret_mounts: {[path: string]: MountType} = {};
46 const wf = getWorkflow(wfdef);
48 const secrets = wf.hints.find(item => item.class === 'http://commonwl.org/cwltool#Secrets') as CwlSecrets | undefined;
49 if (secrets?.secrets) {
51 secrets.secrets.forEach((paramId) => {
52 const param = paramId.split("/").pop();
53 if (!param || !inputs[param]) {
56 const value: string = inputs[param] as string;
57 const mnt = "/secrets/s"+secretCount;
58 secret_mounts[mnt] = {
59 "kind": MountKind.TEXT,
62 inputs[param] = {"$include": mnt}