zcatalyst-cli 1.26.1 → 1.26.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/appsail-utils.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { TAppSailDetails } from './util_modules/config/lib/appsail';
|
|
2
2
|
export declare function filterTargets(allTargets: Array<TAppSailDetails>): Array<TAppSailDetails>;
|
|
3
|
-
export declare function validateAppSail(targDetails: Array<TAppSailDetails
|
|
3
|
+
export declare function validateAppSail(targDetails: Array<TAppSailDetails>, resolveLocalRuntime?: boolean): [Promise<Array<TAppSailDetails>>, Record<string, string>];
|
package/lib/appsail-utils.js
CHANGED
|
@@ -24,6 +24,10 @@ const container_1 = require("./util_modules/container");
|
|
|
24
24
|
const image_1 = require("@zcatalyst/container-plugin/out/endpoints/image");
|
|
25
25
|
const fs_1 = require("./util_modules/fs");
|
|
26
26
|
const util_1 = require("util");
|
|
27
|
+
const node_1 = require("./fn-utils/lib/node");
|
|
28
|
+
const java_1 = require("./fn-utils/lib/java");
|
|
29
|
+
const ensure_python_1 = require("./init/dependencies/python/ensure-python");
|
|
30
|
+
const path_1 = require("path");
|
|
27
31
|
const OCI_IMAGE_INDEX_MEDIA_TYPES = [
|
|
28
32
|
'application/vnd.oci.image.index.v1+json',
|
|
29
33
|
'application/vnd.docker.distribution.manifest.list.v2+json'
|
|
@@ -98,158 +102,195 @@ function filterTargets(allTargets) {
|
|
|
98
102
|
}
|
|
99
103
|
return allTargets;
|
|
100
104
|
}
|
|
101
|
-
function validateAppSail(targDetails) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
105
|
+
function validateAppSail(targDetails, resolveLocalRuntime = true) {
|
|
106
|
+
let isSocket;
|
|
107
|
+
const binPathMap = {};
|
|
108
|
+
const getImageInfo = (target) => __awaiter(this, void 0, void 0, function* () {
|
|
109
|
+
switch (true) {
|
|
110
|
+
case target.source.startsWith(appsail_1.CONTAINER_IMAGE_PROTOCOLS.docker): {
|
|
111
|
+
const imgTag = target.source.replace(appsail_1.CONTAINER_IMAGE_PROTOCOLS.docker, '');
|
|
112
|
+
return (0, image_1.inspectImage)(imgTag);
|
|
113
|
+
}
|
|
114
|
+
case target.source.startsWith(appsail_1.CONTAINER_IMAGE_PROTOCOLS.dockerArchive): {
|
|
115
|
+
const imgTar = target.source.replace(appsail_1.CONTAINER_IMAGE_PROTOCOLS.dockerArchive, '');
|
|
116
|
+
const isFile = yield fs_1.ASYNC.fileExists(imgTar);
|
|
117
|
+
if (!isFile) {
|
|
118
|
+
throw new error_1.default('Invalid image tar path: ' + imgTar, { exit: 1 });
|
|
109
119
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
const manifestJsonStream = yield (0, image_1.getTarEntry)(imgTar, 'manifest.json');
|
|
120
|
-
const repositoriesStream = yield (0, image_1.getTarEntry)(imgTar, 'repositories');
|
|
121
|
-
const indexJsonStream = yield (0, image_1.getTarEntry)(imgTar, 'index.json');
|
|
122
|
-
if (!indexJsonStream) {
|
|
123
|
-
if (manifestJsonStream || repositoriesStream) {
|
|
124
|
-
throw new error_1.default('Legacy docker-archive format is not supported. Only OCI-compliant docker-archive formats (pure OCI or hybrid OCI) are supported.', { exit: 1 });
|
|
125
|
-
}
|
|
126
|
-
throw new error_1.default('Corrupted image tar :: required OCI metadata index.json not found in the tar', { exit: 1 });
|
|
127
|
-
}
|
|
128
|
-
const indexJson = yield fs_1.ASYNC.readStreamAsJSON(indexJsonStream);
|
|
129
|
-
if (indexJson.schemaVersion !== 2) {
|
|
130
|
-
throw new error_1.default('Corrupted image tar :: invalid index.json file. Unsupported schemaVersion', { exit: 1 });
|
|
120
|
+
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
121
|
+
var _a;
|
|
122
|
+
try {
|
|
123
|
+
const manifestJsonStream = yield (0, image_1.getTarEntry)(imgTar, 'manifest.json');
|
|
124
|
+
const repositoriesStream = yield (0, image_1.getTarEntry)(imgTar, 'repositories');
|
|
125
|
+
const indexJsonStream = yield (0, image_1.getTarEntry)(imgTar, 'index.json');
|
|
126
|
+
if (!indexJsonStream) {
|
|
127
|
+
if (manifestJsonStream || repositoriesStream) {
|
|
128
|
+
throw new error_1.default('Legacy docker-archive format is not supported. Only OCI-compliant docker-archive formats (pure OCI or hybrid OCI) are supported.', { exit: 1 });
|
|
131
129
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
});
|
|
145
|
-
if (!(imageDescriptor === null || imageDescriptor === void 0 ? void 0 : imageDescriptor.digest)) {
|
|
146
|
-
throw new error_1.default(`Corrupted image tar :: invalid ${sourceFile} file. Unable to identify image manifest`, { exit: 1 });
|
|
147
|
-
}
|
|
148
|
-
if (traversedDigests.has(imageDescriptor.digest)) {
|
|
149
|
-
throw new error_1.default(`Corrupted image tar :: circular descriptor reference found for digest ${imageDescriptor.digest}`, { exit: 1 });
|
|
150
|
-
}
|
|
151
|
-
if (!imageDescriptor.mediaType ||
|
|
152
|
-
OCI_IMAGE_MANIFEST_MEDIA_TYPES.includes(imageDescriptor.mediaType)) {
|
|
153
|
-
return getBlobPathFromDigest(imageDescriptor.digest, sourceFile);
|
|
154
|
-
}
|
|
155
|
-
traversedDigests.add(imageDescriptor.digest);
|
|
156
|
-
const nestedIndexPath = getBlobPathFromDigest(imageDescriptor.digest, sourceFile);
|
|
157
|
-
const nestedIndexStream = yield (0, image_1.getTarEntry)(imgTar, nestedIndexPath);
|
|
158
|
-
if (!nestedIndexStream) {
|
|
159
|
-
throw new error_1.default(`Corrupted image tar :: nested image index ${nestedIndexPath} not found in the tar`, { exit: 1 });
|
|
130
|
+
throw new error_1.default('Corrupted image tar :: required OCI metadata index.json not found in the tar', { exit: 1 });
|
|
131
|
+
}
|
|
132
|
+
const indexJson = yield fs_1.ASYNC.readStreamAsJSON(indexJsonStream);
|
|
133
|
+
if (indexJson.schemaVersion !== 2) {
|
|
134
|
+
throw new error_1.default('Corrupted image tar :: invalid index.json file. Unsupported schemaVersion', { exit: 1 });
|
|
135
|
+
}
|
|
136
|
+
const traversedDigests = new Set();
|
|
137
|
+
const resolveImageManifestPath = (manifestIndex, sourceFile) => __awaiter(this, void 0, void 0, function* () {
|
|
138
|
+
var _a;
|
|
139
|
+
const imageDescriptor = (_a = manifestIndex.manifests) === null || _a === void 0 ? void 0 : _a.find((manifest) => {
|
|
140
|
+
if (!(manifest === null || manifest === void 0 ? void 0 : manifest.digest)) {
|
|
141
|
+
return false;
|
|
160
142
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
throw new error_1.default(`Corrupted image tar :: invalid nested image index ${nestedIndexPath}. Unsupported schemaVersion`, { exit: 1 });
|
|
143
|
+
if (!manifest.mediaType) {
|
|
144
|
+
return true;
|
|
164
145
|
}
|
|
165
|
-
return
|
|
146
|
+
return (OCI_IMAGE_MANIFEST_MEDIA_TYPES.includes(manifest.mediaType) ||
|
|
147
|
+
OCI_IMAGE_INDEX_MEDIA_TYPES.includes(manifest.mediaType));
|
|
166
148
|
});
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
149
|
+
if (!(imageDescriptor === null || imageDescriptor === void 0 ? void 0 : imageDescriptor.digest)) {
|
|
150
|
+
throw new error_1.default(`Corrupted image tar :: invalid ${sourceFile} file. Unable to identify image manifest`, { exit: 1 });
|
|
151
|
+
}
|
|
152
|
+
if (traversedDigests.has(imageDescriptor.digest)) {
|
|
153
|
+
throw new error_1.default(`Corrupted image tar :: circular descriptor reference found for digest ${imageDescriptor.digest}`, { exit: 1 });
|
|
171
154
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
155
|
+
if (!imageDescriptor.mediaType ||
|
|
156
|
+
OCI_IMAGE_MANIFEST_MEDIA_TYPES.includes(imageDescriptor.mediaType)) {
|
|
157
|
+
return getBlobPathFromDigest(imageDescriptor.digest, sourceFile);
|
|
175
158
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
159
|
+
traversedDigests.add(imageDescriptor.digest);
|
|
160
|
+
const nestedIndexPath = getBlobPathFromDigest(imageDescriptor.digest, sourceFile);
|
|
161
|
+
const nestedIndexStream = yield (0, image_1.getTarEntry)(imgTar, nestedIndexPath);
|
|
162
|
+
if (!nestedIndexStream) {
|
|
163
|
+
throw new error_1.default(`Corrupted image tar :: nested image index ${nestedIndexPath} not found in the tar`, { exit: 1 });
|
|
179
164
|
}
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
throw new error_1.default(`Corrupted image tar :: config blob ${configBlobPath} not found in the tar`, { exit: 1 });
|
|
165
|
+
const nestedIndex = yield fs_1.ASYNC.readStreamAsJSON(nestedIndexStream);
|
|
166
|
+
if (nestedIndex.schemaVersion !== 2) {
|
|
167
|
+
throw new error_1.default(`Corrupted image tar :: invalid nested image index ${nestedIndexPath}. Unsupported schemaVersion`, { exit: 1 });
|
|
184
168
|
}
|
|
185
|
-
|
|
186
|
-
|
|
169
|
+
return resolveImageManifestPath(nestedIndex, nestedIndexPath);
|
|
170
|
+
});
|
|
171
|
+
const imageManifestPath = yield resolveImageManifestPath(indexJson, 'index.json');
|
|
172
|
+
const imageManifestStream = yield (0, image_1.getTarEntry)(imgTar, imageManifestPath);
|
|
173
|
+
if (!imageManifestStream) {
|
|
174
|
+
throw new error_1.default(`Corrupted image tar :: image manifest ${imageManifestPath} not found in the tar`, { exit: 1 });
|
|
187
175
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
: reject(error_1.default.getErrorInstance(er));
|
|
176
|
+
const imageManifest = yield fs_1.ASYNC.readStreamAsJSON(imageManifestStream);
|
|
177
|
+
if (imageManifest.schemaVersion !== 2) {
|
|
178
|
+
throw new error_1.default('Corrupted image tar :: invalid image manifest file. Unsupported schemaVersion', { exit: 1 });
|
|
192
179
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
throw new error_1.default('Unsupported image source: ' + target.source, { exit: 1 });
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
});
|
|
200
|
-
const _details = targDetails.map((targ) => __awaiter(this, void 0, void 0, function* () {
|
|
201
|
-
var _a, _b;
|
|
202
|
-
if (targ.validity.valid) {
|
|
203
|
-
if (targ.runtime === 'custom') {
|
|
204
|
-
if (isSocket === undefined) {
|
|
205
|
-
isSocket = yield (0, container_1.isSocketAccessible)(false);
|
|
206
|
-
}
|
|
207
|
-
if (isSocket === false) {
|
|
208
|
-
targ.validity = {
|
|
209
|
-
valid: false,
|
|
210
|
-
reason: 'ZCatalyst-CLI is unable to communicate with the Container runtime'
|
|
211
|
-
};
|
|
212
|
-
return targ;
|
|
213
|
-
}
|
|
214
|
-
try {
|
|
215
|
-
const imgInfo = (yield getImageInfo(targ));
|
|
216
|
-
const os = 'os' in imgInfo ? imgInfo.os : imgInfo.Os;
|
|
217
|
-
if ((os === null || os === void 0 ? void 0 : os.toLowerCase()) !== 'linux') {
|
|
218
|
-
targ.validity = {
|
|
219
|
-
valid: false,
|
|
220
|
-
reason: 'container image should be Linux based'
|
|
221
|
-
};
|
|
222
|
-
return targ;
|
|
180
|
+
const configDigest = (_a = imageManifest.config) === null || _a === void 0 ? void 0 : _a.digest;
|
|
181
|
+
if (!configDigest) {
|
|
182
|
+
throw new error_1.default('Corrupted image tar :: invalid image manifest file. Unable to identify the config blob', { exit: 1 });
|
|
223
183
|
}
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
targ.validity = {
|
|
229
|
-
valid: false,
|
|
230
|
-
reason: 'container image should be amd64 based'
|
|
231
|
-
};
|
|
232
|
-
return targ;
|
|
184
|
+
const configBlobPath = getBlobPathFromDigest(configDigest, imageManifestPath);
|
|
185
|
+
const configFileStream = yield (0, image_1.getTarEntry)(imgTar, configBlobPath);
|
|
186
|
+
if (!configFileStream) {
|
|
187
|
+
throw new error_1.default(`Corrupted image tar :: config blob ${configBlobPath} not found in the tar`, { exit: 1 });
|
|
233
188
|
}
|
|
189
|
+
const configFile = yield fs_1.ASYNC.readStreamAsJSON(configFileStream);
|
|
190
|
+
resolve(configFile);
|
|
234
191
|
}
|
|
235
192
|
catch (er) {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
};
|
|
193
|
+
er instanceof error_1.default
|
|
194
|
+
? reject(er)
|
|
195
|
+
: reject(error_1.default.getErrorInstance(er));
|
|
240
196
|
}
|
|
197
|
+
}));
|
|
198
|
+
}
|
|
199
|
+
default: {
|
|
200
|
+
throw new error_1.default('Unsupported image source: ' + target.source, { exit: 1 });
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
const _details = targDetails.map((targ) => __awaiter(this, void 0, void 0, function* () {
|
|
205
|
+
var _a, _b, _c;
|
|
206
|
+
if (!targ.validity.valid) {
|
|
207
|
+
return targ;
|
|
208
|
+
}
|
|
209
|
+
if (targ.runtime === 'custom') {
|
|
210
|
+
if (isSocket === undefined) {
|
|
211
|
+
isSocket = yield (0, container_1.isSocketAccessible)(false);
|
|
212
|
+
}
|
|
213
|
+
if (isSocket === false) {
|
|
214
|
+
targ.validity = {
|
|
215
|
+
valid: false,
|
|
216
|
+
reason: 'ZCatalyst-CLI is unable to communicate with the Container runtime'
|
|
217
|
+
};
|
|
218
|
+
return targ;
|
|
219
|
+
}
|
|
220
|
+
try {
|
|
221
|
+
const imgInfo = (yield getImageInfo(targ));
|
|
222
|
+
const os = 'os' in imgInfo ? imgInfo.os : imgInfo.Os;
|
|
223
|
+
if ((os === null || os === void 0 ? void 0 : os.toLowerCase()) !== 'linux') {
|
|
224
|
+
targ.validity = {
|
|
225
|
+
valid: false,
|
|
226
|
+
reason: 'container image should be Linux based'
|
|
227
|
+
};
|
|
241
228
|
return targ;
|
|
242
229
|
}
|
|
243
|
-
|
|
230
|
+
const arch = 'architecture' in imgInfo
|
|
231
|
+
? imgInfo.architecture
|
|
232
|
+
: imgInfo.Architecture;
|
|
233
|
+
if ((arch === null || arch === void 0 ? void 0 : arch.toLowerCase()) !== 'amd64') {
|
|
244
234
|
targ.validity = {
|
|
245
235
|
valid: false,
|
|
246
|
-
reason: '
|
|
236
|
+
reason: 'container image should be amd64 based'
|
|
247
237
|
};
|
|
248
238
|
return targ;
|
|
249
239
|
}
|
|
250
240
|
}
|
|
241
|
+
catch (er) {
|
|
242
|
+
targ.validity = {
|
|
243
|
+
valid: false,
|
|
244
|
+
reason: er instanceof error_1.default ? er.message : (0, util_1.inspect)(er)
|
|
245
|
+
};
|
|
246
|
+
}
|
|
251
247
|
return targ;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
|
|
248
|
+
}
|
|
249
|
+
try {
|
|
250
|
+
const stack = (_a = targ.config) === null || _a === void 0 ? void 0 : _a.stack;
|
|
251
|
+
if (!stack) {
|
|
252
|
+
throw new error_1.default(`Stack is not defined for AppSail target ${targ.name}`, {
|
|
253
|
+
exit: 2
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
if (((_b = targ.config) === null || _b === void 0 ? void 0 : _b.platform) !== 'war' && !((_c = targ.config) === null || _c === void 0 ? void 0 : _c.command)) {
|
|
257
|
+
throw new error_1.default(`Start-up command missing for AppSail target ${targ.name}`, {
|
|
258
|
+
exit: 2
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
if (resolveLocalRuntime === false) {
|
|
262
|
+
return targ;
|
|
263
|
+
}
|
|
264
|
+
if (binPathMap[stack]) {
|
|
265
|
+
return targ;
|
|
266
|
+
}
|
|
267
|
+
switch (true) {
|
|
268
|
+
case stack.startsWith('node'): {
|
|
269
|
+
binPathMap[stack] = yield (0, node_1.ensureNodeVersion)(stack, true);
|
|
270
|
+
break;
|
|
271
|
+
}
|
|
272
|
+
case stack.startsWith('java'): {
|
|
273
|
+
const javaBinPath = yield (0, java_1.ensureJava)(stack);
|
|
274
|
+
if (!javaBinPath) {
|
|
275
|
+
throw new error_1.default(`Invalid bin path for ${stack}`, { exit: 1 });
|
|
276
|
+
}
|
|
277
|
+
binPathMap[stack] = javaBinPath;
|
|
278
|
+
break;
|
|
279
|
+
}
|
|
280
|
+
case stack.startsWith('python'): {
|
|
281
|
+
const stackVersion = stack.replace('python_', '');
|
|
282
|
+
const pyExe = yield (0, ensure_python_1.ensurePython)(stackVersion.replace('_', '.'), false, true);
|
|
283
|
+
binPathMap[stack] = (0, path_1.dirname)(pyExe);
|
|
284
|
+
break;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
catch (err) {
|
|
289
|
+
const error = error_1.default.getErrorInstance(err);
|
|
290
|
+
targ.validity.valid = false;
|
|
291
|
+
targ.validity.reason = error.message;
|
|
292
|
+
}
|
|
293
|
+
return targ;
|
|
294
|
+
}));
|
|
295
|
+
return [Promise.all(_details), binPathMap];
|
|
255
296
|
}
|
|
@@ -43,7 +43,8 @@ exports.default = (...args_1) => __awaiter(void 0, [...args_1], void 0, function
|
|
|
43
43
|
throw new error_1.default('No targets found');
|
|
44
44
|
}
|
|
45
45
|
const filtered = (0, appsail_utils_1.filterTargets)(targets);
|
|
46
|
-
const
|
|
46
|
+
const [_validatePromise] = (0, appsail_utils_1.validateAppSail)(filtered, false);
|
|
47
|
+
const validTargets = (yield _validatePromise).filter((targ) => {
|
|
47
48
|
if (targ.validity.valid) {
|
|
48
49
|
return targ;
|
|
49
50
|
}
|
|
@@ -12,12 +12,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const path_1 = require("path");
|
|
16
15
|
const appsail_utils_1 = require("../../appsail-utils");
|
|
17
16
|
const error_1 = __importDefault(require("../../error"));
|
|
18
|
-
const java_1 = require("../../fn-utils/lib/java");
|
|
19
|
-
const node_1 = require("../../fn-utils/lib/node");
|
|
20
|
-
const ensure_python_1 = require("../../init/dependencies/python/ensure-python");
|
|
21
17
|
const port_resolver_1 = __importDefault(require("../../port-resolver"));
|
|
22
18
|
const runtime_store_1 = __importDefault(require("../../runtime-store"));
|
|
23
19
|
const config_1 = require("../../util_modules/config");
|
|
@@ -30,47 +26,8 @@ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
30
26
|
(0, index_1.debug)('AppSail targets are empty');
|
|
31
27
|
return [];
|
|
32
28
|
}
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
yield Promise.all(validated.map((target) => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
-
var _a;
|
|
37
|
-
try {
|
|
38
|
-
const stack = (_a = target.config) === null || _a === void 0 ? void 0 : _a.stack;
|
|
39
|
-
if (!stack) {
|
|
40
|
-
throw new error_1.default(`Stack is not defined for AppSail target ${target.name}`, {
|
|
41
|
-
exit: 2
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
if (binPathMap[stack]) {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
switch (true) {
|
|
48
|
-
case stack.startsWith('node'): {
|
|
49
|
-
binPathMap[stack] = yield (0, node_1.ensureNodeVersion)(stack, true);
|
|
50
|
-
break;
|
|
51
|
-
}
|
|
52
|
-
case stack.startsWith('java'): {
|
|
53
|
-
const javaBinPath = yield (0, java_1.ensureJava)(stack);
|
|
54
|
-
if (!javaBinPath) {
|
|
55
|
-
throw new error_1.default(`Invalid bin path for ${stack}`, { exit: 1 });
|
|
56
|
-
}
|
|
57
|
-
binPathMap[stack] = javaBinPath;
|
|
58
|
-
break;
|
|
59
|
-
}
|
|
60
|
-
case stack.startsWith('python'): {
|
|
61
|
-
const stackVersion = stack.replace('python_', '');
|
|
62
|
-
const pyExe = yield (0, ensure_python_1.ensurePython)(stackVersion.replace('_', '.'), false, true);
|
|
63
|
-
binPathMap[stack] = (0, path_1.dirname)(pyExe);
|
|
64
|
-
break;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
catch (err) {
|
|
69
|
-
const error = error_1.default.getErrorInstance(err);
|
|
70
|
-
target.validity.valid = false;
|
|
71
|
-
target.validity.reason = error.message;
|
|
72
|
-
}
|
|
73
|
-
})));
|
|
29
|
+
const [_validatePromise, binPathMap] = (0, appsail_utils_1.validateAppSail)(optionTargets);
|
|
30
|
+
const validated = yield _validatePromise;
|
|
74
31
|
const filledTargets = yield Promise.all(validated.map((targ) => __awaiter(void 0, void 0, void 0, function* () {
|
|
75
32
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
76
33
|
if (!targ.validity.valid) {
|
|
@@ -27,7 +27,7 @@ exports.CONTAINER_IMAGE_PROTOCOLS = {
|
|
|
27
27
|
docker: 'docker://',
|
|
28
28
|
dockerArchive: 'docker-archive://'
|
|
29
29
|
};
|
|
30
|
-
function
|
|
30
|
+
function validateManagedAppConfig(source, configJson) {
|
|
31
31
|
if (!configJson) {
|
|
32
32
|
return {
|
|
33
33
|
valid: false,
|
|
@@ -73,6 +73,19 @@ function validateConfig(source, configJson) {
|
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
+
if (!configJson.stack || configJson.stack.length === 0) {
|
|
77
|
+
return {
|
|
78
|
+
valid: false,
|
|
79
|
+
reason: 'Stack is not defined'
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
if (!configJson.command &&
|
|
83
|
+
!(configJson.stack.startsWith('java') && configJson.platform === 'war')) {
|
|
84
|
+
return {
|
|
85
|
+
valid: false,
|
|
86
|
+
reason: 'Start-up command is missing'
|
|
87
|
+
};
|
|
88
|
+
}
|
|
76
89
|
return {
|
|
77
90
|
valid: true
|
|
78
91
|
};
|
|
@@ -177,7 +190,7 @@ function getAllTargetDetails() {
|
|
|
177
190
|
try {
|
|
178
191
|
const configJson = yield fs_1.ASYNC.readJSONFile(catalystConfigPth);
|
|
179
192
|
configJson && (configJson.raw = {});
|
|
180
|
-
target.validity =
|
|
193
|
+
target.validity = validateManagedAppConfig(target.source, configJson);
|
|
181
194
|
target.config = configJson;
|
|
182
195
|
return res(target);
|
|
183
196
|
}
|