hammerkit 2.1.0 → 2.2.0-next.1
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/build.schema.json +126 -28
- package/dist/cli.js +5 -0
- package/dist/dashboard/assets/graph-canvas-D6GMgkoe.js +8 -0
- package/dist/dashboard/assets/index-BNq9j5Jo.js +23 -0
- package/dist/dashboard/assets/index-DP3_hKOe.css +2 -0
- package/dist/dashboard/index.html +2 -2
- package/dist/docker/item-network.js +6 -5
- package/dist/docker/remove-orphaned-containers.js +5 -4
- package/dist/environment/replace-env-variables.js +8 -5
- package/dist/environment/run-source-envs.js +2 -1
- package/dist/executer/archive-task-entry.js +1 -1
- package/dist/executer/check-readiness.js +8 -4
- package/dist/executer/docker-healthcheck.js +73 -0
- package/dist/executer/docker-service.js +21 -15
- package/dist/executer/event-cache.js +5 -1
- package/dist/executer/runner-commands.js +36 -0
- package/dist/file/get-file-context.js +4 -7
- package/dist/harness/connect.js +12 -8
- package/dist/harness/reconnect.js +141 -0
- package/dist/harness/sandbox-client.js +241 -33
- package/dist/harness/service-tools.js +11 -2
- package/dist/kubernetes/ensure-kubernetes-deployment-exists.js +62 -14
- package/dist/kubernetes/ensure-persistent-data.js +1 -1
- package/dist/kubernetes/follow-pod-logs.js +8 -5
- package/dist/kubernetes/kept-claims.js +38 -14
- package/dist/kubernetes/sandbox-runner.js +526 -156
- package/dist/kubernetes/store-kubernetes-data.js +18 -3
- package/dist/kubernetes/sync-changes.js +463 -0
- package/dist/kubernetes/volumes.js +23 -1
- package/dist/network/healthcheck-request.js +38 -0
- package/dist/optimizer/get-work-cache-stats.js +7 -0
- package/dist/optimizer/work-task-cache-description.js +5 -3
- package/dist/planner/image-build.js +5 -0
- package/dist/planner/service-definition.js +2 -1
- package/dist/planner/utils/append-work-service.js +12 -4
- package/dist/planner/utils/dependency-outputs.js +7 -6
- package/dist/planner/validate.js +41 -0
- package/dist/planner/work-healthcheck.js +23 -2
- package/dist/planner/work-item-status.js +12 -2
- package/dist/planner/work-runtime-aggregate.js +1 -0
- package/dist/planner/work-runtime-docker.js +33 -6
- package/dist/planner/work-runtime-kubernetes.js +313 -70
- package/dist/planner/work-runtime-local.js +8 -4
- package/dist/planner/work-secret.js +33 -11
- package/dist/planner/work-service-id.js +30 -6
- package/dist/planner/work-service.js +2 -2
- package/dist/program.js +19 -1
- package/dist/remote/annotations.js +8 -2
- package/dist/remote/bundle.js +6 -8
- package/dist/remote/device-login.js +4 -1
- package/dist/remote/remote-commands.js +16 -7
- package/dist/remote/remote-status.js +1 -1
- package/dist/remote/remote-work-commands.js +220 -68
- package/dist/remote/server-client.js +38 -40
- package/dist/schema/build-file-base-task-schema.js +16 -1
- package/dist/schema/build-file-image-build-schema.js +5 -8
- package/dist/schema/build-file-service-container-healthcheck.js +25 -7
- package/dist/schema/reference-parser.js +108 -43
- package/dist/schema/work-scope-parser.js +8 -0
- package/dist/secrets/prefetch-secrets.js +20 -1
- package/dist/server/artifacts-api.js +56 -0
- package/dist/server/borrowed-quota.js +216 -0
- package/dist/server/capacity.js +18 -6
- package/dist/server/definitions-api.js +62 -8
- package/dist/server/executor.js +117 -30
- package/dist/server/http.js +4 -1
- package/dist/server/keep-artifacts.js +230 -0
- package/dist/server/kubernetes-backend.js +292 -79
- package/dist/server/kubernetes-sandbox-storage.js +86 -24
- package/dist/server/overview.js +73 -9
- package/dist/server/paging.js +167 -0
- package/dist/server/plan.js +16 -1
- package/dist/server/run-access.js +24 -0
- package/dist/server/run-artifacts.js +171 -0
- package/dist/server/run-logs.js +25 -1
- package/dist/server/run-request.js +11 -0
- package/dist/server/run-source-environment.js +1 -1
- package/dist/server/run-worker.js +267 -33
- package/dist/server/runs.js +531 -105
- package/dist/server/sandbox-files-api.js +27 -12
- package/dist/server/sandbox-files.js +12 -10
- package/dist/server/sandbox-follow.js +54 -0
- package/dist/server/sandbox-pod.js +1 -1
- package/dist/server/sandbox-storage.js +38 -1
- package/dist/server/sandbox-sync.js +392 -0
- package/dist/server/sandboxes-api.js +116 -19
- package/dist/server/sandboxes.js +38 -3
- package/dist/server/server-config.js +73 -2
- package/dist/server/server.js +169 -38
- package/dist/server/task-order.js +56 -0
- package/dist/utils/project-path.js +20 -0
- package/dist/utils/tar-files.js +52 -0
- package/dist/utils/tar.js +37 -1
- package/package.json +1 -1
- package/dist/dashboard/assets/graph-canvas-DtJSpova.js +0 -8
- package/dist/dashboard/assets/index-BndChMep.css +0 -2
- package/dist/dashboard/assets/index-DRSwIRXd.js +0 -17
|
@@ -3,10 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.registerWorkCommands = exports.describePlan = exports.describeApproval = exports.keepRuns = exports.describeListedRun = exports.describeRunEnd = void 0;
|
|
6
|
+
exports.registerWorkCommands = exports.describeArtifacts = exports.selectArtifacts = exports.keptProjectOutputs = exports.isProjectPath = exports.describePlan = exports.describeApproval = exports.keepRuns = exports.describeListedRun = exports.describeRunEnd = void 0;
|
|
7
7
|
const commander_1 = require("commander");
|
|
8
8
|
const colors_1 = __importDefault(require("colors"));
|
|
9
|
-
const token_source_1 = require("./token-source");
|
|
10
9
|
const collect_bundle_1 = require("./collect-bundle");
|
|
11
10
|
const bundle_1 = require("./bundle");
|
|
12
11
|
const annotations_1 = require("./annotations");
|
|
@@ -16,11 +15,16 @@ const bundle_text_1 = require("./bundle-text");
|
|
|
16
15
|
const sandbox_client_1 = require("../harness/sandbox-client");
|
|
17
16
|
const units_1 = require("../utils/units");
|
|
18
17
|
const service_tools_1 = require("../harness/service-tools");
|
|
18
|
+
const reconnect_1 = require("../harness/reconnect");
|
|
19
19
|
const path_1 = require("path");
|
|
20
|
+
const promises_1 = require("fs/promises");
|
|
21
|
+
const os_1 = require("os");
|
|
22
|
+
const tar_1 = require("../utils/tar");
|
|
20
23
|
const check_keys_1 = require("../optimizer/check-keys");
|
|
21
24
|
const remote_status_1 = require("./remote-status");
|
|
22
25
|
const timings_1 = require("../server/timings");
|
|
23
26
|
const terminal_prompt_1 = require("../utils/terminal-prompt");
|
|
27
|
+
const project_path_1 = require("../utils/project-path");
|
|
24
28
|
function describeOutcome(planned) {
|
|
25
29
|
switch (planned.outcome) {
|
|
26
30
|
case 'published':
|
|
@@ -170,6 +174,81 @@ function describePlan(plan) {
|
|
|
170
174
|
]);
|
|
171
175
|
}
|
|
172
176
|
exports.describePlan = describePlan;
|
|
177
|
+
// A path in the project, as the server names an output: relative, `/` separated, no `.` or
|
|
178
|
+
// `..` in it. A file is written at it.
|
|
179
|
+
function isProjectPath(path) {
|
|
180
|
+
return (0, project_path_1.isRelativePath)(path, 4096);
|
|
181
|
+
}
|
|
182
|
+
exports.isProjectPath = isProjectPath;
|
|
183
|
+
// `--path` as written: `./app/screenshots/` is `app/screenshots`
|
|
184
|
+
function projectPath(value) {
|
|
185
|
+
const path = path_1.posix
|
|
186
|
+
.normalize(value.replace(/\\/g, '/'))
|
|
187
|
+
.replace(/^(\.\/)+/, '')
|
|
188
|
+
.replace(/\/+$/, '');
|
|
189
|
+
if (!isProjectPath(path)) {
|
|
190
|
+
throw new Error('--path is a path in the project, such as app/cypress/screenshots');
|
|
191
|
+
}
|
|
192
|
+
return path;
|
|
193
|
+
}
|
|
194
|
+
// The outputs a server names that are paths in the project: one that is not is written nowhere,
|
|
195
|
+
// whatever the server says of it.
|
|
196
|
+
function keptProjectOutputs(outputs) {
|
|
197
|
+
return outputs.filter((output) => isProjectPath(output.path));
|
|
198
|
+
}
|
|
199
|
+
exports.keptProjectOutputs = keptProjectOutputs;
|
|
200
|
+
/**
|
|
201
|
+
* The outputs `remote artifacts` takes, each with what of it: of one task, and the output at a
|
|
202
|
+
* path, the outputs below it, or the files below it of the output it is in.
|
|
203
|
+
*/
|
|
204
|
+
function selectArtifacts(outputs, options) {
|
|
205
|
+
return outputs
|
|
206
|
+
.filter((output) => options.task === undefined || output.task === options.task)
|
|
207
|
+
.flatMap((output) => {
|
|
208
|
+
const path = options.path;
|
|
209
|
+
if (path === undefined || output.path.startsWith(`${path}/`)) {
|
|
210
|
+
return [{ output, below: output.path }];
|
|
211
|
+
}
|
|
212
|
+
return path === output.path || path.startsWith(`${output.path}/`) ? [{ output, below: path }] : [];
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
exports.selectArtifacts = selectArtifacts;
|
|
216
|
+
// Writes the chosen outputs into `out`, each at its paths in the project. Only entries of the
|
|
217
|
+
// output, or of the path asked for, are written, and no link out of them: the archives come
|
|
218
|
+
// from a server.
|
|
219
|
+
async function downloadArtifacts(connection, id, chosen, out, write) {
|
|
220
|
+
const staging = await (0, promises_1.mkdtemp)((0, path_1.join)((0, os_1.tmpdir)(), 'hammerkit-artifacts-'));
|
|
221
|
+
try {
|
|
222
|
+
await (0, promises_1.mkdir)(out, { recursive: true });
|
|
223
|
+
for (const { output, below } of chosen) {
|
|
224
|
+
const file = (0, path_1.join)(staging, `${output.id}.tgz`);
|
|
225
|
+
await (0, sandbox_client_1.downloadRunArtifact)(connection, id, output.id, file);
|
|
226
|
+
await (0, tar_1.extractOutput)(file, out, below, true);
|
|
227
|
+
write(`${(0, server_client_1.printable)(below)} of ${(0, server_client_1.printable)(output.task)} -> ${(0, path_1.join)(out, below)}`);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
finally {
|
|
231
|
+
await (0, promises_1.rm)(staging, { recursive: true, force: true });
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
function describeArtifacts(id, serverName, kept, outputs) {
|
|
235
|
+
const left = kept.left.map((output) => `did not keep ${(0, server_client_1.printable)(output.path)} of ${(0, server_client_1.printable)(output.task)}: ${(0, server_client_1.printable)(output.reason)}`);
|
|
236
|
+
if (outputs.length === 0) {
|
|
237
|
+
return [
|
|
238
|
+
`${(0, server_client_1.printable)(id)} on ${serverName} kept no outputs${kept.reason ? `: ${(0, server_client_1.printable)(kept.reason)}` : ''}`,
|
|
239
|
+
...left,
|
|
240
|
+
];
|
|
241
|
+
}
|
|
242
|
+
const tasks = Math.max(...outputs.map((output) => (0, server_client_1.printable)(output.task).length));
|
|
243
|
+
const paths = Math.max(...outputs.map((output) => (0, server_client_1.printable)(output.path).length));
|
|
244
|
+
return [
|
|
245
|
+
`${(0, server_client_1.printable)(id)} on ${serverName} kept ${outputs.length} ${outputs.length === 1 ? 'output' : 'outputs'}, until ${(0, server_client_1.printable)(kept.expiresAt ?? '-')}:`,
|
|
246
|
+
...outputs.map((output) => ` ${(0, server_client_1.printable)(output.task).padEnd(tasks)} ${(0, server_client_1.printable)(output.path).padEnd(paths)} ${(0, units_1.formatSize)(output.bytes)}`),
|
|
247
|
+
...left,
|
|
248
|
+
`download them with: hammerkit remote artifacts ${(0, server_client_1.printable)(id)} --out <dir>`,
|
|
249
|
+
];
|
|
250
|
+
}
|
|
251
|
+
exports.describeArtifacts = describeArtifacts;
|
|
173
252
|
// The ref of a detached checkout: the one branch or tag of origin at its commit. The server
|
|
174
253
|
// would also fetch the commit itself, but an account limited to some branches (`refs`) never
|
|
175
254
|
// runs for a commit, and the run would not say where its code comes from. A branch and a tag
|
|
@@ -199,6 +278,14 @@ function describeMissingRef(repo, ours, checkout) {
|
|
|
199
278
|
`name another, or the commit with --ref ${checkout.commit}`
|
|
200
279
|
: 'name one with --ref'));
|
|
201
280
|
}
|
|
281
|
+
// A call the server refused, said as `callServer` says it: by the server and what it answered
|
|
282
|
+
function describeRefusal(url, e) {
|
|
283
|
+
if (!(e instanceof sandbox_client_1.SandboxClientError) || e.status === undefined || e.status === 401) {
|
|
284
|
+
return e;
|
|
285
|
+
}
|
|
286
|
+
const said = e.message.startsWith(`${(0, reconnect_1.showUrl)(url)} answered`) ? '' : `: ${(0, server_client_1.printable)(e.message)}`;
|
|
287
|
+
return new server_client_1.ServerError(`${(0, reconnect_1.showUrl)(url)} answered ${e.status}${said}`, e.status);
|
|
288
|
+
}
|
|
202
289
|
function registerWorkCommands(remote, context) {
|
|
203
290
|
const { environment, buildFile, getServer, guarded, passthrough, fail } = context;
|
|
204
291
|
// the ref a run starts from: what the options name, else the checkout here
|
|
@@ -219,18 +306,19 @@ function registerWorkCommands(remote, context) {
|
|
|
219
306
|
const commit = options.commit ?? (options.ref ? undefined : checkout.commit);
|
|
220
307
|
return { type: 'ref', repo, ref, ...(commit ? { commit } : {}) };
|
|
221
308
|
};
|
|
309
|
+
// the server to call: its token is read for each call, a CI job or an agent brings its own, a
|
|
310
|
+
// person signs in
|
|
222
311
|
const connect = async (name, how) => {
|
|
223
312
|
const chosen = await getServer(name, how);
|
|
224
|
-
|
|
225
|
-
const token = await (0, token_source_1.getTokenSource)(environment, chosen.name, chosen.server).token();
|
|
226
|
-
return { ...chosen, token };
|
|
313
|
+
return { ...chosen, connection: (0, sandbox_client_1.getServerConnection)(environment, chosen.name, chosen.server) };
|
|
227
314
|
};
|
|
228
315
|
// publishes the bundle with where it comes from and says what it is now: published,
|
|
229
316
|
// already published, or only proposed
|
|
230
|
-
const publishBundle = async (serverName,
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
annotations,
|
|
317
|
+
const publishBundle = async (serverName, connection, bundle, annotations) => {
|
|
318
|
+
// what is published already changes nothing and is said so: sent again, it is the same
|
|
319
|
+
const answer = await (0, server_client_1.callServer)(connection, 'POST', '/v1/definitions', {
|
|
320
|
+
body: { ...bundle, annotations },
|
|
321
|
+
repeat: 'always',
|
|
234
322
|
});
|
|
235
323
|
const version = answer.body;
|
|
236
324
|
const files = Object.keys(bundle.files).length;
|
|
@@ -255,9 +343,13 @@ function registerWorkCommands(remote, context) {
|
|
|
255
343
|
return { version, proposed };
|
|
256
344
|
};
|
|
257
345
|
// what publishing the bundle would do, undefined from a server that can't say (before 2.0)
|
|
258
|
-
const planBundle = async (
|
|
346
|
+
const planBundle = async (connection, bundle) => {
|
|
259
347
|
try {
|
|
260
|
-
|
|
348
|
+
// a plan stores nothing, so it is sent again as often as the server does not answer
|
|
349
|
+
return (await (0, server_client_1.callServer)(connection, 'POST', '/v1/definitions/plan', {
|
|
350
|
+
body: bundle,
|
|
351
|
+
repeat: 'always',
|
|
352
|
+
})).body;
|
|
261
353
|
}
|
|
262
354
|
catch (e) {
|
|
263
355
|
if (e instanceof server_client_1.ServerError && e.status === 404) {
|
|
@@ -291,7 +383,7 @@ function registerWorkCommands(remote, context) {
|
|
|
291
383
|
// terminal says so. Without a terminal and without --publish the run fails and says how
|
|
292
384
|
// to publish it, so CI never waits on a question.
|
|
293
385
|
const submitPublishing = async (target, request, local, publish) => {
|
|
294
|
-
const { serverName,
|
|
386
|
+
const { serverName, connection } = target;
|
|
295
387
|
try {
|
|
296
388
|
return await (0, sandbox_client_1.submitRun)(connection, request);
|
|
297
389
|
}
|
|
@@ -303,14 +395,13 @@ function registerWorkCommands(remote, context) {
|
|
|
303
395
|
}
|
|
304
396
|
const definition = request.definition;
|
|
305
397
|
const notPublished = `the build file here is not published on ${serverName} (${definition})`;
|
|
306
|
-
const token = await connection.token();
|
|
307
398
|
if (!publish) {
|
|
308
399
|
if (!environment.prompt) {
|
|
309
400
|
throw new Error(`${notPublished}, publish it first with: hammerkit remote publish ${serverName}, or pass --publish`);
|
|
310
401
|
}
|
|
311
402
|
// a server before 2.0 can't say what publishing would do: it is asked all the same,
|
|
312
403
|
// and refuses then what the caller may not do
|
|
313
|
-
const planned = await planBundle(
|
|
404
|
+
const planned = await planBundle(connection, local);
|
|
314
405
|
if (planned && planned.outcome === null) {
|
|
315
406
|
throw new Error(`${notPublished}, and you may only run published build files (builds: run): ` +
|
|
316
407
|
`somebody who may publish publishes it with: hammerkit remote publish ${serverName}`);
|
|
@@ -336,7 +427,7 @@ function registerWorkCommands(remote, context) {
|
|
|
336
427
|
}
|
|
337
428
|
}
|
|
338
429
|
const annotations = await (0, annotations_1.collectAnnotations)(buildFile, Object.keys(local.files));
|
|
339
|
-
const { version, proposed } = await publishBundle(serverName,
|
|
430
|
+
const { version, proposed } = await publishBundle(serverName, connection, local, annotations).catch((e) => {
|
|
340
431
|
throw e instanceof server_client_1.ServerError && e.status === 403 ? new Error(`${notPublished}, ${e.message}`) : e;
|
|
341
432
|
});
|
|
342
433
|
if (version.hash !== definition) {
|
|
@@ -356,8 +447,11 @@ function registerWorkCommands(remote, context) {
|
|
|
356
447
|
.action(guarded('Remote publish was not successful', async (name, options) => {
|
|
357
448
|
const bundle = await (0, collect_bundle_1.collectBundle)(buildFile, environment);
|
|
358
449
|
if (options.dryRun) {
|
|
359
|
-
const { name: serverName,
|
|
360
|
-
const answer = await (0, server_client_1.callServer)(
|
|
450
|
+
const { name: serverName, connection } = await connect(name);
|
|
451
|
+
const answer = await (0, server_client_1.callServer)(connection, 'POST', '/v1/definitions/plan', {
|
|
452
|
+
body: bundle,
|
|
453
|
+
repeat: 'always',
|
|
454
|
+
}).catch((e) => {
|
|
361
455
|
throw e instanceof server_client_1.ServerError && e.status === 404
|
|
362
456
|
? new Error(`${serverName} can't check a build file without publishing it, it needs hammerkit 2.0`)
|
|
363
457
|
: e;
|
|
@@ -371,8 +465,8 @@ function registerWorkCommands(remote, context) {
|
|
|
371
465
|
return;
|
|
372
466
|
}
|
|
373
467
|
const annotations = (0, annotations_1.applyAnnotations)(await (0, annotations_1.collectAnnotations)(buildFile, Object.keys(bundle.files)), options.annotation ?? []);
|
|
374
|
-
const { name: serverName,
|
|
375
|
-
await publishBundle(serverName,
|
|
468
|
+
const { name: serverName, connection } = await connect(name);
|
|
469
|
+
await publishBundle(serverName, connection, bundle, annotations);
|
|
376
470
|
}));
|
|
377
471
|
remote
|
|
378
472
|
.command('run <tasks...>')
|
|
@@ -394,7 +488,7 @@ function registerWorkCommands(remote, context) {
|
|
|
394
488
|
const source = await refSource(options);
|
|
395
489
|
const ref = source.ref;
|
|
396
490
|
const { name: serverName, server } = await getServer(options.server, 'with --server <name>');
|
|
397
|
-
const connection =
|
|
491
|
+
const connection = (0, sandbox_client_1.getServerConnection)(environment, serverName, server);
|
|
398
492
|
const runOptions = {};
|
|
399
493
|
for (const key of ['env', 'cache', 'timeout', 'maxTimeout']) {
|
|
400
494
|
if (options[key] !== undefined) {
|
|
@@ -404,7 +498,7 @@ function registerWorkCommands(remote, context) {
|
|
|
404
498
|
if (passthrough.length > 0) {
|
|
405
499
|
runOptions.args = passthrough;
|
|
406
500
|
}
|
|
407
|
-
const submitted = await submitPublishing({ serverName,
|
|
501
|
+
const submitted = await submitPublishing({ serverName, connection }, { definition, tasks, source, options: runOptions }, local, !!options.publish);
|
|
408
502
|
const at = submitted.source.type === 'ref' ? ` at ${(0, server_client_1.printable)(submitted.source.commit)}` : '';
|
|
409
503
|
environment.stdout.write(`${(0, server_client_1.printable)(submitted.id)} on ${serverName}: ${tasks.map(server_client_1.printable).join(', ')} from ${(0, server_client_1.printable)(ref)}${at}\n`);
|
|
410
504
|
if (options.detach) {
|
|
@@ -467,8 +561,8 @@ function registerWorkCommands(remote, context) {
|
|
|
467
561
|
const publicPaths = (options.publicPath ?? []).map(service_tools_1.parsePublicPath);
|
|
468
562
|
const source = await refSource(options);
|
|
469
563
|
const { name: serverName, server } = await getServer(options.server, 'with --server <name>');
|
|
470
|
-
const connection =
|
|
471
|
-
const submitted = await submitPublishing({ serverName,
|
|
564
|
+
const connection = (0, sandbox_client_1.getServerConnection)(environment, serverName, server);
|
|
565
|
+
const submitted = await submitPublishing({ serverName, connection }, {
|
|
472
566
|
definition,
|
|
473
567
|
services,
|
|
474
568
|
endpoints,
|
|
@@ -512,10 +606,12 @@ function registerWorkCommands(remote, context) {
|
|
|
512
606
|
fail(`${(0, server_client_1.printable)(run.id)} did not move to ${(0, server_client_1.printable)(lastMove.commit)}: ${(0, server_client_1.printable)(lastMove.error)}; it stays at ${(0, server_client_1.printable)(run.source.type === 'ref' ? run.source.commit : '-')}`, 1);
|
|
513
607
|
}
|
|
514
608
|
if (run.state === 'asleep') {
|
|
515
|
-
|
|
516
|
-
|
|
609
|
+
// its addresses stay while it sleeps, and a request to one of them wakes it
|
|
610
|
+
environment.stdout.write(`${(0, server_client_1.printable)(run.id)} sleeps, at ${(0, server_client_1.printable)(run.source.type === 'ref' ? run.source.commit : '-')} when it wakes, until ${(0, server_client_1.printable)(run.expiresAt ?? '-')}${run.up?.endpoints.length ? ', a request to an endpoint wakes it' : ''}\n`);
|
|
611
|
+
}
|
|
612
|
+
else {
|
|
613
|
+
environment.stdout.write(`${(0, server_client_1.printable)(run.id)} is up until ${(0, server_client_1.printable)(run.expiresAt ?? '-')}${run.up?.sleepTtl ? `, asleep after ${(0, units_1.formatDuration)(run.up.sleepTtl)} without a request` : ''}\n`);
|
|
517
614
|
}
|
|
518
|
-
environment.stdout.write(`${(0, server_client_1.printable)(run.id)} is up until ${(0, server_client_1.printable)(run.expiresAt ?? '-')}${run.up?.sleepTtl ? `, asleep after ${(0, units_1.formatDuration)(run.up.sleepTtl)} without a request` : ''}\n`);
|
|
519
615
|
for (const endpoint of run.up?.endpoints ?? []) {
|
|
520
616
|
environment.stdout.write(` ${(0, server_client_1.printable)(endpoint.service)}:${endpoint.port} ${(0, server_client_1.printable)(endpoint.url)}\n`);
|
|
521
617
|
}
|
|
@@ -526,8 +622,8 @@ function registerWorkCommands(remote, context) {
|
|
|
526
622
|
.description('show how a server stands for you: the places that run, the queue and why each run in it waits, your limits and the runs that count against them, your service runs')
|
|
527
623
|
.addOption(new commander_1.Option('--json', 'print the overview as the server answers it, for scripts and agents'))
|
|
528
624
|
.action(guarded('Remote status was not successful', async (name, options) => {
|
|
529
|
-
const { name: serverName,
|
|
530
|
-
const overview = (await (0, server_client_1.callServer)(
|
|
625
|
+
const { name: serverName, connection } = await connect(name);
|
|
626
|
+
const overview = (await (0, server_client_1.callServer)(connection, 'GET', '/v1/overview')).body;
|
|
531
627
|
if (options.json) {
|
|
532
628
|
environment.stdout.write(`${JSON.stringify(overview, null, 2)}\n`);
|
|
533
629
|
return;
|
|
@@ -536,7 +632,8 @@ function registerWorkCommands(remote, context) {
|
|
|
536
632
|
environment.stdout.write(`${line}\n`);
|
|
537
633
|
}
|
|
538
634
|
// a server from before /v1/capacity, or one that can not read it, prints without
|
|
539
|
-
|
|
635
|
+
// best effort, printed after the overview: it is not waited for, the overview is already out
|
|
636
|
+
const capacity = await (0, server_client_1.callServer)(connection, 'GET', '/v1/capacity', { reconnectMs: 0 }).catch(() => undefined);
|
|
540
637
|
if (capacity) {
|
|
541
638
|
for (const line of (0, remote_status_1.describeCapacity)(capacity.body, true)) {
|
|
542
639
|
environment.stdout.write(`${line}\n`);
|
|
@@ -548,8 +645,8 @@ function registerWorkCommands(remote, context) {
|
|
|
548
645
|
.description('show what the machines of a server have and what its runs take: CPU and memory requested and in use, per namespace on Kubernetes')
|
|
549
646
|
.addOption(new commander_1.Option('--json', 'print it as the server answers it'))
|
|
550
647
|
.action(guarded('Remote capacity was not successful', async (name, options) => {
|
|
551
|
-
const {
|
|
552
|
-
const capacity = (await (0, server_client_1.callServer)(
|
|
648
|
+
const { connection } = await connect(name);
|
|
649
|
+
const capacity = (await (0, server_client_1.callServer)(connection, 'GET', '/v1/capacity')).body;
|
|
553
650
|
if (options.json) {
|
|
554
651
|
environment.stdout.write(`${JSON.stringify(capacity, null, 2)}\n`);
|
|
555
652
|
return;
|
|
@@ -566,7 +663,7 @@ function registerWorkCommands(remote, context) {
|
|
|
566
663
|
.addOption(new commander_1.Option('--until <when>', 'only the runs created until then: back from now, or a time'))
|
|
567
664
|
.addOption(new commander_1.Option('--json', 'print it as the server answers it'))
|
|
568
665
|
.action(guarded('Remote tasks was not successful', async (name, options) => {
|
|
569
|
-
const { name: serverName,
|
|
666
|
+
const { name: serverName, connection } = await connect(name);
|
|
570
667
|
const query = new URLSearchParams({ scope: options.mine ? 'mine' : 'visible' });
|
|
571
668
|
if (options.since) {
|
|
572
669
|
query.set('since', options.since);
|
|
@@ -574,7 +671,7 @@ function registerWorkCommands(remote, context) {
|
|
|
574
671
|
if (options.until) {
|
|
575
672
|
query.set('until', options.until);
|
|
576
673
|
}
|
|
577
|
-
const { tasks } = (await (0, server_client_1.callServer)(
|
|
674
|
+
const { tasks } = (await (0, server_client_1.callServer)(connection, 'GET', `/v1/tasks?${query}`)).body;
|
|
578
675
|
if (options.json) {
|
|
579
676
|
environment.stdout.write(`${JSON.stringify(tasks, null, 2)}\n`);
|
|
580
677
|
return;
|
|
@@ -592,7 +689,10 @@ function registerWorkCommands(remote, context) {
|
|
|
592
689
|
.description('print the address of the dashboard of a server, the pages of remote status, services, runs and logs')
|
|
593
690
|
.action(guarded('Remote dashboard was not successful', async (name) => {
|
|
594
691
|
const { name: serverName, server } = await getServer(name);
|
|
595
|
-
const discovery = await (0, server_client_1.getDiscovery)(server
|
|
692
|
+
const discovery = await (0, server_client_1.getDiscovery)(server, {
|
|
693
|
+
say: (line) => environment.stderr.write(`${line}\n`),
|
|
694
|
+
signal: environment.abortCtrl.signal,
|
|
695
|
+
});
|
|
596
696
|
if (!discovery.dashboard) {
|
|
597
697
|
throw new Error(`${serverName} has no dashboard: it needs endpoints with a login in its config, see https://hammerkit.dev/docs/remote-compute/status#dashboard`);
|
|
598
698
|
}
|
|
@@ -603,10 +703,11 @@ function registerWorkCommands(remote, context) {
|
|
|
603
703
|
.description('list the service runs that are starting, up or asleep: yours, and those whose endpoints you may open, with their addresses and when they end or sleep')
|
|
604
704
|
.addOption(new commander_1.Option('--ended', 'also the ones that ended, as long as the server keeps them'))
|
|
605
705
|
.action(guarded('Remote services was not successful', async (name, options) => {
|
|
606
|
-
const { name: serverName,
|
|
706
|
+
const { name: serverName, connection } = await connect(name);
|
|
607
707
|
const open = ['awaiting-approval', 'queued', 'running', 'up', 'asleep'];
|
|
608
708
|
const states = options.ended ? '' : `&state=${open.join(',')}`;
|
|
609
|
-
const runs = keepRuns((await (0, server_client_1.callServer)(
|
|
709
|
+
const runs = keepRuns((await (0, server_client_1.callServer)(connection, 'GET', `/v1/runs?scope=visible&kind=services${states}`))
|
|
710
|
+
.body.runs, options.ended ? undefined : open, 'services');
|
|
610
711
|
if (runs.length === 0) {
|
|
611
712
|
environment.stdout.write(`${serverName}: no service runs${options.ended ? '' : ' are starting, up or asleep'}\n`);
|
|
612
713
|
return;
|
|
@@ -640,9 +741,9 @@ function registerWorkCommands(remote, context) {
|
|
|
640
741
|
if (options.services || options.tasks) {
|
|
641
742
|
query.set('kind', options.services ? 'services' : 'tasks');
|
|
642
743
|
}
|
|
643
|
-
const { name: serverName,
|
|
744
|
+
const { name: serverName, connection } = await connect(name);
|
|
644
745
|
const path = `/v1/runs${query.toString() ? `?${query}` : ''}`;
|
|
645
|
-
const runs = keepRuns((await (0, server_client_1.callServer)(
|
|
746
|
+
const runs = keepRuns((await (0, server_client_1.callServer)(connection, 'GET', path)).body.runs, options.state ? String(options.state).split(',') : undefined, options.services ? 'services' : options.tasks ? 'tasks' : undefined);
|
|
646
747
|
if (runs.length === 0) {
|
|
647
748
|
environment.stdout.write(`${serverName}: ${query.toString() ? 'no runs it keeps are like that' : 'you have no runs it still keeps'}\n`);
|
|
648
749
|
return;
|
|
@@ -673,7 +774,7 @@ function registerWorkCommands(remote, context) {
|
|
|
673
774
|
throw new Error('--follow prints the whole log, leave --tail out');
|
|
674
775
|
}
|
|
675
776
|
const { name: serverName, server } = await getServer(name);
|
|
676
|
-
const connection =
|
|
777
|
+
const connection = (0, sandbox_client_1.getServerConnection)(environment, serverName, server);
|
|
677
778
|
const found = await (0, sandbox_client_1.getRun)(connection, id);
|
|
678
779
|
if (!found) {
|
|
679
780
|
throw new Error(`${serverName} keeps no run ${(0, server_client_1.printable)(id)} you may see, list them with: hammerkit remote runs`);
|
|
@@ -704,6 +805,41 @@ function registerWorkCommands(remote, context) {
|
|
|
704
805
|
environment.stdout.write(`${(0, server_client_1.printable)(run.id)} is ${(0, server_client_1.printable)(run.state)}, follow it with --follow\n`);
|
|
705
806
|
}
|
|
706
807
|
}));
|
|
808
|
+
remote
|
|
809
|
+
.command('artifacts <run> [server]')
|
|
810
|
+
.description('list or download the outputs the tasks of a run that ended export (generates with export: true, ' +
|
|
811
|
+
'or export: always also of a task that failed); none of a run in which anything reads a secret')
|
|
812
|
+
.addOption(new commander_1.Option('--task <name>', 'only the outputs of this task'))
|
|
813
|
+
.addOption(new commander_1.Option('--path <path>', 'only the output at this path in the project, or the files of one below it'))
|
|
814
|
+
.addOption(new commander_1.Option('--out <dir>', 'download them into this directory, at their paths in the project; else they are listed'))
|
|
815
|
+
.action(guarded('Remote artifacts was not successful', async (id, name, options) => {
|
|
816
|
+
if (!RUN_ID.test(id)) {
|
|
817
|
+
throw new Error(`${(0, server_client_1.printable)(id)} is not a run id (run_...), list them with: hammerkit remote runs`);
|
|
818
|
+
}
|
|
819
|
+
const path = options.path === undefined ? undefined : projectPath(options.path);
|
|
820
|
+
const { name: serverName, server } = await getServer(name);
|
|
821
|
+
const connection = (0, sandbox_client_1.getServerConnection)(environment, serverName, server);
|
|
822
|
+
const kept = await (0, sandbox_client_1.getRunArtifacts)(connection, id);
|
|
823
|
+
if (!kept) {
|
|
824
|
+
throw new Error(`${serverName} keeps no run ${(0, server_client_1.printable)(id)} you may see, list them with: hammerkit remote runs`);
|
|
825
|
+
}
|
|
826
|
+
const outputs = keptProjectOutputs(kept.outputs);
|
|
827
|
+
const chosen = selectArtifacts(outputs, { task: options.task, path });
|
|
828
|
+
const selecting = options.task !== undefined || path !== undefined;
|
|
829
|
+
if (chosen.length === 0 && selecting) {
|
|
830
|
+
const all = outputs.map((output) => (0, server_client_1.printable)(output.path)).join(' and ') || 'nothing';
|
|
831
|
+
throw new Error(`the run kept nothing ${path !== undefined ? `at or below ${(0, server_client_1.printable)(path)}` : `of ${(0, server_client_1.printable)(options.task)}`}, it kept ${all}`);
|
|
832
|
+
}
|
|
833
|
+
// nothing to download (or no --out): the listing, before anything is made
|
|
834
|
+
if (options.out === undefined || chosen.length === 0) {
|
|
835
|
+
const shown = selecting ? chosen.map(({ output }) => output) : outputs;
|
|
836
|
+
for (const line of describeArtifacts(id, serverName, kept, shown)) {
|
|
837
|
+
environment.stdout.write(`${line}\n`);
|
|
838
|
+
}
|
|
839
|
+
return;
|
|
840
|
+
}
|
|
841
|
+
await downloadArtifacts(connection, id, chosen, (0, path_1.resolve)(environment.cwd, options.out), (line) => environment.stdout.write(`${line}\n`));
|
|
842
|
+
}));
|
|
707
843
|
remote
|
|
708
844
|
.command('extend <run> <ttl> [server]')
|
|
709
845
|
.description('keep a service run that is up for this long from now, such as 8h, at most the maxTtl of the server')
|
|
@@ -711,8 +847,10 @@ function registerWorkCommands(remote, context) {
|
|
|
711
847
|
if (!RUN_ID.test(id)) {
|
|
712
848
|
throw new Error(`${(0, server_client_1.printable)(id)} is not a run id (run_...)`);
|
|
713
849
|
}
|
|
714
|
-
const { name: serverName,
|
|
715
|
-
|
|
850
|
+
const { name: serverName, connection } = await connect(name);
|
|
851
|
+
// the end becomes this long from now, and never sooner than it was: a repeat sent late ends the
|
|
852
|
+
// run at most a retry window later than the first one did
|
|
853
|
+
const run = (await (0, server_client_1.callServer)(connection, 'POST', `/v1/runs/${id}/extend`, { body: { ttl }, repeat: 'always' })).body;
|
|
716
854
|
environment.stdout.write(`${(0, server_client_1.printable)(run.id)} on ${serverName} stays up until ${(0, server_client_1.printable)(run.expiresAt ?? '-')}\n`);
|
|
717
855
|
}));
|
|
718
856
|
remote
|
|
@@ -722,8 +860,9 @@ function registerWorkCommands(remote, context) {
|
|
|
722
860
|
if (!RUN_ID.test(id)) {
|
|
723
861
|
throw new Error(`${(0, server_client_1.printable)(id)} is not a run id (run_...)`);
|
|
724
862
|
}
|
|
725
|
-
const { name: serverName,
|
|
726
|
-
|
|
863
|
+
const { name: serverName, connection } = await connect(name);
|
|
864
|
+
// a run that is over stays so: sent again, the stop answers the same
|
|
865
|
+
const run = (await (0, server_client_1.callServer)(connection, 'POST', `/v1/runs/${id}/cancel`, { repeat: 'always' })).body;
|
|
727
866
|
environment.stdout.write(`${(0, server_client_1.printable)(run.id)} on ${serverName}: ${run.state === 'up' || run.state === 'running' ? 'stopping' : (0, server_client_1.printable)(run.state)}\n`);
|
|
728
867
|
}));
|
|
729
868
|
remote
|
|
@@ -733,8 +872,9 @@ function registerWorkCommands(remote, context) {
|
|
|
733
872
|
if (!RUN_ID.test(id)) {
|
|
734
873
|
throw new Error(`${(0, server_client_1.printable)(id)} is not a run id (run_...)`);
|
|
735
874
|
}
|
|
736
|
-
const { name: serverName,
|
|
737
|
-
|
|
875
|
+
const { name: serverName, connection } = await connect(name);
|
|
876
|
+
// each retry starts a run of its own: sent again only when the server did not take it
|
|
877
|
+
const run = (await (0, server_client_1.callServer)(connection, 'POST', `/v1/runs/${id}/retry`, { repeat: 'unsent' })).body;
|
|
738
878
|
environment.stdout.write(`${(0, server_client_1.printable)(run.id)} on ${serverName} retries ${(0, server_client_1.printable)(id)}: ${(0, server_client_1.printable)(run.state)}, ` +
|
|
739
879
|
`follow it with hammerkit remote logs ${(0, server_client_1.printable)(run.id)} --follow\n`);
|
|
740
880
|
}));
|
|
@@ -764,15 +904,17 @@ function registerWorkCommands(remote, context) {
|
|
|
764
904
|
keys.push({ task, key: found.key });
|
|
765
905
|
}
|
|
766
906
|
}
|
|
767
|
-
const { name: serverName, server
|
|
907
|
+
const { name: serverName, server } = await getServer(options.server, 'with --server <name>');
|
|
768
908
|
const answer = keys.length > 0
|
|
769
|
-
? await (0,
|
|
770
|
-
|
|
909
|
+
? await (0, sandbox_client_1.lookupChecks)((0, sandbox_client_1.getServerConnection)(environment, serverName, server), repo, keys).catch((e) => {
|
|
910
|
+
throw describeRefusal(server.url, e);
|
|
911
|
+
})
|
|
912
|
+
: { checks: [] };
|
|
771
913
|
const missing = [];
|
|
772
914
|
// by what was asked, never by what was answered: a task the answer leaves out, or
|
|
773
915
|
// answers for another key, is not verified
|
|
774
916
|
for (const { task, key } of keys) {
|
|
775
|
-
const check = answer.
|
|
917
|
+
const check = answer.checks.find((answered) => answered.task === task && answered.key === key);
|
|
776
918
|
if (check?.passed) {
|
|
777
919
|
environment.stdout.write(`${(0, server_client_1.printable)(task)}: ${(0, server_client_1.printable)(describePassed(check.passed))}\n`);
|
|
778
920
|
}
|
|
@@ -807,9 +949,9 @@ function registerWorkCommands(remote, context) {
|
|
|
807
949
|
}
|
|
808
950
|
query.append(filter.slice(0, index), filter.slice(index + 1));
|
|
809
951
|
}
|
|
810
|
-
const { name: serverName,
|
|
952
|
+
const { name: serverName, connection } = await connect(name);
|
|
811
953
|
const path = `/v1/definitions${query.toString() !== '' ? `?${query}` : ''}`;
|
|
812
|
-
const { body } = await (0, server_client_1.callServer)(
|
|
954
|
+
const { body } = await (0, server_client_1.callServer)(connection, 'GET', path);
|
|
813
955
|
if (body.definitions.length === 0) {
|
|
814
956
|
environment.stdout.write(`${serverName}: no published versions${query.toString() !== '' ? ' match' : ''}\n`);
|
|
815
957
|
return;
|
|
@@ -834,8 +976,8 @@ function registerWorkCommands(remote, context) {
|
|
|
834
976
|
.command('approvals [server]')
|
|
835
977
|
.description('list the runs on a server that wait for your approval')
|
|
836
978
|
.action(guarded('Remote approvals was not successful', async (name) => {
|
|
837
|
-
const { name: serverName,
|
|
838
|
-
const { body } = await (0, server_client_1.callServer)(
|
|
979
|
+
const { name: serverName, connection } = await connect(name);
|
|
980
|
+
const { body } = await (0, server_client_1.callServer)(connection, 'GET', '/v1/approvals');
|
|
839
981
|
if (body.approvals.length === 0) {
|
|
840
982
|
environment.stdout.write(`${serverName}: no runs wait for your approval\n`);
|
|
841
983
|
return;
|
|
@@ -848,11 +990,11 @@ function registerWorkCommands(remote, context) {
|
|
|
848
990
|
}
|
|
849
991
|
}));
|
|
850
992
|
// A version that is published: who published it, what its tasks do and every file.
|
|
851
|
-
const showPublished = async (hash, serverName,
|
|
993
|
+
const showPublished = async (hash, serverName, connection) => {
|
|
852
994
|
const path = `/v1/definitions/${hash}`;
|
|
853
995
|
let version;
|
|
854
996
|
try {
|
|
855
|
-
version = (await (0, server_client_1.callServer)(
|
|
997
|
+
version = (await (0, server_client_1.callServer)(connection, 'GET', path)).body;
|
|
856
998
|
}
|
|
857
999
|
catch (e) {
|
|
858
1000
|
if (e instanceof server_client_1.ServerError && e.status === 404) {
|
|
@@ -860,7 +1002,7 @@ function registerWorkCommands(remote, context) {
|
|
|
860
1002
|
}
|
|
861
1003
|
throw e;
|
|
862
1004
|
}
|
|
863
|
-
const files = (await (0, server_client_1.callServer)(
|
|
1005
|
+
const files = (await (0, server_client_1.callServer)(connection, 'GET', `${path}/files`)).body;
|
|
864
1006
|
environment.stdout.write(`${colors_1.default.bold((0, server_client_1.printable)(version.hash))} on ${serverName}, published by ${(0, server_client_1.printable)(version.publishedBy.sub)} (${(0, server_client_1.printable)(version.publishedBy.iss)}) at ${(0, server_client_1.printable)(version.publishedAt)}${version.approvedBy ? `, approved by ${(0, server_client_1.printable)(version.approvedBy.sub)}` : ''}\n`);
|
|
865
1007
|
for (const line of [
|
|
866
1008
|
...yankLines(version),
|
|
@@ -879,22 +1021,22 @@ function registerWorkCommands(remote, context) {
|
|
|
879
1021
|
if (!RUN_ID.test(target) && !bundle_1.HASH_PATTERN.test(target)) {
|
|
880
1022
|
throw new Error(`${(0, server_client_1.printable)(target)} is not a run id or a version, list them with: hammerkit remote approvals, remote proposals or remote versions`);
|
|
881
1023
|
}
|
|
882
|
-
const { name: serverName,
|
|
1024
|
+
const { name: serverName, connection } = await connect(name);
|
|
883
1025
|
if (bundle_1.HASH_PATTERN.test(target)) {
|
|
884
1026
|
const path = `/v1/proposals/${target}`;
|
|
885
1027
|
let proposal;
|
|
886
1028
|
try {
|
|
887
|
-
proposal = (await (0, server_client_1.callServer)(
|
|
1029
|
+
proposal = (await (0, server_client_1.callServer)(connection, 'GET', path)).body;
|
|
888
1030
|
}
|
|
889
1031
|
catch (e) {
|
|
890
1032
|
if (e instanceof server_client_1.ServerError && e.status === 404) {
|
|
891
|
-
await showPublished(target, serverName,
|
|
1033
|
+
await showPublished(target, serverName, connection);
|
|
892
1034
|
return;
|
|
893
1035
|
}
|
|
894
1036
|
throw e;
|
|
895
1037
|
}
|
|
896
1038
|
if (proposal.state === 'approved') {
|
|
897
|
-
await showPublished(target, serverName,
|
|
1039
|
+
await showPublished(target, serverName, connection);
|
|
898
1040
|
return;
|
|
899
1041
|
}
|
|
900
1042
|
if (proposal.state !== 'waiting') {
|
|
@@ -906,7 +1048,7 @@ function registerWorkCommands(remote, context) {
|
|
|
906
1048
|
environment.stdout.write(' its files are not kept once it is decided\n');
|
|
907
1049
|
return;
|
|
908
1050
|
}
|
|
909
|
-
const files = (await (0, server_client_1.callServer)(
|
|
1051
|
+
const files = (await (0, server_client_1.callServer)(connection, 'GET', `${path}/files`)).body;
|
|
910
1052
|
environment.stdout.write(`${colors_1.default.bold((0, server_client_1.printable)(proposal.hash))} on ${serverName}, proposed by ${(0, server_client_1.printable)(proposal.proposedBy.sub)} (${(0, server_client_1.printable)(proposal.proposedBy.iss)}), ${(0, server_client_1.printable)(proposal.state)}\n`);
|
|
911
1053
|
for (const line of [
|
|
912
1054
|
...annotationLines(proposal.annotations),
|
|
@@ -918,7 +1060,7 @@ function registerWorkCommands(remote, context) {
|
|
|
918
1060
|
}
|
|
919
1061
|
return;
|
|
920
1062
|
}
|
|
921
|
-
const view = (await (0, server_client_1.callServer)(
|
|
1063
|
+
const view = (await (0, server_client_1.callServer)(connection, 'GET', `/v1/approvals/${target}`)).body;
|
|
922
1064
|
for (const line of describeApproval(view)) {
|
|
923
1065
|
environment.stdout.write(`${line}\n`);
|
|
924
1066
|
}
|
|
@@ -928,8 +1070,8 @@ function registerWorkCommands(remote, context) {
|
|
|
928
1070
|
.command('proposals [server]')
|
|
929
1071
|
.description('list the proposed versions of build files you made or may approve')
|
|
930
1072
|
.action(guarded('Remote proposals was not successful', async (name) => {
|
|
931
|
-
const { name: serverName,
|
|
932
|
-
const { body } = await (0, server_client_1.callServer)(
|
|
1073
|
+
const { name: serverName, connection } = await connect(name);
|
|
1074
|
+
const { body } = await (0, server_client_1.callServer)(connection, 'GET', '/v1/proposals');
|
|
933
1075
|
if (body.proposals.length === 0) {
|
|
934
1076
|
environment.stdout.write(`${serverName}: no proposed versions\n`);
|
|
935
1077
|
return;
|
|
@@ -971,8 +1113,13 @@ function registerWorkCommands(remote, context) {
|
|
|
971
1113
|
if (!bundle_1.HASH_PATTERN.test(target)) {
|
|
972
1114
|
throw new Error(`${(0, server_client_1.printable)(target)} is not a version, name it by its hash: sha256:...`);
|
|
973
1115
|
}
|
|
974
|
-
const { name: serverName,
|
|
975
|
-
|
|
1116
|
+
const { name: serverName, connection } = await connect(name);
|
|
1117
|
+
// a yank sent again after a lost answer ends the same, unless somebody let the version go on
|
|
1118
|
+
// in between. An unyank is not repeated then: it would let a version go on that somebody yanked
|
|
1119
|
+
await (0, server_client_1.callServer)(connection, 'POST', `/v1/definitions/${target}/${action}`, {
|
|
1120
|
+
body: options.reason ? { reason: options.reason } : undefined,
|
|
1121
|
+
repeat: action === 'yank' ? 'always' : 'unsent',
|
|
1122
|
+
});
|
|
976
1123
|
environment.stdout.write(`${action === 'yank' ? 'yanked' : 'let go on'} ${(0, server_client_1.printable)(target)} on ${serverName}\n`);
|
|
977
1124
|
}));
|
|
978
1125
|
}
|
|
@@ -988,9 +1135,14 @@ function registerWorkCommands(remote, context) {
|
|
|
988
1135
|
if (!proposal && !RUN_ID.test(target)) {
|
|
989
1136
|
throw new Error(`${(0, server_client_1.printable)(target)} is not a run id or a proposed version, list them with: hammerkit remote approvals or remote proposals`);
|
|
990
1137
|
}
|
|
991
|
-
const { name: serverName,
|
|
1138
|
+
const { name: serverName, connection } = await connect(name);
|
|
992
1139
|
const path = proposal ? `/v1/proposals/${target}/${action}` : `/v1/approvals/${target}/${action}`;
|
|
993
|
-
|
|
1140
|
+
// a decision taken twice is refused the second time (409): sent again only when the
|
|
1141
|
+
// server did not take it
|
|
1142
|
+
const { body } = await (0, server_client_1.callServer)(connection, 'POST', path, {
|
|
1143
|
+
body: options.reason ? { reason: options.reason } : undefined,
|
|
1144
|
+
repeat: 'unsent',
|
|
1145
|
+
});
|
|
994
1146
|
const rejected = body.state === 'rejected';
|
|
995
1147
|
environment.stdout.write(proposal
|
|
996
1148
|
? rejected
|