(app, options)
| 107 | }; |
| 108 | |
| 109 | const create = async function (app, options) { |
| 110 | const destinationDir = destDir(app); |
| 111 | |
| 112 | let transformK8sConfigs = function () { |
| 113 | return new Promise((resolve, reject) => { |
| 114 | let kubernetesTargetDir = destinationDir + '/kubernetes'; |
| 115 | let kubeConfSCCWorker = getSCCWorkerDeploymentDefPath( |
| 116 | kubernetesTargetDir, |
| 117 | ); |
| 118 | try { |
| 119 | let kubeConfContentSCCWorker = fs.readFileSync(kubeConfSCCWorker, { |
| 120 | encoding: 'utf8', |
| 121 | }); |
| 122 | let deploymentConfSCCWorker = YAML.parse(kubeConfContentSCCWorker); |
| 123 | |
| 124 | deploymentConfSCCWorker.spec.template.spec.volumes = [ |
| 125 | { |
| 126 | name: 'app-src-volume', |
| 127 | emptyDir: {}, |
| 128 | }, |
| 129 | ]; |
| 130 | |
| 131 | let containers = deploymentConfSCCWorker.spec.template.spec.containers; |
| 132 | let templateSpec = deploymentConfSCCWorker.spec.template.spec; |
| 133 | |
| 134 | if (!templateSpec.initContainers) { |
| 135 | templateSpec.initContainers = []; |
| 136 | } |
| 137 | let initContainers = templateSpec.initContainers; |
| 138 | let appSrcContainerIndex; |
| 139 | containers.forEach((value, index) => { |
| 140 | if (value && value.name == 'scc-worker') { |
| 141 | appSrcContainerIndex = index; |
| 142 | return; |
| 143 | } |
| 144 | }); |
| 145 | if (!containers[appSrcContainerIndex].volumeMounts) { |
| 146 | containers[appSrcContainerIndex].volumeMounts = []; |
| 147 | } |
| 148 | containers[appSrcContainerIndex].volumeMounts.push({ |
| 149 | mountPath: '/usr/src/app', |
| 150 | name: 'app-src-volume', |
| 151 | }); |
| 152 | initContainers.push({ |
| 153 | name: 'app-src-container', |
| 154 | image: '', // image name will be generated during deployment |
| 155 | volumeMounts: [ |
| 156 | { |
| 157 | mountPath: '/usr/dest', |
| 158 | name: 'app-src-volume', |
| 159 | }, |
| 160 | ], |
| 161 | command: ['cp', '-a', '/usr/src/.', '/usr/dest/'], |
| 162 | }); |
| 163 | let formattedYAMLString = sanitizeYAML( |
| 164 | YAML.stringify(deploymentConfSCCWorker, Infinity, 2), |
| 165 | ); |
| 166 | fs.writeFileSync(kubeConfSCCWorker, formattedYAMLString); |
nothing calls this directly
no test coverage detected
searching dependent graphs…