MCPcopy Index your code
hub / github.com/SocketCluster/socketcluster / create

Function create

bin/actions/create.js:109–212  ·  view source on GitHub ↗
(app, options)

Source from the content-addressed store, hash-verified

107};
108
109const 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);

Callers

nothing calls this directly

Calls 7

destDirFunction · 0.85
fileExistsSyncFunction · 0.85
confirmReplaceSetupFunction · 0.85
createSuccessFunction · 0.85
setupMessageFunction · 0.85
copyDirRecursiveFunction · 0.85
transformK8sConfigsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…