@cloudflare/containers-shared 0.16.0
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/README.md +18 -0
- package/dist/index.d.mts +3843 -0
- package/dist/index.mjs +4967 -0
- package/dist/index.mjs.map +1 -0
- package/dist/metafile-esm.json +1 -0
- package/package.json +55 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,4967 @@
|
|
|
1
|
+
import { spawn, execFileSync, execFile } from 'node:child_process';
|
|
2
|
+
import crypto, { randomUUID } from 'node:crypto';
|
|
3
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { getDockerPath } from '@cloudflare/workers-utils/docker-path';
|
|
6
|
+
import { UserError, FatalError } from '@cloudflare/workers-utils/errors';
|
|
7
|
+
import { isDirectory } from '@cloudflare/workers-utils/fs-helpers';
|
|
8
|
+
import { COMPLIANCE_REGION_CONFIG_UNKNOWN, getComplianceRegionSubdomain } from '@cloudflare/workers-utils/compliance';
|
|
9
|
+
import { release } from 'node:os';
|
|
10
|
+
import assert from 'node:assert';
|
|
11
|
+
import { setTimeout } from 'node:timers/promises';
|
|
12
|
+
import { log, startSection, newline, endSection, updateStatus, success, shapes } from '@cloudflare/cli-shared-helpers';
|
|
13
|
+
import { green, red, dim, brandColor, bold } from '@cloudflare/cli-shared-helpers/colors';
|
|
14
|
+
import { formatConfigSnippet } from '@cloudflare/workers-utils';
|
|
15
|
+
import { spinner } from '@cloudflare/cli-shared-helpers/interactive';
|
|
16
|
+
|
|
17
|
+
var __defProp = Object.defineProperty;
|
|
18
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
19
|
+
|
|
20
|
+
// src/client/core/ApiError.ts
|
|
21
|
+
var ApiError = class extends Error {
|
|
22
|
+
static {
|
|
23
|
+
__name(this, "ApiError");
|
|
24
|
+
}
|
|
25
|
+
url;
|
|
26
|
+
status;
|
|
27
|
+
statusText;
|
|
28
|
+
body;
|
|
29
|
+
request;
|
|
30
|
+
constructor(request2, response, message) {
|
|
31
|
+
super(message);
|
|
32
|
+
this.name = "ApiError";
|
|
33
|
+
this.url = response.url;
|
|
34
|
+
this.status = response.status;
|
|
35
|
+
this.statusText = response.statusText;
|
|
36
|
+
this.body = response.body;
|
|
37
|
+
this.request = request2;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// src/client/core/CancelablePromise.ts
|
|
42
|
+
var CancelError = class extends Error {
|
|
43
|
+
static {
|
|
44
|
+
__name(this, "CancelError");
|
|
45
|
+
}
|
|
46
|
+
constructor(message) {
|
|
47
|
+
super(message);
|
|
48
|
+
this.name = "CancelError";
|
|
49
|
+
}
|
|
50
|
+
get isCancelled() {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
var CancelablePromise = class {
|
|
55
|
+
static {
|
|
56
|
+
__name(this, "CancelablePromise");
|
|
57
|
+
}
|
|
58
|
+
#isResolved;
|
|
59
|
+
#isRejected;
|
|
60
|
+
#isCancelled;
|
|
61
|
+
#cancelHandlers;
|
|
62
|
+
#promise;
|
|
63
|
+
#resolve;
|
|
64
|
+
#reject;
|
|
65
|
+
constructor(executor) {
|
|
66
|
+
this.#isResolved = false;
|
|
67
|
+
this.#isRejected = false;
|
|
68
|
+
this.#isCancelled = false;
|
|
69
|
+
this.#cancelHandlers = [];
|
|
70
|
+
this.#promise = new Promise((resolve2, reject) => {
|
|
71
|
+
this.#resolve = resolve2;
|
|
72
|
+
this.#reject = reject;
|
|
73
|
+
const onResolve = /* @__PURE__ */ __name((value) => {
|
|
74
|
+
if (this.#isResolved || this.#isRejected || this.#isCancelled) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
this.#isResolved = true;
|
|
78
|
+
this.#resolve?.(value);
|
|
79
|
+
}, "onResolve");
|
|
80
|
+
const onReject = /* @__PURE__ */ __name((reason) => {
|
|
81
|
+
if (this.#isResolved || this.#isRejected || this.#isCancelled) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
this.#isRejected = true;
|
|
85
|
+
this.#reject?.(reason);
|
|
86
|
+
}, "onReject");
|
|
87
|
+
const onCancel = /* @__PURE__ */ __name((cancelHandler) => {
|
|
88
|
+
if (this.#isResolved || this.#isRejected || this.#isCancelled) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
this.#cancelHandlers.push(cancelHandler);
|
|
92
|
+
}, "onCancel");
|
|
93
|
+
Object.defineProperty(onCancel, "isResolved", {
|
|
94
|
+
get: /* @__PURE__ */ __name(() => this.#isResolved, "get")
|
|
95
|
+
});
|
|
96
|
+
Object.defineProperty(onCancel, "isRejected", {
|
|
97
|
+
get: /* @__PURE__ */ __name(() => this.#isRejected, "get")
|
|
98
|
+
});
|
|
99
|
+
Object.defineProperty(onCancel, "isCancelled", {
|
|
100
|
+
get: /* @__PURE__ */ __name(() => this.#isCancelled, "get")
|
|
101
|
+
});
|
|
102
|
+
return executor(onResolve, onReject, onCancel);
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
get [Symbol.toStringTag]() {
|
|
106
|
+
return "Cancellable Promise";
|
|
107
|
+
}
|
|
108
|
+
then(onFulfilled, onRejected) {
|
|
109
|
+
return this.#promise.then(onFulfilled, onRejected);
|
|
110
|
+
}
|
|
111
|
+
catch(onRejected) {
|
|
112
|
+
return this.#promise.catch(onRejected);
|
|
113
|
+
}
|
|
114
|
+
finally(onFinally) {
|
|
115
|
+
return this.#promise.finally(onFinally);
|
|
116
|
+
}
|
|
117
|
+
cancel() {
|
|
118
|
+
if (this.#isResolved || this.#isRejected || this.#isCancelled) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
this.#isCancelled = true;
|
|
122
|
+
if (this.#cancelHandlers.length) {
|
|
123
|
+
try {
|
|
124
|
+
for (const cancelHandler of this.#cancelHandlers) {
|
|
125
|
+
cancelHandler();
|
|
126
|
+
}
|
|
127
|
+
} catch (error) {
|
|
128
|
+
console.warn("Cancellation threw an error", error);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
this.#cancelHandlers.length = 0;
|
|
133
|
+
this.#reject?.(new CancelError("Request aborted"));
|
|
134
|
+
}
|
|
135
|
+
get isCancelled() {
|
|
136
|
+
return this.#isCancelled;
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
// src/client/core/OpenAPI.ts
|
|
141
|
+
var OpenAPI = {
|
|
142
|
+
BASE: "",
|
|
143
|
+
VERSION: "1.0.0",
|
|
144
|
+
WITH_CREDENTIALS: false,
|
|
145
|
+
CREDENTIALS: "include",
|
|
146
|
+
TOKEN: void 0,
|
|
147
|
+
USERNAME: void 0,
|
|
148
|
+
PASSWORD: void 0,
|
|
149
|
+
HEADERS: void 0,
|
|
150
|
+
ENCODE_PATH: void 0,
|
|
151
|
+
LOGGER: void 0
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
// src/client/core/request.ts
|
|
155
|
+
var isDefined = /* @__PURE__ */ __name((value) => {
|
|
156
|
+
return value !== void 0 && value !== null;
|
|
157
|
+
}, "isDefined");
|
|
158
|
+
var isString = /* @__PURE__ */ __name((value) => {
|
|
159
|
+
return typeof value === "string";
|
|
160
|
+
}, "isString");
|
|
161
|
+
var isStringWithValue = /* @__PURE__ */ __name((value) => {
|
|
162
|
+
return isString(value) && value !== "";
|
|
163
|
+
}, "isStringWithValue");
|
|
164
|
+
var isBlob = /* @__PURE__ */ __name((value) => {
|
|
165
|
+
return typeof value === "object" && typeof value.type === "string" && typeof value.stream === "function" && typeof value.arrayBuffer === "function" && typeof value.constructor === "function" && typeof value.constructor.name === "string" && /^(Blob|File)$/.test(value.constructor.name) && /^(Blob|File)$/.test(value[Symbol.toStringTag]);
|
|
166
|
+
}, "isBlob");
|
|
167
|
+
var isErrorResponse = /* @__PURE__ */ __name((value) => {
|
|
168
|
+
return typeof value === "object" && value !== null && "error" in value && typeof value.error === "string";
|
|
169
|
+
}, "isErrorResponse");
|
|
170
|
+
var base64 = /* @__PURE__ */ __name((str) => {
|
|
171
|
+
try {
|
|
172
|
+
return btoa(str);
|
|
173
|
+
} catch (err) {
|
|
174
|
+
return Buffer.from(str).toString("base64");
|
|
175
|
+
}
|
|
176
|
+
}, "base64");
|
|
177
|
+
var getQueryString = /* @__PURE__ */ __name((params) => {
|
|
178
|
+
const qs = [];
|
|
179
|
+
const append = /* @__PURE__ */ __name((key, value) => {
|
|
180
|
+
qs.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`);
|
|
181
|
+
}, "append");
|
|
182
|
+
const process2 = /* @__PURE__ */ __name((key, value) => {
|
|
183
|
+
if (isDefined(value)) {
|
|
184
|
+
if (Array.isArray(value)) {
|
|
185
|
+
value.forEach((v) => {
|
|
186
|
+
process2(key, v);
|
|
187
|
+
});
|
|
188
|
+
} else if (typeof value === "object") {
|
|
189
|
+
Object.entries(value).forEach(([k, v]) => {
|
|
190
|
+
process2(`${key}[${k}]`, v);
|
|
191
|
+
});
|
|
192
|
+
} else {
|
|
193
|
+
append(key, value);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}, "process");
|
|
197
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
198
|
+
process2(key, value);
|
|
199
|
+
});
|
|
200
|
+
if (qs.length > 0) {
|
|
201
|
+
return `?${qs.join("&")}`;
|
|
202
|
+
}
|
|
203
|
+
return "";
|
|
204
|
+
}, "getQueryString");
|
|
205
|
+
var getUrl = /* @__PURE__ */ __name((config, options) => {
|
|
206
|
+
const encoder = config.ENCODE_PATH || encodeURI;
|
|
207
|
+
const path = options.url.replace("{api-version}", config.VERSION).replace(/{(.*?)}/g, (substring, group) => {
|
|
208
|
+
if (options.path?.hasOwnProperty(group)) {
|
|
209
|
+
return encoder(String(options.path[group]));
|
|
210
|
+
}
|
|
211
|
+
return substring;
|
|
212
|
+
});
|
|
213
|
+
const url = `${config.BASE}${path}`;
|
|
214
|
+
if (options.query) {
|
|
215
|
+
return `${url}${getQueryString(options.query)}`;
|
|
216
|
+
}
|
|
217
|
+
return url;
|
|
218
|
+
}, "getUrl");
|
|
219
|
+
var getFormData = /* @__PURE__ */ __name((options) => {
|
|
220
|
+
if (options.formData) {
|
|
221
|
+
const formData = new FormData();
|
|
222
|
+
const process2 = /* @__PURE__ */ __name(async (key, value) => {
|
|
223
|
+
if (isString(value)) {
|
|
224
|
+
formData.append(key, value);
|
|
225
|
+
} else {
|
|
226
|
+
formData.append(key, JSON.stringify(value));
|
|
227
|
+
}
|
|
228
|
+
}, "process");
|
|
229
|
+
Object.entries(options.formData).filter(([_, value]) => isDefined(value)).forEach(([key, value]) => {
|
|
230
|
+
if (Array.isArray(value)) {
|
|
231
|
+
value.forEach((v) => process2(key, v));
|
|
232
|
+
} else {
|
|
233
|
+
process2(key, value);
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
return formData;
|
|
237
|
+
}
|
|
238
|
+
return void 0;
|
|
239
|
+
}, "getFormData");
|
|
240
|
+
var resolve = /* @__PURE__ */ __name(async (options, resolver) => {
|
|
241
|
+
if (typeof resolver === "function") {
|
|
242
|
+
return resolver(options);
|
|
243
|
+
}
|
|
244
|
+
return resolver;
|
|
245
|
+
}, "resolve");
|
|
246
|
+
var getHeaders = /* @__PURE__ */ __name(async (config, options) => {
|
|
247
|
+
const token = await resolve(options, config.TOKEN);
|
|
248
|
+
const username = await resolve(options, config.USERNAME);
|
|
249
|
+
const password = await resolve(options, config.PASSWORD);
|
|
250
|
+
const additionalHeaders = await resolve(options, config.HEADERS);
|
|
251
|
+
const headers = Object.entries({
|
|
252
|
+
Accept: "application/json",
|
|
253
|
+
...additionalHeaders,
|
|
254
|
+
...options.headers
|
|
255
|
+
}).filter(([_, value]) => isDefined(value)).reduce(
|
|
256
|
+
(headers2, [key, value]) => ({
|
|
257
|
+
...headers2,
|
|
258
|
+
[key]: String(value)
|
|
259
|
+
}),
|
|
260
|
+
{}
|
|
261
|
+
);
|
|
262
|
+
if (isStringWithValue(token)) {
|
|
263
|
+
headers["Authorization"] = `Bearer ${token}`;
|
|
264
|
+
}
|
|
265
|
+
if (isStringWithValue(username) && isStringWithValue(password)) {
|
|
266
|
+
const credentials = base64(`${username}:${password}`);
|
|
267
|
+
headers["Authorization"] = `Basic ${credentials}`;
|
|
268
|
+
}
|
|
269
|
+
if (options.body) {
|
|
270
|
+
if (options.mediaType) {
|
|
271
|
+
headers["Content-Type"] = options.mediaType;
|
|
272
|
+
} else if (isBlob(options.body)) {
|
|
273
|
+
headers["Content-Type"] = options.body.type || "application/octet-stream";
|
|
274
|
+
} else if (isString(options.body)) {
|
|
275
|
+
headers["Content-Type"] = "text/plain";
|
|
276
|
+
} else {
|
|
277
|
+
headers["Content-Type"] = "application/json";
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
return new Headers(headers);
|
|
281
|
+
}, "getHeaders");
|
|
282
|
+
var getRequestBody = /* @__PURE__ */ __name((options) => {
|
|
283
|
+
if (options.body !== void 0) {
|
|
284
|
+
if (options.mediaType?.includes("/json")) {
|
|
285
|
+
return JSON.stringify(options.body);
|
|
286
|
+
} else if (isString(options.body) || isBlob(options.body)) {
|
|
287
|
+
return options.body;
|
|
288
|
+
} else {
|
|
289
|
+
return JSON.stringify(options.body);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
return void 0;
|
|
293
|
+
}, "getRequestBody");
|
|
294
|
+
var isResponseSchemaV4 = /* @__PURE__ */ __name((config, _options) => {
|
|
295
|
+
return config.BASE.endsWith("/containers");
|
|
296
|
+
}, "isResponseSchemaV4");
|
|
297
|
+
var parseResponseSchemaV4 = /* @__PURE__ */ __name((url, response, responseHeader, responseBody) => {
|
|
298
|
+
const fetchResult2 = typeof responseBody === "object" ? responseBody : JSON.parse(responseBody);
|
|
299
|
+
const ok = response.ok && fetchResult2.success;
|
|
300
|
+
let result;
|
|
301
|
+
if (ok) {
|
|
302
|
+
if (fetchResult2.result !== void 0) {
|
|
303
|
+
result = fetchResult2.result;
|
|
304
|
+
} else {
|
|
305
|
+
result = {};
|
|
306
|
+
}
|
|
307
|
+
} else if (isErrorResponse(fetchResult2)) {
|
|
308
|
+
result = fetchResult2;
|
|
309
|
+
} else {
|
|
310
|
+
result = { error: fetchResult2.errors?.[0]?.message };
|
|
311
|
+
}
|
|
312
|
+
return {
|
|
313
|
+
url,
|
|
314
|
+
ok,
|
|
315
|
+
status: response.status,
|
|
316
|
+
statusText: response.statusText,
|
|
317
|
+
body: responseHeader ?? result
|
|
318
|
+
};
|
|
319
|
+
}, "parseResponseSchemaV4");
|
|
320
|
+
var sendRequest = /* @__PURE__ */ __name(async (config, options, url, body, formData, headers, onCancel) => {
|
|
321
|
+
const controller = new AbortController();
|
|
322
|
+
const request2 = {
|
|
323
|
+
headers,
|
|
324
|
+
body: body ?? formData,
|
|
325
|
+
method: options.method,
|
|
326
|
+
signal: controller.signal
|
|
327
|
+
};
|
|
328
|
+
if (config.WITH_CREDENTIALS) {
|
|
329
|
+
request2.credentials = config.CREDENTIALS;
|
|
330
|
+
}
|
|
331
|
+
onCancel(() => controller.abort());
|
|
332
|
+
return await fetch(url, request2);
|
|
333
|
+
}, "sendRequest");
|
|
334
|
+
var getResponseHeader = /* @__PURE__ */ __name((response, responseHeader) => {
|
|
335
|
+
if (responseHeader) {
|
|
336
|
+
const content = response.headers.get(responseHeader);
|
|
337
|
+
if (isString(content)) {
|
|
338
|
+
return content;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
return void 0;
|
|
342
|
+
}, "getResponseHeader");
|
|
343
|
+
var getResponseBody = /* @__PURE__ */ __name(async (response) => {
|
|
344
|
+
if (response.status !== 204) {
|
|
345
|
+
try {
|
|
346
|
+
const contentType = response.headers.get("Content-Type");
|
|
347
|
+
if (contentType) {
|
|
348
|
+
const jsonTypes = ["application/json", "application/problem+json"];
|
|
349
|
+
const isJSON = jsonTypes.some(
|
|
350
|
+
(type) => contentType.toLowerCase().startsWith(type)
|
|
351
|
+
);
|
|
352
|
+
if (isJSON) {
|
|
353
|
+
return await response.json();
|
|
354
|
+
} else {
|
|
355
|
+
return await response.text();
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
} catch (error) {
|
|
359
|
+
console.error(error);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
return void 0;
|
|
363
|
+
}, "getResponseBody");
|
|
364
|
+
var catchErrorCodes = /* @__PURE__ */ __name((options, result) => {
|
|
365
|
+
const errors = {
|
|
366
|
+
400: "Bad Request",
|
|
367
|
+
401: "Unauthorized",
|
|
368
|
+
403: "Forbidden",
|
|
369
|
+
404: "Not Found",
|
|
370
|
+
500: "Internal Server Error",
|
|
371
|
+
502: "Bad Gateway",
|
|
372
|
+
503: "Service Unavailable",
|
|
373
|
+
...options.errors
|
|
374
|
+
};
|
|
375
|
+
const error = errors[result.status];
|
|
376
|
+
if (error) {
|
|
377
|
+
throw new ApiError(options, result, error);
|
|
378
|
+
}
|
|
379
|
+
if (!result.ok) {
|
|
380
|
+
throw new ApiError(options, result, "Generic Error");
|
|
381
|
+
}
|
|
382
|
+
}, "catchErrorCodes");
|
|
383
|
+
var executeRequest = /* @__PURE__ */ __name(async (config, options, onCancel) => {
|
|
384
|
+
const url = getUrl(config, options);
|
|
385
|
+
const formData = getFormData(options);
|
|
386
|
+
const body = getRequestBody(options);
|
|
387
|
+
const headers = await getHeaders(config, options);
|
|
388
|
+
debugLogRequest(config, url, headers, formData ?? body ?? {});
|
|
389
|
+
if (onCancel.isCancelled) {
|
|
390
|
+
return null;
|
|
391
|
+
}
|
|
392
|
+
const response = await sendRequest(
|
|
393
|
+
config,
|
|
394
|
+
options,
|
|
395
|
+
url,
|
|
396
|
+
body,
|
|
397
|
+
formData,
|
|
398
|
+
headers,
|
|
399
|
+
onCancel
|
|
400
|
+
);
|
|
401
|
+
const responseBody = await getResponseBody(response);
|
|
402
|
+
const responseHeader = getResponseHeader(response, options.responseHeader);
|
|
403
|
+
return { url, response, responseBody, responseHeader };
|
|
404
|
+
}, "executeRequest");
|
|
405
|
+
var buildApiResult = /* @__PURE__ */ __name((config, options, req) => {
|
|
406
|
+
if (isResponseSchemaV4(config, options)) {
|
|
407
|
+
return parseResponseSchemaV4(
|
|
408
|
+
req.url,
|
|
409
|
+
req.response,
|
|
410
|
+
req.responseHeader,
|
|
411
|
+
req.responseBody
|
|
412
|
+
);
|
|
413
|
+
}
|
|
414
|
+
return {
|
|
415
|
+
url: req.url,
|
|
416
|
+
ok: req.response.ok,
|
|
417
|
+
status: req.response.status,
|
|
418
|
+
statusText: req.response.statusText,
|
|
419
|
+
body: req.responseHeader ?? req.responseBody
|
|
420
|
+
};
|
|
421
|
+
}, "buildApiResult");
|
|
422
|
+
var request = /* @__PURE__ */ __name((config, options) => {
|
|
423
|
+
return new CancelablePromise(async (resolve2, reject, onCancel) => {
|
|
424
|
+
try {
|
|
425
|
+
const req = await executeRequest(config, options, onCancel);
|
|
426
|
+
if (!req) {
|
|
427
|
+
return;
|
|
428
|
+
}
|
|
429
|
+
const result = buildApiResult(config, options, req);
|
|
430
|
+
debugLogResponse(config, result);
|
|
431
|
+
catchErrorCodes(options, result);
|
|
432
|
+
resolve2(result.body);
|
|
433
|
+
} catch (error) {
|
|
434
|
+
reject(error);
|
|
435
|
+
}
|
|
436
|
+
});
|
|
437
|
+
}, "request");
|
|
438
|
+
var requestPaginated = /* @__PURE__ */ __name((config, options) => {
|
|
439
|
+
return new CancelablePromise(async (resolve2, reject, onCancel) => {
|
|
440
|
+
try {
|
|
441
|
+
const req = await executeRequest(config, options, onCancel);
|
|
442
|
+
if (!req) {
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
const result = buildApiResult(config, options, req);
|
|
446
|
+
debugLogResponse(config, result);
|
|
447
|
+
catchErrorCodes(options, result);
|
|
448
|
+
let resultInfo;
|
|
449
|
+
if (isResponseSchemaV4(config, options)) {
|
|
450
|
+
const fetchResult2 = typeof req.responseBody === "object" ? req.responseBody : JSON.parse(req.responseBody);
|
|
451
|
+
resultInfo = fetchResult2.result_info;
|
|
452
|
+
}
|
|
453
|
+
resolve2({
|
|
454
|
+
data: result.body,
|
|
455
|
+
resultInfo
|
|
456
|
+
});
|
|
457
|
+
} catch (error) {
|
|
458
|
+
reject(error);
|
|
459
|
+
}
|
|
460
|
+
});
|
|
461
|
+
}, "requestPaginated");
|
|
462
|
+
var debugLogRequest = /* @__PURE__ */ __name(async (config, url, headers, body) => {
|
|
463
|
+
config.LOGGER?.debug(`-- START CF API REQUEST: ${url}`);
|
|
464
|
+
const logHeaders = new Headers(headers);
|
|
465
|
+
logHeaders.delete("Authorization");
|
|
466
|
+
config.LOGGER?.debugWithSanitization(
|
|
467
|
+
"HEADERS:",
|
|
468
|
+
JSON.stringify(logHeaders, null, 2)
|
|
469
|
+
);
|
|
470
|
+
config.LOGGER?.debugWithSanitization(
|
|
471
|
+
"BODY:",
|
|
472
|
+
JSON.stringify(
|
|
473
|
+
body instanceof FormData ? await new Response(body).text() : body,
|
|
474
|
+
null,
|
|
475
|
+
2
|
|
476
|
+
)
|
|
477
|
+
);
|
|
478
|
+
config.LOGGER?.debug("-- END CF API REQUEST");
|
|
479
|
+
}, "debugLogRequest");
|
|
480
|
+
var debugLogResponse = /* @__PURE__ */ __name((config, response) => {
|
|
481
|
+
config.LOGGER?.debug(
|
|
482
|
+
"-- START CF API RESPONSE:",
|
|
483
|
+
response.statusText,
|
|
484
|
+
response.status
|
|
485
|
+
);
|
|
486
|
+
config.LOGGER?.debugWithSanitization("RESPONSE:", response.body);
|
|
487
|
+
config.LOGGER?.debug("-- END CF API RESPONSE");
|
|
488
|
+
}, "debugLogResponse");
|
|
489
|
+
|
|
490
|
+
// src/client/models/ApplicationAffinityColocation.ts
|
|
491
|
+
var ApplicationAffinityColocation = /* @__PURE__ */ ((ApplicationAffinityColocation2) => {
|
|
492
|
+
ApplicationAffinityColocation2["DATACENTER"] = "datacenter";
|
|
493
|
+
return ApplicationAffinityColocation2;
|
|
494
|
+
})(ApplicationAffinityColocation || {});
|
|
495
|
+
|
|
496
|
+
// src/client/models/ApplicationAffinityHardwareGeneration.ts
|
|
497
|
+
var ApplicationAffinityHardwareGeneration = /* @__PURE__ */ ((ApplicationAffinityHardwareGeneration2) => {
|
|
498
|
+
ApplicationAffinityHardwareGeneration2["HIGHEST_OVERALL_PERFORMANCE"] = "highest-overall-performance";
|
|
499
|
+
return ApplicationAffinityHardwareGeneration2;
|
|
500
|
+
})(ApplicationAffinityHardwareGeneration || {});
|
|
501
|
+
|
|
502
|
+
// src/client/models/ApplicationMutationError.ts
|
|
503
|
+
var ApplicationMutationError = /* @__PURE__ */ ((ApplicationMutationError2) => {
|
|
504
|
+
ApplicationMutationError2["IMAGE_REGISTRY_RETURNED_ERROR"] = "IMAGE_REGISTRY_RETURNED_ERROR";
|
|
505
|
+
ApplicationMutationError2["IMAGE_REGISTRY_DOESNT_CONTAIN_IMAGE"] = "IMAGE_REGISTRY_DOESNT_CONTAIN_IMAGE";
|
|
506
|
+
ApplicationMutationError2["VALIDATE_INPUT"] = "VALIDATE_INPUT";
|
|
507
|
+
ApplicationMutationError2["SURPASSED_BASE_LIMITS"] = "SURPASSED_BASE_LIMITS";
|
|
508
|
+
ApplicationMutationError2["SURPASSED_TOTAL_LIMITS"] = "SURPASSED_TOTAL_LIMITS";
|
|
509
|
+
ApplicationMutationError2["LOCATION_NOT_ALLOWED"] = "LOCATION_NOT_ALLOWED";
|
|
510
|
+
ApplicationMutationError2["LOCATION_SURPASSED_BASE_LIMITS"] = "LOCATION_SURPASSED_BASE_LIMITS";
|
|
511
|
+
ApplicationMutationError2["IMAGE_REGISTRY_NOT_CONFIGURED"] = "IMAGE_REGISTRY_NOT_CONFIGURED";
|
|
512
|
+
ApplicationMutationError2["JOB_CREATE_NOT_ALLOWED"] = "JOB_CREATE_NOT_ALLOWED";
|
|
513
|
+
ApplicationMutationError2["DURABLE_OBJECT_NOT_FOUND"] = "DURABLE_OBJECT_NOT_FOUND";
|
|
514
|
+
ApplicationMutationError2["DURABLE_OBJECT_NOT_CONTAINER_ENABLED"] = "DURABLE_OBJECT_NOT_CONTAINER_ENABLED";
|
|
515
|
+
ApplicationMutationError2["DURABLE_OBJECT_ALREADY_HAS_APPLICATION"] = "DURABLE_OBJECT_ALREADY_HAS_APPLICATION";
|
|
516
|
+
return ApplicationMutationError2;
|
|
517
|
+
})(ApplicationMutationError || {});
|
|
518
|
+
|
|
519
|
+
// src/client/models/ApplicationRollout.ts
|
|
520
|
+
var ApplicationRollout;
|
|
521
|
+
((ApplicationRollout2) => {
|
|
522
|
+
((kind2) => {
|
|
523
|
+
kind2["FULL_AUTO"] = "full_auto";
|
|
524
|
+
kind2["FULL_MANUAL"] = "full_manual";
|
|
525
|
+
kind2["DURABLE_OBJECTS_AUTO"] = "durable_objects_auto";
|
|
526
|
+
})(ApplicationRollout2.kind || (ApplicationRollout2.kind = {}));
|
|
527
|
+
((strategy2) => {
|
|
528
|
+
strategy2["ROLLING"] = "rolling";
|
|
529
|
+
})(ApplicationRollout2.strategy || (ApplicationRollout2.strategy = {}));
|
|
530
|
+
((status2) => {
|
|
531
|
+
status2["PENDING"] = "pending";
|
|
532
|
+
status2["PROGRESSING"] = "progressing";
|
|
533
|
+
status2["COMPLETED"] = "completed";
|
|
534
|
+
status2["REVERTED"] = "reverted";
|
|
535
|
+
status2["REPLACED"] = "replaced";
|
|
536
|
+
})(ApplicationRollout2.status || (ApplicationRollout2.status = {}));
|
|
537
|
+
})(ApplicationRollout || (ApplicationRollout = {}));
|
|
538
|
+
|
|
539
|
+
// src/client/models/AssignIPv4.ts
|
|
540
|
+
var AssignIPv4 = /* @__PURE__ */ ((AssignIPv42) => {
|
|
541
|
+
AssignIPv42["NONE"] = "none";
|
|
542
|
+
AssignIPv42["PREDEFINED"] = "predefined";
|
|
543
|
+
AssignIPv42["ACCOUNT"] = "account";
|
|
544
|
+
return AssignIPv42;
|
|
545
|
+
})(AssignIPv4 || {});
|
|
546
|
+
|
|
547
|
+
// src/client/models/AssignIPv6.ts
|
|
548
|
+
var AssignIPv6 = /* @__PURE__ */ ((AssignIPv62) => {
|
|
549
|
+
AssignIPv62["NONE"] = "none";
|
|
550
|
+
AssignIPv62["PREDEFINED"] = "predefined";
|
|
551
|
+
AssignIPv62["ACCOUNT"] = "account";
|
|
552
|
+
return AssignIPv62;
|
|
553
|
+
})(AssignIPv6 || {});
|
|
554
|
+
|
|
555
|
+
// src/client/models/BadRequestWithCodeError.ts
|
|
556
|
+
var BadRequestWithCodeError;
|
|
557
|
+
((BadRequestWithCodeError2) => {
|
|
558
|
+
((error2) => {
|
|
559
|
+
error2["VALIDATE_INPUT"] = "VALIDATE_INPUT";
|
|
560
|
+
})(BadRequestWithCodeError2.error || (BadRequestWithCodeError2.error = {}));
|
|
561
|
+
})(BadRequestWithCodeError || (BadRequestWithCodeError = {}));
|
|
562
|
+
|
|
563
|
+
// src/client/models/ContainerNetworkMode.ts
|
|
564
|
+
var ContainerNetworkMode = /* @__PURE__ */ ((ContainerNetworkMode2) => {
|
|
565
|
+
ContainerNetworkMode2["PUBLIC"] = "public";
|
|
566
|
+
ContainerNetworkMode2["PUBLIC_BY_PORT"] = "public-by-port";
|
|
567
|
+
ContainerNetworkMode2["PRIVATE"] = "private";
|
|
568
|
+
return ContainerNetworkMode2;
|
|
569
|
+
})(ContainerNetworkMode || {});
|
|
570
|
+
|
|
571
|
+
// src/client/models/ContainerImagePreparationStatus.ts
|
|
572
|
+
var ContainerImagePreparationStatus = /* @__PURE__ */ ((ContainerImagePreparationStatus2) => {
|
|
573
|
+
ContainerImagePreparationStatus2["PENDING"] = "pending";
|
|
574
|
+
ContainerImagePreparationStatus2["READY"] = "ready";
|
|
575
|
+
ContainerImagePreparationStatus2["ERROR"] = "error";
|
|
576
|
+
return ContainerImagePreparationStatus2;
|
|
577
|
+
})(ContainerImagePreparationStatus || {});
|
|
578
|
+
|
|
579
|
+
// src/client/models/CreateApplicationRolloutRequest.ts
|
|
580
|
+
var CreateApplicationRolloutRequest;
|
|
581
|
+
((CreateApplicationRolloutRequest2) => {
|
|
582
|
+
((strategy2) => {
|
|
583
|
+
strategy2["ROLLING"] = "rolling";
|
|
584
|
+
})(CreateApplicationRolloutRequest2.strategy || (CreateApplicationRolloutRequest2.strategy = {}));
|
|
585
|
+
((step_percentage2) => {
|
|
586
|
+
step_percentage2[step_percentage2["_5"] = 5] = "_5";
|
|
587
|
+
step_percentage2[step_percentage2["_10"] = 10] = "_10";
|
|
588
|
+
step_percentage2[step_percentage2["_20"] = 20] = "_20";
|
|
589
|
+
step_percentage2[step_percentage2["_25"] = 25] = "_25";
|
|
590
|
+
step_percentage2[step_percentage2["_50"] = 50] = "_50";
|
|
591
|
+
step_percentage2[step_percentage2["_100"] = 100] = "_100";
|
|
592
|
+
})(CreateApplicationRolloutRequest2.step_percentage || (CreateApplicationRolloutRequest2.step_percentage = {}));
|
|
593
|
+
((kind2) => {
|
|
594
|
+
kind2["FULL_AUTO"] = "full_auto";
|
|
595
|
+
kind2["FULL_MANUAL"] = "full_manual";
|
|
596
|
+
})(CreateApplicationRolloutRequest2.kind || (CreateApplicationRolloutRequest2.kind = {}));
|
|
597
|
+
})(CreateApplicationRolloutRequest || (CreateApplicationRolloutRequest = {}));
|
|
598
|
+
|
|
599
|
+
// src/client/models/DeploymentCheckKind.ts
|
|
600
|
+
var DeploymentCheckKind = /* @__PURE__ */ ((DeploymentCheckKind2) => {
|
|
601
|
+
DeploymentCheckKind2["HEALTH"] = "health";
|
|
602
|
+
DeploymentCheckKind2["READY"] = "ready";
|
|
603
|
+
return DeploymentCheckKind2;
|
|
604
|
+
})(DeploymentCheckKind || {});
|
|
605
|
+
|
|
606
|
+
// src/client/models/DeploymentCheckType.ts
|
|
607
|
+
var DeploymentCheckType = /* @__PURE__ */ ((DeploymentCheckType2) => {
|
|
608
|
+
DeploymentCheckType2["HTTP"] = "http";
|
|
609
|
+
DeploymentCheckType2["TCP"] = "tcp";
|
|
610
|
+
return DeploymentCheckType2;
|
|
611
|
+
})(DeploymentCheckType || {});
|
|
612
|
+
|
|
613
|
+
// src/client/models/DeploymentMutationError.ts
|
|
614
|
+
var DeploymentMutationError = /* @__PURE__ */ ((DeploymentMutationError2) => {
|
|
615
|
+
DeploymentMutationError2["VALIDATE_INPUT"] = "VALIDATE_INPUT";
|
|
616
|
+
DeploymentMutationError2["SURPASSED_BASE_LIMITS"] = "SURPASSED_BASE_LIMITS";
|
|
617
|
+
DeploymentMutationError2["SURPASSED_TOTAL_LIMITS"] = "SURPASSED_TOTAL_LIMITS";
|
|
618
|
+
DeploymentMutationError2["LOCATION_NOT_ALLOWED"] = "LOCATION_NOT_ALLOWED";
|
|
619
|
+
DeploymentMutationError2["LOCATION_SURPASSED_BASE_LIMITS"] = "LOCATION_SURPASSED_BASE_LIMITS";
|
|
620
|
+
DeploymentMutationError2["IMAGE_REGISTRY_NOT_CONFIGURED"] = "IMAGE_REGISTRY_NOT_CONFIGURED";
|
|
621
|
+
return DeploymentMutationError2;
|
|
622
|
+
})(DeploymentMutationError || {});
|
|
623
|
+
|
|
624
|
+
// src/client/models/DeploymentNotFoundError.ts
|
|
625
|
+
var DeploymentNotFoundError;
|
|
626
|
+
((DeploymentNotFoundError2) => {
|
|
627
|
+
((error2) => {
|
|
628
|
+
error2["DEPLOYMENT_NOT_FOUND"] = "DEPLOYMENT_NOT_FOUND";
|
|
629
|
+
})(DeploymentNotFoundError2.error || (DeploymentNotFoundError2.error = {}));
|
|
630
|
+
})(DeploymentNotFoundError || (DeploymentNotFoundError = {}));
|
|
631
|
+
|
|
632
|
+
// src/client/models/DeploymentPlacementState.ts
|
|
633
|
+
var DeploymentPlacementState = /* @__PURE__ */ ((DeploymentPlacementState2) => {
|
|
634
|
+
DeploymentPlacementState2["RUNNING"] = "running";
|
|
635
|
+
DeploymentPlacementState2["STOPPED"] = "stopped";
|
|
636
|
+
DeploymentPlacementState2["STARTING"] = "starting";
|
|
637
|
+
DeploymentPlacementState2["STOPPING"] = "stopping";
|
|
638
|
+
return DeploymentPlacementState2;
|
|
639
|
+
})(DeploymentPlacementState || {});
|
|
640
|
+
|
|
641
|
+
// src/client/models/DeploymentQueuedReason.ts
|
|
642
|
+
var DeploymentQueuedReason = /* @__PURE__ */ ((DeploymentQueuedReason2) => {
|
|
643
|
+
DeploymentQueuedReason2["UNKNOWN"] = "unknown";
|
|
644
|
+
DeploymentQueuedReason2["LOCATION_OVERPROVISIONED"] = "location_overprovisioned";
|
|
645
|
+
return DeploymentQueuedReason2;
|
|
646
|
+
})(DeploymentQueuedReason || {});
|
|
647
|
+
|
|
648
|
+
// src/client/models/DeploymentSchedulingState.ts
|
|
649
|
+
var DeploymentSchedulingState = /* @__PURE__ */ ((DeploymentSchedulingState2) => {
|
|
650
|
+
DeploymentSchedulingState2["SCHEDULED"] = "scheduled";
|
|
651
|
+
DeploymentSchedulingState2["PLACED"] = "placed";
|
|
652
|
+
return DeploymentSchedulingState2;
|
|
653
|
+
})(DeploymentSchedulingState || {});
|
|
654
|
+
|
|
655
|
+
// src/client/models/DeploymentType.ts
|
|
656
|
+
var DeploymentType = /* @__PURE__ */ ((DeploymentType2) => {
|
|
657
|
+
DeploymentType2["DEFAULT"] = "default";
|
|
658
|
+
DeploymentType2["JOBS"] = "jobs";
|
|
659
|
+
DeploymentType2["DURABLE_OBJECT"] = "durable_object";
|
|
660
|
+
return DeploymentType2;
|
|
661
|
+
})(DeploymentType || {});
|
|
662
|
+
|
|
663
|
+
// src/client/models/DurableObjectStatusHealth.ts
|
|
664
|
+
var DurableObjectStatusHealth = /* @__PURE__ */ ((DurableObjectStatusHealth2) => {
|
|
665
|
+
DurableObjectStatusHealth2["CONNECTED"] = "connected";
|
|
666
|
+
DurableObjectStatusHealth2["DISCONNECTED"] = "disconnected";
|
|
667
|
+
return DurableObjectStatusHealth2;
|
|
668
|
+
})(DurableObjectStatusHealth || {});
|
|
669
|
+
|
|
670
|
+
// src/client/models/EventName.ts
|
|
671
|
+
var EventName = /* @__PURE__ */ ((EventName2) => {
|
|
672
|
+
EventName2["SCHEDULER_PLACED"] = "SchedulerPlaced";
|
|
673
|
+
EventName2["NETWORKING_IPASSIGNED"] = "NetworkingIPAssigned";
|
|
674
|
+
EventName2["VMSTARTED"] = "VMStarted";
|
|
675
|
+
EventName2["IMAGE_PULLED"] = "ImagePulled";
|
|
676
|
+
EventName2["IMAGE_PULL_ERROR"] = "ImagePullError";
|
|
677
|
+
EventName2["VMFAILED_TO_START"] = "VMFailedToStart";
|
|
678
|
+
EventName2["NETWORKING_IPASSIGNMENT_FAILED"] = "NetworkingIPAssignmentFailed";
|
|
679
|
+
EventName2["VMRUNNING"] = "VMRunning";
|
|
680
|
+
EventName2["VMSTOPPING"] = "VMStopping";
|
|
681
|
+
EventName2["VMSTOPPED"] = "VMStopped";
|
|
682
|
+
EventName2["VMFAILED"] = "VMFailed";
|
|
683
|
+
EventName2["RUNTIME_START_FAILED"] = "RuntimeStartFailed";
|
|
684
|
+
EventName2["SSHSTARTED"] = "SSHStarted";
|
|
685
|
+
EventName2["SERVICE_HEALTH_UPDATES"] = "ServiceHealthUpdates";
|
|
686
|
+
EventName2["CHECK_UPDATE"] = "CheckUpdate";
|
|
687
|
+
EventName2["DURABLE_OBJECT_CONNECTED"] = "DurableObjectConnected";
|
|
688
|
+
EventName2["CONTAINER_STARTED"] = "ContainerStarted";
|
|
689
|
+
return EventName2;
|
|
690
|
+
})(EventName || {});
|
|
691
|
+
|
|
692
|
+
// src/client/models/EventType.ts
|
|
693
|
+
var EventType = /* @__PURE__ */ ((EventType2) => {
|
|
694
|
+
EventType2["INFO"] = "Info";
|
|
695
|
+
EventType2["ERROR"] = "Error";
|
|
696
|
+
EventType2["WARN"] = "Warn";
|
|
697
|
+
EventType2["USER_ERROR"] = "UserError";
|
|
698
|
+
EventType2["SYSTEM_ERROR"] = "SystemError";
|
|
699
|
+
return EventType2;
|
|
700
|
+
})(EventType || {});
|
|
701
|
+
|
|
702
|
+
// src/client/models/ExternalRegistryKind.ts
|
|
703
|
+
var ExternalRegistryKind = /* @__PURE__ */ ((ExternalRegistryKind2) => {
|
|
704
|
+
ExternalRegistryKind2["ECR"] = "ECR";
|
|
705
|
+
ExternalRegistryKind2["DOCKER_HUB"] = "DockerHub";
|
|
706
|
+
ExternalRegistryKind2["GAR"] = "GAR";
|
|
707
|
+
return ExternalRegistryKind2;
|
|
708
|
+
})(ExternalRegistryKind || {});
|
|
709
|
+
|
|
710
|
+
// src/client/models/HTTPMethod.ts
|
|
711
|
+
var HTTPMethod = /* @__PURE__ */ ((HTTPMethod2) => {
|
|
712
|
+
HTTPMethod2["GET"] = "GET";
|
|
713
|
+
HTTPMethod2["POST"] = "POST";
|
|
714
|
+
HTTPMethod2["PATCH"] = "PATCH";
|
|
715
|
+
HTTPMethod2["PUT"] = "PUT";
|
|
716
|
+
HTTPMethod2["OPTIONS"] = "OPTIONS";
|
|
717
|
+
HTTPMethod2["DELETE"] = "DELETE";
|
|
718
|
+
HTTPMethod2["HEAD"] = "HEAD";
|
|
719
|
+
return HTTPMethod2;
|
|
720
|
+
})(HTTPMethod || {});
|
|
721
|
+
|
|
722
|
+
// src/client/models/ImageRegistryAlreadyExistsError.ts
|
|
723
|
+
var ImageRegistryAlreadyExistsError;
|
|
724
|
+
((ImageRegistryAlreadyExistsError2) => {
|
|
725
|
+
((error2) => {
|
|
726
|
+
error2["IMAGE_REGISTRY_ALREADY_EXISTS"] = "IMAGE_REGISTRY_ALREADY_EXISTS";
|
|
727
|
+
})(ImageRegistryAlreadyExistsError2.error || (ImageRegistryAlreadyExistsError2.error = {}));
|
|
728
|
+
})(ImageRegistryAlreadyExistsError || (ImageRegistryAlreadyExistsError = {}));
|
|
729
|
+
|
|
730
|
+
// src/client/models/ImageRegistryIsPublic.ts
|
|
731
|
+
var ImageRegistryIsPublic;
|
|
732
|
+
((ImageRegistryIsPublic2) => {
|
|
733
|
+
((error2) => {
|
|
734
|
+
error2["IMAGE_REGISTRY_IS_PUBLIC"] = "IMAGE_REGISTRY_IS_PUBLIC";
|
|
735
|
+
})(ImageRegistryIsPublic2.error || (ImageRegistryIsPublic2.error = {}));
|
|
736
|
+
})(ImageRegistryIsPublic || (ImageRegistryIsPublic = {}));
|
|
737
|
+
|
|
738
|
+
// src/client/models/ImageRegistryNotAllowedError.ts
|
|
739
|
+
var ImageRegistryNotAllowedError;
|
|
740
|
+
((ImageRegistryNotAllowedError2) => {
|
|
741
|
+
((error2) => {
|
|
742
|
+
error2["IMAGE_REGISTRY_NOT_ALLOWED"] = "IMAGE_REGISTRY_NOT_ALLOWED";
|
|
743
|
+
})(ImageRegistryNotAllowedError2.error || (ImageRegistryNotAllowedError2.error = {}));
|
|
744
|
+
})(ImageRegistryNotAllowedError || (ImageRegistryNotAllowedError = {}));
|
|
745
|
+
|
|
746
|
+
// src/client/models/ImageRegistryNotFoundError.ts
|
|
747
|
+
var ImageRegistryNotFoundError;
|
|
748
|
+
((ImageRegistryNotFoundError2) => {
|
|
749
|
+
((error2) => {
|
|
750
|
+
error2["IMAGE_REGISTRY_NOT_FOUND"] = "IMAGE_REGISTRY_NOT_FOUND";
|
|
751
|
+
})(ImageRegistryNotFoundError2.error || (ImageRegistryNotFoundError2.error = {}));
|
|
752
|
+
})(ImageRegistryNotFoundError || (ImageRegistryNotFoundError = {}));
|
|
753
|
+
|
|
754
|
+
// src/client/models/ImageRegistryPermissions.ts
|
|
755
|
+
var ImageRegistryPermissions = /* @__PURE__ */ ((ImageRegistryPermissions2) => {
|
|
756
|
+
ImageRegistryPermissions2["PULL"] = "pull";
|
|
757
|
+
ImageRegistryPermissions2["PUSH"] = "push";
|
|
758
|
+
ImageRegistryPermissions2["LIBRARY_PUSH"] = "library_push";
|
|
759
|
+
return ImageRegistryPermissions2;
|
|
760
|
+
})(ImageRegistryPermissions || {});
|
|
761
|
+
|
|
762
|
+
// src/client/models/ImageRegistryProtocolAlreadyExists.ts
|
|
763
|
+
var ImageRegistryProtocolAlreadyExists;
|
|
764
|
+
((ImageRegistryProtocolAlreadyExists2) => {
|
|
765
|
+
((error2) => {
|
|
766
|
+
error2["IMAGE_REGISTRY_PROTOCOL_ALREADY_EXISTS"] = "IMAGE_REGISTRY_PROTOCOL_ALREADY_EXISTS";
|
|
767
|
+
})(ImageRegistryProtocolAlreadyExists2.error || (ImageRegistryProtocolAlreadyExists2.error = {}));
|
|
768
|
+
})(ImageRegistryProtocolAlreadyExists || (ImageRegistryProtocolAlreadyExists = {}));
|
|
769
|
+
|
|
770
|
+
// src/client/models/ImageRegistryProtocolIsReferencedError.ts
|
|
771
|
+
var ImageRegistryProtocolIsReferencedError;
|
|
772
|
+
((ImageRegistryProtocolIsReferencedError2) => {
|
|
773
|
+
((error2) => {
|
|
774
|
+
error2["IMAGE_REGISTRY_PROTO_IS_REFERENCED"] = "IMAGE_REGISTRY_PROTO_IS_REFERENCED";
|
|
775
|
+
})(ImageRegistryProtocolIsReferencedError2.error || (ImageRegistryProtocolIsReferencedError2.error = {}));
|
|
776
|
+
})(ImageRegistryProtocolIsReferencedError || (ImageRegistryProtocolIsReferencedError = {}));
|
|
777
|
+
|
|
778
|
+
// src/client/models/ImageRegistryProtocolNotFound.ts
|
|
779
|
+
var ImageRegistryProtocolNotFound;
|
|
780
|
+
((ImageRegistryProtocolNotFound2) => {
|
|
781
|
+
((error2) => {
|
|
782
|
+
error2["IMAGE_REGISTRY_PROTOCOL_NOT_FOUND"] = "IMAGE_REGISTRY_PROTOCOL_NOT_FOUND";
|
|
783
|
+
})(ImageRegistryProtocolNotFound2.error || (ImageRegistryProtocolNotFound2.error = {}));
|
|
784
|
+
})(ImageRegistryProtocolNotFound || (ImageRegistryProtocolNotFound = {}));
|
|
785
|
+
|
|
786
|
+
// src/client/models/InstanceType.ts
|
|
787
|
+
var InstanceType = /* @__PURE__ */ ((InstanceType2) => {
|
|
788
|
+
InstanceType2["LITE"] = "lite";
|
|
789
|
+
InstanceType2["DEV"] = "dev";
|
|
790
|
+
InstanceType2["BASIC"] = "basic";
|
|
791
|
+
InstanceType2["STANDARD"] = "standard";
|
|
792
|
+
InstanceType2["STANDARD_1"] = "standard-1";
|
|
793
|
+
InstanceType2["STANDARD_2"] = "standard-2";
|
|
794
|
+
InstanceType2["STANDARD_3"] = "standard-3";
|
|
795
|
+
InstanceType2["STANDARD_4"] = "standard-4";
|
|
796
|
+
return InstanceType2;
|
|
797
|
+
})(InstanceType || {});
|
|
798
|
+
|
|
799
|
+
// src/client/models/IPType.ts
|
|
800
|
+
var IPType = /* @__PURE__ */ ((IPType2) => {
|
|
801
|
+
IPType2["V4"] = "v4";
|
|
802
|
+
IPType2["V6"] = "v6";
|
|
803
|
+
return IPType2;
|
|
804
|
+
})(IPType || {});
|
|
805
|
+
|
|
806
|
+
// src/client/models/JobStatusHealth.ts
|
|
807
|
+
var JobStatusHealth = /* @__PURE__ */ ((JobStatusHealth2) => {
|
|
808
|
+
JobStatusHealth2["QUEUED"] = "Queued";
|
|
809
|
+
JobStatusHealth2["SCHEDULED"] = "Scheduled";
|
|
810
|
+
JobStatusHealth2["PLACED"] = "Placed";
|
|
811
|
+
JobStatusHealth2["RUNNING"] = "Running";
|
|
812
|
+
JobStatusHealth2["STOPPED"] = "Stopped";
|
|
813
|
+
return JobStatusHealth2;
|
|
814
|
+
})(JobStatusHealth || {});
|
|
815
|
+
|
|
816
|
+
// src/client/models/NetworkMode.ts
|
|
817
|
+
var NetworkMode = /* @__PURE__ */ ((NetworkMode2) => {
|
|
818
|
+
NetworkMode2["USO"] = "uso";
|
|
819
|
+
NetworkMode2["VHOST"] = "vhost";
|
|
820
|
+
NetworkMode2["XDP"] = "xdp";
|
|
821
|
+
return NetworkMode2;
|
|
822
|
+
})(NetworkMode || {});
|
|
823
|
+
|
|
824
|
+
// src/client/models/NodeGroup.ts
|
|
825
|
+
var NodeGroup = /* @__PURE__ */ ((NodeGroup2) => {
|
|
826
|
+
NodeGroup2["METAL"] = "metal";
|
|
827
|
+
NodeGroup2["CLOUDCHAMBER"] = "cloudchamber";
|
|
828
|
+
return NodeGroup2;
|
|
829
|
+
})(NodeGroup || {});
|
|
830
|
+
|
|
831
|
+
// src/client/models/PlacementStatusHealth.ts
|
|
832
|
+
var PlacementStatusHealth = /* @__PURE__ */ ((PlacementStatusHealth2) => {
|
|
833
|
+
PlacementStatusHealth2["PLACED"] = "placed";
|
|
834
|
+
PlacementStatusHealth2["STOPPING"] = "stopping";
|
|
835
|
+
PlacementStatusHealth2["RUNNING"] = "running";
|
|
836
|
+
PlacementStatusHealth2["FAILED"] = "failed";
|
|
837
|
+
PlacementStatusHealth2["STOPPED"] = "stopped";
|
|
838
|
+
PlacementStatusHealth2["UNHEALTHY"] = "unhealthy";
|
|
839
|
+
return PlacementStatusHealth2;
|
|
840
|
+
})(PlacementStatusHealth || {});
|
|
841
|
+
|
|
842
|
+
// src/client/models/ProvisionerConfiguration.ts
|
|
843
|
+
var ProvisionerConfiguration;
|
|
844
|
+
((ProvisionerConfiguration2) => {
|
|
845
|
+
((type2) => {
|
|
846
|
+
type2["NONE"] = "none";
|
|
847
|
+
type2["CLOUDINIT"] = "cloudinit";
|
|
848
|
+
})(ProvisionerConfiguration2.type || (ProvisionerConfiguration2.type = {}));
|
|
849
|
+
})(ProvisionerConfiguration || (ProvisionerConfiguration = {}));
|
|
850
|
+
|
|
851
|
+
// src/client/models/RolloutStep.ts
|
|
852
|
+
var RolloutStep;
|
|
853
|
+
((RolloutStep2) => {
|
|
854
|
+
((status2) => {
|
|
855
|
+
status2["PENDING"] = "pending";
|
|
856
|
+
status2["PROGRESSING"] = "progressing";
|
|
857
|
+
status2["REVERTING"] = "reverting";
|
|
858
|
+
status2["COMPLETED"] = "completed";
|
|
859
|
+
status2["REVERTED"] = "reverted";
|
|
860
|
+
})(RolloutStep2.status || (RolloutStep2.status = {}));
|
|
861
|
+
})(RolloutStep || (RolloutStep = {}));
|
|
862
|
+
|
|
863
|
+
// src/client/models/SchedulingPolicy.ts
|
|
864
|
+
var SchedulingPolicy = /* @__PURE__ */ ((SchedulingPolicy2) => {
|
|
865
|
+
SchedulingPolicy2["DURABLE_OBJECT"] = "durable_object";
|
|
866
|
+
SchedulingPolicy2["MOON"] = "moon";
|
|
867
|
+
SchedulingPolicy2["GPU"] = "gpu";
|
|
868
|
+
SchedulingPolicy2["REGIONAL"] = "regional";
|
|
869
|
+
SchedulingPolicy2["FILL_METALS"] = "fill_metals";
|
|
870
|
+
SchedulingPolicy2["DEFAULT"] = "default";
|
|
871
|
+
return SchedulingPolicy2;
|
|
872
|
+
})(SchedulingPolicy || {});
|
|
873
|
+
|
|
874
|
+
// src/client/models/SecretAccessType.ts
|
|
875
|
+
var SecretAccessType = /* @__PURE__ */ ((SecretAccessType2) => {
|
|
876
|
+
SecretAccessType2["ENV"] = "env";
|
|
877
|
+
return SecretAccessType2;
|
|
878
|
+
})(SecretAccessType || {});
|
|
879
|
+
|
|
880
|
+
// src/client/models/SecretNameAlreadyExists.ts
|
|
881
|
+
var SecretNameAlreadyExists;
|
|
882
|
+
((SecretNameAlreadyExists2) => {
|
|
883
|
+
((error2) => {
|
|
884
|
+
error2["SECRET_NAME_ALREADY_EXISTS"] = "SECRET_NAME_ALREADY_EXISTS";
|
|
885
|
+
})(SecretNameAlreadyExists2.error || (SecretNameAlreadyExists2.error = {}));
|
|
886
|
+
})(SecretNameAlreadyExists || (SecretNameAlreadyExists = {}));
|
|
887
|
+
|
|
888
|
+
// src/client/models/SecretNotFound.ts
|
|
889
|
+
var SecretNotFound;
|
|
890
|
+
((SecretNotFound2) => {
|
|
891
|
+
((error2) => {
|
|
892
|
+
error2["SECRET_NAME_NOT_FOUND"] = "SECRET_NAME_NOT_FOUND";
|
|
893
|
+
})(SecretNotFound2.error || (SecretNotFound2.error = {}));
|
|
894
|
+
})(SecretNotFound || (SecretNotFound = {}));
|
|
895
|
+
|
|
896
|
+
// src/client/models/SSHPublicKeyNotFoundError.ts
|
|
897
|
+
var SSHPublicKeyNotFoundError;
|
|
898
|
+
((SSHPublicKeyNotFoundError2) => {
|
|
899
|
+
((error2) => {
|
|
900
|
+
error2["SSH_PUBLIC_KEY_NOT_FOUND"] = "SSH_PUBLIC_KEY_NOT_FOUND";
|
|
901
|
+
})(SSHPublicKeyNotFoundError2.error || (SSHPublicKeyNotFoundError2.error = {}));
|
|
902
|
+
})(SSHPublicKeyNotFoundError || (SSHPublicKeyNotFoundError = {}));
|
|
903
|
+
|
|
904
|
+
// src/client/models/UpdateApplicationRolloutRequest.ts
|
|
905
|
+
var UpdateApplicationRolloutRequest;
|
|
906
|
+
((UpdateApplicationRolloutRequest2) => {
|
|
907
|
+
((action2) => {
|
|
908
|
+
action2["NEXT"] = "next";
|
|
909
|
+
action2["PREVIOUS"] = "previous";
|
|
910
|
+
action2["REVERT"] = "revert";
|
|
911
|
+
})(UpdateApplicationRolloutRequest2.action || (UpdateApplicationRolloutRequest2.action = {}));
|
|
912
|
+
})(UpdateApplicationRolloutRequest || (UpdateApplicationRolloutRequest = {}));
|
|
913
|
+
|
|
914
|
+
// src/client/services/AccountService.ts
|
|
915
|
+
var AccountService = class {
|
|
916
|
+
static {
|
|
917
|
+
__name(this, "AccountService");
|
|
918
|
+
}
|
|
919
|
+
/**
|
|
920
|
+
* Get complete account details related to Cloudchamber
|
|
921
|
+
* Get complete account details related to Cloudchamber, like limits and available locations
|
|
922
|
+
* @returns CompleteAccountCustomer Complete account for the user
|
|
923
|
+
* @throws ApiError
|
|
924
|
+
*/
|
|
925
|
+
static getMe() {
|
|
926
|
+
return request(OpenAPI, {
|
|
927
|
+
method: "GET",
|
|
928
|
+
url: "/me",
|
|
929
|
+
errors: {
|
|
930
|
+
401: `Unauthorized`,
|
|
931
|
+
500: `There has been an internal error`
|
|
932
|
+
}
|
|
933
|
+
});
|
|
934
|
+
}
|
|
935
|
+
/**
|
|
936
|
+
* Modify account details like defaults
|
|
937
|
+
* Modify account details like defaults
|
|
938
|
+
* @param requestBody
|
|
939
|
+
* @returns CompleteAccountCustomer Complete account for the user
|
|
940
|
+
* @throws ApiError
|
|
941
|
+
*/
|
|
942
|
+
static modifyMe(requestBody) {
|
|
943
|
+
return request(OpenAPI, {
|
|
944
|
+
method: "PATCH",
|
|
945
|
+
url: "/me",
|
|
946
|
+
body: requestBody,
|
|
947
|
+
mediaType: "application/json",
|
|
948
|
+
errors: {
|
|
949
|
+
400: `Bad Request that contains a specific constant code and details object about the error.`,
|
|
950
|
+
401: `Unauthorized`,
|
|
951
|
+
500: `There has been an internal error`
|
|
952
|
+
}
|
|
953
|
+
});
|
|
954
|
+
}
|
|
955
|
+
};
|
|
956
|
+
|
|
957
|
+
// src/client/services/ApplicationsService.ts
|
|
958
|
+
var ApplicationsService = class {
|
|
959
|
+
static {
|
|
960
|
+
__name(this, "ApplicationsService");
|
|
961
|
+
}
|
|
962
|
+
/**
|
|
963
|
+
* Create a new application
|
|
964
|
+
* Create a new application. An Application represents an intent to run one or more containers, with the same image, dynamically scheduled based on constraints
|
|
965
|
+
* @param requestBody
|
|
966
|
+
* @returns Application A newly created application
|
|
967
|
+
* @throws ApiError
|
|
968
|
+
*/
|
|
969
|
+
static createApplication(requestBody) {
|
|
970
|
+
return request(OpenAPI, {
|
|
971
|
+
method: "POST",
|
|
972
|
+
url: "/applications",
|
|
973
|
+
body: requestBody,
|
|
974
|
+
mediaType: "application/json",
|
|
975
|
+
errors: {
|
|
976
|
+
400: `Could not create the application because of input/limits reasons, more details in the error code`,
|
|
977
|
+
401: `Unauthorized`,
|
|
978
|
+
500: `There has been an internal error`
|
|
979
|
+
}
|
|
980
|
+
});
|
|
981
|
+
}
|
|
982
|
+
/**
|
|
983
|
+
* List Applications associated with your account
|
|
984
|
+
* Lists all the applications that are associated with your account
|
|
985
|
+
* @param name Filter applications by name
|
|
986
|
+
* @param image Filter applications by image
|
|
987
|
+
* @param label Filter applications by label
|
|
988
|
+
* @returns ListApplications Get all application associated with your account
|
|
989
|
+
* @throws ApiError
|
|
990
|
+
*/
|
|
991
|
+
static listApplications(name, image, label) {
|
|
992
|
+
return request(OpenAPI, {
|
|
993
|
+
method: "GET",
|
|
994
|
+
url: "/applications",
|
|
995
|
+
query: {
|
|
996
|
+
name,
|
|
997
|
+
image,
|
|
998
|
+
label
|
|
999
|
+
},
|
|
1000
|
+
errors: {
|
|
1001
|
+
401: `Unauthorized`,
|
|
1002
|
+
500: `There has been an internal error`
|
|
1003
|
+
}
|
|
1004
|
+
});
|
|
1005
|
+
}
|
|
1006
|
+
/**
|
|
1007
|
+
* Get a single application by id
|
|
1008
|
+
* Returns a single application by id
|
|
1009
|
+
* @param applicationId
|
|
1010
|
+
* @returns Application A single application
|
|
1011
|
+
* @throws ApiError
|
|
1012
|
+
*/
|
|
1013
|
+
static getApplication(applicationId) {
|
|
1014
|
+
return request(OpenAPI, {
|
|
1015
|
+
method: "GET",
|
|
1016
|
+
url: "/applications/{application_id}",
|
|
1017
|
+
path: {
|
|
1018
|
+
application_id: applicationId
|
|
1019
|
+
},
|
|
1020
|
+
errors: {
|
|
1021
|
+
401: `Unauthorized`,
|
|
1022
|
+
404: `Response body when an Application is not found`,
|
|
1023
|
+
500: `There has been an internal error`
|
|
1024
|
+
}
|
|
1025
|
+
});
|
|
1026
|
+
}
|
|
1027
|
+
/**
|
|
1028
|
+
* Modify an application
|
|
1029
|
+
* Modifies a single application by id.
|
|
1030
|
+
* @param applicationId
|
|
1031
|
+
* @param requestBody
|
|
1032
|
+
* @returns Application Modify application response
|
|
1033
|
+
* @throws ApiError
|
|
1034
|
+
*/
|
|
1035
|
+
static modifyApplication(applicationId, requestBody) {
|
|
1036
|
+
return request(OpenAPI, {
|
|
1037
|
+
method: "PATCH",
|
|
1038
|
+
url: "/applications/{application_id}",
|
|
1039
|
+
path: {
|
|
1040
|
+
application_id: applicationId
|
|
1041
|
+
},
|
|
1042
|
+
body: requestBody,
|
|
1043
|
+
mediaType: "application/json",
|
|
1044
|
+
errors: {
|
|
1045
|
+
400: `Could not modify the application because of input/limits reasons, more details in the error code`,
|
|
1046
|
+
401: `Unauthorized`,
|
|
1047
|
+
404: `Response body when an Application is not found`,
|
|
1048
|
+
500: `There has been an internal error`
|
|
1049
|
+
}
|
|
1050
|
+
});
|
|
1051
|
+
}
|
|
1052
|
+
/**
|
|
1053
|
+
* Delete a single application by id
|
|
1054
|
+
* Deletes a single application by id
|
|
1055
|
+
* @param applicationId
|
|
1056
|
+
* @returns EmptyResponse Delete application response
|
|
1057
|
+
* @throws ApiError
|
|
1058
|
+
*/
|
|
1059
|
+
static deleteApplication(applicationId) {
|
|
1060
|
+
return request(OpenAPI, {
|
|
1061
|
+
method: "DELETE",
|
|
1062
|
+
url: "/applications/{application_id}",
|
|
1063
|
+
path: {
|
|
1064
|
+
application_id: applicationId
|
|
1065
|
+
},
|
|
1066
|
+
errors: {
|
|
1067
|
+
401: `Unauthorized`,
|
|
1068
|
+
404: `Response body when an Application is not found`,
|
|
1069
|
+
500: `There has been an internal error`
|
|
1070
|
+
}
|
|
1071
|
+
});
|
|
1072
|
+
}
|
|
1073
|
+
/**
|
|
1074
|
+
* Application queue status
|
|
1075
|
+
* Get an application's queue status. Only works under an application with type jobs.
|
|
1076
|
+
* @param applicationId
|
|
1077
|
+
* @returns ApplicationStatus Application status with details about the job queue, instances and other metadata for introspection.
|
|
1078
|
+
* @throws ApiError
|
|
1079
|
+
*/
|
|
1080
|
+
static getApplicationStatus(applicationId) {
|
|
1081
|
+
return request(OpenAPI, {
|
|
1082
|
+
method: "GET",
|
|
1083
|
+
url: "/applications/{application_id}/status",
|
|
1084
|
+
path: {
|
|
1085
|
+
application_id: applicationId
|
|
1086
|
+
},
|
|
1087
|
+
errors: {
|
|
1088
|
+
401: `Unauthorized`,
|
|
1089
|
+
404: `Response body when an Application is not found`,
|
|
1090
|
+
500: `There has been an internal error`
|
|
1091
|
+
}
|
|
1092
|
+
});
|
|
1093
|
+
}
|
|
1094
|
+
/**
|
|
1095
|
+
* Create a new job within an application
|
|
1096
|
+
* Returns the created job
|
|
1097
|
+
* @param applicationId
|
|
1098
|
+
* @param requestBody
|
|
1099
|
+
* @returns ApplicationJob A single job within an application
|
|
1100
|
+
* @throws ApiError
|
|
1101
|
+
*/
|
|
1102
|
+
static createApplicationJob(applicationId, requestBody) {
|
|
1103
|
+
return request(OpenAPI, {
|
|
1104
|
+
method: "POST",
|
|
1105
|
+
url: "/applications/{application_id}/jobs",
|
|
1106
|
+
path: {
|
|
1107
|
+
application_id: applicationId
|
|
1108
|
+
},
|
|
1109
|
+
body: requestBody,
|
|
1110
|
+
mediaType: "application/json",
|
|
1111
|
+
errors: {
|
|
1112
|
+
400: `Can't create the application job because it has bad inputs`,
|
|
1113
|
+
401: `Unauthorized`,
|
|
1114
|
+
404: `Response body when an Application is not found`,
|
|
1115
|
+
500: `There has been an internal error`
|
|
1116
|
+
}
|
|
1117
|
+
});
|
|
1118
|
+
}
|
|
1119
|
+
/**
|
|
1120
|
+
* Get an application job by application and job id
|
|
1121
|
+
* Returns a single application job by id with its current status
|
|
1122
|
+
* @param applicationId
|
|
1123
|
+
* @param jobId
|
|
1124
|
+
* @returns ApplicationJob A single application
|
|
1125
|
+
* @throws ApiError
|
|
1126
|
+
*/
|
|
1127
|
+
static getApplicationJob(applicationId, jobId) {
|
|
1128
|
+
return request(OpenAPI, {
|
|
1129
|
+
method: "GET",
|
|
1130
|
+
url: "/applications/{application_id}/jobs/{job_id}",
|
|
1131
|
+
path: {
|
|
1132
|
+
application_id: applicationId,
|
|
1133
|
+
job_id: jobId
|
|
1134
|
+
},
|
|
1135
|
+
errors: {
|
|
1136
|
+
401: `Unauthorized`,
|
|
1137
|
+
404: `Response body when an Application/Job is not found`,
|
|
1138
|
+
500: `There has been an internal error`
|
|
1139
|
+
}
|
|
1140
|
+
});
|
|
1141
|
+
}
|
|
1142
|
+
/**
|
|
1143
|
+
* Delete an application job by application and job id
|
|
1144
|
+
* Cleans up the specific job from the Application and all its assoicated resources
|
|
1145
|
+
* @param applicationId
|
|
1146
|
+
* @param jobId
|
|
1147
|
+
* @returns GenericMessageResponse Generic OK response
|
|
1148
|
+
* @throws ApiError
|
|
1149
|
+
*/
|
|
1150
|
+
static deleteApplicationJob(applicationId, jobId) {
|
|
1151
|
+
return request(OpenAPI, {
|
|
1152
|
+
method: "DELETE",
|
|
1153
|
+
url: "/applications/{application_id}/jobs/{job_id}",
|
|
1154
|
+
path: {
|
|
1155
|
+
application_id: applicationId,
|
|
1156
|
+
job_id: jobId
|
|
1157
|
+
},
|
|
1158
|
+
errors: {
|
|
1159
|
+
401: `Unauthorized`,
|
|
1160
|
+
404: `Response body when an Application/Job is not found`,
|
|
1161
|
+
500: `There has been an internal error`
|
|
1162
|
+
}
|
|
1163
|
+
});
|
|
1164
|
+
}
|
|
1165
|
+
/**
|
|
1166
|
+
* Modify an existing application job
|
|
1167
|
+
* Modify an application job state
|
|
1168
|
+
* @param applicationId
|
|
1169
|
+
* @param jobId
|
|
1170
|
+
* @param requestBody
|
|
1171
|
+
* @returns ApplicationJob A modified job within an application
|
|
1172
|
+
* @throws ApiError
|
|
1173
|
+
*/
|
|
1174
|
+
static modifyApplicationJob(applicationId, jobId, requestBody) {
|
|
1175
|
+
return request(OpenAPI, {
|
|
1176
|
+
method: "PATCH",
|
|
1177
|
+
url: "/applications/{application_id}/jobs/{job_id}",
|
|
1178
|
+
path: {
|
|
1179
|
+
application_id: applicationId,
|
|
1180
|
+
job_id: jobId
|
|
1181
|
+
},
|
|
1182
|
+
body: requestBody,
|
|
1183
|
+
mediaType: "application/json",
|
|
1184
|
+
errors: {
|
|
1185
|
+
400: `Can't modify the application job because it has bad inputs`,
|
|
1186
|
+
401: `Unauthorized`,
|
|
1187
|
+
404: `Response body when an Application/Job is not found`,
|
|
1188
|
+
500: `There has been an internal error`
|
|
1189
|
+
}
|
|
1190
|
+
});
|
|
1191
|
+
}
|
|
1192
|
+
/**
|
|
1193
|
+
* Create a new rollout for an application
|
|
1194
|
+
* A rollout can be used to update the application's configuration across instances with minimal downtime.
|
|
1195
|
+
* @param applicationId
|
|
1196
|
+
* @param requestBody
|
|
1197
|
+
* @returns ApplicationRollout
|
|
1198
|
+
* @throws ApiError
|
|
1199
|
+
*/
|
|
1200
|
+
static createApplicationRollout(applicationId, requestBody) {
|
|
1201
|
+
return request(OpenAPI, {
|
|
1202
|
+
method: "POST",
|
|
1203
|
+
url: "/applications/{application_id}/rollouts",
|
|
1204
|
+
path: {
|
|
1205
|
+
application_id: applicationId
|
|
1206
|
+
},
|
|
1207
|
+
body: requestBody,
|
|
1208
|
+
mediaType: "application/json",
|
|
1209
|
+
errors: {
|
|
1210
|
+
400: `Can't update the application rollout because it has bad inputs`,
|
|
1211
|
+
401: `Unauthorized`,
|
|
1212
|
+
404: `Response body when an Application is not found`,
|
|
1213
|
+
500: `There has been an internal error`
|
|
1214
|
+
}
|
|
1215
|
+
});
|
|
1216
|
+
}
|
|
1217
|
+
/**
|
|
1218
|
+
* List rollouts
|
|
1219
|
+
* List all rollouts within an application
|
|
1220
|
+
* @param applicationId
|
|
1221
|
+
* @param limit The amount of rollouts to return. By default it is all of them.
|
|
1222
|
+
* @param last The last rollout that was used to paginate
|
|
1223
|
+
* @returns ApplicationRollout
|
|
1224
|
+
* @throws ApiError
|
|
1225
|
+
*/
|
|
1226
|
+
static listApplicationRollouts(applicationId, limit, last) {
|
|
1227
|
+
return request(OpenAPI, {
|
|
1228
|
+
method: "GET",
|
|
1229
|
+
url: "/applications/{application_id}/rollouts",
|
|
1230
|
+
path: {
|
|
1231
|
+
application_id: applicationId
|
|
1232
|
+
},
|
|
1233
|
+
query: {
|
|
1234
|
+
limit,
|
|
1235
|
+
last
|
|
1236
|
+
},
|
|
1237
|
+
errors: {
|
|
1238
|
+
401: `Unauthorized`,
|
|
1239
|
+
404: `Response body when an Application is not found`,
|
|
1240
|
+
500: `There has been an internal error`
|
|
1241
|
+
}
|
|
1242
|
+
});
|
|
1243
|
+
}
|
|
1244
|
+
/**
|
|
1245
|
+
* Get a rollout by id within an application
|
|
1246
|
+
* View rollout configurations and state for a specific rollout
|
|
1247
|
+
* @param applicationId
|
|
1248
|
+
* @param rolloutId
|
|
1249
|
+
* @returns ApplicationRollout
|
|
1250
|
+
* @throws ApiError
|
|
1251
|
+
*/
|
|
1252
|
+
static getApplicationRollout(applicationId, rolloutId) {
|
|
1253
|
+
return request(OpenAPI, {
|
|
1254
|
+
method: "GET",
|
|
1255
|
+
url: "/applications/{application_id}/rollouts/{rollout_id}",
|
|
1256
|
+
path: {
|
|
1257
|
+
application_id: applicationId,
|
|
1258
|
+
rollout_id: rolloutId
|
|
1259
|
+
},
|
|
1260
|
+
errors: {
|
|
1261
|
+
401: `Unauthorized`,
|
|
1262
|
+
404: `Response body when an Application is not found`,
|
|
1263
|
+
500: `There has been an internal error`
|
|
1264
|
+
}
|
|
1265
|
+
});
|
|
1266
|
+
}
|
|
1267
|
+
/**
|
|
1268
|
+
* Update a rollout within an application
|
|
1269
|
+
* A rollout can be updated to modify its current state. Actions include - next, previous, rollback
|
|
1270
|
+
* @param applicationId
|
|
1271
|
+
* @param rolloutId
|
|
1272
|
+
* @param requestBody
|
|
1273
|
+
* @returns UpdateRolloutResponse
|
|
1274
|
+
* @throws ApiError
|
|
1275
|
+
*/
|
|
1276
|
+
static updateApplicationRollout(applicationId, rolloutId, requestBody) {
|
|
1277
|
+
return request(OpenAPI, {
|
|
1278
|
+
method: "POST",
|
|
1279
|
+
url: "/applications/{application_id}/rollouts/{rollout_id}",
|
|
1280
|
+
path: {
|
|
1281
|
+
application_id: applicationId,
|
|
1282
|
+
rollout_id: rolloutId
|
|
1283
|
+
},
|
|
1284
|
+
body: requestBody,
|
|
1285
|
+
mediaType: "application/json",
|
|
1286
|
+
errors: {
|
|
1287
|
+
400: `Can't create the application rollout because it has bad inputs`,
|
|
1288
|
+
401: `Unauthorized`,
|
|
1289
|
+
404: `Response body when an Application is not found`,
|
|
1290
|
+
500: `There has been an internal error`
|
|
1291
|
+
}
|
|
1292
|
+
});
|
|
1293
|
+
}
|
|
1294
|
+
/**
|
|
1295
|
+
* Delete a rollout within an application by its rollout id
|
|
1296
|
+
* Cleans up the specific rollout from the Application if it is not in use
|
|
1297
|
+
* @param applicationId
|
|
1298
|
+
* @param rolloutId
|
|
1299
|
+
* @returns EmptyResponse
|
|
1300
|
+
* @throws ApiError
|
|
1301
|
+
*/
|
|
1302
|
+
static deleteApplicationRollout(applicationId, rolloutId) {
|
|
1303
|
+
return request(OpenAPI, {
|
|
1304
|
+
method: "DELETE",
|
|
1305
|
+
url: "/applications/{application_id}/rollouts/{rollout_id}",
|
|
1306
|
+
path: {
|
|
1307
|
+
application_id: applicationId,
|
|
1308
|
+
rollout_id: rolloutId
|
|
1309
|
+
},
|
|
1310
|
+
errors: {
|
|
1311
|
+
401: `Unauthorized`,
|
|
1312
|
+
404: `Response body when an Application is not found`,
|
|
1313
|
+
500: `There has been an internal error`
|
|
1314
|
+
}
|
|
1315
|
+
});
|
|
1316
|
+
}
|
|
1317
|
+
/**
|
|
1318
|
+
* Get a single applications deployments
|
|
1319
|
+
* Returns a single applications deployments
|
|
1320
|
+
* @param applicationId
|
|
1321
|
+
* @returns ListDeploymentsV2 List of deployments with their corresponding placements
|
|
1322
|
+
* @throws ApiError
|
|
1323
|
+
*/
|
|
1324
|
+
static listDeploymentsByApplication(applicationId) {
|
|
1325
|
+
return request(OpenAPI, {
|
|
1326
|
+
method: "GET",
|
|
1327
|
+
url: "/applications/{application_id}/deployments",
|
|
1328
|
+
path: {
|
|
1329
|
+
application_id: applicationId
|
|
1330
|
+
},
|
|
1331
|
+
errors: {
|
|
1332
|
+
401: `Unauthorized`,
|
|
1333
|
+
404: `Response body when an Application is not found`,
|
|
1334
|
+
500: `There has been an internal error`
|
|
1335
|
+
}
|
|
1336
|
+
});
|
|
1337
|
+
}
|
|
1338
|
+
/**
|
|
1339
|
+
* Get a specific deployment within an application
|
|
1340
|
+
* Get a deployment by its app and deployment IDs
|
|
1341
|
+
* @param applicationId
|
|
1342
|
+
* @param deploymentId
|
|
1343
|
+
* @returns DeploymentV2 Get a specific deployment along with its respective placements
|
|
1344
|
+
* @throws ApiError
|
|
1345
|
+
*/
|
|
1346
|
+
static getApplicationsV3Deployment(applicationId, deploymentId) {
|
|
1347
|
+
return request(OpenAPI, {
|
|
1348
|
+
method: "GET",
|
|
1349
|
+
url: "/applications/{application_id}/deployments/{deployment_id}",
|
|
1350
|
+
path: {
|
|
1351
|
+
application_id: applicationId,
|
|
1352
|
+
deployment_id: deploymentId
|
|
1353
|
+
},
|
|
1354
|
+
errors: {
|
|
1355
|
+
400: `Unknown account`,
|
|
1356
|
+
401: `Unauthorized`,
|
|
1357
|
+
404: `Deployment not found`,
|
|
1358
|
+
500: `Deployment Get Error`
|
|
1359
|
+
}
|
|
1360
|
+
});
|
|
1361
|
+
}
|
|
1362
|
+
/**
|
|
1363
|
+
* Recreate an existing deployment within an application.
|
|
1364
|
+
* The given existing deployment is deleted and a replacement deployment is created. The latter retains some properties of the former that cannot be set by the client.
|
|
1365
|
+
*
|
|
1366
|
+
* @param applicationId
|
|
1367
|
+
* @param deploymentId
|
|
1368
|
+
* @param requestBody
|
|
1369
|
+
* @returns DeploymentV2 Deployment created
|
|
1370
|
+
* @throws ApiError
|
|
1371
|
+
*/
|
|
1372
|
+
static recreateDeploymentV3(applicationId, deploymentId, requestBody) {
|
|
1373
|
+
return request(OpenAPI, {
|
|
1374
|
+
method: "POST",
|
|
1375
|
+
url: "/applications/{application_id}/deployments/{deployment_id}/recreate",
|
|
1376
|
+
path: {
|
|
1377
|
+
application_id: applicationId,
|
|
1378
|
+
deployment_id: deploymentId
|
|
1379
|
+
},
|
|
1380
|
+
body: requestBody,
|
|
1381
|
+
mediaType: "application/json",
|
|
1382
|
+
errors: {
|
|
1383
|
+
400: `Could not create the deployment because of input/limits reasons, more details in the error code`,
|
|
1384
|
+
401: `Unauthorized`,
|
|
1385
|
+
404: `Deployment not found`,
|
|
1386
|
+
500: `Deployment Creation Error`
|
|
1387
|
+
}
|
|
1388
|
+
});
|
|
1389
|
+
}
|
|
1390
|
+
/**
|
|
1391
|
+
* List container applications with pagination (Dash endpoint)
|
|
1392
|
+
* Returns summary application data suitable for list display
|
|
1393
|
+
* @param perPage Number of results per page
|
|
1394
|
+
* @param pageToken Token for fetching the next page
|
|
1395
|
+
* @returns PaginatedResult<DashApplication[]> Paginated list of applications
|
|
1396
|
+
* @throws ApiError
|
|
1397
|
+
*/
|
|
1398
|
+
static listDashApplications(perPage, pageToken) {
|
|
1399
|
+
return requestPaginated(OpenAPI, {
|
|
1400
|
+
method: "GET",
|
|
1401
|
+
url: "/dash/applications",
|
|
1402
|
+
query: {
|
|
1403
|
+
per_page: perPage,
|
|
1404
|
+
page_token: pageToken
|
|
1405
|
+
},
|
|
1406
|
+
errors: {
|
|
1407
|
+
401: `Unauthorized`,
|
|
1408
|
+
404: `Not found`,
|
|
1409
|
+
500: `There has been an internal error`
|
|
1410
|
+
}
|
|
1411
|
+
});
|
|
1412
|
+
}
|
|
1413
|
+
/**
|
|
1414
|
+
* List container instances for a given application
|
|
1415
|
+
* Returns instances and optional durable object instances with pagination support
|
|
1416
|
+
* @param applicationId
|
|
1417
|
+
* @param perPage Number of results per page
|
|
1418
|
+
* @param pageToken Token for fetching the next page
|
|
1419
|
+
* @returns PaginatedResult<DashApplicationInstances> Paginated list of instances
|
|
1420
|
+
* @throws ApiError
|
|
1421
|
+
*/
|
|
1422
|
+
static listDashApplicationInstances(applicationId, perPage, pageToken) {
|
|
1423
|
+
return requestPaginated(OpenAPI, {
|
|
1424
|
+
method: "GET",
|
|
1425
|
+
url: "/dash/applications/{application_id}/instances",
|
|
1426
|
+
path: {
|
|
1427
|
+
application_id: applicationId
|
|
1428
|
+
},
|
|
1429
|
+
query: {
|
|
1430
|
+
per_page: perPage,
|
|
1431
|
+
page_token: pageToken
|
|
1432
|
+
},
|
|
1433
|
+
errors: {
|
|
1434
|
+
401: `Unauthorized`,
|
|
1435
|
+
404: `Application not found`,
|
|
1436
|
+
500: `Internal error`
|
|
1437
|
+
}
|
|
1438
|
+
});
|
|
1439
|
+
}
|
|
1440
|
+
};
|
|
1441
|
+
|
|
1442
|
+
// src/client/services/ContainerImagePreparationsService.ts
|
|
1443
|
+
var ContainerImagePreparationsService = class {
|
|
1444
|
+
static {
|
|
1445
|
+
__name(this, "ContainerImagePreparationsService");
|
|
1446
|
+
}
|
|
1447
|
+
/**
|
|
1448
|
+
* Prepare a digest-pinned managed image for the Containers runtime.
|
|
1449
|
+
*/
|
|
1450
|
+
static prepareContainerImage(requestBody) {
|
|
1451
|
+
return request(OpenAPI, {
|
|
1452
|
+
method: "POST",
|
|
1453
|
+
url: "/image-preparations",
|
|
1454
|
+
body: requestBody,
|
|
1455
|
+
mediaType: "application/json",
|
|
1456
|
+
errors: {
|
|
1457
|
+
400: `The image is invalid or does not exist in this account`,
|
|
1458
|
+
401: `Unauthorized`,
|
|
1459
|
+
403: `Container image preparation is not enabled for this account`,
|
|
1460
|
+
500: `There has been an internal error`
|
|
1461
|
+
}
|
|
1462
|
+
});
|
|
1463
|
+
}
|
|
1464
|
+
};
|
|
1465
|
+
|
|
1466
|
+
// src/client/services/DeploymentsService.ts
|
|
1467
|
+
var DeploymentsService = class {
|
|
1468
|
+
static {
|
|
1469
|
+
__name(this, "DeploymentsService");
|
|
1470
|
+
}
|
|
1471
|
+
/**
|
|
1472
|
+
* Get a specific deployment within an application
|
|
1473
|
+
* Get a deployment by its app and deployment IDs
|
|
1474
|
+
* @param applicationId
|
|
1475
|
+
* @param deploymentId
|
|
1476
|
+
* @returns DeploymentV2 Get a specific deployment along with its respective placements
|
|
1477
|
+
* @throws ApiError
|
|
1478
|
+
*/
|
|
1479
|
+
static getApplicationsV3Deployment(applicationId, deploymentId) {
|
|
1480
|
+
return request(OpenAPI, {
|
|
1481
|
+
method: "GET",
|
|
1482
|
+
url: "/applications/{application_id}/deployments/{deployment_id}",
|
|
1483
|
+
path: {
|
|
1484
|
+
application_id: applicationId,
|
|
1485
|
+
deployment_id: deploymentId
|
|
1486
|
+
},
|
|
1487
|
+
errors: {
|
|
1488
|
+
400: `Unknown account`,
|
|
1489
|
+
401: `Unauthorized`,
|
|
1490
|
+
404: `Deployment not found`,
|
|
1491
|
+
500: `Deployment Get Error`
|
|
1492
|
+
}
|
|
1493
|
+
});
|
|
1494
|
+
}
|
|
1495
|
+
/**
|
|
1496
|
+
* Recreate an existing deployment within an application.
|
|
1497
|
+
* The given existing deployment is deleted and a replacement deployment is created. The latter retains some properties of the former that cannot be set by the client.
|
|
1498
|
+
*
|
|
1499
|
+
* @param applicationId
|
|
1500
|
+
* @param deploymentId
|
|
1501
|
+
* @param requestBody
|
|
1502
|
+
* @returns DeploymentV2 Deployment created
|
|
1503
|
+
* @throws ApiError
|
|
1504
|
+
*/
|
|
1505
|
+
static recreateDeploymentV3(applicationId, deploymentId, requestBody) {
|
|
1506
|
+
return request(OpenAPI, {
|
|
1507
|
+
method: "POST",
|
|
1508
|
+
url: "/applications/{application_id}/deployments/{deployment_id}/recreate",
|
|
1509
|
+
path: {
|
|
1510
|
+
application_id: applicationId,
|
|
1511
|
+
deployment_id: deploymentId
|
|
1512
|
+
},
|
|
1513
|
+
body: requestBody,
|
|
1514
|
+
mediaType: "application/json",
|
|
1515
|
+
errors: {
|
|
1516
|
+
400: `Could not create the deployment because of input/limits reasons, more details in the error code`,
|
|
1517
|
+
401: `Unauthorized`,
|
|
1518
|
+
404: `Deployment not found`,
|
|
1519
|
+
500: `Deployment Creation Error`
|
|
1520
|
+
}
|
|
1521
|
+
});
|
|
1522
|
+
}
|
|
1523
|
+
/**
|
|
1524
|
+
* Get credentials to SSH into a Container
|
|
1525
|
+
* Get a JWT to hit the SSH port on a given container.
|
|
1526
|
+
* @param instanceId
|
|
1527
|
+
* @returns WranglerSSHResponse Credentials to SSH into a Container
|
|
1528
|
+
* @throws ApiError
|
|
1529
|
+
*/
|
|
1530
|
+
static containerWranglerSsh(instanceId) {
|
|
1531
|
+
return request(OpenAPI, {
|
|
1532
|
+
method: "GET",
|
|
1533
|
+
url: "/instances/{instance_id}/ssh",
|
|
1534
|
+
path: {
|
|
1535
|
+
instance_id: instanceId
|
|
1536
|
+
},
|
|
1537
|
+
errors: {
|
|
1538
|
+
400: `Unknown account`,
|
|
1539
|
+
401: `Unauthorized`,
|
|
1540
|
+
404: `Deployment not found`,
|
|
1541
|
+
500: `There has been an internal error`
|
|
1542
|
+
}
|
|
1543
|
+
});
|
|
1544
|
+
}
|
|
1545
|
+
/**
|
|
1546
|
+
* Create a new deployment
|
|
1547
|
+
* Creates a new deployment. A Deployment represents an intent to run one container, with image, in a particular location
|
|
1548
|
+
* @param requestBody
|
|
1549
|
+
* @returns DeploymentV2 Deployment created
|
|
1550
|
+
* @throws ApiError
|
|
1551
|
+
*/
|
|
1552
|
+
static createDeploymentV2(requestBody) {
|
|
1553
|
+
return request(OpenAPI, {
|
|
1554
|
+
method: "POST",
|
|
1555
|
+
url: "/deployments/v2",
|
|
1556
|
+
body: requestBody,
|
|
1557
|
+
mediaType: "application/json",
|
|
1558
|
+
errors: {
|
|
1559
|
+
400: `Could not create the deployment because of input/limits reasons, more details in the error code`,
|
|
1560
|
+
401: `Unauthorized`,
|
|
1561
|
+
409: `Deployment already exists`,
|
|
1562
|
+
500: `Deployment Creation Error`
|
|
1563
|
+
}
|
|
1564
|
+
});
|
|
1565
|
+
}
|
|
1566
|
+
/**
|
|
1567
|
+
* List deployments
|
|
1568
|
+
* List all deployments in the current account. Optionally filter them
|
|
1569
|
+
* @param appId Filter deployments by application id
|
|
1570
|
+
* @param location Filter deployments by location
|
|
1571
|
+
* @param image Filter deployments by image
|
|
1572
|
+
* @param state Filter deployments by placement state
|
|
1573
|
+
* @param ipv4 Filter deployments by ipv4 address
|
|
1574
|
+
* @param label Filter deployments by label
|
|
1575
|
+
* @returns ListDeploymentsV2 List of deployments with their corresponding placements
|
|
1576
|
+
* @throws ApiError
|
|
1577
|
+
*/
|
|
1578
|
+
static listDeploymentsV2(appId, location, image, state, ipv4, label) {
|
|
1579
|
+
return request(OpenAPI, {
|
|
1580
|
+
method: "GET",
|
|
1581
|
+
url: "/deployments/v2",
|
|
1582
|
+
query: {
|
|
1583
|
+
app_id: appId,
|
|
1584
|
+
location,
|
|
1585
|
+
image,
|
|
1586
|
+
state,
|
|
1587
|
+
ipv4,
|
|
1588
|
+
label
|
|
1589
|
+
},
|
|
1590
|
+
errors: {
|
|
1591
|
+
400: `Unknown account`,
|
|
1592
|
+
401: `Unauthorized`,
|
|
1593
|
+
500: `Deployment List Error`
|
|
1594
|
+
}
|
|
1595
|
+
});
|
|
1596
|
+
}
|
|
1597
|
+
/**
|
|
1598
|
+
* Get a specific deployment
|
|
1599
|
+
* Get a deployment by its deployment
|
|
1600
|
+
* @param deploymentId
|
|
1601
|
+
* @returns DeploymentV2 Get a specific deployment along with its respective placements
|
|
1602
|
+
* @throws ApiError
|
|
1603
|
+
*/
|
|
1604
|
+
static getDeploymentV2(deploymentId) {
|
|
1605
|
+
return request(OpenAPI, {
|
|
1606
|
+
method: "GET",
|
|
1607
|
+
url: "/deployments/{deployment_id}/v2",
|
|
1608
|
+
path: {
|
|
1609
|
+
deployment_id: deploymentId
|
|
1610
|
+
},
|
|
1611
|
+
errors: {
|
|
1612
|
+
400: `Unknown account`,
|
|
1613
|
+
401: `Unauthorized`,
|
|
1614
|
+
404: `Deployment not found`,
|
|
1615
|
+
500: `Deployment Get Error`
|
|
1616
|
+
}
|
|
1617
|
+
});
|
|
1618
|
+
}
|
|
1619
|
+
/**
|
|
1620
|
+
* Modify an existing deployment
|
|
1621
|
+
* Change specific properties in an existing deployment
|
|
1622
|
+
* @param deploymentId
|
|
1623
|
+
* @param requestBody
|
|
1624
|
+
* @returns DeploymentV2 Deployment modified
|
|
1625
|
+
* @throws ApiError
|
|
1626
|
+
*/
|
|
1627
|
+
static modifyDeploymentV2(deploymentId, requestBody) {
|
|
1628
|
+
return request(OpenAPI, {
|
|
1629
|
+
method: "PATCH",
|
|
1630
|
+
url: "/deployments/{deployment_id}/v2",
|
|
1631
|
+
path: {
|
|
1632
|
+
deployment_id: deploymentId
|
|
1633
|
+
},
|
|
1634
|
+
body: requestBody,
|
|
1635
|
+
mediaType: "application/json",
|
|
1636
|
+
errors: {
|
|
1637
|
+
400: `Can't modify the deployment because it surpasses limits or it has bad input`,
|
|
1638
|
+
401: `Unauthorized`,
|
|
1639
|
+
404: `Deployment not found`,
|
|
1640
|
+
500: `Deployment Modification Error`
|
|
1641
|
+
}
|
|
1642
|
+
});
|
|
1643
|
+
}
|
|
1644
|
+
/**
|
|
1645
|
+
* Delete a specific deployment
|
|
1646
|
+
* Delete a deployment by its deployment ID
|
|
1647
|
+
* @param deploymentId
|
|
1648
|
+
* @returns EmptyResponse Delete a specific deployment along with its respective placements
|
|
1649
|
+
* @throws ApiError
|
|
1650
|
+
*/
|
|
1651
|
+
static deleteDeploymentV2(deploymentId) {
|
|
1652
|
+
return request(OpenAPI, {
|
|
1653
|
+
method: "DELETE",
|
|
1654
|
+
url: "/deployments/{deployment_id}/v2",
|
|
1655
|
+
path: {
|
|
1656
|
+
deployment_id: deploymentId
|
|
1657
|
+
},
|
|
1658
|
+
errors: {
|
|
1659
|
+
400: `Unknown account`,
|
|
1660
|
+
401: `Unauthorized`,
|
|
1661
|
+
404: `Deployment not found`,
|
|
1662
|
+
500: `Deployment Delete Error`
|
|
1663
|
+
}
|
|
1664
|
+
});
|
|
1665
|
+
}
|
|
1666
|
+
/**
|
|
1667
|
+
* Recreate an existing deployment.
|
|
1668
|
+
* The given existing deployment is deleted and a replacement deployment is created. The latter retains some properties of the former that cannot be set by the client.
|
|
1669
|
+
*
|
|
1670
|
+
* @param deploymentId
|
|
1671
|
+
* @param requestBody
|
|
1672
|
+
* @returns DeploymentV2 Deployment created
|
|
1673
|
+
* @throws ApiError
|
|
1674
|
+
*/
|
|
1675
|
+
static recreateDeployment(deploymentId, requestBody) {
|
|
1676
|
+
return request(OpenAPI, {
|
|
1677
|
+
method: "POST",
|
|
1678
|
+
url: "/deployments/{deployment_id}/recreate",
|
|
1679
|
+
path: {
|
|
1680
|
+
deployment_id: deploymentId
|
|
1681
|
+
},
|
|
1682
|
+
body: requestBody,
|
|
1683
|
+
mediaType: "application/json",
|
|
1684
|
+
errors: {
|
|
1685
|
+
400: `Could not create the deployment because of input/limits reasons, more details in the error code`,
|
|
1686
|
+
401: `Unauthorized`,
|
|
1687
|
+
404: `Deployment not found`,
|
|
1688
|
+
500: `Deployment Creation Error`
|
|
1689
|
+
}
|
|
1690
|
+
});
|
|
1691
|
+
}
|
|
1692
|
+
/**
|
|
1693
|
+
* Replace a deployment
|
|
1694
|
+
* You can stop the current placement and create a new one. The new one will have the same durable properties of the deployment, but will otherwise be like new
|
|
1695
|
+
* @param placementId
|
|
1696
|
+
* @param requestBody
|
|
1697
|
+
* @returns DeploymentV2 Deployment replaced
|
|
1698
|
+
* @throws ApiError
|
|
1699
|
+
*/
|
|
1700
|
+
static replaceDeployment(placementId, requestBody) {
|
|
1701
|
+
return request(OpenAPI, {
|
|
1702
|
+
method: "POST",
|
|
1703
|
+
url: "/placements/{placement_id}",
|
|
1704
|
+
path: {
|
|
1705
|
+
placement_id: placementId
|
|
1706
|
+
},
|
|
1707
|
+
body: requestBody,
|
|
1708
|
+
mediaType: "application/json",
|
|
1709
|
+
errors: {
|
|
1710
|
+
400: `Responses with 400 status code`,
|
|
1711
|
+
401: `Unauthorized`,
|
|
1712
|
+
404: `Placement not found`,
|
|
1713
|
+
500: `Deployment Replacement Error`
|
|
1714
|
+
}
|
|
1715
|
+
});
|
|
1716
|
+
}
|
|
1717
|
+
};
|
|
1718
|
+
|
|
1719
|
+
// src/client/services/ImageRegistriesService.ts
|
|
1720
|
+
var ImageRegistriesService = class {
|
|
1721
|
+
static {
|
|
1722
|
+
__name(this, "ImageRegistriesService");
|
|
1723
|
+
}
|
|
1724
|
+
/**
|
|
1725
|
+
* Create an image registry protocol that resolves to multiple domains.
|
|
1726
|
+
* @param requestBody
|
|
1727
|
+
* @returns ImageRegistryProtocol The image registry protocol was created
|
|
1728
|
+
* @throws ApiError
|
|
1729
|
+
*/
|
|
1730
|
+
static createImageRegistryProtocol(requestBody) {
|
|
1731
|
+
return request(OpenAPI, {
|
|
1732
|
+
method: "POST",
|
|
1733
|
+
url: "/registries/protos",
|
|
1734
|
+
body: requestBody,
|
|
1735
|
+
mediaType: "application/json",
|
|
1736
|
+
errors: {
|
|
1737
|
+
400: `Bad Request that contains a specific constant code and details object about the error.`,
|
|
1738
|
+
403: `The registry that is being added is not allowed`,
|
|
1739
|
+
409: `Image registry protocol already exists`,
|
|
1740
|
+
500: `There has been an internal error`
|
|
1741
|
+
}
|
|
1742
|
+
});
|
|
1743
|
+
}
|
|
1744
|
+
/**
|
|
1745
|
+
* List all image registry protocols.
|
|
1746
|
+
* @returns ImageRegistryProtocols The image registry protocols in the account
|
|
1747
|
+
* @throws ApiError
|
|
1748
|
+
*/
|
|
1749
|
+
static listImageRegistryProtocols() {
|
|
1750
|
+
return request(OpenAPI, {
|
|
1751
|
+
method: "GET",
|
|
1752
|
+
url: "/registries/protos",
|
|
1753
|
+
errors: {
|
|
1754
|
+
500: `There has been an internal error`
|
|
1755
|
+
}
|
|
1756
|
+
});
|
|
1757
|
+
}
|
|
1758
|
+
/**
|
|
1759
|
+
* Modify an image registry protocol. The previous list of domains will be replaced by the ones you specify in this endpoint.
|
|
1760
|
+
* @param requestBody
|
|
1761
|
+
* @returns ImageRegistryProtocol The image registry protocol was modified
|
|
1762
|
+
* @throws ApiError
|
|
1763
|
+
*/
|
|
1764
|
+
static modifyImageRegistryProtocol(requestBody) {
|
|
1765
|
+
return request(OpenAPI, {
|
|
1766
|
+
method: "PUT",
|
|
1767
|
+
url: "/registries/protos",
|
|
1768
|
+
body: requestBody,
|
|
1769
|
+
mediaType: "application/json",
|
|
1770
|
+
errors: {
|
|
1771
|
+
400: `Bad Request that contains a specific constant code and details object about the error.`,
|
|
1772
|
+
403: `The registry that is being added is not allowed`,
|
|
1773
|
+
404: `Image registry protocol doesn't exist`,
|
|
1774
|
+
500: `There has been an internal error`
|
|
1775
|
+
}
|
|
1776
|
+
});
|
|
1777
|
+
}
|
|
1778
|
+
/**
|
|
1779
|
+
* Delete an image registry protocol. Be careful, if there is deployments running referencing this protocol they won't be able to pull the image.
|
|
1780
|
+
* @param proto
|
|
1781
|
+
* @returns EmptyResponse Image registry protocol was deleted successfully
|
|
1782
|
+
* @throws ApiError
|
|
1783
|
+
*/
|
|
1784
|
+
static deleteImageRegistryProto(proto) {
|
|
1785
|
+
return request(OpenAPI, {
|
|
1786
|
+
method: "DELETE",
|
|
1787
|
+
url: "/registries/protos/{proto}",
|
|
1788
|
+
path: {
|
|
1789
|
+
proto
|
|
1790
|
+
},
|
|
1791
|
+
errors: {
|
|
1792
|
+
400: `The image registry protocol couldn't be deleted because it's referenced by a deployment or application`,
|
|
1793
|
+
404: `Image registry protocol doesn't exist`,
|
|
1794
|
+
500: `There has been an internal error`
|
|
1795
|
+
}
|
|
1796
|
+
});
|
|
1797
|
+
}
|
|
1798
|
+
/**
|
|
1799
|
+
* Get a JWT to pull from the image registry
|
|
1800
|
+
* Get a JWT to pull from the image registry specifying its domain
|
|
1801
|
+
* @param domain
|
|
1802
|
+
* @param requestBody
|
|
1803
|
+
* @returns AccountRegistryToken Credentials with 'pull' or 'push' permissions to access the registry
|
|
1804
|
+
* @throws ApiError
|
|
1805
|
+
*/
|
|
1806
|
+
static generateImageRegistryCredentials(domain, requestBody) {
|
|
1807
|
+
return request(OpenAPI, {
|
|
1808
|
+
method: "POST",
|
|
1809
|
+
url: "/registries/{domain}/credentials",
|
|
1810
|
+
path: {
|
|
1811
|
+
domain
|
|
1812
|
+
},
|
|
1813
|
+
body: requestBody,
|
|
1814
|
+
mediaType: "application/json",
|
|
1815
|
+
errors: {
|
|
1816
|
+
400: `Bad Request that contains a specific constant code and details object about the error.`,
|
|
1817
|
+
404: `The image registry does not exist`,
|
|
1818
|
+
409: `The registry was configured as public, so credentials can not be generated`,
|
|
1819
|
+
500: `There has been an internal error`
|
|
1820
|
+
}
|
|
1821
|
+
});
|
|
1822
|
+
}
|
|
1823
|
+
/**
|
|
1824
|
+
* Delete a registry from the account
|
|
1825
|
+
* Delete a registry from the account, this will make Cloudchamber unable to pull images from the registry
|
|
1826
|
+
* @param domain
|
|
1827
|
+
* @returns EmptyResponse The image registry is deleted
|
|
1828
|
+
* @throws ApiError
|
|
1829
|
+
*/
|
|
1830
|
+
static deleteImageRegistry(domain) {
|
|
1831
|
+
return request(OpenAPI, {
|
|
1832
|
+
method: "DELETE",
|
|
1833
|
+
url: "/registries/{domain}",
|
|
1834
|
+
path: {
|
|
1835
|
+
domain
|
|
1836
|
+
},
|
|
1837
|
+
errors: {
|
|
1838
|
+
404: `The image registry does not exist`,
|
|
1839
|
+
500: `There has been an internal error`
|
|
1840
|
+
}
|
|
1841
|
+
});
|
|
1842
|
+
}
|
|
1843
|
+
/**
|
|
1844
|
+
* Get the list of configured registries in the account
|
|
1845
|
+
* Get the list of configured registries in the account
|
|
1846
|
+
* @returns CustomerImageRegistry The list of registries that are added in the account
|
|
1847
|
+
* @throws ApiError
|
|
1848
|
+
*/
|
|
1849
|
+
static listImageRegistries() {
|
|
1850
|
+
return request(OpenAPI, {
|
|
1851
|
+
method: "GET",
|
|
1852
|
+
url: "/registries",
|
|
1853
|
+
errors: {
|
|
1854
|
+
500: `There has been an internal error`
|
|
1855
|
+
}
|
|
1856
|
+
});
|
|
1857
|
+
}
|
|
1858
|
+
/**
|
|
1859
|
+
* Add a new image registry configuration
|
|
1860
|
+
* Add a new image registry into your account, so then Cloudflare can pull docker images with public key JWT authentication
|
|
1861
|
+
* @param requestBody
|
|
1862
|
+
* @returns CustomerImageRegistry Created a new image registry in the account
|
|
1863
|
+
* @throws ApiError
|
|
1864
|
+
*/
|
|
1865
|
+
static createImageRegistry(requestBody) {
|
|
1866
|
+
return request(OpenAPI, {
|
|
1867
|
+
method: "POST",
|
|
1868
|
+
url: "/registries",
|
|
1869
|
+
body: requestBody,
|
|
1870
|
+
mediaType: "application/json",
|
|
1871
|
+
errors: {
|
|
1872
|
+
400: `Image registry input is malformed, see the error details`,
|
|
1873
|
+
403: `The registry that is being added is not allowed`,
|
|
1874
|
+
409: `The image registry already exists in the account`,
|
|
1875
|
+
500: `There has been an internal error`
|
|
1876
|
+
}
|
|
1877
|
+
});
|
|
1878
|
+
}
|
|
1879
|
+
};
|
|
1880
|
+
|
|
1881
|
+
// src/client/services/IPsService.ts
|
|
1882
|
+
var IPsService = class {
|
|
1883
|
+
static {
|
|
1884
|
+
__name(this, "IPsService");
|
|
1885
|
+
}
|
|
1886
|
+
/**
|
|
1887
|
+
* List IPs
|
|
1888
|
+
* List IPs
|
|
1889
|
+
* @param placementId Filter out ips that are not assigned to the specified placement, can also be known as 'alloc_id' in Nomad.
|
|
1890
|
+
* @param allocated Filter out ips that are not allocated
|
|
1891
|
+
* @param ipType Filter out ips by type
|
|
1892
|
+
* @param deploymentId Filter out by deployment ID
|
|
1893
|
+
* @returns IPAllocationsWithFilter Result of listing IPs
|
|
1894
|
+
* @throws ApiError
|
|
1895
|
+
*/
|
|
1896
|
+
static listIPs(placementId, allocated, ipType, deploymentId) {
|
|
1897
|
+
return request(OpenAPI, {
|
|
1898
|
+
method: "GET",
|
|
1899
|
+
url: "/ips",
|
|
1900
|
+
query: {
|
|
1901
|
+
placement_id: placementId,
|
|
1902
|
+
allocated,
|
|
1903
|
+
ipType,
|
|
1904
|
+
deployment_id: deploymentId
|
|
1905
|
+
},
|
|
1906
|
+
errors: {
|
|
1907
|
+
400: `Unknown account`,
|
|
1908
|
+
401: `Unauthorized`
|
|
1909
|
+
}
|
|
1910
|
+
});
|
|
1911
|
+
}
|
|
1912
|
+
};
|
|
1913
|
+
|
|
1914
|
+
// src/client/services/JobsService.ts
|
|
1915
|
+
var JobsService = class {
|
|
1916
|
+
static {
|
|
1917
|
+
__name(this, "JobsService");
|
|
1918
|
+
}
|
|
1919
|
+
/**
|
|
1920
|
+
* Application queue status
|
|
1921
|
+
* Get an application's queue status. Only works under an application with type jobs.
|
|
1922
|
+
* @param applicationId
|
|
1923
|
+
* @returns ApplicationStatus Application status with details about the job queue, instances and other metadata for introspection.
|
|
1924
|
+
* @throws ApiError
|
|
1925
|
+
*/
|
|
1926
|
+
static getApplicationStatus(applicationId) {
|
|
1927
|
+
return request(OpenAPI, {
|
|
1928
|
+
method: "GET",
|
|
1929
|
+
url: "/applications/{application_id}/status",
|
|
1930
|
+
path: {
|
|
1931
|
+
application_id: applicationId
|
|
1932
|
+
},
|
|
1933
|
+
errors: {
|
|
1934
|
+
401: `Unauthorized`,
|
|
1935
|
+
404: `Response body when an Application is not found`,
|
|
1936
|
+
500: `There has been an internal error`
|
|
1937
|
+
}
|
|
1938
|
+
});
|
|
1939
|
+
}
|
|
1940
|
+
/**
|
|
1941
|
+
* Create a new job within an application
|
|
1942
|
+
* Returns the created job
|
|
1943
|
+
* @param applicationId
|
|
1944
|
+
* @param requestBody
|
|
1945
|
+
* @returns ApplicationJob A single job within an application
|
|
1946
|
+
* @throws ApiError
|
|
1947
|
+
*/
|
|
1948
|
+
static createApplicationJob(applicationId, requestBody) {
|
|
1949
|
+
return request(OpenAPI, {
|
|
1950
|
+
method: "POST",
|
|
1951
|
+
url: "/applications/{application_id}/jobs",
|
|
1952
|
+
path: {
|
|
1953
|
+
application_id: applicationId
|
|
1954
|
+
},
|
|
1955
|
+
body: requestBody,
|
|
1956
|
+
mediaType: "application/json",
|
|
1957
|
+
errors: {
|
|
1958
|
+
400: `Can't create the application job because it has bad inputs`,
|
|
1959
|
+
401: `Unauthorized`,
|
|
1960
|
+
404: `Response body when an Application is not found`,
|
|
1961
|
+
500: `There has been an internal error`
|
|
1962
|
+
}
|
|
1963
|
+
});
|
|
1964
|
+
}
|
|
1965
|
+
/**
|
|
1966
|
+
* Get an application job by application and job id
|
|
1967
|
+
* Returns a single application job by id with its current status
|
|
1968
|
+
* @param applicationId
|
|
1969
|
+
* @param jobId
|
|
1970
|
+
* @returns ApplicationJob A single application
|
|
1971
|
+
* @throws ApiError
|
|
1972
|
+
*/
|
|
1973
|
+
static getApplicationJob(applicationId, jobId) {
|
|
1974
|
+
return request(OpenAPI, {
|
|
1975
|
+
method: "GET",
|
|
1976
|
+
url: "/applications/{application_id}/jobs/{job_id}",
|
|
1977
|
+
path: {
|
|
1978
|
+
application_id: applicationId,
|
|
1979
|
+
job_id: jobId
|
|
1980
|
+
},
|
|
1981
|
+
errors: {
|
|
1982
|
+
401: `Unauthorized`,
|
|
1983
|
+
404: `Response body when an Application/Job is not found`,
|
|
1984
|
+
500: `There has been an internal error`
|
|
1985
|
+
}
|
|
1986
|
+
});
|
|
1987
|
+
}
|
|
1988
|
+
/**
|
|
1989
|
+
* Delete an application job by application and job id
|
|
1990
|
+
* Cleans up the specific job from the Application and all its assoicated resources
|
|
1991
|
+
* @param applicationId
|
|
1992
|
+
* @param jobId
|
|
1993
|
+
* @returns GenericMessageResponse Generic OK response
|
|
1994
|
+
* @throws ApiError
|
|
1995
|
+
*/
|
|
1996
|
+
static deleteApplicationJob(applicationId, jobId) {
|
|
1997
|
+
return request(OpenAPI, {
|
|
1998
|
+
method: "DELETE",
|
|
1999
|
+
url: "/applications/{application_id}/jobs/{job_id}",
|
|
2000
|
+
path: {
|
|
2001
|
+
application_id: applicationId,
|
|
2002
|
+
job_id: jobId
|
|
2003
|
+
},
|
|
2004
|
+
errors: {
|
|
2005
|
+
401: `Unauthorized`,
|
|
2006
|
+
404: `Response body when an Application/Job is not found`,
|
|
2007
|
+
500: `There has been an internal error`
|
|
2008
|
+
}
|
|
2009
|
+
});
|
|
2010
|
+
}
|
|
2011
|
+
/**
|
|
2012
|
+
* Modify an existing application job
|
|
2013
|
+
* Modify an application job state
|
|
2014
|
+
* @param applicationId
|
|
2015
|
+
* @param jobId
|
|
2016
|
+
* @param requestBody
|
|
2017
|
+
* @returns ApplicationJob A modified job within an application
|
|
2018
|
+
* @throws ApiError
|
|
2019
|
+
*/
|
|
2020
|
+
static modifyApplicationJob(applicationId, jobId, requestBody) {
|
|
2021
|
+
return request(OpenAPI, {
|
|
2022
|
+
method: "PATCH",
|
|
2023
|
+
url: "/applications/{application_id}/jobs/{job_id}",
|
|
2024
|
+
path: {
|
|
2025
|
+
application_id: applicationId,
|
|
2026
|
+
job_id: jobId
|
|
2027
|
+
},
|
|
2028
|
+
body: requestBody,
|
|
2029
|
+
mediaType: "application/json",
|
|
2030
|
+
errors: {
|
|
2031
|
+
400: `Can't modify the application job because it has bad inputs`,
|
|
2032
|
+
401: `Unauthorized`,
|
|
2033
|
+
404: `Response body when an Application/Job is not found`,
|
|
2034
|
+
500: `There has been an internal error`
|
|
2035
|
+
}
|
|
2036
|
+
});
|
|
2037
|
+
}
|
|
2038
|
+
};
|
|
2039
|
+
|
|
2040
|
+
// src/client/services/PlacementsService.ts
|
|
2041
|
+
var PlacementsService = class {
|
|
2042
|
+
static {
|
|
2043
|
+
__name(this, "PlacementsService");
|
|
2044
|
+
}
|
|
2045
|
+
/**
|
|
2046
|
+
* List placements
|
|
2047
|
+
* List all placements under a given deploymentID with all its events
|
|
2048
|
+
* @param deploymentId
|
|
2049
|
+
* @returns ListPlacements A list of placements along with its events under a deployment
|
|
2050
|
+
* @throws ApiError
|
|
2051
|
+
*/
|
|
2052
|
+
static listPlacements(deploymentId) {
|
|
2053
|
+
return request(OpenAPI, {
|
|
2054
|
+
method: "GET",
|
|
2055
|
+
url: "/deployments/{deployment_id}/placements",
|
|
2056
|
+
path: {
|
|
2057
|
+
deployment_id: deploymentId
|
|
2058
|
+
},
|
|
2059
|
+
errors: {
|
|
2060
|
+
400: `Unknown account`,
|
|
2061
|
+
401: `Unauthorized`,
|
|
2062
|
+
404: `Deployment not found`,
|
|
2063
|
+
500: `List Placements Error`
|
|
2064
|
+
}
|
|
2065
|
+
});
|
|
2066
|
+
}
|
|
2067
|
+
/**
|
|
2068
|
+
* Get placement
|
|
2069
|
+
* A Placement represents the lifetime of a single instance of a Deployment
|
|
2070
|
+
* @param placementId
|
|
2071
|
+
* @returns PlacementWithEvents A specific placement along with its events
|
|
2072
|
+
* @throws ApiError
|
|
2073
|
+
*/
|
|
2074
|
+
static getPlacement(placementId) {
|
|
2075
|
+
return request(OpenAPI, {
|
|
2076
|
+
method: "GET",
|
|
2077
|
+
url: "/placements/{placement_id}",
|
|
2078
|
+
path: {
|
|
2079
|
+
placement_id: placementId
|
|
2080
|
+
},
|
|
2081
|
+
errors: {
|
|
2082
|
+
400: `Unknown account`,
|
|
2083
|
+
401: `Unauthorized`,
|
|
2084
|
+
404: `Placement not found`,
|
|
2085
|
+
500: `Get Placement Error`
|
|
2086
|
+
}
|
|
2087
|
+
});
|
|
2088
|
+
}
|
|
2089
|
+
/**
|
|
2090
|
+
* Replace a deployment
|
|
2091
|
+
* You can stop the current placement and create a new one. The new one will have the same durable properties of the deployment, but will otherwise be like new
|
|
2092
|
+
* @param placementId
|
|
2093
|
+
* @param requestBody
|
|
2094
|
+
* @returns DeploymentV2 Deployment replaced
|
|
2095
|
+
* @throws ApiError
|
|
2096
|
+
*/
|
|
2097
|
+
static replaceDeployment(placementId, requestBody) {
|
|
2098
|
+
return request(OpenAPI, {
|
|
2099
|
+
method: "POST",
|
|
2100
|
+
url: "/placements/{placement_id}",
|
|
2101
|
+
path: {
|
|
2102
|
+
placement_id: placementId
|
|
2103
|
+
},
|
|
2104
|
+
body: requestBody,
|
|
2105
|
+
mediaType: "application/json",
|
|
2106
|
+
errors: {
|
|
2107
|
+
400: `Responses with 400 status code`,
|
|
2108
|
+
401: `Unauthorized`,
|
|
2109
|
+
404: `Placement not found`,
|
|
2110
|
+
500: `Deployment Replacement Error`
|
|
2111
|
+
}
|
|
2112
|
+
});
|
|
2113
|
+
}
|
|
2114
|
+
};
|
|
2115
|
+
|
|
2116
|
+
// src/client/services/RolloutsService.ts
|
|
2117
|
+
var RolloutsService = class {
|
|
2118
|
+
static {
|
|
2119
|
+
__name(this, "RolloutsService");
|
|
2120
|
+
}
|
|
2121
|
+
/**
|
|
2122
|
+
* Create a new rollout for an application
|
|
2123
|
+
* A rollout can be used to update the application's configuration across instances with minimal downtime.
|
|
2124
|
+
* @param applicationId
|
|
2125
|
+
* @param requestBody
|
|
2126
|
+
* @returns ApplicationRollout
|
|
2127
|
+
* @throws ApiError
|
|
2128
|
+
*/
|
|
2129
|
+
static createApplicationRollout(applicationId, requestBody) {
|
|
2130
|
+
return request(OpenAPI, {
|
|
2131
|
+
method: "POST",
|
|
2132
|
+
url: "/applications/{application_id}/rollouts",
|
|
2133
|
+
path: {
|
|
2134
|
+
application_id: applicationId
|
|
2135
|
+
},
|
|
2136
|
+
body: requestBody,
|
|
2137
|
+
mediaType: "application/json",
|
|
2138
|
+
errors: {
|
|
2139
|
+
400: `Can't update the application rollout because it has bad inputs`,
|
|
2140
|
+
401: `Unauthorized`,
|
|
2141
|
+
404: `Response body when an Application is not found`,
|
|
2142
|
+
500: `There has been an internal error`
|
|
2143
|
+
}
|
|
2144
|
+
});
|
|
2145
|
+
}
|
|
2146
|
+
/**
|
|
2147
|
+
* List rollouts
|
|
2148
|
+
* List all rollouts within an application
|
|
2149
|
+
* @param applicationId
|
|
2150
|
+
* @param limit The amount of rollouts to return. By default it is all of them.
|
|
2151
|
+
* @param last The last rollout that was used to paginate
|
|
2152
|
+
* @returns ApplicationRollout
|
|
2153
|
+
* @throws ApiError
|
|
2154
|
+
*/
|
|
2155
|
+
static listApplicationRollouts(applicationId, limit, last) {
|
|
2156
|
+
return request(OpenAPI, {
|
|
2157
|
+
method: "GET",
|
|
2158
|
+
url: "/applications/{application_id}/rollouts",
|
|
2159
|
+
path: {
|
|
2160
|
+
application_id: applicationId
|
|
2161
|
+
},
|
|
2162
|
+
query: {
|
|
2163
|
+
limit,
|
|
2164
|
+
last
|
|
2165
|
+
},
|
|
2166
|
+
errors: {
|
|
2167
|
+
401: `Unauthorized`,
|
|
2168
|
+
404: `Response body when an Application is not found`,
|
|
2169
|
+
500: `There has been an internal error`
|
|
2170
|
+
}
|
|
2171
|
+
});
|
|
2172
|
+
}
|
|
2173
|
+
/**
|
|
2174
|
+
* Get a rollout by id within an application
|
|
2175
|
+
* View rollout configurations and state for a specific rollout
|
|
2176
|
+
* @param applicationId
|
|
2177
|
+
* @param rolloutId
|
|
2178
|
+
* @returns ApplicationRollout
|
|
2179
|
+
* @throws ApiError
|
|
2180
|
+
*/
|
|
2181
|
+
static getApplicationRollout(applicationId, rolloutId) {
|
|
2182
|
+
return request(OpenAPI, {
|
|
2183
|
+
method: "GET",
|
|
2184
|
+
url: "/applications/{application_id}/rollouts/{rollout_id}",
|
|
2185
|
+
path: {
|
|
2186
|
+
application_id: applicationId,
|
|
2187
|
+
rollout_id: rolloutId
|
|
2188
|
+
},
|
|
2189
|
+
errors: {
|
|
2190
|
+
401: `Unauthorized`,
|
|
2191
|
+
404: `Response body when an Application is not found`,
|
|
2192
|
+
500: `There has been an internal error`
|
|
2193
|
+
}
|
|
2194
|
+
});
|
|
2195
|
+
}
|
|
2196
|
+
/**
|
|
2197
|
+
* Update a rollout within an application
|
|
2198
|
+
* A rollout can be updated to modify its current state. Actions include - next, previous, rollback
|
|
2199
|
+
* @param applicationId
|
|
2200
|
+
* @param rolloutId
|
|
2201
|
+
* @param requestBody
|
|
2202
|
+
* @returns UpdateRolloutResponse
|
|
2203
|
+
* @throws ApiError
|
|
2204
|
+
*/
|
|
2205
|
+
static updateApplicationRollout(applicationId, rolloutId, requestBody) {
|
|
2206
|
+
return request(OpenAPI, {
|
|
2207
|
+
method: "POST",
|
|
2208
|
+
url: "/applications/{application_id}/rollouts/{rollout_id}",
|
|
2209
|
+
path: {
|
|
2210
|
+
application_id: applicationId,
|
|
2211
|
+
rollout_id: rolloutId
|
|
2212
|
+
},
|
|
2213
|
+
body: requestBody,
|
|
2214
|
+
mediaType: "application/json",
|
|
2215
|
+
errors: {
|
|
2216
|
+
400: `Can't create the application rollout because it has bad inputs`,
|
|
2217
|
+
401: `Unauthorized`,
|
|
2218
|
+
404: `Response body when an Application is not found`,
|
|
2219
|
+
500: `There has been an internal error`
|
|
2220
|
+
}
|
|
2221
|
+
});
|
|
2222
|
+
}
|
|
2223
|
+
/**
|
|
2224
|
+
* Delete a rollout within an application by its rollout id
|
|
2225
|
+
* Cleans up the specific rollout from the Application if it is not in use
|
|
2226
|
+
* @param applicationId
|
|
2227
|
+
* @param rolloutId
|
|
2228
|
+
* @returns EmptyResponse
|
|
2229
|
+
* @throws ApiError
|
|
2230
|
+
*/
|
|
2231
|
+
static deleteApplicationRollout(applicationId, rolloutId) {
|
|
2232
|
+
return request(OpenAPI, {
|
|
2233
|
+
method: "DELETE",
|
|
2234
|
+
url: "/applications/{application_id}/rollouts/{rollout_id}",
|
|
2235
|
+
path: {
|
|
2236
|
+
application_id: applicationId,
|
|
2237
|
+
rollout_id: rolloutId
|
|
2238
|
+
},
|
|
2239
|
+
errors: {
|
|
2240
|
+
401: `Unauthorized`,
|
|
2241
|
+
404: `Response body when an Application is not found`,
|
|
2242
|
+
500: `There has been an internal error`
|
|
2243
|
+
}
|
|
2244
|
+
});
|
|
2245
|
+
}
|
|
2246
|
+
};
|
|
2247
|
+
|
|
2248
|
+
// src/client/services/SecretsService.ts
|
|
2249
|
+
var SecretsService = class {
|
|
2250
|
+
static {
|
|
2251
|
+
__name(this, "SecretsService");
|
|
2252
|
+
}
|
|
2253
|
+
/**
|
|
2254
|
+
* Add a new secret to the account
|
|
2255
|
+
* Add a new secret to the account that can be associated with an application/deployment.
|
|
2256
|
+
* @param requestBody
|
|
2257
|
+
* @returns SecretMetadata Secret created successfully
|
|
2258
|
+
* @throws ApiError
|
|
2259
|
+
*/
|
|
2260
|
+
static createSecret(requestBody) {
|
|
2261
|
+
return request(OpenAPI, {
|
|
2262
|
+
method: "POST",
|
|
2263
|
+
url: "/secrets",
|
|
2264
|
+
body: requestBody,
|
|
2265
|
+
mediaType: "application/json",
|
|
2266
|
+
errors: {
|
|
2267
|
+
400: `Bad Request`,
|
|
2268
|
+
409: `Secret with this name already exists in this account`,
|
|
2269
|
+
500: `Generic error response`
|
|
2270
|
+
}
|
|
2271
|
+
});
|
|
2272
|
+
}
|
|
2273
|
+
/**
|
|
2274
|
+
* List Secrets
|
|
2275
|
+
* List all secrets in an account with metadata
|
|
2276
|
+
* @returns ListSecretsMetadata List Secrets response
|
|
2277
|
+
* @throws ApiError
|
|
2278
|
+
*/
|
|
2279
|
+
static listSecrets() {
|
|
2280
|
+
return request(OpenAPI, {
|
|
2281
|
+
method: "GET",
|
|
2282
|
+
url: "/secrets",
|
|
2283
|
+
errors: {
|
|
2284
|
+
500: `Generic error response`
|
|
2285
|
+
}
|
|
2286
|
+
});
|
|
2287
|
+
}
|
|
2288
|
+
/**
|
|
2289
|
+
* Get secret metadata
|
|
2290
|
+
* Get secret metadata by name
|
|
2291
|
+
* @param secretName
|
|
2292
|
+
* @returns SecretMetadata Get secret response
|
|
2293
|
+
* @throws ApiError
|
|
2294
|
+
*/
|
|
2295
|
+
static getSecret(secretName) {
|
|
2296
|
+
return request(OpenAPI, {
|
|
2297
|
+
method: "GET",
|
|
2298
|
+
url: "/secrets/{secretName}",
|
|
2299
|
+
path: {
|
|
2300
|
+
secretName
|
|
2301
|
+
},
|
|
2302
|
+
errors: {
|
|
2303
|
+
404: `Secret not found error`,
|
|
2304
|
+
500: `Generic error response`
|
|
2305
|
+
}
|
|
2306
|
+
});
|
|
2307
|
+
}
|
|
2308
|
+
/**
|
|
2309
|
+
* Update an existing secret
|
|
2310
|
+
* Update a secret within an account. This bumps its version field. Corresponding applications/deployments would get the updated secret in its next placement.
|
|
2311
|
+
* @param secretName
|
|
2312
|
+
* @param requestBody
|
|
2313
|
+
* @returns SecretMetadata Modify Secrets response
|
|
2314
|
+
* @throws ApiError
|
|
2315
|
+
*/
|
|
2316
|
+
static modifySecret(secretName, requestBody) {
|
|
2317
|
+
return request(OpenAPI, {
|
|
2318
|
+
method: "PATCH",
|
|
2319
|
+
url: "/secrets/{secretName}",
|
|
2320
|
+
path: {
|
|
2321
|
+
secretName
|
|
2322
|
+
},
|
|
2323
|
+
body: requestBody,
|
|
2324
|
+
mediaType: "application/json",
|
|
2325
|
+
errors: {
|
|
2326
|
+
400: `Bad Request`,
|
|
2327
|
+
404: `Secret not found error`,
|
|
2328
|
+
500: `Generic error response`
|
|
2329
|
+
}
|
|
2330
|
+
});
|
|
2331
|
+
}
|
|
2332
|
+
/**
|
|
2333
|
+
* Delete an existing secret
|
|
2334
|
+
* Delete a secret within an account.
|
|
2335
|
+
* @param secretName
|
|
2336
|
+
* @returns GenericMessageResponse Generic OK response
|
|
2337
|
+
* @throws ApiError
|
|
2338
|
+
*/
|
|
2339
|
+
static deleteSecret(secretName) {
|
|
2340
|
+
return request(OpenAPI, {
|
|
2341
|
+
method: "DELETE",
|
|
2342
|
+
url: "/secrets/{secretName}",
|
|
2343
|
+
path: {
|
|
2344
|
+
secretName
|
|
2345
|
+
},
|
|
2346
|
+
errors: {
|
|
2347
|
+
404: `Secret not found error`,
|
|
2348
|
+
500: `Generic error response`
|
|
2349
|
+
}
|
|
2350
|
+
});
|
|
2351
|
+
}
|
|
2352
|
+
};
|
|
2353
|
+
|
|
2354
|
+
// src/client/services/SshPublicKeysService.ts
|
|
2355
|
+
var SshPublicKeysService = class {
|
|
2356
|
+
static {
|
|
2357
|
+
__name(this, "SshPublicKeysService");
|
|
2358
|
+
}
|
|
2359
|
+
/**
|
|
2360
|
+
* Add SSH public key
|
|
2361
|
+
* Adds a new ssh public key to an account. This can then be associated with a specific deployment during its creation or modification.
|
|
2362
|
+
* @param requestBody
|
|
2363
|
+
* @returns SSHPublicKeyItem SSH Public key added successfully
|
|
2364
|
+
* @throws ApiError
|
|
2365
|
+
*/
|
|
2366
|
+
static createSshPublicKey(requestBody) {
|
|
2367
|
+
return request(OpenAPI, {
|
|
2368
|
+
method: "POST",
|
|
2369
|
+
url: "/ssh-public-keys",
|
|
2370
|
+
body: requestBody,
|
|
2371
|
+
mediaType: "application/json",
|
|
2372
|
+
errors: {
|
|
2373
|
+
401: `Unauthorized`,
|
|
2374
|
+
500: `Create SSH Public key error`
|
|
2375
|
+
}
|
|
2376
|
+
});
|
|
2377
|
+
}
|
|
2378
|
+
/**
|
|
2379
|
+
* List SSH Public keys
|
|
2380
|
+
* List all SSH Public keys in an account
|
|
2381
|
+
* @returns ListSSHPublicKeys List SSH Public keys response
|
|
2382
|
+
* @throws ApiError
|
|
2383
|
+
*/
|
|
2384
|
+
static listSshPublicKeys() {
|
|
2385
|
+
return request(OpenAPI, {
|
|
2386
|
+
method: "GET",
|
|
2387
|
+
url: "/ssh-public-keys",
|
|
2388
|
+
errors: {
|
|
2389
|
+
401: `Unauthorized`,
|
|
2390
|
+
500: `List SSH Public keys error`
|
|
2391
|
+
}
|
|
2392
|
+
});
|
|
2393
|
+
}
|
|
2394
|
+
/**
|
|
2395
|
+
* Delete SSH public key from the account
|
|
2396
|
+
* Delete an SSH public key from an account.
|
|
2397
|
+
* @param sshPublicKeyName
|
|
2398
|
+
* @returns EmptyResponse SSH Public key was removed successfully
|
|
2399
|
+
* @throws ApiError
|
|
2400
|
+
*/
|
|
2401
|
+
static deleteSshPublicKey(sshPublicKeyName) {
|
|
2402
|
+
return request(OpenAPI, {
|
|
2403
|
+
method: "DELETE",
|
|
2404
|
+
url: "/ssh-public-keys/{sshPublicKeyName}",
|
|
2405
|
+
path: {
|
|
2406
|
+
sshPublicKeyName
|
|
2407
|
+
},
|
|
2408
|
+
errors: {
|
|
2409
|
+
401: `Unauthorized`,
|
|
2410
|
+
404: `Response body when the SSH public key that is trying to be found does not exist`,
|
|
2411
|
+
500: `There has been an internal error`
|
|
2412
|
+
}
|
|
2413
|
+
});
|
|
2414
|
+
}
|
|
2415
|
+
};
|
|
2416
|
+
|
|
2417
|
+
// src/context.ts
|
|
2418
|
+
var noop = /* @__PURE__ */ __name(() => {
|
|
2419
|
+
}, "noop");
|
|
2420
|
+
var logger = {
|
|
2421
|
+
debug: noop,
|
|
2422
|
+
log: noop,
|
|
2423
|
+
info: noop,
|
|
2424
|
+
warn: noop,
|
|
2425
|
+
error: noop
|
|
2426
|
+
};
|
|
2427
|
+
var fetchResult = /* @__PURE__ */ __name(() => {
|
|
2428
|
+
throw new Error("initContainersSharedContext() must be called first");
|
|
2429
|
+
}, "fetchResult");
|
|
2430
|
+
var fetchPagedListResult = /* @__PURE__ */ __name(() => {
|
|
2431
|
+
throw new Error("initContainersSharedContext() must be called first");
|
|
2432
|
+
}, "fetchPagedListResult");
|
|
2433
|
+
function initContainersSharedContext(ctx) {
|
|
2434
|
+
logger = ctx.logger;
|
|
2435
|
+
fetchResult = ctx.fetchResult;
|
|
2436
|
+
if (ctx.fetchPagedListResult !== void 0) {
|
|
2437
|
+
fetchPagedListResult = ctx.fetchPagedListResult;
|
|
2438
|
+
}
|
|
2439
|
+
}
|
|
2440
|
+
__name(initContainersSharedContext, "initContainersSharedContext");
|
|
2441
|
+
|
|
2442
|
+
// src/registry.ts
|
|
2443
|
+
var getCloudflareRegistryWithAccountNamespace = /* @__PURE__ */ __name((accountID, tag, complianceConfig) => {
|
|
2444
|
+
return `${getCloudflareContainerRegistry(complianceConfig)}/${accountID}/${tag}`;
|
|
2445
|
+
}, "getCloudflareRegistryWithAccountNamespace");
|
|
2446
|
+
var MF_DEV_CONTAINER_PREFIX = "cloudflare-dev";
|
|
2447
|
+
|
|
2448
|
+
// src/knobs.ts
|
|
2449
|
+
function getCloudflareContainerRegistry(complianceConfig = COMPLIANCE_REGION_CONFIG_UNKNOWN) {
|
|
2450
|
+
if (process.env.CLOUDFLARE_CONTAINER_REGISTRY) {
|
|
2451
|
+
return process.env.CLOUDFLARE_CONTAINER_REGISTRY;
|
|
2452
|
+
}
|
|
2453
|
+
const environmentPrefix = process.env.WRANGLER_API_ENVIRONMENT === "staging" ? "staging." : "";
|
|
2454
|
+
const complianceRegionSubdomain = getComplianceRegionSubdomain(complianceConfig);
|
|
2455
|
+
return `${environmentPrefix}registry${complianceRegionSubdomain}.cloudflare.com`;
|
|
2456
|
+
}
|
|
2457
|
+
__name(getCloudflareContainerRegistry, "getCloudflareContainerRegistry");
|
|
2458
|
+
var getDevContainerImageName = /* @__PURE__ */ __name((name, tag) => {
|
|
2459
|
+
return `${MF_DEV_CONTAINER_PREFIX}/${name.toLowerCase()}:${tag}`;
|
|
2460
|
+
}, "getDevContainerImageName");
|
|
2461
|
+
var FUSE_CONTAINER_PRIVILEGES = {
|
|
2462
|
+
capabilities: ["SYS_ADMIN"],
|
|
2463
|
+
devices: [
|
|
2464
|
+
{
|
|
2465
|
+
pathOnHost: "/dev/fuse",
|
|
2466
|
+
pathInContainer: "/dev/fuse",
|
|
2467
|
+
cgroupPermissions: "rwm"
|
|
2468
|
+
}
|
|
2469
|
+
],
|
|
2470
|
+
securityOpt: ["apparmor:unconfined"]
|
|
2471
|
+
};
|
|
2472
|
+
function configureOpenAPIForContainerPull(accountId, apiToken, apiBase = "https://api.cloudflare.com/client/v4") {
|
|
2473
|
+
OpenAPI.BASE = `${apiBase}/accounts/${accountId}/containers`;
|
|
2474
|
+
OpenAPI.CREDENTIALS = "omit";
|
|
2475
|
+
const existingHeaders = typeof OpenAPI.HEADERS === "object" ? OpenAPI.HEADERS : {};
|
|
2476
|
+
OpenAPI.HEADERS = {
|
|
2477
|
+
...existingHeaders,
|
|
2478
|
+
Authorization: `Bearer ${apiToken}`
|
|
2479
|
+
};
|
|
2480
|
+
}
|
|
2481
|
+
__name(configureOpenAPIForContainerPull, "configureOpenAPIForContainerPull");
|
|
2482
|
+
async function dockerLoginImageRegistry(pathToDocker, domain) {
|
|
2483
|
+
const expirationMinutes = 15;
|
|
2484
|
+
const credentials = await ImageRegistriesService.generateImageRegistryCredentials(domain, {
|
|
2485
|
+
expiration_minutes: expirationMinutes,
|
|
2486
|
+
permissions: [
|
|
2487
|
+
"push" /* PUSH */,
|
|
2488
|
+
"pull" /* PULL */
|
|
2489
|
+
]
|
|
2490
|
+
});
|
|
2491
|
+
const child = spawn(
|
|
2492
|
+
pathToDocker,
|
|
2493
|
+
["login", "--password-stdin", "--username", credentials.username, domain],
|
|
2494
|
+
{ stdio: ["pipe", "inherit", "inherit"] }
|
|
2495
|
+
).on("error", (err) => {
|
|
2496
|
+
throw err;
|
|
2497
|
+
});
|
|
2498
|
+
child.stdin.write(credentials.password);
|
|
2499
|
+
child.stdin.end();
|
|
2500
|
+
await new Promise((resolve2, reject) => {
|
|
2501
|
+
child.on("close", (code) => {
|
|
2502
|
+
if (code === 0) {
|
|
2503
|
+
resolve2();
|
|
2504
|
+
} else {
|
|
2505
|
+
reject(
|
|
2506
|
+
new UserError(`Login failed with code: ${code}`, {
|
|
2507
|
+
telemetryMessage: false
|
|
2508
|
+
})
|
|
2509
|
+
);
|
|
2510
|
+
}
|
|
2511
|
+
});
|
|
2512
|
+
});
|
|
2513
|
+
}
|
|
2514
|
+
__name(dockerLoginImageRegistry, "dockerLoginImageRegistry");
|
|
2515
|
+
async function dockerImageInspect(dockerPath, options) {
|
|
2516
|
+
return new Promise((resolve2, reject) => {
|
|
2517
|
+
const proc = spawn(
|
|
2518
|
+
dockerPath,
|
|
2519
|
+
["image", "inspect", options.imageTag, "--format", options.formatString],
|
|
2520
|
+
{
|
|
2521
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
2522
|
+
}
|
|
2523
|
+
);
|
|
2524
|
+
let stdout = "";
|
|
2525
|
+
let stderr = "";
|
|
2526
|
+
proc.stdout.on("data", (chunk) => stdout += chunk);
|
|
2527
|
+
proc.stderr.on("data", (chunk) => stderr += chunk);
|
|
2528
|
+
proc.on("close", (code) => {
|
|
2529
|
+
if (code !== 0) {
|
|
2530
|
+
return reject(
|
|
2531
|
+
new UserError(`failed inspecting image locally: ${stderr.trim()}`, {
|
|
2532
|
+
telemetryMessage: false
|
|
2533
|
+
})
|
|
2534
|
+
);
|
|
2535
|
+
}
|
|
2536
|
+
resolve2(stdout.trim());
|
|
2537
|
+
});
|
|
2538
|
+
proc.on("error", (err) => reject(err));
|
|
2539
|
+
});
|
|
2540
|
+
}
|
|
2541
|
+
__name(dockerImageInspect, "dockerImageInspect");
|
|
2542
|
+
|
|
2543
|
+
// src/utils.ts
|
|
2544
|
+
var runDockerCmd = /* @__PURE__ */ __name((dockerPath, args, stdio) => {
|
|
2545
|
+
let aborted = false;
|
|
2546
|
+
let resolve2;
|
|
2547
|
+
let reject;
|
|
2548
|
+
const ready = new Promise((res, rej) => {
|
|
2549
|
+
resolve2 = res;
|
|
2550
|
+
reject = rej;
|
|
2551
|
+
});
|
|
2552
|
+
const child = spawn(dockerPath, args, {
|
|
2553
|
+
stdio: stdio ?? "inherit",
|
|
2554
|
+
// We need to set detached to true so that the child process
|
|
2555
|
+
// will control all of its child processes and we can kill
|
|
2556
|
+
// all of them in case we need to abort the build process.
|
|
2557
|
+
// On Windows, detached: true opens a new console window per child
|
|
2558
|
+
// process, so we only set it on non-Windows platforms.
|
|
2559
|
+
detached: process.platform !== "win32",
|
|
2560
|
+
// Prevent child processes from opening visible console windows on Windows.
|
|
2561
|
+
// This is a no-op on non-Windows platforms.
|
|
2562
|
+
windowsHide: true
|
|
2563
|
+
});
|
|
2564
|
+
let errorHandled = false;
|
|
2565
|
+
child.on("close", (code) => {
|
|
2566
|
+
if (code === 0 || aborted) {
|
|
2567
|
+
resolve2({ aborted });
|
|
2568
|
+
} else if (!errorHandled) {
|
|
2569
|
+
errorHandled = true;
|
|
2570
|
+
reject(
|
|
2571
|
+
new UserError(`Docker command exited with code: ${code}`, {
|
|
2572
|
+
telemetryMessage: false
|
|
2573
|
+
})
|
|
2574
|
+
);
|
|
2575
|
+
}
|
|
2576
|
+
});
|
|
2577
|
+
child.on("error", (err) => {
|
|
2578
|
+
if (!errorHandled) {
|
|
2579
|
+
errorHandled = true;
|
|
2580
|
+
reject(
|
|
2581
|
+
new UserError(`Docker command failed: ${err.message}`, {
|
|
2582
|
+
telemetryMessage: false
|
|
2583
|
+
})
|
|
2584
|
+
);
|
|
2585
|
+
}
|
|
2586
|
+
});
|
|
2587
|
+
return {
|
|
2588
|
+
abort: /* @__PURE__ */ __name(() => {
|
|
2589
|
+
aborted = true;
|
|
2590
|
+
child.unref();
|
|
2591
|
+
if (child.pid !== void 0) {
|
|
2592
|
+
if (process.platform === "win32") {
|
|
2593
|
+
child.kill();
|
|
2594
|
+
} else {
|
|
2595
|
+
process.kill(-child.pid);
|
|
2596
|
+
}
|
|
2597
|
+
}
|
|
2598
|
+
}, "abort"),
|
|
2599
|
+
ready,
|
|
2600
|
+
then: /* @__PURE__ */ __name(async (onResolve, onReject) => ready.then(onResolve).catch(onReject), "then")
|
|
2601
|
+
};
|
|
2602
|
+
}, "runDockerCmd");
|
|
2603
|
+
var runDockerCmdWithOutput = /* @__PURE__ */ __name((dockerPath, args) => {
|
|
2604
|
+
try {
|
|
2605
|
+
const stdout = execFileSync(dockerPath, args, { encoding: "utf8" });
|
|
2606
|
+
return stdout.trim();
|
|
2607
|
+
} catch (error) {
|
|
2608
|
+
throw new UserError(
|
|
2609
|
+
`Failed running docker command: ${error.message}. Command: ${dockerPath} ${args.join(" ")}`,
|
|
2610
|
+
{ telemetryMessage: false }
|
|
2611
|
+
);
|
|
2612
|
+
}
|
|
2613
|
+
}, "runDockerCmdWithOutput");
|
|
2614
|
+
async function containerPrivilegesAllowed(dockerHost, dockerPath = "docker") {
|
|
2615
|
+
const platform = process.platform;
|
|
2616
|
+
if (!isLocalDockerEndpoint(dockerHost) || platform !== "darwin" && platform !== "linux") {
|
|
2617
|
+
return false;
|
|
2618
|
+
}
|
|
2619
|
+
const securityOptions = await getDockerSecurityOptions(
|
|
2620
|
+
dockerPath,
|
|
2621
|
+
dockerHost
|
|
2622
|
+
);
|
|
2623
|
+
const rootless = Array.isArray(securityOptions) && securityOptions.some(
|
|
2624
|
+
(option) => option === "name=rootless" || option === "rootless"
|
|
2625
|
+
);
|
|
2626
|
+
const localVm = platform === "darwin" || platform === "linux" && detectWsl();
|
|
2627
|
+
const localRootlessLinux = platform === "linux" && existsSync("/dev/fuse") && rootless;
|
|
2628
|
+
return localVm || localRootlessLinux;
|
|
2629
|
+
}
|
|
2630
|
+
__name(containerPrivilegesAllowed, "containerPrivilegesAllowed");
|
|
2631
|
+
function isLocalDockerEndpoint(dockerHost) {
|
|
2632
|
+
try {
|
|
2633
|
+
const url = new URL(dockerHost);
|
|
2634
|
+
return url.protocol === "unix:" && url.hostname === "" && url.pathname.startsWith("/");
|
|
2635
|
+
} catch {
|
|
2636
|
+
return false;
|
|
2637
|
+
}
|
|
2638
|
+
}
|
|
2639
|
+
__name(isLocalDockerEndpoint, "isLocalDockerEndpoint");
|
|
2640
|
+
async function getDockerSecurityOptions(dockerPath, dockerHost) {
|
|
2641
|
+
const output = await new Promise((resolve2, reject) => {
|
|
2642
|
+
execFile(
|
|
2643
|
+
dockerPath,
|
|
2644
|
+
["--host", dockerHost, "info", "--format", "{{json .SecurityOptions}}"],
|
|
2645
|
+
{ encoding: "utf8", timeout: 5e3 },
|
|
2646
|
+
(error, stdout) => {
|
|
2647
|
+
if (error === null) {
|
|
2648
|
+
resolve2(stdout);
|
|
2649
|
+
} else {
|
|
2650
|
+
reject(error);
|
|
2651
|
+
}
|
|
2652
|
+
}
|
|
2653
|
+
);
|
|
2654
|
+
});
|
|
2655
|
+
return JSON.parse(output);
|
|
2656
|
+
}
|
|
2657
|
+
__name(getDockerSecurityOptions, "getDockerSecurityOptions");
|
|
2658
|
+
function detectWsl() {
|
|
2659
|
+
return process.platform === "linux" && release().toLowerCase().includes("microsoft");
|
|
2660
|
+
}
|
|
2661
|
+
__name(detectWsl, "detectWsl");
|
|
2662
|
+
var isDockerRunning = /* @__PURE__ */ __name(async (dockerPath) => {
|
|
2663
|
+
try {
|
|
2664
|
+
await runDockerCmd(dockerPath, ["info"], ["inherit", "pipe", "pipe"]);
|
|
2665
|
+
} catch {
|
|
2666
|
+
return false;
|
|
2667
|
+
}
|
|
2668
|
+
return true;
|
|
2669
|
+
}, "isDockerRunning");
|
|
2670
|
+
var verifyDockerInstalled = /* @__PURE__ */ __name(async ({
|
|
2671
|
+
dockerPath,
|
|
2672
|
+
operation,
|
|
2673
|
+
imageNoun,
|
|
2674
|
+
hint
|
|
2675
|
+
}) => {
|
|
2676
|
+
const dockerIsRunning = await isDockerRunning(dockerPath);
|
|
2677
|
+
if (!dockerIsRunning) {
|
|
2678
|
+
throw new UserError(
|
|
2679
|
+
getFailedToRunDockerErrorMessage({
|
|
2680
|
+
operation,
|
|
2681
|
+
imageNoun,
|
|
2682
|
+
hint
|
|
2683
|
+
}),
|
|
2684
|
+
{
|
|
2685
|
+
telemetryMessage: false
|
|
2686
|
+
}
|
|
2687
|
+
);
|
|
2688
|
+
}
|
|
2689
|
+
}, "verifyDockerInstalled");
|
|
2690
|
+
function getFailedToRunDockerErrorMessage({
|
|
2691
|
+
operation,
|
|
2692
|
+
imageNoun,
|
|
2693
|
+
hint
|
|
2694
|
+
}) {
|
|
2695
|
+
const beforeOperation = operation ? ` before ${operation}` : "";
|
|
2696
|
+
const headline = `The Docker CLI is needed to build ${imageNoun}${beforeOperation} but could not be launched.`;
|
|
2697
|
+
let daemonHint;
|
|
2698
|
+
if (process.platform === "darwin") {
|
|
2699
|
+
daemonHint = "open the Docker Desktop app or run `open -a Docker`";
|
|
2700
|
+
} else if (process.platform === "win32") {
|
|
2701
|
+
daemonHint = "open the Docker Desktop app";
|
|
2702
|
+
} else {
|
|
2703
|
+
daemonHint = "run `sudo systemctl start docker`";
|
|
2704
|
+
}
|
|
2705
|
+
const steps = `To fix this, try the following:
|
|
2706
|
+
- If Docker is not installed, download it from https://docs.docker.com/get-started/get-docker/
|
|
2707
|
+
- If Docker is installed but the daemon is not running,
|
|
2708
|
+
${daemonHint}.
|
|
2709
|
+
- If you use an alternative Docker-compatible CLI (e.g. Podman),
|
|
2710
|
+
set the WRANGLER_DOCKER_BIN environment variable to its path and DOCKER_HOST to its socket.`;
|
|
2711
|
+
const alternatives = "Note: Other container tooling that is compatible with the Docker CLI and engine may work, but is not yet guaranteed to do so.";
|
|
2712
|
+
let message = `${headline}
|
|
2713
|
+
${steps}
|
|
2714
|
+
|
|
2715
|
+
${alternatives}`;
|
|
2716
|
+
if (hint) {
|
|
2717
|
+
message += `
|
|
2718
|
+
|
|
2719
|
+
${hint}`;
|
|
2720
|
+
}
|
|
2721
|
+
return message;
|
|
2722
|
+
}
|
|
2723
|
+
__name(getFailedToRunDockerErrorMessage, "getFailedToRunDockerErrorMessage");
|
|
2724
|
+
var cleanupContainers = /* @__PURE__ */ __name((dockerPath, imageTags) => {
|
|
2725
|
+
try {
|
|
2726
|
+
const containerIds = getContainerIdsByImageTags(dockerPath, imageTags);
|
|
2727
|
+
if (containerIds.length === 0) {
|
|
2728
|
+
return true;
|
|
2729
|
+
}
|
|
2730
|
+
runDockerCmdWithOutput(dockerPath, ["rm", "--force", ...containerIds]);
|
|
2731
|
+
return true;
|
|
2732
|
+
} catch {
|
|
2733
|
+
return false;
|
|
2734
|
+
}
|
|
2735
|
+
}, "cleanupContainers");
|
|
2736
|
+
function getContainerIdsByImageTags(dockerPath, imageTags) {
|
|
2737
|
+
const ids = /* @__PURE__ */ new Set();
|
|
2738
|
+
for (const imageTag of imageTags) {
|
|
2739
|
+
const containerIdsFromImage = getContainerIdsFromImage(
|
|
2740
|
+
dockerPath,
|
|
2741
|
+
imageTag
|
|
2742
|
+
);
|
|
2743
|
+
containerIdsFromImage.forEach((id) => ids.add(id));
|
|
2744
|
+
}
|
|
2745
|
+
return Array.from(ids);
|
|
2746
|
+
}
|
|
2747
|
+
__name(getContainerIdsByImageTags, "getContainerIdsByImageTags");
|
|
2748
|
+
var getContainerIdsFromImage = /* @__PURE__ */ __name((dockerPath, ancestorImage) => {
|
|
2749
|
+
const output = runDockerCmdWithOutput(dockerPath, [
|
|
2750
|
+
"ps",
|
|
2751
|
+
"-a",
|
|
2752
|
+
"--filter",
|
|
2753
|
+
`ancestor=${ancestorImage}`,
|
|
2754
|
+
"--format",
|
|
2755
|
+
"{{.ID}}"
|
|
2756
|
+
]);
|
|
2757
|
+
return output.split("\n").filter((line) => line.trim());
|
|
2758
|
+
}, "getContainerIdsFromImage");
|
|
2759
|
+
async function checkExposedPorts(dockerPath, options) {
|
|
2760
|
+
const output = await dockerImageInspect(dockerPath, {
|
|
2761
|
+
imageTag: options.image_tag,
|
|
2762
|
+
formatString: "{{ len .Config.ExposedPorts }}"
|
|
2763
|
+
});
|
|
2764
|
+
if (output === "0") {
|
|
2765
|
+
throw new UserError(
|
|
2766
|
+
`The container "${options.class_name}" does not expose any ports. In your Dockerfile, please expose any ports you intend to connect to.
|
|
2767
|
+
For additional information please see: https://developers.cloudflare.com/containers/local-dev/#exposing-ports.
|
|
2768
|
+
`,
|
|
2769
|
+
{ telemetryMessage: false }
|
|
2770
|
+
);
|
|
2771
|
+
}
|
|
2772
|
+
}
|
|
2773
|
+
__name(checkExposedPorts, "checkExposedPorts");
|
|
2774
|
+
function generateContainerBuildId() {
|
|
2775
|
+
return randomUUID().slice(0, 8);
|
|
2776
|
+
}
|
|
2777
|
+
__name(generateContainerBuildId, "generateContainerBuildId");
|
|
2778
|
+
function getDockerSocketFromContext(dockerPath) {
|
|
2779
|
+
try {
|
|
2780
|
+
const output = runDockerCmdWithOutput(dockerPath, [
|
|
2781
|
+
"context",
|
|
2782
|
+
"ls",
|
|
2783
|
+
"--format",
|
|
2784
|
+
"json"
|
|
2785
|
+
]);
|
|
2786
|
+
const lines = output.trim().split("\n");
|
|
2787
|
+
const contexts = lines.map((line) => JSON.parse(line));
|
|
2788
|
+
const currentContext = contexts.find((context) => context.Current === true);
|
|
2789
|
+
if (currentContext && currentContext.DockerEndpoint) {
|
|
2790
|
+
return currentContext.DockerEndpoint;
|
|
2791
|
+
}
|
|
2792
|
+
} catch {
|
|
2793
|
+
}
|
|
2794
|
+
return null;
|
|
2795
|
+
}
|
|
2796
|
+
__name(getDockerSocketFromContext, "getDockerSocketFromContext");
|
|
2797
|
+
function resolveDockerHost(dockerPath) {
|
|
2798
|
+
if (process.env.WRANGLER_DOCKER_HOST) {
|
|
2799
|
+
return process.env.WRANGLER_DOCKER_HOST;
|
|
2800
|
+
}
|
|
2801
|
+
if (process.env.DOCKER_HOST) {
|
|
2802
|
+
return process.env.DOCKER_HOST;
|
|
2803
|
+
}
|
|
2804
|
+
const contextSocket = getDockerSocketFromContext(dockerPath);
|
|
2805
|
+
if (contextSocket) {
|
|
2806
|
+
return contextSocket;
|
|
2807
|
+
}
|
|
2808
|
+
return process.platform === "win32" ? "//./pipe/docker_engine" : "unix:///var/run/docker.sock";
|
|
2809
|
+
}
|
|
2810
|
+
__name(resolveDockerHost, "resolveDockerHost");
|
|
2811
|
+
var getDockerHostFromEnv = /* @__PURE__ */ __name(() => {
|
|
2812
|
+
const fromEnv = process.env.WRANGLER_DOCKER_HOST ?? process.env.DOCKER_HOST;
|
|
2813
|
+
return fromEnv ?? process.platform === "win32" ? "//./pipe/docker_engine" : "unix:///var/run/docker.sock";
|
|
2814
|
+
}, "getDockerHostFromEnv");
|
|
2815
|
+
async function getImageRepoTags(dockerPath, imageTag) {
|
|
2816
|
+
try {
|
|
2817
|
+
const output = await dockerImageInspect(dockerPath, {
|
|
2818
|
+
imageTag,
|
|
2819
|
+
formatString: "{{ range .RepoTags }}{{ . }}\n{{ end }}"
|
|
2820
|
+
});
|
|
2821
|
+
return output.split("\n").filter((tag) => tag.trim() !== "");
|
|
2822
|
+
} catch {
|
|
2823
|
+
return [];
|
|
2824
|
+
}
|
|
2825
|
+
}
|
|
2826
|
+
__name(getImageRepoTags, "getImageRepoTags");
|
|
2827
|
+
async function cleanupDuplicateImageTags(dockerPath, imageTag) {
|
|
2828
|
+
try {
|
|
2829
|
+
const repoTags = await getImageRepoTags(dockerPath, imageTag);
|
|
2830
|
+
const currentBuildId = getImageTag(imageTag);
|
|
2831
|
+
const tagsToRemove = repoTags.filter(
|
|
2832
|
+
(tag) => tag.startsWith("cloudflare-dev") && getImageTag(tag) !== currentBuildId
|
|
2833
|
+
);
|
|
2834
|
+
if (tagsToRemove.length > 0) {
|
|
2835
|
+
runDockerCmdWithOutput(dockerPath, ["rmi", ...tagsToRemove]);
|
|
2836
|
+
}
|
|
2837
|
+
} catch {
|
|
2838
|
+
}
|
|
2839
|
+
}
|
|
2840
|
+
__name(cleanupDuplicateImageTags, "cleanupDuplicateImageTags");
|
|
2841
|
+
function getImageTag(imageTag) {
|
|
2842
|
+
const tagSeparatorIndex = imageTag.lastIndexOf(":");
|
|
2843
|
+
return tagSeparatorIndex === -1 ? void 0 : imageTag.slice(tagSeparatorIndex + 1);
|
|
2844
|
+
}
|
|
2845
|
+
__name(getImageTag, "getImageTag");
|
|
2846
|
+
|
|
2847
|
+
// src/images.ts
|
|
2848
|
+
var DEFAULT_CONTAINER_EGRESS_INTERCEPTOR_IMAGE = "cloudflare/proxy-everything:3cb1195@sha256:0ef6716c52430096900b150d84a3302057d6cd2319dae7987128c85d0733e3c8";
|
|
2849
|
+
function getEgressInterceptorPlatform() {
|
|
2850
|
+
return process.env.MINIFLARE_CONTAINER_EGRESS_IMAGE_PLATFORM;
|
|
2851
|
+
}
|
|
2852
|
+
__name(getEgressInterceptorPlatform, "getEgressInterceptorPlatform");
|
|
2853
|
+
function getEgressInterceptorImage() {
|
|
2854
|
+
return process.env.MINIFLARE_CONTAINER_EGRESS_IMAGE ?? DEFAULT_CONTAINER_EGRESS_INTERCEPTOR_IMAGE;
|
|
2855
|
+
}
|
|
2856
|
+
__name(getEgressInterceptorImage, "getEgressInterceptorImage");
|
|
2857
|
+
async function pullEgressInterceptorImage(dockerPath) {
|
|
2858
|
+
const image = getEgressInterceptorImage();
|
|
2859
|
+
const platform = getEgressInterceptorPlatform();
|
|
2860
|
+
const args = ["pull", image];
|
|
2861
|
+
if (platform !== void 0) {
|
|
2862
|
+
args.push("--platform", platform);
|
|
2863
|
+
}
|
|
2864
|
+
await runDockerCmd(dockerPath, args);
|
|
2865
|
+
}
|
|
2866
|
+
__name(pullEgressInterceptorImage, "pullEgressInterceptorImage");
|
|
2867
|
+
async function pullImage(dockerPath, options, logger2, complianceConfig) {
|
|
2868
|
+
const domain = new URL(`http://${options.image_uri}`).hostname;
|
|
2869
|
+
const isExternalRegistry = domain !== getCloudflareContainerRegistry(complianceConfig);
|
|
2870
|
+
try {
|
|
2871
|
+
await dockerLoginImageRegistry(dockerPath, domain);
|
|
2872
|
+
} catch (e) {
|
|
2873
|
+
if (!isExternalRegistry) {
|
|
2874
|
+
throw e;
|
|
2875
|
+
}
|
|
2876
|
+
logger2?.warn(
|
|
2877
|
+
"Unable to retrieve configured registry credentials from Cloudflare.\nUnless this is a public image, you will need to run `wrangler containers registries configure` before deploying.\nAttempting to pull image anyway..."
|
|
2878
|
+
);
|
|
2879
|
+
}
|
|
2880
|
+
const pull = runDockerCmd(dockerPath, [
|
|
2881
|
+
"pull",
|
|
2882
|
+
options.image_uri,
|
|
2883
|
+
// All containers running on our platform need to be built for amd64 architecture, but by default docker pull seems to look for an image matching the host system, so we need to specify this here
|
|
2884
|
+
"--platform",
|
|
2885
|
+
"linux/amd64"
|
|
2886
|
+
]);
|
|
2887
|
+
const ready = pull.ready.then(async ({ aborted }) => {
|
|
2888
|
+
if (!aborted) {
|
|
2889
|
+
await runDockerCmd(dockerPath, [
|
|
2890
|
+
"tag",
|
|
2891
|
+
options.image_uri,
|
|
2892
|
+
options.image_tag
|
|
2893
|
+
]);
|
|
2894
|
+
}
|
|
2895
|
+
});
|
|
2896
|
+
return {
|
|
2897
|
+
abort: /* @__PURE__ */ __name(() => {
|
|
2898
|
+
pull.abort();
|
|
2899
|
+
}, "abort"),
|
|
2900
|
+
ready
|
|
2901
|
+
};
|
|
2902
|
+
}
|
|
2903
|
+
__name(pullImage, "pullImage");
|
|
2904
|
+
async function prepareContainerImagesForDev(args) {
|
|
2905
|
+
const {
|
|
2906
|
+
dockerPath,
|
|
2907
|
+
containerOptions,
|
|
2908
|
+
onContainerImagePreparationStart,
|
|
2909
|
+
onContainerImagePreparationEnd
|
|
2910
|
+
} = args;
|
|
2911
|
+
let aborted = false;
|
|
2912
|
+
if (process.platform === "win32") {
|
|
2913
|
+
throw new UserError(
|
|
2914
|
+
"Local development with containers is currently not supported on Windows. You should use WSL instead. You can also set `enable_containers` to false if you do not need to develop the container part of your application.",
|
|
2915
|
+
{ telemetryMessage: false }
|
|
2916
|
+
);
|
|
2917
|
+
}
|
|
2918
|
+
await verifyDockerInstalled({
|
|
2919
|
+
dockerPath,
|
|
2920
|
+
operation: "running dev",
|
|
2921
|
+
imageNoun: containerOptions.length !== 1 ? "the configured images" : "the configured image",
|
|
2922
|
+
hint: "To suppress this error if you do not intend on triggering any container instances, set dev.enable_containers to false in your Wrangler config or pass --enable-containers=false."
|
|
2923
|
+
});
|
|
2924
|
+
for (const options of containerOptions) {
|
|
2925
|
+
if ("dockerfile" in options) {
|
|
2926
|
+
const build = await startContainerBuild({
|
|
2927
|
+
pathToDocker: dockerPath,
|
|
2928
|
+
verifyDockerIsRunning: false,
|
|
2929
|
+
build: {
|
|
2930
|
+
tag: options.image_tag,
|
|
2931
|
+
pathToDockerfile: options.dockerfile,
|
|
2932
|
+
buildContext: options.image_build_context,
|
|
2933
|
+
args: options.image_vars,
|
|
2934
|
+
platform: "linux/amd64"
|
|
2935
|
+
}
|
|
2936
|
+
});
|
|
2937
|
+
onContainerImagePreparationStart({
|
|
2938
|
+
containerOptions: options,
|
|
2939
|
+
abort: /* @__PURE__ */ __name(() => {
|
|
2940
|
+
aborted = true;
|
|
2941
|
+
build.abort();
|
|
2942
|
+
}, "abort")
|
|
2943
|
+
});
|
|
2944
|
+
await build.ready;
|
|
2945
|
+
onContainerImagePreparationEnd({
|
|
2946
|
+
containerOptions: options
|
|
2947
|
+
});
|
|
2948
|
+
} else {
|
|
2949
|
+
const pull = await pullImage(
|
|
2950
|
+
dockerPath,
|
|
2951
|
+
options,
|
|
2952
|
+
args.logger,
|
|
2953
|
+
args.complianceConfig
|
|
2954
|
+
);
|
|
2955
|
+
onContainerImagePreparationStart({
|
|
2956
|
+
containerOptions: options,
|
|
2957
|
+
abort: /* @__PURE__ */ __name(() => {
|
|
2958
|
+
aborted = true;
|
|
2959
|
+
pull.abort();
|
|
2960
|
+
}, "abort")
|
|
2961
|
+
});
|
|
2962
|
+
await pull.ready;
|
|
2963
|
+
onContainerImagePreparationEnd({
|
|
2964
|
+
containerOptions: options
|
|
2965
|
+
});
|
|
2966
|
+
}
|
|
2967
|
+
if (!aborted) {
|
|
2968
|
+
await cleanupDuplicateImageTags(dockerPath, options.image_tag);
|
|
2969
|
+
await checkExposedPorts(dockerPath, options);
|
|
2970
|
+
}
|
|
2971
|
+
}
|
|
2972
|
+
if (!aborted) {
|
|
2973
|
+
await pullEgressInterceptorImage(dockerPath);
|
|
2974
|
+
}
|
|
2975
|
+
}
|
|
2976
|
+
__name(prepareContainerImagesForDev, "prepareContainerImagesForDev");
|
|
2977
|
+
function resolveImageName(accountId, image, complianceConfig) {
|
|
2978
|
+
let url;
|
|
2979
|
+
try {
|
|
2980
|
+
url = new URL(`http://${image}`);
|
|
2981
|
+
} catch {
|
|
2982
|
+
}
|
|
2983
|
+
if (url === void 0 || !url.host.match(/[:.]/) && url.hostname !== "localhost") {
|
|
2984
|
+
return getCloudflareRegistryWithAccountNamespace(
|
|
2985
|
+
accountId,
|
|
2986
|
+
image,
|
|
2987
|
+
complianceConfig
|
|
2988
|
+
);
|
|
2989
|
+
}
|
|
2990
|
+
if (url.hostname !== getCloudflareContainerRegistry(complianceConfig)) {
|
|
2991
|
+
return image;
|
|
2992
|
+
}
|
|
2993
|
+
if (url.pathname.startsWith(`/${accountId}`)) {
|
|
2994
|
+
return image;
|
|
2995
|
+
}
|
|
2996
|
+
const accountIdPattern = /^\/([a-f0-9]{32})\//;
|
|
2997
|
+
const match = accountIdPattern.exec(url.pathname);
|
|
2998
|
+
if (match) {
|
|
2999
|
+
const foundAccountId = match[1];
|
|
3000
|
+
if (foundAccountId !== accountId) {
|
|
3001
|
+
throw new Error(
|
|
3002
|
+
`Image "${image}" does not belong to your account
|
|
3003
|
+
Image appears to belong to account: "${foundAccountId}"
|
|
3004
|
+
Current account: "${accountId}"`
|
|
3005
|
+
);
|
|
3006
|
+
}
|
|
3007
|
+
return image;
|
|
3008
|
+
}
|
|
3009
|
+
return `${url.hostname}/${accountId}${url.pathname}`;
|
|
3010
|
+
}
|
|
3011
|
+
__name(resolveImageName, "resolveImageName");
|
|
3012
|
+
var getAndValidateRegistryType = /* @__PURE__ */ __name((domain, complianceConfig) => {
|
|
3013
|
+
if (domain.includes("://")) {
|
|
3014
|
+
throw new Error(
|
|
3015
|
+
`${domain} is invalid:
|
|
3016
|
+
Image reference should not include the protocol part (e.g: registry.cloudflare.com rather than https://registry.cloudflare.com)`
|
|
3017
|
+
);
|
|
3018
|
+
}
|
|
3019
|
+
let url;
|
|
3020
|
+
try {
|
|
3021
|
+
url = new URL(`http://${domain}`);
|
|
3022
|
+
} catch (e) {
|
|
3023
|
+
if (e instanceof Error) {
|
|
3024
|
+
throw new Error(`${domain} is invalid:
|
|
3025
|
+
${e.message}`);
|
|
3026
|
+
}
|
|
3027
|
+
throw e;
|
|
3028
|
+
}
|
|
3029
|
+
const acceptedRegistries = [
|
|
3030
|
+
{
|
|
3031
|
+
type: "ECR" /* ECR */,
|
|
3032
|
+
pattern: /^[0-9]{12}\.dkr\.ecr\.[a-z0-9-]+\.amazonaws\.com$/,
|
|
3033
|
+
name: "AWS ECR",
|
|
3034
|
+
secretType: "AWS Secret Access Key"
|
|
3035
|
+
},
|
|
3036
|
+
{
|
|
3037
|
+
type: "DockerHub" /* DOCKER_HUB */,
|
|
3038
|
+
pattern: /^docker\.io$/,
|
|
3039
|
+
name: "DockerHub",
|
|
3040
|
+
secretType: "DockerHub PAT Token"
|
|
3041
|
+
},
|
|
3042
|
+
{
|
|
3043
|
+
type: "GAR" /* GAR */,
|
|
3044
|
+
pattern: /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?-docker\.pkg\.dev$/,
|
|
3045
|
+
name: "Google Artifact Registry",
|
|
3046
|
+
secretType: "Google Service Account JSON Key"
|
|
3047
|
+
},
|
|
3048
|
+
{
|
|
3049
|
+
type: "cloudflare",
|
|
3050
|
+
pattern: new RegExp(
|
|
3051
|
+
`^${getCloudflareContainerRegistry(complianceConfig).replace(/[\\.]/g, "\\$&")}$`
|
|
3052
|
+
),
|
|
3053
|
+
name: "Cloudflare Containers Managed Registry"
|
|
3054
|
+
}
|
|
3055
|
+
];
|
|
3056
|
+
const match = acceptedRegistries.find(
|
|
3057
|
+
(registry) => registry.pattern.test(url.hostname)
|
|
3058
|
+
);
|
|
3059
|
+
if (!match) {
|
|
3060
|
+
const supportedRegistries = acceptedRegistries.filter((r) => r.type !== "cloudflare").map((r) => r.name).join(", ");
|
|
3061
|
+
throw new UserError(
|
|
3062
|
+
`${url.hostname} is not a supported image registry.
|
|
3063
|
+
Currently we support the following non-Cloudflare registries: ${supportedRegistries}.
|
|
3064
|
+
To use an existing image from another repository, see https://developers.cloudflare.com/containers/platform-details/image-management/#using-pre-built-container-images`,
|
|
3065
|
+
{ telemetryMessage: false }
|
|
3066
|
+
);
|
|
3067
|
+
}
|
|
3068
|
+
return match;
|
|
3069
|
+
}, "getAndValidateRegistryType");
|
|
3070
|
+
function invalidGarCredentialError() {
|
|
3071
|
+
return new UserError(
|
|
3072
|
+
"The Google service account key must be a JSON key file or its base64-encoded form.",
|
|
3073
|
+
{
|
|
3074
|
+
telemetryMessage: "containers registries configure invalid gar credential"
|
|
3075
|
+
}
|
|
3076
|
+
);
|
|
3077
|
+
}
|
|
3078
|
+
__name(invalidGarCredentialError, "invalidGarCredentialError");
|
|
3079
|
+
function tryParseJson(value) {
|
|
3080
|
+
try {
|
|
3081
|
+
return JSON.parse(value);
|
|
3082
|
+
} catch {
|
|
3083
|
+
return void 0;
|
|
3084
|
+
}
|
|
3085
|
+
}
|
|
3086
|
+
__name(tryParseJson, "tryParseJson");
|
|
3087
|
+
function assertJsonObject(parsed) {
|
|
3088
|
+
if (typeof parsed !== "object" || parsed === null) {
|
|
3089
|
+
throw invalidGarCredentialError();
|
|
3090
|
+
}
|
|
3091
|
+
return parsed;
|
|
3092
|
+
}
|
|
3093
|
+
__name(assertJsonObject, "assertJsonObject");
|
|
3094
|
+
function validateServiceAccountKey(accountKey) {
|
|
3095
|
+
const privateKey = accountKey.private_key;
|
|
3096
|
+
const clientEmail = accountKey.client_email;
|
|
3097
|
+
const rawPrivateKeyId = accountKey.private_key_id;
|
|
3098
|
+
if (typeof privateKey !== "string" || typeof clientEmail !== "string") {
|
|
3099
|
+
throw new UserError(
|
|
3100
|
+
"The Google service account key is missing required fields (private_key, client_email).",
|
|
3101
|
+
{
|
|
3102
|
+
telemetryMessage: "containers registries configure gar credential missing fields"
|
|
3103
|
+
}
|
|
3104
|
+
);
|
|
3105
|
+
}
|
|
3106
|
+
if (privateKey.length === 0 || clientEmail.length === 0) {
|
|
3107
|
+
throw new UserError(
|
|
3108
|
+
"The Google service account key has an empty private_key or client_email.",
|
|
3109
|
+
{
|
|
3110
|
+
telemetryMessage: "containers registries configure gar credential empty fields"
|
|
3111
|
+
}
|
|
3112
|
+
);
|
|
3113
|
+
}
|
|
3114
|
+
let privateKeyId;
|
|
3115
|
+
if (rawPrivateKeyId === void 0) {
|
|
3116
|
+
privateKeyId = void 0;
|
|
3117
|
+
} else if (typeof rawPrivateKeyId === "string" && rawPrivateKeyId.length > 0) {
|
|
3118
|
+
privateKeyId = rawPrivateKeyId;
|
|
3119
|
+
} else {
|
|
3120
|
+
throw new UserError(
|
|
3121
|
+
"The Google service account key has an empty or invalid private_key_id.",
|
|
3122
|
+
{
|
|
3123
|
+
telemetryMessage: "containers registries configure gar credential invalid private key id"
|
|
3124
|
+
}
|
|
3125
|
+
);
|
|
3126
|
+
}
|
|
3127
|
+
return {
|
|
3128
|
+
private_key: privateKey,
|
|
3129
|
+
client_email: clientEmail,
|
|
3130
|
+
private_key_id: privateKeyId
|
|
3131
|
+
};
|
|
3132
|
+
}
|
|
3133
|
+
__name(validateServiceAccountKey, "validateServiceAccountKey");
|
|
3134
|
+
function validateAndEncodeGarKey(rawKey, expectedEmail) {
|
|
3135
|
+
const trimmed = rawKey.trim();
|
|
3136
|
+
let base64Key;
|
|
3137
|
+
let json;
|
|
3138
|
+
const rawJson = tryParseJson(trimmed);
|
|
3139
|
+
if (rawJson !== void 0) {
|
|
3140
|
+
json = assertJsonObject(rawJson);
|
|
3141
|
+
base64Key = Buffer.from(trimmed, "utf8").toString("base64");
|
|
3142
|
+
} else {
|
|
3143
|
+
if (trimmed.startsWith("-----BEGIN")) {
|
|
3144
|
+
throw new UserError(
|
|
3145
|
+
"The provided key appears to be a PEM private key. Provide the full Google service-account JSON key file, not just the private key.",
|
|
3146
|
+
{
|
|
3147
|
+
telemetryMessage: "containers registries configure gar credential pem key"
|
|
3148
|
+
}
|
|
3149
|
+
);
|
|
3150
|
+
}
|
|
3151
|
+
base64Key = trimmed.replace(/\s+/g, "");
|
|
3152
|
+
const decodedJson = tryParseJson(
|
|
3153
|
+
Buffer.from(base64Key, "base64").toString("utf8")
|
|
3154
|
+
);
|
|
3155
|
+
if (decodedJson === void 0) {
|
|
3156
|
+
throw invalidGarCredentialError();
|
|
3157
|
+
}
|
|
3158
|
+
json = assertJsonObject(decodedJson);
|
|
3159
|
+
}
|
|
3160
|
+
const key = validateServiceAccountKey(json);
|
|
3161
|
+
if (key.client_email !== expectedEmail) {
|
|
3162
|
+
throw new UserError(
|
|
3163
|
+
`The provided --gar-email "${expectedEmail}" does not match the service account email "${key.client_email}" in the key.`,
|
|
3164
|
+
{
|
|
3165
|
+
telemetryMessage: "containers registries configure gar email mismatch"
|
|
3166
|
+
}
|
|
3167
|
+
);
|
|
3168
|
+
}
|
|
3169
|
+
return base64Key;
|
|
3170
|
+
}
|
|
3171
|
+
__name(validateAndEncodeGarKey, "validateAndEncodeGarKey");
|
|
3172
|
+
var MB = 1e3 * 1e3;
|
|
3173
|
+
var MiB = 1024 * 1024;
|
|
3174
|
+
var instanceTypes = {
|
|
3175
|
+
// lite is the default instance type when REQUIRE_INSTANCE_TYPE is set
|
|
3176
|
+
lite: {
|
|
3177
|
+
vcpu: 0.0625,
|
|
3178
|
+
memory_mib: 256,
|
|
3179
|
+
disk_mb: 2e3
|
|
3180
|
+
},
|
|
3181
|
+
dev: {
|
|
3182
|
+
vcpu: 0.0625,
|
|
3183
|
+
memory_mib: 256,
|
|
3184
|
+
disk_mb: 2e3
|
|
3185
|
+
},
|
|
3186
|
+
basic: {
|
|
3187
|
+
vcpu: 0.25,
|
|
3188
|
+
memory_mib: 1024,
|
|
3189
|
+
disk_mb: 4e3
|
|
3190
|
+
},
|
|
3191
|
+
standard: {
|
|
3192
|
+
vcpu: 0.5,
|
|
3193
|
+
memory_mib: 4096,
|
|
3194
|
+
disk_mb: 8e3
|
|
3195
|
+
},
|
|
3196
|
+
"standard-1": {
|
|
3197
|
+
vcpu: 0.5,
|
|
3198
|
+
memory_mib: 4096,
|
|
3199
|
+
disk_mb: 8e3
|
|
3200
|
+
},
|
|
3201
|
+
"standard-2": {
|
|
3202
|
+
vcpu: 1,
|
|
3203
|
+
memory_mib: 6144,
|
|
3204
|
+
disk_mb: 12e3
|
|
3205
|
+
},
|
|
3206
|
+
"standard-3": {
|
|
3207
|
+
vcpu: 2,
|
|
3208
|
+
memory_mib: 8192,
|
|
3209
|
+
disk_mb: 16e3
|
|
3210
|
+
},
|
|
3211
|
+
"standard-4": {
|
|
3212
|
+
vcpu: 4,
|
|
3213
|
+
memory_mib: 12288,
|
|
3214
|
+
disk_mb: 2e4
|
|
3215
|
+
}
|
|
3216
|
+
};
|
|
3217
|
+
var LEGACY_TO_CANONICAL = {
|
|
3218
|
+
dev: "lite" /* LITE */,
|
|
3219
|
+
standard: "standard-1" /* STANDARD_1 */
|
|
3220
|
+
};
|
|
3221
|
+
function configToUsage(containerConfig) {
|
|
3222
|
+
if ("instance_type" in containerConfig) {
|
|
3223
|
+
return getInstanceTypeUsage(containerConfig.instance_type);
|
|
3224
|
+
}
|
|
3225
|
+
return {
|
|
3226
|
+
vcpu: containerConfig.vcpu,
|
|
3227
|
+
memory_mib: containerConfig.memory_mib,
|
|
3228
|
+
disk_mb: containerConfig.disk_bytes / MB
|
|
3229
|
+
};
|
|
3230
|
+
}
|
|
3231
|
+
__name(configToUsage, "configToUsage");
|
|
3232
|
+
function accountToLimits(account) {
|
|
3233
|
+
return {
|
|
3234
|
+
vcpu: account.limits.vcpu_per_deployment,
|
|
3235
|
+
memory_mib: account.limits.memory_mib_per_deployment,
|
|
3236
|
+
disk_mb: account.limits.disk_mb_per_deployment
|
|
3237
|
+
};
|
|
3238
|
+
}
|
|
3239
|
+
__name(accountToLimits, "accountToLimits");
|
|
3240
|
+
function getInstanceTypeUsage(instanceType) {
|
|
3241
|
+
return instanceTypes[instanceType];
|
|
3242
|
+
}
|
|
3243
|
+
__name(getInstanceTypeUsage, "getInstanceTypeUsage");
|
|
3244
|
+
function inferInstanceType(config) {
|
|
3245
|
+
for (const [instanceType, configuration] of Object.entries(instanceTypes)) {
|
|
3246
|
+
if (config.vcpu === configuration.vcpu && config.memory_mib === configuration.memory_mib && config.disk?.size_mb === configuration.disk_mb) {
|
|
3247
|
+
const canonical = instanceType in LEGACY_TO_CANONICAL ? LEGACY_TO_CANONICAL[instanceType] : void 0;
|
|
3248
|
+
return canonical ?? instanceType;
|
|
3249
|
+
}
|
|
3250
|
+
}
|
|
3251
|
+
}
|
|
3252
|
+
__name(inferInstanceType, "inferInstanceType");
|
|
3253
|
+
function cleanForInstanceType(app) {
|
|
3254
|
+
if (!("configuration" in app)) {
|
|
3255
|
+
return app;
|
|
3256
|
+
}
|
|
3257
|
+
const instance_type = inferInstanceType(app.configuration);
|
|
3258
|
+
if (instance_type !== void 0) {
|
|
3259
|
+
app.configuration.instance_type = instance_type;
|
|
3260
|
+
}
|
|
3261
|
+
delete app.configuration.disk;
|
|
3262
|
+
delete app.configuration.memory;
|
|
3263
|
+
delete app.configuration.memory_mib;
|
|
3264
|
+
delete app.configuration.vcpu;
|
|
3265
|
+
return app;
|
|
3266
|
+
}
|
|
3267
|
+
__name(cleanForInstanceType, "cleanForInstanceType");
|
|
3268
|
+
async function ensureContainerLimits(options) {
|
|
3269
|
+
const limits = accountToLimits(options.account);
|
|
3270
|
+
if (!options.containerConfig) {
|
|
3271
|
+
await ensureImageFitsLimits({
|
|
3272
|
+
availableSizeInBytes: limits.disk_mb * MB,
|
|
3273
|
+
pathToDocker: options.pathToDocker,
|
|
3274
|
+
imageTag: options.imageTag
|
|
3275
|
+
});
|
|
3276
|
+
return;
|
|
3277
|
+
}
|
|
3278
|
+
const usage = configToUsage(options.containerConfig);
|
|
3279
|
+
const errors = [];
|
|
3280
|
+
if (usage.vcpu > limits.vcpu) {
|
|
3281
|
+
errors.push(
|
|
3282
|
+
`Your container configuration uses ${usage.vcpu} vCPU which exceeds the account limit of ${limits.vcpu} vCPU.`
|
|
3283
|
+
);
|
|
3284
|
+
}
|
|
3285
|
+
if (usage.memory_mib > limits.memory_mib) {
|
|
3286
|
+
errors.push(
|
|
3287
|
+
`Your container configuration uses ${usage.memory_mib} MiB of memory which exceeds the account limit of ${limits.memory_mib} MiB.`
|
|
3288
|
+
);
|
|
3289
|
+
}
|
|
3290
|
+
if (usage.disk_mb > limits.disk_mb) {
|
|
3291
|
+
errors.push(
|
|
3292
|
+
`Your container configuration uses ${usage.disk_mb} MB of disk which exceeds the account limit of ${limits.disk_mb} MB.`
|
|
3293
|
+
);
|
|
3294
|
+
}
|
|
3295
|
+
if (errors.length > 0) {
|
|
3296
|
+
throw new UserError(`Exceeded account limits: ${errors.join(" ")}`, {
|
|
3297
|
+
telemetryMessage: "cloudchamber limits account limit exceeded"
|
|
3298
|
+
});
|
|
3299
|
+
}
|
|
3300
|
+
await ensureImageFitsLimits({
|
|
3301
|
+
availableSizeInBytes: usage.disk_mb * MB,
|
|
3302
|
+
pathToDocker: options.pathToDocker,
|
|
3303
|
+
imageTag: options.imageTag
|
|
3304
|
+
});
|
|
3305
|
+
}
|
|
3306
|
+
__name(ensureContainerLimits, "ensureContainerLimits");
|
|
3307
|
+
async function ensureImageFitsLimits(options) {
|
|
3308
|
+
const inspectOutput = await dockerImageInspect(options.pathToDocker, {
|
|
3309
|
+
imageTag: options.imageTag,
|
|
3310
|
+
formatString: "{{ .Size }} {{ len .RootFS.Layers }}"
|
|
3311
|
+
});
|
|
3312
|
+
const [sizeStr, layerStr] = inspectOutput.split(" ");
|
|
3313
|
+
if (sizeStr === void 0 || layerStr === void 0) {
|
|
3314
|
+
throw new Error(
|
|
3315
|
+
`Expected docker image inspect output to include image size and layer count, got ${inspectOutput}`
|
|
3316
|
+
);
|
|
3317
|
+
}
|
|
3318
|
+
const size = parseInt(sizeStr, 10);
|
|
3319
|
+
const layers = parseInt(layerStr, 10);
|
|
3320
|
+
const requiredSizeInBytes = Math.ceil(size * 1.1 + layers * 16 * MiB);
|
|
3321
|
+
logger.debug(
|
|
3322
|
+
`Disk size limits when building container image: availableSize=${Math.ceil(options.availableSizeInBytes / MB)}MB, requiredSize=${Math.ceil(requiredSizeInBytes / MB)}MB`
|
|
3323
|
+
);
|
|
3324
|
+
if (options.availableSizeInBytes < requiredSizeInBytes) {
|
|
3325
|
+
throw new UserError(
|
|
3326
|
+
`Image too large: needs ${Math.ceil(requiredSizeInBytes / MB)}MB, but your app is limited to images with size ${options.availableSizeInBytes / MB}MB. You need more disk for this image.`,
|
|
3327
|
+
{ telemetryMessage: "cloudchamber limits image too large" }
|
|
3328
|
+
);
|
|
3329
|
+
}
|
|
3330
|
+
}
|
|
3331
|
+
__name(ensureImageFitsLimits, "ensureImageFitsLimits");
|
|
3332
|
+
async function getContainerAccount(accountId, complianceConfig) {
|
|
3333
|
+
if (accountId === void 0) {
|
|
3334
|
+
return await AccountService.getMe();
|
|
3335
|
+
}
|
|
3336
|
+
return await fetchResult(
|
|
3337
|
+
complianceConfig ?? {},
|
|
3338
|
+
`/accounts/${accountId}/containers/me`
|
|
3339
|
+
);
|
|
3340
|
+
}
|
|
3341
|
+
__name(getContainerAccount, "getContainerAccount");
|
|
3342
|
+
|
|
3343
|
+
// src/build.ts
|
|
3344
|
+
function isDockerfileContainerConfig(container) {
|
|
3345
|
+
return "dockerfile" in container;
|
|
3346
|
+
}
|
|
3347
|
+
__name(isDockerfileContainerConfig, "isDockerfileContainerConfig");
|
|
3348
|
+
async function constructBuildCommand(options) {
|
|
3349
|
+
const platform = options.platform ?? "linux/amd64";
|
|
3350
|
+
const buildCmd = [
|
|
3351
|
+
"build",
|
|
3352
|
+
"--load",
|
|
3353
|
+
"-t",
|
|
3354
|
+
options.tag,
|
|
3355
|
+
"--platform",
|
|
3356
|
+
platform,
|
|
3357
|
+
"--provenance=false"
|
|
3358
|
+
];
|
|
3359
|
+
if (options.args) {
|
|
3360
|
+
for (const arg in options.args) {
|
|
3361
|
+
buildCmd.push("--build-arg", `${arg}=${options.args[arg]}`);
|
|
3362
|
+
}
|
|
3363
|
+
}
|
|
3364
|
+
if (process.env.WRANGLER_CI_OVERRIDE_NETWORK_MODE_HOST) {
|
|
3365
|
+
buildCmd.push("--network", "host");
|
|
3366
|
+
}
|
|
3367
|
+
const dockerfile = readFileSync(options.pathToDockerfile, "utf-8");
|
|
3368
|
+
buildCmd.push("-f", "-");
|
|
3369
|
+
buildCmd.push(options.buildContext);
|
|
3370
|
+
logger?.debug(`Building image with command: ${buildCmd.join(" ")}`);
|
|
3371
|
+
return { buildCmd, dockerfile };
|
|
3372
|
+
}
|
|
3373
|
+
__name(constructBuildCommand, "constructBuildCommand");
|
|
3374
|
+
async function startContainerBuild({
|
|
3375
|
+
build,
|
|
3376
|
+
pathToDocker,
|
|
3377
|
+
verifyDockerIsRunning
|
|
3378
|
+
}) {
|
|
3379
|
+
const { buildCmd, dockerfile } = await constructBuildCommand(build);
|
|
3380
|
+
return await dockerBuild(pathToDocker, {
|
|
3381
|
+
buildCmd,
|
|
3382
|
+
dockerfile,
|
|
3383
|
+
verifyDockerIsRunning
|
|
3384
|
+
});
|
|
3385
|
+
}
|
|
3386
|
+
__name(startContainerBuild, "startContainerBuild");
|
|
3387
|
+
var DIGEST_SUFFIX_REGEXP = /@[A-Za-z][A-Za-z0-9]*(?:[-_+.][A-Za-z][A-Za-z0-9]*)*:[a-fA-F0-9]{32,}$/;
|
|
3388
|
+
var DIGEST_VALUE_REGEXP = /^[A-Za-z][A-Za-z0-9]*(?:[-_+.][A-Za-z][A-Za-z0-9]*)*:[a-fA-F0-9]{32,}$/;
|
|
3389
|
+
var TAG_SUFFIX_REGEXP = /:[\w][\w.-]{0,127}$/;
|
|
3390
|
+
function getRepositoryOnly(externalAccountId, imageTag, complianceConfig) {
|
|
3391
|
+
return resolveImageName(externalAccountId, imageTag, complianceConfig).replace(DIGEST_SUFFIX_REGEXP, "").replace(TAG_SUFFIX_REGEXP, "");
|
|
3392
|
+
}
|
|
3393
|
+
__name(getRepositoryOnly, "getRepositoryOnly");
|
|
3394
|
+
function imageRefWithDigest(externalAccountId, imageTag, digest, complianceConfig) {
|
|
3395
|
+
if (!DIGEST_VALUE_REGEXP.test(digest)) {
|
|
3396
|
+
throw new Error(
|
|
3397
|
+
`Expected image digest to match algorithm:hex format, got ${digest}`
|
|
3398
|
+
);
|
|
3399
|
+
}
|
|
3400
|
+
return `${getRepositoryOnly(externalAccountId, imageTag, complianceConfig)}@${digest}`;
|
|
3401
|
+
}
|
|
3402
|
+
__name(imageRefWithDigest, "imageRefWithDigest");
|
|
3403
|
+
function findManifestDigest(manifestOutput) {
|
|
3404
|
+
const parsedManifest = JSON.parse(manifestOutput);
|
|
3405
|
+
const digest = parsedManifest?.Descriptor?.digest;
|
|
3406
|
+
if (typeof digest !== "string" || digest.length === 0) {
|
|
3407
|
+
throw new Error(
|
|
3408
|
+
`Expected docker manifest inspect output to include Descriptor.digest, got ${manifestOutput}`
|
|
3409
|
+
);
|
|
3410
|
+
}
|
|
3411
|
+
return digest;
|
|
3412
|
+
}
|
|
3413
|
+
__name(findManifestDigest, "findManifestDigest");
|
|
3414
|
+
function findRemoteDigest(repoDigestsJson, externalAccountId, imageTag, complianceConfig) {
|
|
3415
|
+
const parsedDigests = JSON.parse(repoDigestsJson);
|
|
3416
|
+
if (!Array.isArray(parsedDigests)) {
|
|
3417
|
+
throw new Error(
|
|
3418
|
+
`Expected RepoDigests from docker inspect to be an array but got ${JSON.stringify(parsedDigests)}`
|
|
3419
|
+
);
|
|
3420
|
+
}
|
|
3421
|
+
const repositoryOnly = getRepositoryOnly(
|
|
3422
|
+
externalAccountId,
|
|
3423
|
+
imageTag,
|
|
3424
|
+
complianceConfig
|
|
3425
|
+
);
|
|
3426
|
+
logger.debug("respositoryOnly:", repositoryOnly);
|
|
3427
|
+
const digest = parsedDigests.find((d) => {
|
|
3428
|
+
if (typeof d !== "string" || !d.includes("@")) {
|
|
3429
|
+
return false;
|
|
3430
|
+
}
|
|
3431
|
+
const resolved = resolveImageName(externalAccountId, d, complianceConfig);
|
|
3432
|
+
logger.debug(`Comparing ${resolved.split("@")[0]} to ${repositoryOnly}`);
|
|
3433
|
+
return resolved.split("@")[0] === repositoryOnly;
|
|
3434
|
+
});
|
|
3435
|
+
if (!digest) {
|
|
3436
|
+
throw new Error(
|
|
3437
|
+
`Could not find a digest for the image ${repositoryOnly}. Found digests: ${parsedDigests.join(", ")}`
|
|
3438
|
+
);
|
|
3439
|
+
}
|
|
3440
|
+
const [, hash] = digest.split("@");
|
|
3441
|
+
assertString(hash, `Expected digest "${digest}" to include a hash`);
|
|
3442
|
+
return imageRefWithDigest(
|
|
3443
|
+
externalAccountId,
|
|
3444
|
+
imageTag,
|
|
3445
|
+
hash,
|
|
3446
|
+
complianceConfig
|
|
3447
|
+
);
|
|
3448
|
+
}
|
|
3449
|
+
__name(findRemoteDigest, "findRemoteDigest");
|
|
3450
|
+
function assertString(value, message) {
|
|
3451
|
+
if (value === void 0) {
|
|
3452
|
+
throw new Error(message);
|
|
3453
|
+
}
|
|
3454
|
+
}
|
|
3455
|
+
__name(assertString, "assertString");
|
|
3456
|
+
async function tagAndPushImage({
|
|
3457
|
+
pathToDocker,
|
|
3458
|
+
sourceTag,
|
|
3459
|
+
targetTag,
|
|
3460
|
+
externalAccountId,
|
|
3461
|
+
complianceConfig,
|
|
3462
|
+
cleanupSourceTag
|
|
3463
|
+
}) {
|
|
3464
|
+
const namespacedImageTag = resolveImageName(
|
|
3465
|
+
externalAccountId,
|
|
3466
|
+
targetTag,
|
|
3467
|
+
complianceConfig
|
|
3468
|
+
);
|
|
3469
|
+
await runDockerCmd(pathToDocker, ["tag", sourceTag, namespacedImageTag]);
|
|
3470
|
+
if (cleanupSourceTag) {
|
|
3471
|
+
logger.debug(`Untagging built image: ${sourceTag}.`);
|
|
3472
|
+
await runDockerCmd(pathToDocker, ["image", "rm", sourceTag]);
|
|
3473
|
+
}
|
|
3474
|
+
await runDockerCmd(pathToDocker, ["push", namespacedImageTag]);
|
|
3475
|
+
return namespacedImageTag;
|
|
3476
|
+
}
|
|
3477
|
+
__name(tagAndPushImage, "tagAndPushImage");
|
|
3478
|
+
async function pushImageIfChanged({
|
|
3479
|
+
pathToDocker,
|
|
3480
|
+
sourceTag,
|
|
3481
|
+
targetTag,
|
|
3482
|
+
containerConfig,
|
|
3483
|
+
accountId,
|
|
3484
|
+
complianceConfig,
|
|
3485
|
+
cleanupSourceTag
|
|
3486
|
+
}) {
|
|
3487
|
+
const imageInfo = await dockerImageInspect(pathToDocker, {
|
|
3488
|
+
imageTag: sourceTag,
|
|
3489
|
+
formatString: "{{ json .RepoDigests }}"
|
|
3490
|
+
});
|
|
3491
|
+
logger.debug(`'docker image inspect ${sourceTag}':`, imageInfo);
|
|
3492
|
+
const account = await getContainerAccount(accountId, complianceConfig);
|
|
3493
|
+
await ensureContainerLimits({
|
|
3494
|
+
pathToDocker,
|
|
3495
|
+
imageTag: sourceTag,
|
|
3496
|
+
account,
|
|
3497
|
+
containerConfig
|
|
3498
|
+
});
|
|
3499
|
+
await dockerLoginImageRegistry(
|
|
3500
|
+
pathToDocker,
|
|
3501
|
+
// Won't be an external registry since this is building from a Dockerfile
|
|
3502
|
+
// rather than specifying an image URI.
|
|
3503
|
+
getCloudflareContainerRegistry(complianceConfig)
|
|
3504
|
+
);
|
|
3505
|
+
try {
|
|
3506
|
+
const remoteDigest2 = findRemoteDigest(
|
|
3507
|
+
imageInfo,
|
|
3508
|
+
account.external_account_id,
|
|
3509
|
+
targetTag,
|
|
3510
|
+
complianceConfig
|
|
3511
|
+
);
|
|
3512
|
+
const [, hash] = remoteDigest2.split("@");
|
|
3513
|
+
logger.debug(
|
|
3514
|
+
`'docker manifest inspect -v ${resolveImageName(account.external_account_id, remoteDigest2, complianceConfig)}:`
|
|
3515
|
+
);
|
|
3516
|
+
const remoteManifest = runDockerCmdWithOutput(pathToDocker, [
|
|
3517
|
+
"manifest",
|
|
3518
|
+
"inspect",
|
|
3519
|
+
"-v",
|
|
3520
|
+
resolveImageName(
|
|
3521
|
+
account.external_account_id,
|
|
3522
|
+
remoteDigest2,
|
|
3523
|
+
complianceConfig
|
|
3524
|
+
)
|
|
3525
|
+
]);
|
|
3526
|
+
const parsedRemoteManifest = JSON.parse(remoteManifest);
|
|
3527
|
+
if (parsedRemoteManifest.Descriptor.digest === hash) {
|
|
3528
|
+
logger.log("Image already exists remotely, skipping push");
|
|
3529
|
+
logger.debug(
|
|
3530
|
+
`Untagging built image: ${sourceTag} since there was no change.`
|
|
3531
|
+
);
|
|
3532
|
+
await runDockerCmd(pathToDocker, ["image", "rm", sourceTag]);
|
|
3533
|
+
return { remoteDigest: remoteDigest2 };
|
|
3534
|
+
}
|
|
3535
|
+
} catch (error) {
|
|
3536
|
+
if (error instanceof Error) {
|
|
3537
|
+
logger.debug(
|
|
3538
|
+
`Checking for local image ${sourceTag} failed with error: ${error.message}`
|
|
3539
|
+
);
|
|
3540
|
+
}
|
|
3541
|
+
}
|
|
3542
|
+
logger.log(
|
|
3543
|
+
`Image does not exist remotely, pushing: ${resolveImageName(
|
|
3544
|
+
account.external_account_id,
|
|
3545
|
+
targetTag,
|
|
3546
|
+
complianceConfig
|
|
3547
|
+
)}`
|
|
3548
|
+
);
|
|
3549
|
+
const namespacedImageTag = await tagAndPushImage({
|
|
3550
|
+
pathToDocker,
|
|
3551
|
+
sourceTag,
|
|
3552
|
+
targetTag,
|
|
3553
|
+
externalAccountId: account.external_account_id,
|
|
3554
|
+
complianceConfig,
|
|
3555
|
+
cleanupSourceTag
|
|
3556
|
+
});
|
|
3557
|
+
let remoteDigest;
|
|
3558
|
+
try {
|
|
3559
|
+
const pushedImageInfo = await dockerImageInspect(pathToDocker, {
|
|
3560
|
+
imageTag: namespacedImageTag,
|
|
3561
|
+
formatString: "{{ json .RepoDigests }}"
|
|
3562
|
+
});
|
|
3563
|
+
remoteDigest = findRemoteDigest(
|
|
3564
|
+
pushedImageInfo,
|
|
3565
|
+
account.external_account_id,
|
|
3566
|
+
namespacedImageTag,
|
|
3567
|
+
complianceConfig
|
|
3568
|
+
);
|
|
3569
|
+
} catch (error) {
|
|
3570
|
+
if (error instanceof Error) {
|
|
3571
|
+
logger.debug(
|
|
3572
|
+
`Inspecting pushed image ${namespacedImageTag} failed with error: ${error.message}`
|
|
3573
|
+
);
|
|
3574
|
+
}
|
|
3575
|
+
const remoteManifest = runDockerCmdWithOutput(pathToDocker, [
|
|
3576
|
+
"manifest",
|
|
3577
|
+
"inspect",
|
|
3578
|
+
"-v",
|
|
3579
|
+
namespacedImageTag
|
|
3580
|
+
]);
|
|
3581
|
+
remoteDigest = imageRefWithDigest(
|
|
3582
|
+
account.external_account_id,
|
|
3583
|
+
namespacedImageTag,
|
|
3584
|
+
findManifestDigest(remoteManifest),
|
|
3585
|
+
complianceConfig
|
|
3586
|
+
);
|
|
3587
|
+
}
|
|
3588
|
+
return { remoteDigest };
|
|
3589
|
+
}
|
|
3590
|
+
__name(pushImageIfChanged, "pushImageIfChanged");
|
|
3591
|
+
async function buildCommand(args, complianceConfig) {
|
|
3592
|
+
if (existsSync(args.PATH) && !isDirectory(args.PATH)) {
|
|
3593
|
+
throw new UserError(
|
|
3594
|
+
`${args.PATH} is not a directory. Please specify a valid directory path.`,
|
|
3595
|
+
{ telemetryMessage: "container build invalid path" }
|
|
3596
|
+
);
|
|
3597
|
+
}
|
|
3598
|
+
if (args.platform !== void 0 && args.platform !== "linux/amd64") {
|
|
3599
|
+
throw new UserError(
|
|
3600
|
+
`Unsupported platform: Platform "${args.platform}" is unsupported. Please use "linux/amd64" instead.`,
|
|
3601
|
+
{ telemetryMessage: "container build unsupported platform" }
|
|
3602
|
+
);
|
|
3603
|
+
}
|
|
3604
|
+
const pathToDockerfile = join(args.PATH, "Dockerfile");
|
|
3605
|
+
const pathToDocker = args.pathToDocker ?? getDockerPath();
|
|
3606
|
+
try {
|
|
3607
|
+
const build = await startContainerBuild({
|
|
3608
|
+
pathToDocker,
|
|
3609
|
+
build: {
|
|
3610
|
+
tag: args.tag,
|
|
3611
|
+
pathToDockerfile,
|
|
3612
|
+
buildContext: args.PATH,
|
|
3613
|
+
platform: args.platform
|
|
3614
|
+
// No option to add env vars at build time...?
|
|
3615
|
+
}
|
|
3616
|
+
});
|
|
3617
|
+
await build.ready;
|
|
3618
|
+
if (args.push) {
|
|
3619
|
+
await pushImageIfChanged({
|
|
3620
|
+
pathToDocker,
|
|
3621
|
+
sourceTag: args.tag,
|
|
3622
|
+
targetTag: args.tag,
|
|
3623
|
+
complianceConfig
|
|
3624
|
+
});
|
|
3625
|
+
}
|
|
3626
|
+
} catch (error) {
|
|
3627
|
+
if (error instanceof Error) {
|
|
3628
|
+
throw new UserError(error.message, {
|
|
3629
|
+
cause: error,
|
|
3630
|
+
telemetryMessage: "container build image operation failed"
|
|
3631
|
+
});
|
|
3632
|
+
}
|
|
3633
|
+
throw new UserError("An unknown error occurred", {
|
|
3634
|
+
telemetryMessage: "container build unknown error"
|
|
3635
|
+
});
|
|
3636
|
+
}
|
|
3637
|
+
}
|
|
3638
|
+
__name(buildCommand, "buildCommand");
|
|
3639
|
+
async function pushCommand(args, accountId, complianceConfig) {
|
|
3640
|
+
try {
|
|
3641
|
+
const dockerPath = args.pathToDocker ?? getDockerPath();
|
|
3642
|
+
await dockerLoginImageRegistry(
|
|
3643
|
+
dockerPath,
|
|
3644
|
+
getCloudflareContainerRegistry(complianceConfig)
|
|
3645
|
+
);
|
|
3646
|
+
await checkImagePlatform(dockerPath, args.TAG);
|
|
3647
|
+
const newTag = await tagAndPushImage({
|
|
3648
|
+
pathToDocker: dockerPath,
|
|
3649
|
+
sourceTag: args.TAG,
|
|
3650
|
+
targetTag: args.TAG,
|
|
3651
|
+
externalAccountId: accountId,
|
|
3652
|
+
complianceConfig
|
|
3653
|
+
});
|
|
3654
|
+
logger.log(`Pushed image: ${newTag}`);
|
|
3655
|
+
} catch (error) {
|
|
3656
|
+
if (error instanceof Error) {
|
|
3657
|
+
throw new UserError(error.message, {
|
|
3658
|
+
telemetryMessage: "container push failed"
|
|
3659
|
+
});
|
|
3660
|
+
}
|
|
3661
|
+
throw new UserError("An unknown error occurred", {
|
|
3662
|
+
telemetryMessage: "container push unknown error"
|
|
3663
|
+
});
|
|
3664
|
+
}
|
|
3665
|
+
}
|
|
3666
|
+
__name(pushCommand, "pushCommand");
|
|
3667
|
+
async function checkImagePlatform(pathToDocker, imageTag, expectedPlatform = "linux/amd64") {
|
|
3668
|
+
const platform = await dockerImageInspect(pathToDocker, {
|
|
3669
|
+
imageTag,
|
|
3670
|
+
formatString: "{{ .Os }}/{{ .Architecture }}"
|
|
3671
|
+
});
|
|
3672
|
+
if (platform !== expectedPlatform) {
|
|
3673
|
+
throw new Error(
|
|
3674
|
+
`Unsupported platform: Image platform (${platform}) does not match the expected platform (${expectedPlatform})`
|
|
3675
|
+
);
|
|
3676
|
+
}
|
|
3677
|
+
}
|
|
3678
|
+
__name(checkImagePlatform, "checkImagePlatform");
|
|
3679
|
+
async function buildAndMaybePush(args, pathToDocker, push, containerConfig, verifyDockerIsRunning, complianceConfig) {
|
|
3680
|
+
try {
|
|
3681
|
+
const build = await startContainerBuild({
|
|
3682
|
+
pathToDocker,
|
|
3683
|
+
verifyDockerIsRunning,
|
|
3684
|
+
build: args
|
|
3685
|
+
});
|
|
3686
|
+
await build.ready;
|
|
3687
|
+
if (!push) {
|
|
3688
|
+
return { newTag: args.tag };
|
|
3689
|
+
}
|
|
3690
|
+
return await pushImageIfChanged({
|
|
3691
|
+
pathToDocker,
|
|
3692
|
+
sourceTag: args.tag,
|
|
3693
|
+
targetTag: args.tag,
|
|
3694
|
+
containerConfig,
|
|
3695
|
+
complianceConfig,
|
|
3696
|
+
cleanupSourceTag: true
|
|
3697
|
+
});
|
|
3698
|
+
} catch (error) {
|
|
3699
|
+
if (error instanceof Error) {
|
|
3700
|
+
throw new UserError(error.message, {
|
|
3701
|
+
cause: error,
|
|
3702
|
+
telemetryMessage: "container build image operation failed"
|
|
3703
|
+
});
|
|
3704
|
+
}
|
|
3705
|
+
throw new UserError("An unknown error occurred", {
|
|
3706
|
+
telemetryMessage: "container build unknown error"
|
|
3707
|
+
});
|
|
3708
|
+
}
|
|
3709
|
+
}
|
|
3710
|
+
__name(buildAndMaybePush, "buildAndMaybePush");
|
|
3711
|
+
async function buildContainerImage(containerConfig, pathToDocker, verifyDockerIsRunning) {
|
|
3712
|
+
const localTag = `${getContainerImageRepositoryName(
|
|
3713
|
+
containerConfig
|
|
3714
|
+
)}:wrangler-${crypto.randomUUID()}`;
|
|
3715
|
+
logger.log("Building image", localTag);
|
|
3716
|
+
try {
|
|
3717
|
+
const build = await startContainerBuild({
|
|
3718
|
+
pathToDocker,
|
|
3719
|
+
verifyDockerIsRunning,
|
|
3720
|
+
build: {
|
|
3721
|
+
tag: localTag,
|
|
3722
|
+
pathToDockerfile: containerConfig.dockerfile,
|
|
3723
|
+
buildContext: containerConfig.image_build_context,
|
|
3724
|
+
args: containerConfig.image_vars
|
|
3725
|
+
}
|
|
3726
|
+
});
|
|
3727
|
+
await build.ready;
|
|
3728
|
+
return { container: containerConfig, localTag };
|
|
3729
|
+
} catch (error) {
|
|
3730
|
+
if (error instanceof Error) {
|
|
3731
|
+
throw new UserError(error.message, {
|
|
3732
|
+
cause: error,
|
|
3733
|
+
telemetryMessage: "container build image operation failed"
|
|
3734
|
+
});
|
|
3735
|
+
}
|
|
3736
|
+
throw new UserError("An unknown error occurred", {
|
|
3737
|
+
telemetryMessage: "container build unknown error"
|
|
3738
|
+
});
|
|
3739
|
+
}
|
|
3740
|
+
}
|
|
3741
|
+
__name(buildContainerImage, "buildContainerImage");
|
|
3742
|
+
async function buildContainerImages(containers, pathToDocker, verifyDockerIsRunning) {
|
|
3743
|
+
const builtImages = [];
|
|
3744
|
+
try {
|
|
3745
|
+
for (const container of containers.filter(isDockerfileContainerConfig)) {
|
|
3746
|
+
builtImages.push(
|
|
3747
|
+
await buildContainerImage(
|
|
3748
|
+
container,
|
|
3749
|
+
pathToDocker,
|
|
3750
|
+
verifyDockerIsRunning
|
|
3751
|
+
)
|
|
3752
|
+
);
|
|
3753
|
+
}
|
|
3754
|
+
} catch (error) {
|
|
3755
|
+
await cleanupBuiltImages(builtImages, pathToDocker);
|
|
3756
|
+
throw error;
|
|
3757
|
+
}
|
|
3758
|
+
return builtImages;
|
|
3759
|
+
}
|
|
3760
|
+
__name(buildContainerImages, "buildContainerImages");
|
|
3761
|
+
async function pushBuiltContainerImage(builtImage, versionId, pathToDocker, accountId, complianceConfig) {
|
|
3762
|
+
try {
|
|
3763
|
+
const imageRef = await pushImageIfChanged({
|
|
3764
|
+
pathToDocker,
|
|
3765
|
+
sourceTag: builtImage.localTag,
|
|
3766
|
+
targetTag: getContainerImageTag(builtImage.container, versionId),
|
|
3767
|
+
containerConfig: builtImage.container,
|
|
3768
|
+
accountId,
|
|
3769
|
+
complianceConfig,
|
|
3770
|
+
cleanupSourceTag: true
|
|
3771
|
+
});
|
|
3772
|
+
builtImage.localTagCleaned = true;
|
|
3773
|
+
return imageRef;
|
|
3774
|
+
} catch (error) {
|
|
3775
|
+
if (error instanceof Error) {
|
|
3776
|
+
throw new UserError(error.message, {
|
|
3777
|
+
cause: error,
|
|
3778
|
+
telemetryMessage: "container build image operation failed"
|
|
3779
|
+
});
|
|
3780
|
+
}
|
|
3781
|
+
throw new UserError("An unknown error occurred", {
|
|
3782
|
+
telemetryMessage: "container build unknown error"
|
|
3783
|
+
});
|
|
3784
|
+
}
|
|
3785
|
+
}
|
|
3786
|
+
__name(pushBuiltContainerImage, "pushBuiltContainerImage");
|
|
3787
|
+
async function cleanupBuiltImages(builtImages, pathToDocker) {
|
|
3788
|
+
for (const builtImage of builtImages) {
|
|
3789
|
+
if (builtImage.localTagCleaned) {
|
|
3790
|
+
continue;
|
|
3791
|
+
}
|
|
3792
|
+
try {
|
|
3793
|
+
logger.debug(`Untagging built image: ${builtImage.localTag}.`);
|
|
3794
|
+
await runDockerCmd(pathToDocker, ["image", "rm", builtImage.localTag]);
|
|
3795
|
+
builtImage.localTagCleaned = true;
|
|
3796
|
+
} catch (error) {
|
|
3797
|
+
if (error instanceof Error) {
|
|
3798
|
+
logger.debug(
|
|
3799
|
+
`Cleaning up built image ${builtImage.localTag} failed with error: ${error.message}`
|
|
3800
|
+
);
|
|
3801
|
+
}
|
|
3802
|
+
}
|
|
3803
|
+
}
|
|
3804
|
+
}
|
|
3805
|
+
__name(cleanupBuiltImages, "cleanupBuiltImages");
|
|
3806
|
+
function getContainerImageTag(containerConfig, imageTag) {
|
|
3807
|
+
return `${getContainerImageRepositoryName(containerConfig)}:${imageTag.split("-")[0]}`;
|
|
3808
|
+
}
|
|
3809
|
+
__name(getContainerImageTag, "getContainerImageTag");
|
|
3810
|
+
function getContainerImageRepositoryName(containerConfig) {
|
|
3811
|
+
return containerConfig.name.toLowerCase();
|
|
3812
|
+
}
|
|
3813
|
+
__name(getContainerImageRepositoryName, "getContainerImageRepositoryName");
|
|
3814
|
+
async function dockerBuild(dockerPath, options) {
|
|
3815
|
+
if (options.verifyDockerIsRunning !== false) {
|
|
3816
|
+
await verifyDockerInstalled({
|
|
3817
|
+
dockerPath,
|
|
3818
|
+
imageNoun: "the image"
|
|
3819
|
+
});
|
|
3820
|
+
}
|
|
3821
|
+
let errorHandled = false;
|
|
3822
|
+
let resolve2;
|
|
3823
|
+
let reject;
|
|
3824
|
+
const ready = new Promise((res, rej) => {
|
|
3825
|
+
resolve2 = res;
|
|
3826
|
+
reject = rej;
|
|
3827
|
+
});
|
|
3828
|
+
const child = spawn(dockerPath, options.buildCmd, {
|
|
3829
|
+
stdio: ["pipe", "inherit", "inherit"],
|
|
3830
|
+
// We need to set detached to true so that the child process
|
|
3831
|
+
// will control all of its child processes and we can kill
|
|
3832
|
+
// all of them in case we need to abort the build process.
|
|
3833
|
+
// On Windows, detached: true opens a new console window per child
|
|
3834
|
+
// process, so we only set it on non-Windows platforms.
|
|
3835
|
+
detached: process.platform !== "win32",
|
|
3836
|
+
// Prevent child processes from opening visible console windows on Windows.
|
|
3837
|
+
// This is a no-op on non-Windows platforms.
|
|
3838
|
+
windowsHide: true
|
|
3839
|
+
});
|
|
3840
|
+
if (child.stdin !== null) {
|
|
3841
|
+
child.stdin.write(options.dockerfile);
|
|
3842
|
+
child.stdin.end();
|
|
3843
|
+
}
|
|
3844
|
+
child.on("exit", (code) => {
|
|
3845
|
+
if (code === 0) {
|
|
3846
|
+
resolve2();
|
|
3847
|
+
} else if (!errorHandled) {
|
|
3848
|
+
errorHandled = true;
|
|
3849
|
+
reject(
|
|
3850
|
+
new UserError(`Docker build exited with code: ${code}`, {
|
|
3851
|
+
telemetryMessage: false
|
|
3852
|
+
})
|
|
3853
|
+
);
|
|
3854
|
+
}
|
|
3855
|
+
});
|
|
3856
|
+
child.on("error", (err) => {
|
|
3857
|
+
if (!errorHandled) {
|
|
3858
|
+
errorHandled = true;
|
|
3859
|
+
reject(err);
|
|
3860
|
+
}
|
|
3861
|
+
});
|
|
3862
|
+
return {
|
|
3863
|
+
abort: /* @__PURE__ */ __name(() => {
|
|
3864
|
+
child.unref();
|
|
3865
|
+
if (child.pid !== void 0) {
|
|
3866
|
+
if (process.platform === "win32") {
|
|
3867
|
+
child.kill();
|
|
3868
|
+
} else {
|
|
3869
|
+
process.kill(-child.pid);
|
|
3870
|
+
}
|
|
3871
|
+
}
|
|
3872
|
+
}, "abort"),
|
|
3873
|
+
ready
|
|
3874
|
+
};
|
|
3875
|
+
}
|
|
3876
|
+
__name(dockerBuild, "dockerBuild");
|
|
3877
|
+
var Diff = class {
|
|
3878
|
+
static {
|
|
3879
|
+
__name(this, "Diff");
|
|
3880
|
+
}
|
|
3881
|
+
#results = [];
|
|
3882
|
+
get changes() {
|
|
3883
|
+
return this.#results.filter((r) => r.added || r.removed).length;
|
|
3884
|
+
}
|
|
3885
|
+
constructor(a, b) {
|
|
3886
|
+
const oldString = tokenize(a);
|
|
3887
|
+
const newString = tokenize(b);
|
|
3888
|
+
const newLen = newString.length;
|
|
3889
|
+
const oldLen = oldString.length;
|
|
3890
|
+
let editLength = 1;
|
|
3891
|
+
const bestPath = [
|
|
3892
|
+
{ oldPos: -1, lastComponent: void 0 }
|
|
3893
|
+
];
|
|
3894
|
+
const initialPath = bestPath[0];
|
|
3895
|
+
if (initialPath === void 0) {
|
|
3896
|
+
throw new Error("unreachable");
|
|
3897
|
+
}
|
|
3898
|
+
let newPos = this.#extractCommon(initialPath, newString, oldString, 0);
|
|
3899
|
+
if (initialPath.oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
|
|
3900
|
+
this.#results = this.#buildValues(
|
|
3901
|
+
initialPath.lastComponent,
|
|
3902
|
+
newString,
|
|
3903
|
+
oldString,
|
|
3904
|
+
false
|
|
3905
|
+
);
|
|
3906
|
+
return;
|
|
3907
|
+
}
|
|
3908
|
+
let minDiagonalToConsider = -Infinity;
|
|
3909
|
+
let maxDiagonalToConsider = Infinity;
|
|
3910
|
+
let done = false;
|
|
3911
|
+
while (!done) {
|
|
3912
|
+
for (let diagonalPath = Math.max(minDiagonalToConsider, -editLength); diagonalPath <= Math.min(maxDiagonalToConsider, editLength); diagonalPath += 2) {
|
|
3913
|
+
let basePath;
|
|
3914
|
+
const removePath = bestPath[diagonalPath - 1];
|
|
3915
|
+
const addPath = bestPath[diagonalPath + 1];
|
|
3916
|
+
if (removePath) {
|
|
3917
|
+
bestPath[diagonalPath - 1] = void 0;
|
|
3918
|
+
}
|
|
3919
|
+
let canAdd = false;
|
|
3920
|
+
if (addPath) {
|
|
3921
|
+
const addPathNewPos = addPath.oldPos - diagonalPath;
|
|
3922
|
+
canAdd = addPath && 0 <= addPathNewPos && addPathNewPos < newLen;
|
|
3923
|
+
}
|
|
3924
|
+
const canRemove = removePath && removePath.oldPos + 1 < oldLen;
|
|
3925
|
+
if (!canAdd && !canRemove) {
|
|
3926
|
+
bestPath[diagonalPath] = void 0;
|
|
3927
|
+
continue;
|
|
3928
|
+
}
|
|
3929
|
+
if (addPath && (!canRemove || canAdd && (removePath?.oldPos ?? 0) < (addPath?.oldPos ?? 0))) {
|
|
3930
|
+
basePath = this.#addToPath(addPath, true, false, 0);
|
|
3931
|
+
} else if (removePath) {
|
|
3932
|
+
basePath = this.#addToPath(removePath, false, true, 1);
|
|
3933
|
+
} else {
|
|
3934
|
+
throw new Error("unreachable");
|
|
3935
|
+
}
|
|
3936
|
+
newPos = this.#extractCommon(
|
|
3937
|
+
basePath,
|
|
3938
|
+
newString,
|
|
3939
|
+
oldString,
|
|
3940
|
+
diagonalPath
|
|
3941
|
+
);
|
|
3942
|
+
if (basePath.oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
|
|
3943
|
+
this.#results = this.#buildValues(
|
|
3944
|
+
basePath.lastComponent,
|
|
3945
|
+
newString,
|
|
3946
|
+
oldString,
|
|
3947
|
+
false
|
|
3948
|
+
);
|
|
3949
|
+
done = true;
|
|
3950
|
+
break;
|
|
3951
|
+
}
|
|
3952
|
+
bestPath[diagonalPath] = basePath;
|
|
3953
|
+
if (basePath.oldPos + 1 >= oldLen) {
|
|
3954
|
+
maxDiagonalToConsider = Math.min(
|
|
3955
|
+
maxDiagonalToConsider,
|
|
3956
|
+
diagonalPath - 1
|
|
3957
|
+
);
|
|
3958
|
+
}
|
|
3959
|
+
if (newPos + 1 >= newLen) {
|
|
3960
|
+
minDiagonalToConsider = Math.max(
|
|
3961
|
+
minDiagonalToConsider,
|
|
3962
|
+
diagonalPath + 1
|
|
3963
|
+
);
|
|
3964
|
+
}
|
|
3965
|
+
}
|
|
3966
|
+
editLength++;
|
|
3967
|
+
}
|
|
3968
|
+
}
|
|
3969
|
+
/**
|
|
3970
|
+
* Results but refined to be printed/stringified.
|
|
3971
|
+
*
|
|
3972
|
+
* In particular the results returned here are ordered to try to avoid cases
|
|
3973
|
+
* in which an addition/removal is incorrectly split.
|
|
3974
|
+
*
|
|
3975
|
+
* For example, the standard results can produce something like:
|
|
3976
|
+
* ```
|
|
3977
|
+
* ...
|
|
3978
|
+
* - "vars": {
|
|
3979
|
+
* + "vars": {},
|
|
3980
|
+
* - "MY_VAR": "variable set in the dash"
|
|
3981
|
+
* - },
|
|
3982
|
+
* ...
|
|
3983
|
+
* ```
|
|
3984
|
+
* (notice how the first removal is separated from the last two,
|
|
3985
|
+
* making the diff much less readable).
|
|
3986
|
+
* Such change in the refined results will instead look like:
|
|
3987
|
+
* ```
|
|
3988
|
+
* ...
|
|
3989
|
+
* + "vars": {},
|
|
3990
|
+
* - "vars": {
|
|
3991
|
+
* - "MY_VAR": "variable set in the dash"
|
|
3992
|
+
* - },
|
|
3993
|
+
* ...
|
|
3994
|
+
* ```
|
|
3995
|
+
*/
|
|
3996
|
+
get #resultsForPrint() {
|
|
3997
|
+
const results = [
|
|
3998
|
+
...this.#results.filter((r) => !!r.value && r.value !== "\n")
|
|
3999
|
+
];
|
|
4000
|
+
const swapLines = /* @__PURE__ */ __name((i, j) => {
|
|
4001
|
+
const current = results[i];
|
|
4002
|
+
const adjacent = results[j];
|
|
4003
|
+
if (current === void 0 || adjacent === void 0) {
|
|
4004
|
+
return;
|
|
4005
|
+
}
|
|
4006
|
+
results[i] = adjacent;
|
|
4007
|
+
results[j] = current;
|
|
4008
|
+
}, "swapLines");
|
|
4009
|
+
const numOfLines = /* @__PURE__ */ __name((str) => str.split("\n").length, "numOfLines");
|
|
4010
|
+
const isLoneResult = /* @__PURE__ */ __name((index, target) => {
|
|
4011
|
+
const currentIdx = index;
|
|
4012
|
+
const adjacentIdx = currentIdx + target;
|
|
4013
|
+
const nextIdx = currentIdx + target + target;
|
|
4014
|
+
const current = results[currentIdx];
|
|
4015
|
+
const adjacent = results[adjacentIdx];
|
|
4016
|
+
const next = results[nextIdx];
|
|
4017
|
+
if (!current || !adjacent || !next) {
|
|
4018
|
+
return false;
|
|
4019
|
+
}
|
|
4020
|
+
const previousIdx = index - target;
|
|
4021
|
+
const isAlternation = /* @__PURE__ */ __name((type) => current[type] === true && results[previousIdx]?.[type] !== current[type] && adjacent[type === "added" ? "removed" : "added"] === true && next[type] === true, "isAlternation");
|
|
4022
|
+
if (!isAlternation("added") && !isAlternation("removed")) {
|
|
4023
|
+
return false;
|
|
4024
|
+
}
|
|
4025
|
+
return numOfLines(current.value ?? "") === 1 && numOfLines(adjacent.value ?? "") === 1 && numOfLines(next.value ?? "") > 1;
|
|
4026
|
+
}, "isLoneResult");
|
|
4027
|
+
for (let i = 0; i < results.length; i++) {
|
|
4028
|
+
if (isLoneResult(i, 1)) {
|
|
4029
|
+
swapLines(i, i + 1);
|
|
4030
|
+
continue;
|
|
4031
|
+
}
|
|
4032
|
+
if (isLoneResult(i, -1)) {
|
|
4033
|
+
swapLines(i, i - 1);
|
|
4034
|
+
continue;
|
|
4035
|
+
}
|
|
4036
|
+
}
|
|
4037
|
+
return results;
|
|
4038
|
+
}
|
|
4039
|
+
toString(options = {
|
|
4040
|
+
contextLines: 3
|
|
4041
|
+
}) {
|
|
4042
|
+
let output = "";
|
|
4043
|
+
let state = "init";
|
|
4044
|
+
const context = [];
|
|
4045
|
+
for (const result of this.#resultsForPrint) {
|
|
4046
|
+
if (result.value === void 0) {
|
|
4047
|
+
continue;
|
|
4048
|
+
}
|
|
4049
|
+
if (result.added || result.removed) {
|
|
4050
|
+
if (state === "diff") {
|
|
4051
|
+
context.splice(0, options.contextLines).filter(Boolean).forEach((c) => {
|
|
4052
|
+
output += ` ${c}
|
|
4053
|
+
`;
|
|
4054
|
+
});
|
|
4055
|
+
if (context.length > options.contextLines) {
|
|
4056
|
+
output += "\n ...\n\n";
|
|
4057
|
+
}
|
|
4058
|
+
}
|
|
4059
|
+
context.splice(0, context.length - options.contextLines);
|
|
4060
|
+
if (state === "init") {
|
|
4061
|
+
while (context[0]?.trim() === "") {
|
|
4062
|
+
context.shift();
|
|
4063
|
+
}
|
|
4064
|
+
}
|
|
4065
|
+
context.filter(Boolean).forEach((c) => {
|
|
4066
|
+
output += ` ${c}
|
|
4067
|
+
`;
|
|
4068
|
+
});
|
|
4069
|
+
context.length = 0;
|
|
4070
|
+
for (const l of result.value.split("\n")) {
|
|
4071
|
+
if (l) {
|
|
4072
|
+
output += `${result.added ? green("+") : red("-")} ${l}
|
|
4073
|
+
`;
|
|
4074
|
+
}
|
|
4075
|
+
}
|
|
4076
|
+
state = "diff";
|
|
4077
|
+
} else {
|
|
4078
|
+
const lines = result.value.replace(/^\n|\n$/g, "").split("\n");
|
|
4079
|
+
context.push(...lines);
|
|
4080
|
+
}
|
|
4081
|
+
}
|
|
4082
|
+
if (state === "diff") {
|
|
4083
|
+
context.splice(options.contextLines);
|
|
4084
|
+
while (context[context.length - 1]?.trim() === "") {
|
|
4085
|
+
context.pop();
|
|
4086
|
+
}
|
|
4087
|
+
context.filter(Boolean).forEach((c) => {
|
|
4088
|
+
output += ` ${c}
|
|
4089
|
+
`;
|
|
4090
|
+
});
|
|
4091
|
+
}
|
|
4092
|
+
return output.replace(/\n$/, "");
|
|
4093
|
+
}
|
|
4094
|
+
print(options = {
|
|
4095
|
+
contextLines: 3
|
|
4096
|
+
}) {
|
|
4097
|
+
log(this.toString(options));
|
|
4098
|
+
}
|
|
4099
|
+
#addToPath(path, added, removed, oldPosInc) {
|
|
4100
|
+
const last = path.lastComponent;
|
|
4101
|
+
if (last && last.added === added && last.removed === removed) {
|
|
4102
|
+
return {
|
|
4103
|
+
oldPos: path.oldPos + oldPosInc,
|
|
4104
|
+
lastComponent: {
|
|
4105
|
+
count: last.count + 1,
|
|
4106
|
+
added,
|
|
4107
|
+
removed,
|
|
4108
|
+
previousComponent: last.previousComponent
|
|
4109
|
+
}
|
|
4110
|
+
};
|
|
4111
|
+
}
|
|
4112
|
+
return {
|
|
4113
|
+
oldPos: path.oldPos + oldPosInc,
|
|
4114
|
+
lastComponent: {
|
|
4115
|
+
count: 1,
|
|
4116
|
+
added,
|
|
4117
|
+
removed,
|
|
4118
|
+
previousComponent: last
|
|
4119
|
+
}
|
|
4120
|
+
};
|
|
4121
|
+
}
|
|
4122
|
+
#extractCommon(basePath, newString, oldString, diagonalPath) {
|
|
4123
|
+
const newLen = newString.length;
|
|
4124
|
+
const oldLen = oldString.length;
|
|
4125
|
+
let oldPos = basePath.oldPos, newPos = oldPos - diagonalPath, commonCount = 0;
|
|
4126
|
+
while (newPos + 1 < newLen && oldPos + 1 < oldLen && oldString[oldPos + 1] === newString[newPos + 1]) {
|
|
4127
|
+
newPos++;
|
|
4128
|
+
oldPos++;
|
|
4129
|
+
commonCount++;
|
|
4130
|
+
}
|
|
4131
|
+
if (commonCount) {
|
|
4132
|
+
basePath.lastComponent = {
|
|
4133
|
+
count: commonCount,
|
|
4134
|
+
previousComponent: basePath.lastComponent,
|
|
4135
|
+
added: false,
|
|
4136
|
+
removed: false
|
|
4137
|
+
};
|
|
4138
|
+
}
|
|
4139
|
+
basePath.oldPos = oldPos;
|
|
4140
|
+
return newPos;
|
|
4141
|
+
}
|
|
4142
|
+
#buildValues(lastComponent, newString, oldString, useLongestToken) {
|
|
4143
|
+
const components = [];
|
|
4144
|
+
let nextComponent;
|
|
4145
|
+
while (lastComponent) {
|
|
4146
|
+
components.push(lastComponent);
|
|
4147
|
+
nextComponent = lastComponent.previousComponent;
|
|
4148
|
+
delete lastComponent.previousComponent;
|
|
4149
|
+
lastComponent = nextComponent;
|
|
4150
|
+
}
|
|
4151
|
+
components.reverse();
|
|
4152
|
+
const componentLen = components.length;
|
|
4153
|
+
let componentPos = 0, newPos = 0, oldPos = 0;
|
|
4154
|
+
for (; componentPos < componentLen; componentPos++) {
|
|
4155
|
+
const component = components[componentPos];
|
|
4156
|
+
if (component === void 0) {
|
|
4157
|
+
throw new Error("unreachable");
|
|
4158
|
+
}
|
|
4159
|
+
if (!component.removed) {
|
|
4160
|
+
if (!component.added && useLongestToken) {
|
|
4161
|
+
let value = newString.slice(newPos, newPos + component.count);
|
|
4162
|
+
value = value.map((el, i) => {
|
|
4163
|
+
const oldValue = oldString[oldPos + i];
|
|
4164
|
+
if (oldValue !== void 0 && oldValue.length > el.length) {
|
|
4165
|
+
return oldValue;
|
|
4166
|
+
}
|
|
4167
|
+
return el;
|
|
4168
|
+
});
|
|
4169
|
+
component.value = value.join("");
|
|
4170
|
+
} else {
|
|
4171
|
+
component.value = newString.slice(newPos, newPos + component.count).join("");
|
|
4172
|
+
}
|
|
4173
|
+
newPos += component.count;
|
|
4174
|
+
if (!component.added) {
|
|
4175
|
+
oldPos += component.count;
|
|
4176
|
+
}
|
|
4177
|
+
} else {
|
|
4178
|
+
component.value = oldString.slice(oldPos, oldPos + component.count).join("");
|
|
4179
|
+
oldPos += component.count;
|
|
4180
|
+
}
|
|
4181
|
+
}
|
|
4182
|
+
return components;
|
|
4183
|
+
}
|
|
4184
|
+
};
|
|
4185
|
+
function tokenize(value) {
|
|
4186
|
+
const retLines = [];
|
|
4187
|
+
const linesAndNewlines = value.split(/(\n|\r\n)/);
|
|
4188
|
+
if (!linesAndNewlines[linesAndNewlines.length - 1]) {
|
|
4189
|
+
linesAndNewlines.pop();
|
|
4190
|
+
}
|
|
4191
|
+
for (let i = 0; i < linesAndNewlines.length; i++) {
|
|
4192
|
+
const line = linesAndNewlines[i];
|
|
4193
|
+
if (line !== void 0) {
|
|
4194
|
+
retLines.push(line);
|
|
4195
|
+
}
|
|
4196
|
+
}
|
|
4197
|
+
return retLines.filter((s) => s !== "");
|
|
4198
|
+
}
|
|
4199
|
+
__name(tokenize, "tokenize");
|
|
4200
|
+
|
|
4201
|
+
// src/object.ts
|
|
4202
|
+
function stripUndefined(r) {
|
|
4203
|
+
for (const k in r) {
|
|
4204
|
+
if (r[k] === void 0) {
|
|
4205
|
+
delete r[k];
|
|
4206
|
+
}
|
|
4207
|
+
}
|
|
4208
|
+
return r;
|
|
4209
|
+
}
|
|
4210
|
+
__name(stripUndefined, "stripUndefined");
|
|
4211
|
+
function sortObjectKeys(unordered) {
|
|
4212
|
+
if (Array.isArray(unordered)) {
|
|
4213
|
+
return unordered;
|
|
4214
|
+
}
|
|
4215
|
+
return Object.keys(unordered).sort().reduce(
|
|
4216
|
+
(obj, key) => {
|
|
4217
|
+
obj[key] = unordered[key];
|
|
4218
|
+
return obj;
|
|
4219
|
+
},
|
|
4220
|
+
{}
|
|
4221
|
+
);
|
|
4222
|
+
}
|
|
4223
|
+
__name(sortObjectKeys, "sortObjectKeys");
|
|
4224
|
+
function sortObjectRecursive(object) {
|
|
4225
|
+
if (typeof object !== "object") {
|
|
4226
|
+
return object;
|
|
4227
|
+
}
|
|
4228
|
+
if (Array.isArray(object)) {
|
|
4229
|
+
return object.map((obj) => sortObjectRecursive(obj));
|
|
4230
|
+
}
|
|
4231
|
+
const objectCopy = { ...object };
|
|
4232
|
+
for (const [key, value] of Object.entries(object)) {
|
|
4233
|
+
if (typeof value === "object") {
|
|
4234
|
+
if (value === null) {
|
|
4235
|
+
continue;
|
|
4236
|
+
}
|
|
4237
|
+
objectCopy[key] = sortObjectRecursive(
|
|
4238
|
+
value
|
|
4239
|
+
);
|
|
4240
|
+
}
|
|
4241
|
+
}
|
|
4242
|
+
return sortObjectKeys(objectCopy);
|
|
4243
|
+
}
|
|
4244
|
+
__name(sortObjectRecursive, "sortObjectRecursive");
|
|
4245
|
+
async function promiseSpinner(promise, {
|
|
4246
|
+
message
|
|
4247
|
+
} = {
|
|
4248
|
+
message: "Loading"
|
|
4249
|
+
}) {
|
|
4250
|
+
if (process.env.CI || !process.stdin.isTTY) {
|
|
4251
|
+
return promise;
|
|
4252
|
+
}
|
|
4253
|
+
const { start, stop } = spinner();
|
|
4254
|
+
start(message);
|
|
4255
|
+
const t = await promise.catch((err) => {
|
|
4256
|
+
stop();
|
|
4257
|
+
throw err;
|
|
4258
|
+
});
|
|
4259
|
+
stop();
|
|
4260
|
+
return t;
|
|
4261
|
+
}
|
|
4262
|
+
__name(promiseSpinner, "promiseSpinner");
|
|
4263
|
+
|
|
4264
|
+
// src/deploy.ts
|
|
4265
|
+
function createDurableObjectNamespaceResolver(config, { versionId, accountId, scriptName, dispatchNamespace }) {
|
|
4266
|
+
const boundDOs = new Set(
|
|
4267
|
+
config.durable_objects.bindings.map((binding) => binding.class_name)
|
|
4268
|
+
);
|
|
4269
|
+
let maybeVersionInfo;
|
|
4270
|
+
let maybeAllDurableObjects;
|
|
4271
|
+
return async (className) => {
|
|
4272
|
+
if (boundDOs.has(className) && dispatchNamespace === void 0) {
|
|
4273
|
+
maybeVersionInfo ??= await fetchUploadedVersion(
|
|
4274
|
+
config,
|
|
4275
|
+
accountId,
|
|
4276
|
+
scriptName,
|
|
4277
|
+
versionId
|
|
4278
|
+
);
|
|
4279
|
+
const targetDurableObject2 = maybeVersionInfo.resources.bindings.find(
|
|
4280
|
+
(binding) => binding.type === "durable_object_namespace" && binding.class_name === className && (binding.script_name === void 0 || binding.script_name === scriptName) && binding.namespace_id !== void 0
|
|
4281
|
+
);
|
|
4282
|
+
if (!targetDurableObject2?.namespace_id) {
|
|
4283
|
+
throw new UserError(
|
|
4284
|
+
"Could not deploy container configuration as durable object was not found in list of bindings",
|
|
4285
|
+
{
|
|
4286
|
+
telemetryMessage: "containers deploy durable object binding missing"
|
|
4287
|
+
}
|
|
4288
|
+
);
|
|
4289
|
+
}
|
|
4290
|
+
return targetDurableObject2.namespace_id;
|
|
4291
|
+
}
|
|
4292
|
+
maybeAllDurableObjects ??= await listDurableObjects(config, accountId);
|
|
4293
|
+
const targetDurableObject = maybeAllDurableObjects.find(
|
|
4294
|
+
(durableObject) => durableObject.class === className && durableObject.script === scriptName && durableObject.preview === void 0 && durableObject.dispatch_namespace === dispatchNamespace
|
|
4295
|
+
);
|
|
4296
|
+
if (!targetDurableObject) {
|
|
4297
|
+
throw new UserError(
|
|
4298
|
+
"Could not deploy container configuration as durable object was not found in the account namespace list",
|
|
4299
|
+
{
|
|
4300
|
+
telemetryMessage: "containers deploy durable object namespace missing"
|
|
4301
|
+
}
|
|
4302
|
+
);
|
|
4303
|
+
}
|
|
4304
|
+
return targetDurableObject.id;
|
|
4305
|
+
};
|
|
4306
|
+
}
|
|
4307
|
+
__name(createDurableObjectNamespaceResolver, "createDurableObjectNamespaceResolver");
|
|
4308
|
+
async function deployContainers(config, containerDeployments, { versionId, accountId, scriptName, dispatchNamespace }) {
|
|
4309
|
+
const resolveNamespaceId = createDurableObjectNamespaceResolver(config, {
|
|
4310
|
+
versionId,
|
|
4311
|
+
accountId,
|
|
4312
|
+
scriptName,
|
|
4313
|
+
dispatchNamespace
|
|
4314
|
+
});
|
|
4315
|
+
for (const { container, imageRef } of containerDeployments) {
|
|
4316
|
+
const namespaceId = await resolveNamespaceId(container.class_name);
|
|
4317
|
+
await apply(
|
|
4318
|
+
{
|
|
4319
|
+
imageRef,
|
|
4320
|
+
durable_object_namespace_id: namespaceId
|
|
4321
|
+
},
|
|
4322
|
+
container,
|
|
4323
|
+
config,
|
|
4324
|
+
accountId
|
|
4325
|
+
);
|
|
4326
|
+
}
|
|
4327
|
+
}
|
|
4328
|
+
__name(deployContainers, "deployContainers");
|
|
4329
|
+
async function fetchUploadedVersion(config, accountId, scriptName, versionId) {
|
|
4330
|
+
for (let attempt = 0; attempt < 5; attempt++) {
|
|
4331
|
+
try {
|
|
4332
|
+
return await fetchResult(
|
|
4333
|
+
config,
|
|
4334
|
+
`/accounts/${accountId}/workers/scripts/${scriptName}/versions/${versionId}`
|
|
4335
|
+
);
|
|
4336
|
+
} catch (error) {
|
|
4337
|
+
if (!isUploadedVersionNotReadyError(error) || attempt === 4) {
|
|
4338
|
+
throw error;
|
|
4339
|
+
}
|
|
4340
|
+
await setTimeout(500);
|
|
4341
|
+
}
|
|
4342
|
+
}
|
|
4343
|
+
throw new Error("Unable to fetch uploaded Worker version");
|
|
4344
|
+
}
|
|
4345
|
+
__name(fetchUploadedVersion, "fetchUploadedVersion");
|
|
4346
|
+
function isUploadedVersionNotReadyError(error) {
|
|
4347
|
+
return error instanceof Error && "code" in error && error.code === 100146;
|
|
4348
|
+
}
|
|
4349
|
+
__name(isUploadedVersionNotReadyError, "isUploadedVersionNotReadyError");
|
|
4350
|
+
async function listDurableObjects(complianceConfig, accountId) {
|
|
4351
|
+
return await fetchPagedListResult(
|
|
4352
|
+
complianceConfig,
|
|
4353
|
+
`/accounts/${accountId}/workers/durable_objects/namespaces`,
|
|
4354
|
+
{},
|
|
4355
|
+
new URLSearchParams({ per_page: "1000" })
|
|
4356
|
+
);
|
|
4357
|
+
}
|
|
4358
|
+
__name(listDurableObjects, "listDurableObjects");
|
|
4359
|
+
function mergeDeep(target, source) {
|
|
4360
|
+
if (typeof target !== "object" || target === null) {
|
|
4361
|
+
return source;
|
|
4362
|
+
}
|
|
4363
|
+
if (typeof source !== "object" || source === null) {
|
|
4364
|
+
return target;
|
|
4365
|
+
}
|
|
4366
|
+
const result = { ...target };
|
|
4367
|
+
for (const key of Object.keys(source)) {
|
|
4368
|
+
const srcVal = source[key];
|
|
4369
|
+
const tgtVal = target[key];
|
|
4370
|
+
if (isObject(tgtVal) && isObject(srcVal)) {
|
|
4371
|
+
result[key] = mergeDeep(tgtVal, srcVal);
|
|
4372
|
+
} else {
|
|
4373
|
+
result[key] = srcVal;
|
|
4374
|
+
}
|
|
4375
|
+
}
|
|
4376
|
+
return result;
|
|
4377
|
+
}
|
|
4378
|
+
__name(mergeDeep, "mergeDeep");
|
|
4379
|
+
function isObject(value) {
|
|
4380
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4381
|
+
}
|
|
4382
|
+
__name(isObject, "isObject");
|
|
4383
|
+
function createApplicationToModifyApplication(req) {
|
|
4384
|
+
return {
|
|
4385
|
+
configuration: req.configuration,
|
|
4386
|
+
observability: req.observability,
|
|
4387
|
+
max_instances: req.max_instances,
|
|
4388
|
+
constraints: req.constraints,
|
|
4389
|
+
affinities: req.affinities,
|
|
4390
|
+
scheduling_policy: req.scheduling_policy,
|
|
4391
|
+
rollout_active_grace_period: req.rollout_active_grace_period
|
|
4392
|
+
};
|
|
4393
|
+
}
|
|
4394
|
+
__name(createApplicationToModifyApplication, "createApplicationToModifyApplication");
|
|
4395
|
+
function isLegacyObservabilityEnabled(observability) {
|
|
4396
|
+
return observability?.logs?.enabled === true;
|
|
4397
|
+
}
|
|
4398
|
+
__name(isLegacyObservabilityEnabled, "isLegacyObservabilityEnabled");
|
|
4399
|
+
function hasLegacyRolloutObservabilityEnabled(app) {
|
|
4400
|
+
return isLegacyObservabilityEnabled(app?.configuration.observability) || isLegacyObservabilityEnabled(
|
|
4401
|
+
app?.scheduling_hint?.target.configuration.observability
|
|
4402
|
+
);
|
|
4403
|
+
}
|
|
4404
|
+
__name(hasLegacyRolloutObservabilityEnabled, "hasLegacyRolloutObservabilityEnabled");
|
|
4405
|
+
function getLatestLegacyObservabilityState(app) {
|
|
4406
|
+
return app?.scheduling_hint?.target.configuration.observability ?? app?.configuration.observability;
|
|
4407
|
+
}
|
|
4408
|
+
__name(getLatestLegacyObservabilityState, "getLatestLegacyObservabilityState");
|
|
4409
|
+
function usesTopLevelObservability(app) {
|
|
4410
|
+
return app?.observability !== void 0;
|
|
4411
|
+
}
|
|
4412
|
+
__name(usesTopLevelObservability, "usesTopLevelObservability");
|
|
4413
|
+
function hasTopLevelOnlyObservabilityFields(observability) {
|
|
4414
|
+
return observability.target_instance_percentage !== void 0 || observability.target_instance_count !== void 0;
|
|
4415
|
+
}
|
|
4416
|
+
__name(hasTopLevelOnlyObservabilityFields, "hasTopLevelOnlyObservabilityFields");
|
|
4417
|
+
function selectObservabilityWriteTarget(prevApp) {
|
|
4418
|
+
if (prevApp === void 0) {
|
|
4419
|
+
return "top-level";
|
|
4420
|
+
}
|
|
4421
|
+
if (hasLegacyRolloutObservabilityEnabled(prevApp)) {
|
|
4422
|
+
return "configuration";
|
|
4423
|
+
}
|
|
4424
|
+
return "top-level";
|
|
4425
|
+
}
|
|
4426
|
+
__name(selectObservabilityWriteTarget, "selectObservabilityWriteTarget");
|
|
4427
|
+
function hasMixedEnabledObservability(app) {
|
|
4428
|
+
return app.observability?.logs?.enabled === true && isLegacyObservabilityEnabled(app.configuration.observability);
|
|
4429
|
+
}
|
|
4430
|
+
__name(hasMixedEnabledObservability, "hasMixedEnabledObservability");
|
|
4431
|
+
function requiresObservabilityMigration(app, observability) {
|
|
4432
|
+
return hasLegacyRolloutObservabilityEnabled(app) && (app.observability?.logs?.enabled === true || usesTopLevelObservability(app) && observability.logs_enabled);
|
|
4433
|
+
}
|
|
4434
|
+
__name(requiresObservabilityMigration, "requiresObservabilityMigration");
|
|
4435
|
+
function buildLegacyObservabilityMigrationPatch(app) {
|
|
4436
|
+
const observability = app.configuration.observability;
|
|
4437
|
+
assert(observability?.logs?.enabled === true);
|
|
4438
|
+
return { logs: observability.logs };
|
|
4439
|
+
}
|
|
4440
|
+
__name(buildLegacyObservabilityMigrationPatch, "buildLegacyObservabilityMigrationPatch");
|
|
4441
|
+
function migrateLegacyObservabilityState(app, observability) {
|
|
4442
|
+
const configuration = { ...app.configuration };
|
|
4443
|
+
delete configuration.observability;
|
|
4444
|
+
return {
|
|
4445
|
+
...app,
|
|
4446
|
+
configuration,
|
|
4447
|
+
observability
|
|
4448
|
+
};
|
|
4449
|
+
}
|
|
4450
|
+
__name(migrateLegacyObservabilityState, "migrateLegacyObservabilityState");
|
|
4451
|
+
function buildTopLevelObservability(observability) {
|
|
4452
|
+
return stripUndefined({
|
|
4453
|
+
logs: { enabled: observability.logs_enabled },
|
|
4454
|
+
target_instance_percentage: observability.target_instance_percentage,
|
|
4455
|
+
target_instance_count: observability.target_instance_count
|
|
4456
|
+
});
|
|
4457
|
+
}
|
|
4458
|
+
__name(buildTopLevelObservability, "buildTopLevelObservability");
|
|
4459
|
+
function buildConfigurationObservability(observability) {
|
|
4460
|
+
return {
|
|
4461
|
+
logs: {
|
|
4462
|
+
enabled: observability.logs_enabled
|
|
4463
|
+
}
|
|
4464
|
+
};
|
|
4465
|
+
}
|
|
4466
|
+
__name(buildConfigurationObservability, "buildConfigurationObservability");
|
|
4467
|
+
function isSameApplicationObservability(left, right) {
|
|
4468
|
+
return left?.logs?.enabled === right?.logs?.enabled && left?.target_instance_percentage === right?.target_instance_percentage && left?.target_instance_count === right?.target_instance_count;
|
|
4469
|
+
}
|
|
4470
|
+
__name(isSameApplicationObservability, "isSameApplicationObservability");
|
|
4471
|
+
function buildTopLevelObservabilityPatch(observability, prevApp, writeTarget) {
|
|
4472
|
+
if (writeTarget === "configuration" && !usesTopLevelObservability(prevApp)) {
|
|
4473
|
+
return void 0;
|
|
4474
|
+
}
|
|
4475
|
+
const shouldWriteDisabledTopLevelObservability = prevApp?.observability !== void 0 && (prevApp.observability.logs?.enabled === true || prevApp.observability.target_instance_percentage !== void 0 || prevApp.observability.target_instance_count !== void 0);
|
|
4476
|
+
if (!observability.logs_enabled && !hasTopLevelOnlyObservabilityFields(observability)) {
|
|
4477
|
+
return shouldWriteDisabledTopLevelObservability ? buildTopLevelObservability(observability) : void 0;
|
|
4478
|
+
}
|
|
4479
|
+
const nextObservability = buildTopLevelObservability(observability);
|
|
4480
|
+
return isSameApplicationObservability(
|
|
4481
|
+
nextObservability,
|
|
4482
|
+
prevApp?.observability
|
|
4483
|
+
) ? void 0 : nextObservability;
|
|
4484
|
+
}
|
|
4485
|
+
__name(buildTopLevelObservabilityPatch, "buildTopLevelObservabilityPatch");
|
|
4486
|
+
function buildConfigurationObservabilityPatch(observability, prevApp) {
|
|
4487
|
+
const latestLegacyLogsEnabled = getLatestLegacyObservabilityState(prevApp)?.logs?.enabled;
|
|
4488
|
+
if (observability.logs_enabled === latestLegacyLogsEnabled) {
|
|
4489
|
+
return void 0;
|
|
4490
|
+
}
|
|
4491
|
+
if (!observability.logs_enabled && latestLegacyLogsEnabled === void 0) {
|
|
4492
|
+
return void 0;
|
|
4493
|
+
}
|
|
4494
|
+
return buildConfigurationObservability(observability);
|
|
4495
|
+
}
|
|
4496
|
+
__name(buildConfigurationObservabilityPatch, "buildConfigurationObservabilityPatch");
|
|
4497
|
+
function buildApplicationObservabilityPatch(observability, writeTarget, prevApp) {
|
|
4498
|
+
const nextTopLevelObservability = buildTopLevelObservabilityPatch(
|
|
4499
|
+
observability,
|
|
4500
|
+
prevApp,
|
|
4501
|
+
writeTarget
|
|
4502
|
+
);
|
|
4503
|
+
if (writeTarget === "configuration") {
|
|
4504
|
+
const nextConfigurationObservability = buildConfigurationObservabilityPatch(
|
|
4505
|
+
observability,
|
|
4506
|
+
prevApp
|
|
4507
|
+
);
|
|
4508
|
+
return {
|
|
4509
|
+
...nextTopLevelObservability !== void 0 ? { observability: nextTopLevelObservability } : {},
|
|
4510
|
+
...nextConfigurationObservability !== void 0 ? {
|
|
4511
|
+
configurationObservability: nextConfigurationObservability
|
|
4512
|
+
} : {}
|
|
4513
|
+
};
|
|
4514
|
+
}
|
|
4515
|
+
return nextTopLevelObservability !== void 0 ? { observability: nextTopLevelObservability } : {};
|
|
4516
|
+
}
|
|
4517
|
+
__name(buildApplicationObservabilityPatch, "buildApplicationObservabilityPatch");
|
|
4518
|
+
function assertCanUseApplicationObservabilityTargeting(prevApp, containerConfig) {
|
|
4519
|
+
if (!hasTopLevelOnlyObservabilityFields(containerConfig.observability)) {
|
|
4520
|
+
return;
|
|
4521
|
+
}
|
|
4522
|
+
if (!hasLegacyRolloutObservabilityEnabled(prevApp)) {
|
|
4523
|
+
return;
|
|
4524
|
+
}
|
|
4525
|
+
throw new UserError(
|
|
4526
|
+
`Application-level observability targeting cannot be enabled for container ${containerConfig.name} while it still uses legacy rollout-based observability. Set containers[].observability.enabled = false in your Wrangler config and deploy once, then deploy again with target_instance_percentage or target_instance_count.`,
|
|
4527
|
+
{
|
|
4528
|
+
telemetryMessage: "containers deploy observability migration blocked"
|
|
4529
|
+
}
|
|
4530
|
+
);
|
|
4531
|
+
}
|
|
4532
|
+
__name(assertCanUseApplicationObservabilityTargeting, "assertCanUseApplicationObservabilityTargeting");
|
|
4533
|
+
function hasRolloutDiff(prevApp, nextApp) {
|
|
4534
|
+
const normalizedPrevApp = stripUndefined({ ...prevApp });
|
|
4535
|
+
const normalizedNextApp = stripUndefined({ ...nextApp });
|
|
4536
|
+
delete normalizedPrevApp.observability;
|
|
4537
|
+
delete normalizedNextApp.observability;
|
|
4538
|
+
return JSON.stringify(sortObjectRecursive(normalizedPrevApp)) !== JSON.stringify(sortObjectRecursive(normalizedNextApp));
|
|
4539
|
+
}
|
|
4540
|
+
__name(hasRolloutDiff, "hasRolloutDiff");
|
|
4541
|
+
function containerConfigToCreateRequest(accountId, containerApp, imageRef, durableObjectNamespaceId, complianceConfig, observabilityWriteTarget, prevApp) {
|
|
4542
|
+
const { observability, configurationObservability } = buildApplicationObservabilityPatch(
|
|
4543
|
+
containerApp.observability,
|
|
4544
|
+
observabilityWriteTarget,
|
|
4545
|
+
prevApp
|
|
4546
|
+
);
|
|
4547
|
+
return {
|
|
4548
|
+
name: containerApp.name,
|
|
4549
|
+
scheduling_policy: containerApp.scheduling_policy,
|
|
4550
|
+
...observability !== void 0 ? { observability } : {},
|
|
4551
|
+
configuration: {
|
|
4552
|
+
// De-sugar image name
|
|
4553
|
+
image: resolveImageName(accountId, imageRef, complianceConfig),
|
|
4554
|
+
// if disk/memory/vcpu is not defined in config, AND instance_type is also not defined, this will already have been defaulted to 'dev'
|
|
4555
|
+
..."instance_type" in containerApp ? { instance_type: containerApp.instance_type } : {
|
|
4556
|
+
disk: { size_mb: containerApp.disk_bytes / (1e3 * 1e3) },
|
|
4557
|
+
memory_mib: containerApp.memory_mib,
|
|
4558
|
+
vcpu: containerApp.vcpu
|
|
4559
|
+
},
|
|
4560
|
+
...configurationObservability !== void 0 ? { observability: configurationObservability } : {},
|
|
4561
|
+
wrangler_ssh: containerApp.wrangler_ssh,
|
|
4562
|
+
authorized_keys: containerApp.authorized_keys,
|
|
4563
|
+
trusted_user_ca_keys: containerApp.trusted_user_ca_keys
|
|
4564
|
+
},
|
|
4565
|
+
// deprecated in favour of max_instances
|
|
4566
|
+
instances: 0,
|
|
4567
|
+
max_instances: containerApp.max_instances,
|
|
4568
|
+
constraints: containerApp.constraints,
|
|
4569
|
+
affinities: containerApp.affinities,
|
|
4570
|
+
durable_objects: {
|
|
4571
|
+
namespace_id: durableObjectNamespaceId
|
|
4572
|
+
},
|
|
4573
|
+
rollout_active_grace_period: containerApp.rollout_active_grace_period
|
|
4574
|
+
};
|
|
4575
|
+
}
|
|
4576
|
+
__name(containerConfigToCreateRequest, "containerConfigToCreateRequest");
|
|
4577
|
+
function formatContainerSnippetForDisplay(container, configPath) {
|
|
4578
|
+
const configurationForDisplay = container.configuration === void 0 ? void 0 : Object.fromEntries(
|
|
4579
|
+
Object.entries(container.configuration).map(([key, value]) => [
|
|
4580
|
+
key === "wrangler_ssh" ? "ssh" : key,
|
|
4581
|
+
value
|
|
4582
|
+
])
|
|
4583
|
+
);
|
|
4584
|
+
const snippet = {
|
|
4585
|
+
containers: [
|
|
4586
|
+
{
|
|
4587
|
+
...container,
|
|
4588
|
+
configuration: configurationForDisplay
|
|
4589
|
+
}
|
|
4590
|
+
]
|
|
4591
|
+
};
|
|
4592
|
+
return formatConfigSnippet(snippet, configPath);
|
|
4593
|
+
}
|
|
4594
|
+
__name(formatContainerSnippetForDisplay, "formatContainerSnippetForDisplay");
|
|
4595
|
+
async function apply(args, containerConfig, config, accountId) {
|
|
4596
|
+
if (!config.containers || config.containers.length === 0) {
|
|
4597
|
+
return;
|
|
4598
|
+
}
|
|
4599
|
+
startSection(
|
|
4600
|
+
"Deploy a container application",
|
|
4601
|
+
"deploy changes to your application"
|
|
4602
|
+
);
|
|
4603
|
+
const existingApplications = await promiseSpinner(
|
|
4604
|
+
ApplicationsService.listApplications(),
|
|
4605
|
+
{ message: "Loading applications" }
|
|
4606
|
+
);
|
|
4607
|
+
let prevApp = existingApplications.find(
|
|
4608
|
+
(app) => app.name === containerConfig.name
|
|
4609
|
+
);
|
|
4610
|
+
const imageRef = "remoteDigest" in args.imageRef ? args.imageRef.remoteDigest : args.imageRef.newTag;
|
|
4611
|
+
log(dim("Container application changes\n"));
|
|
4612
|
+
let migratedLegacyObservability = false;
|
|
4613
|
+
if (prevApp !== void 0) {
|
|
4614
|
+
if (!prevApp.durable_objects?.namespace_id) {
|
|
4615
|
+
throw new FatalError(
|
|
4616
|
+
"The previous deploy of this container application was not associated with a durable object",
|
|
4617
|
+
{
|
|
4618
|
+
telemetryMessage: "containers deploy previous durable object missing"
|
|
4619
|
+
}
|
|
4620
|
+
);
|
|
4621
|
+
}
|
|
4622
|
+
if (prevApp.durable_objects.namespace_id !== args.durable_object_namespace_id) {
|
|
4623
|
+
throw new UserError(
|
|
4624
|
+
`There is already an application with the name ${containerConfig.name} deployed that is associated with a different durable object namespace (${prevApp.durable_objects.namespace_id}). Either change the container name or delete the existing application first.`,
|
|
4625
|
+
{
|
|
4626
|
+
telemetryMessage: "trying to redeploy container to different durable object"
|
|
4627
|
+
}
|
|
4628
|
+
);
|
|
4629
|
+
}
|
|
4630
|
+
if (containerConfig.rollout_kind !== "none") {
|
|
4631
|
+
if (requiresObservabilityMigration(
|
|
4632
|
+
prevApp,
|
|
4633
|
+
containerConfig.observability
|
|
4634
|
+
) && (prevApp.active_rollout_id !== void 0 || isLegacyObservabilityEnabled(
|
|
4635
|
+
prevApp.scheduling_hint?.target.configuration.observability
|
|
4636
|
+
))) {
|
|
4637
|
+
throw new UserError(
|
|
4638
|
+
`Cannot migrate observability configuration for container ${containerConfig.name} while an application rollout is active. Wait for the rollout to finish, then deploy again.`,
|
|
4639
|
+
{
|
|
4640
|
+
telemetryMessage: "containers deploy observability migration rollout active"
|
|
4641
|
+
}
|
|
4642
|
+
);
|
|
4643
|
+
}
|
|
4644
|
+
if (hasMixedEnabledObservability(prevApp)) {
|
|
4645
|
+
const migrationObservability = buildLegacyObservabilityMigrationPatch(prevApp);
|
|
4646
|
+
await doAction({
|
|
4647
|
+
action: "modify",
|
|
4648
|
+
application: { observability: migrationObservability },
|
|
4649
|
+
id: prevApp.id,
|
|
4650
|
+
name: prevApp.name,
|
|
4651
|
+
successMessage: `Migrated observability configuration for ${brandColor(prevApp.name)} (Application ID: ${prevApp.id})`
|
|
4652
|
+
});
|
|
4653
|
+
prevApp = migrateLegacyObservabilityState(
|
|
4654
|
+
prevApp,
|
|
4655
|
+
migrationObservability
|
|
4656
|
+
);
|
|
4657
|
+
migratedLegacyObservability = true;
|
|
4658
|
+
}
|
|
4659
|
+
}
|
|
4660
|
+
}
|
|
4661
|
+
const observabilityWriteTarget = selectObservabilityWriteTarget(prevApp);
|
|
4662
|
+
if (prevApp !== void 0) {
|
|
4663
|
+
assertCanUseApplicationObservabilityTargeting(prevApp, containerConfig);
|
|
4664
|
+
}
|
|
4665
|
+
const appConfig = stripUndefined(
|
|
4666
|
+
mergeIfUnsafe(
|
|
4667
|
+
config,
|
|
4668
|
+
containerConfigToCreateRequest(
|
|
4669
|
+
accountId,
|
|
4670
|
+
containerConfig,
|
|
4671
|
+
imageRef,
|
|
4672
|
+
args.durable_object_namespace_id,
|
|
4673
|
+
config,
|
|
4674
|
+
observabilityWriteTarget,
|
|
4675
|
+
prevApp
|
|
4676
|
+
),
|
|
4677
|
+
containerConfig.name
|
|
4678
|
+
)
|
|
4679
|
+
);
|
|
4680
|
+
if (prevApp !== void 0 && prevApp !== null) {
|
|
4681
|
+
const normalisedPrevApp = sortObjectRecursive(
|
|
4682
|
+
stripUndefined(
|
|
4683
|
+
cleanApplicationFromAPI(
|
|
4684
|
+
prevApp,
|
|
4685
|
+
containerConfig,
|
|
4686
|
+
accountId,
|
|
4687
|
+
observabilityWriteTarget,
|
|
4688
|
+
config
|
|
4689
|
+
)
|
|
4690
|
+
)
|
|
4691
|
+
);
|
|
4692
|
+
const modifyReq = stripUndefined(
|
|
4693
|
+
mergeIfUnsafe(
|
|
4694
|
+
config,
|
|
4695
|
+
createApplicationToModifyApplication(appConfig),
|
|
4696
|
+
appConfig.name
|
|
4697
|
+
)
|
|
4698
|
+
);
|
|
4699
|
+
const normalizedModifyReq = sortObjectRecursive(modifyReq);
|
|
4700
|
+
const nowContainer = mergeDeep(normalisedPrevApp, normalizedModifyReq);
|
|
4701
|
+
if (normalizedModifyReq.observability !== void 0) {
|
|
4702
|
+
nowContainer.observability = normalizedModifyReq.observability;
|
|
4703
|
+
}
|
|
4704
|
+
const shouldCreateRollout = hasRolloutDiff(normalisedPrevApp, nowContainer);
|
|
4705
|
+
const prev = formatContainerSnippetForDisplay(
|
|
4706
|
+
normalisedPrevApp,
|
|
4707
|
+
config.configPath
|
|
4708
|
+
);
|
|
4709
|
+
const now = formatContainerSnippetForDisplay(
|
|
4710
|
+
nowContainer,
|
|
4711
|
+
config.configPath
|
|
4712
|
+
);
|
|
4713
|
+
const diff = new Diff(prev, now);
|
|
4714
|
+
if (diff.changes === 0) {
|
|
4715
|
+
if (migratedLegacyObservability) {
|
|
4716
|
+
newline();
|
|
4717
|
+
endSection("Applied changes");
|
|
4718
|
+
return;
|
|
4719
|
+
}
|
|
4720
|
+
updateStatus(`no changes ${brandColor(prevApp.name)}`);
|
|
4721
|
+
endSection("No changes to be made");
|
|
4722
|
+
return;
|
|
4723
|
+
}
|
|
4724
|
+
updateStatus(`${brandColor.underline("EDIT")} ${prevApp.name}`, false);
|
|
4725
|
+
newline();
|
|
4726
|
+
diff.print();
|
|
4727
|
+
newline();
|
|
4728
|
+
if (containerConfig.rollout_kind !== "none") {
|
|
4729
|
+
await doAction({
|
|
4730
|
+
action: "modify",
|
|
4731
|
+
application: modifyReq,
|
|
4732
|
+
id: prevApp.id,
|
|
4733
|
+
name: prevApp.name,
|
|
4734
|
+
...shouldCreateRollout ? {
|
|
4735
|
+
rollout_step_percentage: containerConfig.rollout_step_percentage,
|
|
4736
|
+
rollout_kind: containerConfig.rollout_kind == "full_manual" ? CreateApplicationRolloutRequest.kind.FULL_MANUAL : CreateApplicationRolloutRequest.kind.FULL_AUTO
|
|
4737
|
+
} : {}
|
|
4738
|
+
});
|
|
4739
|
+
} else {
|
|
4740
|
+
log("Skipping application rollout");
|
|
4741
|
+
newline();
|
|
4742
|
+
}
|
|
4743
|
+
} else {
|
|
4744
|
+
updateStatus(bold.underline(green.underline("NEW")) + ` ${appConfig.name}`);
|
|
4745
|
+
const configStr = formatContainerSnippetForDisplay(
|
|
4746
|
+
appConfig,
|
|
4747
|
+
config.configPath
|
|
4748
|
+
);
|
|
4749
|
+
configStr.trimEnd().split("\n").forEach((el) => log(` ${el}`));
|
|
4750
|
+
newline();
|
|
4751
|
+
await doAction({
|
|
4752
|
+
action: "create",
|
|
4753
|
+
application: appConfig
|
|
4754
|
+
});
|
|
4755
|
+
}
|
|
4756
|
+
newline();
|
|
4757
|
+
endSection("Applied changes");
|
|
4758
|
+
}
|
|
4759
|
+
__name(apply, "apply");
|
|
4760
|
+
function mergeIfUnsafe(fullConfig, containerConfig, name) {
|
|
4761
|
+
const unsafeContainerConfig = fullConfig.containers?.find((original) => {
|
|
4762
|
+
return original.name === name && original.unsafe !== void 0;
|
|
4763
|
+
});
|
|
4764
|
+
if (unsafeContainerConfig) {
|
|
4765
|
+
return mergeDeep(
|
|
4766
|
+
containerConfig,
|
|
4767
|
+
unsafeContainerConfig.unsafe
|
|
4768
|
+
);
|
|
4769
|
+
} else {
|
|
4770
|
+
return containerConfig;
|
|
4771
|
+
}
|
|
4772
|
+
}
|
|
4773
|
+
__name(mergeIfUnsafe, "mergeIfUnsafe");
|
|
4774
|
+
function formatError(err) {
|
|
4775
|
+
try {
|
|
4776
|
+
const maybeError = JSON.parse(err.body.error);
|
|
4777
|
+
if (maybeError.error !== void 0) {
|
|
4778
|
+
const message = [];
|
|
4779
|
+
message.push(`${maybeError.error}`);
|
|
4780
|
+
if (maybeError.details !== void 0 && typeof maybeError.details === "object") {
|
|
4781
|
+
for (const key in maybeError.details) {
|
|
4782
|
+
message.push(`${brandColor(key)} ${maybeError.details[key]}`);
|
|
4783
|
+
}
|
|
4784
|
+
}
|
|
4785
|
+
return message.join("\n");
|
|
4786
|
+
}
|
|
4787
|
+
} catch {
|
|
4788
|
+
}
|
|
4789
|
+
return JSON.stringify(err.body);
|
|
4790
|
+
}
|
|
4791
|
+
__name(formatError, "formatError");
|
|
4792
|
+
var doAction = /* @__PURE__ */ __name(async (action) => {
|
|
4793
|
+
if (action.action === "create") {
|
|
4794
|
+
let application;
|
|
4795
|
+
try {
|
|
4796
|
+
application = await promiseSpinner(
|
|
4797
|
+
ApplicationsService.createApplication(action.application),
|
|
4798
|
+
{ message: `Creating "${action.application.name}"` }
|
|
4799
|
+
);
|
|
4800
|
+
} catch (err) {
|
|
4801
|
+
if (!(err instanceof Error)) {
|
|
4802
|
+
throw err;
|
|
4803
|
+
}
|
|
4804
|
+
if (!(err instanceof ApiError)) {
|
|
4805
|
+
throw new FatalError(
|
|
4806
|
+
`Unexpected error creating application: ${err.message}`,
|
|
4807
|
+
{ telemetryMessage: "containers deploy create unexpected error" }
|
|
4808
|
+
);
|
|
4809
|
+
}
|
|
4810
|
+
if (err.status === 400) {
|
|
4811
|
+
throw new UserError(
|
|
4812
|
+
`Error creating application due to a misconfiguration:
|
|
4813
|
+
${formatError(err)}`,
|
|
4814
|
+
{ telemetryMessage: "containers deploy create misconfiguration" }
|
|
4815
|
+
);
|
|
4816
|
+
}
|
|
4817
|
+
throw new UserError(`Error creating application:
|
|
4818
|
+
${formatError(err)}`, {
|
|
4819
|
+
telemetryMessage: "containers deploy create request failed"
|
|
4820
|
+
});
|
|
4821
|
+
}
|
|
4822
|
+
success(
|
|
4823
|
+
`Created application ${brandColor(action.application.name)} (Application ID: ${application.id})`,
|
|
4824
|
+
{
|
|
4825
|
+
shape: shapes.bar
|
|
4826
|
+
}
|
|
4827
|
+
);
|
|
4828
|
+
}
|
|
4829
|
+
if (action.action === "modify") {
|
|
4830
|
+
try {
|
|
4831
|
+
await promiseSpinner(
|
|
4832
|
+
ApplicationsService.modifyApplication(action.id, action.application),
|
|
4833
|
+
{ message: `Modifying ${action.application.name}` }
|
|
4834
|
+
);
|
|
4835
|
+
} catch (err) {
|
|
4836
|
+
if (!(err instanceof Error)) {
|
|
4837
|
+
throw err;
|
|
4838
|
+
}
|
|
4839
|
+
if (!(err instanceof ApiError)) {
|
|
4840
|
+
throw new UserError(
|
|
4841
|
+
`Unexpected error modifying application "${action.name}": ${err.message}`,
|
|
4842
|
+
{ telemetryMessage: "containers deploy modify unexpected error" }
|
|
4843
|
+
);
|
|
4844
|
+
}
|
|
4845
|
+
if (err.status === 400) {
|
|
4846
|
+
throw new UserError(
|
|
4847
|
+
`Error modifying application "${action.name}" due to a misconfiguration:
|
|
4848
|
+
|
|
4849
|
+
${formatError(err)}`,
|
|
4850
|
+
{ telemetryMessage: "containers deploy modify misconfiguration" }
|
|
4851
|
+
);
|
|
4852
|
+
}
|
|
4853
|
+
throw new UserError(
|
|
4854
|
+
`Error modifying application "${action.name}":
|
|
4855
|
+
${formatError(err)}`,
|
|
4856
|
+
{ telemetryMessage: "containers deploy modify request failed" }
|
|
4857
|
+
);
|
|
4858
|
+
}
|
|
4859
|
+
if (action.rollout_step_percentage !== void 0 && action.rollout_kind !== void 0) {
|
|
4860
|
+
try {
|
|
4861
|
+
await promiseSpinner(
|
|
4862
|
+
RolloutsService.createApplicationRollout(action.id, {
|
|
4863
|
+
description: "Progressive update",
|
|
4864
|
+
strategy: CreateApplicationRolloutRequest.strategy.ROLLING,
|
|
4865
|
+
target_configuration: action.application.configuration ?? {},
|
|
4866
|
+
...configRolloutStepsToAPI(action.rollout_step_percentage),
|
|
4867
|
+
kind: action.rollout_kind
|
|
4868
|
+
}),
|
|
4869
|
+
{
|
|
4870
|
+
message: `rolling out container version ${action.name}`
|
|
4871
|
+
}
|
|
4872
|
+
);
|
|
4873
|
+
} catch (err) {
|
|
4874
|
+
if (!(err instanceof Error)) {
|
|
4875
|
+
throw err;
|
|
4876
|
+
}
|
|
4877
|
+
if (!(err instanceof ApiError)) {
|
|
4878
|
+
throw new UserError(
|
|
4879
|
+
`Unexpected error rolling out application "${action.name}":
|
|
4880
|
+
${err.message}`,
|
|
4881
|
+
{ telemetryMessage: "containers deploy rollout unexpected error" }
|
|
4882
|
+
);
|
|
4883
|
+
}
|
|
4884
|
+
if (err.status === 400) {
|
|
4885
|
+
throw new UserError(
|
|
4886
|
+
`Error rolling out application "${action.name}" due to a misconfiguration:
|
|
4887
|
+
|
|
4888
|
+
${formatError(err)}`,
|
|
4889
|
+
{ telemetryMessage: "containers deploy rollout misconfiguration" }
|
|
4890
|
+
);
|
|
4891
|
+
}
|
|
4892
|
+
throw new UserError(
|
|
4893
|
+
`Error rolling out application "${action.name}":
|
|
4894
|
+
${formatError(err)}`,
|
|
4895
|
+
{ telemetryMessage: "containers deploy rollout request failed" }
|
|
4896
|
+
);
|
|
4897
|
+
}
|
|
4898
|
+
}
|
|
4899
|
+
success(
|
|
4900
|
+
action.successMessage ?? `Modified application ${brandColor(action.name)} (Application ID: ${action.id})`,
|
|
4901
|
+
{
|
|
4902
|
+
shape: shapes.bar
|
|
4903
|
+
}
|
|
4904
|
+
);
|
|
4905
|
+
}
|
|
4906
|
+
}, "doAction");
|
|
4907
|
+
function cleanApplicationFromAPI(prev, currentConfig, accountId, observabilityWriteTarget, complianceConfig) {
|
|
4908
|
+
const configuration = {
|
|
4909
|
+
...prev.configuration,
|
|
4910
|
+
image: resolveImageName(
|
|
4911
|
+
accountId,
|
|
4912
|
+
prev.configuration.image,
|
|
4913
|
+
complianceConfig
|
|
4914
|
+
)
|
|
4915
|
+
};
|
|
4916
|
+
if (observabilityWriteTarget === "top-level") {
|
|
4917
|
+
delete configuration.observability;
|
|
4918
|
+
}
|
|
4919
|
+
const cleanedPreviousApp = {
|
|
4920
|
+
configuration,
|
|
4921
|
+
constraints: prev.constraints,
|
|
4922
|
+
max_instances: prev.max_instances,
|
|
4923
|
+
name: prev.name,
|
|
4924
|
+
scheduling_policy: prev.scheduling_policy,
|
|
4925
|
+
affinities: prev.affinities,
|
|
4926
|
+
rollout_active_grace_period: prev.rollout_active_grace_period
|
|
4927
|
+
};
|
|
4928
|
+
if (observabilityWriteTarget === "configuration" && getLatestLegacyObservabilityState(prev) !== void 0) {
|
|
4929
|
+
cleanedPreviousApp.configuration.observability = getLatestLegacyObservabilityState(prev);
|
|
4930
|
+
}
|
|
4931
|
+
if (prev.observability !== void 0) {
|
|
4932
|
+
cleanedPreviousApp.observability = prev.observability;
|
|
4933
|
+
}
|
|
4934
|
+
if ("instance_type" in currentConfig) {
|
|
4935
|
+
const instance_type = inferInstanceType(cleanedPreviousApp.configuration);
|
|
4936
|
+
if (!instance_type) {
|
|
4937
|
+
return cleanedPreviousApp;
|
|
4938
|
+
}
|
|
4939
|
+
cleanedPreviousApp.configuration.instance_type = instance_type;
|
|
4940
|
+
delete cleanedPreviousApp.configuration.disk;
|
|
4941
|
+
delete cleanedPreviousApp.configuration.memory;
|
|
4942
|
+
delete cleanedPreviousApp.configuration.memory_mib;
|
|
4943
|
+
delete cleanedPreviousApp.configuration.vcpu;
|
|
4944
|
+
}
|
|
4945
|
+
return cleanedPreviousApp;
|
|
4946
|
+
}
|
|
4947
|
+
__name(cleanApplicationFromAPI, "cleanApplicationFromAPI");
|
|
4948
|
+
var configRolloutStepsToAPI = /* @__PURE__ */ __name((rolloutSteps) => {
|
|
4949
|
+
if (typeof rolloutSteps === "number") {
|
|
4950
|
+
return { step_percentage: rolloutSteps };
|
|
4951
|
+
} else {
|
|
4952
|
+
const output = [];
|
|
4953
|
+
let index = 1;
|
|
4954
|
+
for (const step of rolloutSteps) {
|
|
4955
|
+
output.push({
|
|
4956
|
+
step_size: { percentage: step },
|
|
4957
|
+
description: `Step ${index} of ${rolloutSteps.length} - rollout at ${step}% of instances`
|
|
4958
|
+
});
|
|
4959
|
+
index++;
|
|
4960
|
+
}
|
|
4961
|
+
return { steps: output };
|
|
4962
|
+
}
|
|
4963
|
+
}, "configRolloutStepsToAPI");
|
|
4964
|
+
|
|
4965
|
+
export { AccountService, ApiError, ApplicationAffinityColocation, ApplicationAffinityHardwareGeneration, ApplicationMutationError, ApplicationRollout, ApplicationsService, AssignIPv4, AssignIPv6, BadRequestWithCodeError, CancelError, CancelablePromise, ContainerImagePreparationStatus, ContainerImagePreparationsService, ContainerNetworkMode, CreateApplicationRolloutRequest, DEFAULT_CONTAINER_EGRESS_INTERCEPTOR_IMAGE, DeploymentCheckKind, DeploymentCheckType, DeploymentMutationError, DeploymentNotFoundError, DeploymentPlacementState, DeploymentQueuedReason, DeploymentSchedulingState, DeploymentType, DeploymentsService, Diff, DurableObjectStatusHealth, EventName, EventType, ExternalRegistryKind, FUSE_CONTAINER_PRIVILEGES, HTTPMethod, IPType, IPsService, ImageRegistriesService, ImageRegistryAlreadyExistsError, ImageRegistryIsPublic, ImageRegistryNotAllowedError, ImageRegistryNotFoundError, ImageRegistryPermissions, ImageRegistryProtocolAlreadyExists, ImageRegistryProtocolIsReferencedError, ImageRegistryProtocolNotFound, InstanceType, JobStatusHealth, JobsService, MF_DEV_CONTAINER_PREFIX, NetworkMode, NodeGroup, OpenAPI, PlacementStatusHealth, PlacementsService, ProvisionerConfiguration, RolloutStep, RolloutsService, SSHPublicKeyNotFoundError, SchedulingPolicy, SecretAccessType, SecretNameAlreadyExists, SecretNotFound, SecretsService, SshPublicKeysService, UpdateApplicationRolloutRequest, apply, buildAndMaybePush, buildCommand, buildContainerImages, checkExposedPorts, cleanApplicationFromAPI, cleanForInstanceType, cleanupBuiltImages, cleanupContainers, cleanupDuplicateImageTags, configRolloutStepsToAPI, configureOpenAPIForContainerPull, containerPrivilegesAllowed, createDurableObjectNamespaceResolver, deployContainers, dockerBuild, dockerImageInspect, dockerLoginImageRegistry, ensureContainerLimits, ensureImageFitsLimits, fetchPagedListResult, fetchResult, formatError, generateContainerBuildId, getAndValidateRegistryType, getCloudflareContainerRegistry, getCloudflareRegistryWithAccountNamespace, getContainerAccount, getContainerIdsByImageTags, getContainerIdsFromImage, getContainerImageTag, getDevContainerImageName, getDockerHostFromEnv, getDockerSocketFromContext, getEgressInterceptorImage, getEgressInterceptorPlatform, getImageRepoTags, getInstanceTypeUsage, inferInstanceType, initContainersSharedContext, isDockerRunning, isDockerfileContainerConfig, listDurableObjects, logger, prepareContainerImagesForDev, promiseSpinner, pullEgressInterceptorImage, pullImage, pushBuiltContainerImage, pushCommand, pushImageIfChanged, request, requestPaginated, resolveDockerHost, resolveImageName, runDockerCmd, runDockerCmdWithOutput, sortObjectRecursive, startContainerBuild, stripUndefined, validateAndEncodeGarKey, verifyDockerInstalled };
|
|
4966
|
+
//# sourceMappingURL=index.mjs.map
|
|
4967
|
+
//# sourceMappingURL=index.mjs.map
|