@kvbox/cli 0.6.25 → 0.6.27
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/dist/kvbox.js +547 -261
- package/dist/kvbox.js.map +1 -1
- package/package.json +1 -1
package/dist/kvbox.js
CHANGED
|
@@ -155,7 +155,7 @@ async function spin(message, work, opts = {}) {
|
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
// src/program.ts
|
|
158
|
-
import { Command as
|
|
158
|
+
import { Command as Command180 } from "commander";
|
|
159
159
|
|
|
160
160
|
// ../shared/src/version.ts
|
|
161
161
|
import { createRequire } from "module";
|
|
@@ -170,7 +170,7 @@ function versionOf(srcFileUrl, injected) {
|
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
// src/version.ts
|
|
173
|
-
var VERSION = versionOf(import.meta.url, true ? "0.6.
|
|
173
|
+
var VERSION = versionOf(import.meta.url, true ? "0.6.27" : void 0);
|
|
174
174
|
|
|
175
175
|
// src/commands/vm/index.ts
|
|
176
176
|
import { Command as Command44 } from "commander";
|
|
@@ -468,6 +468,9 @@ function parseMib(text2) {
|
|
|
468
468
|
return Number.isInteger(mib2) && mib2 > 0 ? mib2 : void 0;
|
|
469
469
|
}
|
|
470
470
|
|
|
471
|
+
// ../shared/src/ranges.ts
|
|
472
|
+
var IPV4_RE = /^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/;
|
|
473
|
+
|
|
471
474
|
// ../shared/src/api.ts
|
|
472
475
|
var SizeSchema = z2.enum(SIZE_NAMES);
|
|
473
476
|
var BOX_SSH_USER = "kvbox";
|
|
@@ -492,24 +495,24 @@ var PortsRequest = z2.object({
|
|
|
492
495
|
keep: z2.boolean().optional()
|
|
493
496
|
});
|
|
494
497
|
var BoxPortSchema = z2.number().int().min(1).max(65535);
|
|
495
|
-
var BoxLinkSchema = z2.object({ from: z2.string(), port: BoxPortSchema });
|
|
498
|
+
var BoxLinkSchema = z2.object({ from: z2.string(), port: BoxPortSchema, host: z2.string().optional() });
|
|
496
499
|
var LinkRequest = z2.object({
|
|
497
500
|
from: z2.string().min(1),
|
|
498
501
|
fromOwner: z2.string().optional(),
|
|
499
502
|
port: BoxPortSchema,
|
|
500
503
|
/**
|
|
501
|
-
* The box `from` is on another host (#
|
|
502
|
-
*
|
|
504
|
+
* The box `from` is on another host (#241, a control plane's call only): `host` by name, where its address
|
|
505
|
+
* is `ip`. This host cannot see that box, so the control plane says its address; the host takes one only
|
|
506
|
+
* inside the range of that host, which it knows from the tunnel between them.
|
|
503
507
|
*/
|
|
504
|
-
far: z2.object({
|
|
508
|
+
far: z2.object({ ip: z2.string().regex(IPV4_RE), host: z2.string().min(1) }).optional()
|
|
505
509
|
});
|
|
506
510
|
var FarLinkRequest = z2.object({
|
|
507
511
|
to: z2.string().min(1),
|
|
508
512
|
toOwner: z2.string().optional(),
|
|
509
513
|
port: BoxPortSchema,
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
key: z2.string().min(32)
|
|
514
|
+
ip: z2.string().regex(IPV4_RE),
|
|
515
|
+
host: z2.string().min(1)
|
|
513
516
|
});
|
|
514
517
|
var FarUnlinkRequest = FarLinkRequest.pick({ to: true, toOwner: true, port: true });
|
|
515
518
|
var ClaimSubdomainRequest = z2.object({ name: z2.string(), port: BoxPortSchema });
|
|
@@ -799,6 +802,11 @@ var MachineSchema = z2.object({
|
|
|
799
802
|
volumes: z2.array(z2.object({ name: z2.string(), sizeGib: z2.number().int(), mountPath: z2.string() })).optional(),
|
|
800
803
|
/** Boxes that may reach this one, each on one port (#98). Absent: none. */
|
|
801
804
|
links: z2.array(BoxLinkSchema).optional(),
|
|
805
|
+
/**
|
|
806
|
+
* Boxes on other hosts this one reaches (#241), each on one port: `to` is named like a link's `from`,
|
|
807
|
+
* `host` is the host it is on. The other side of that box's `links` entry. Absent: none.
|
|
808
|
+
*/
|
|
809
|
+
reaches: z2.array(z2.object({ to: z2.string(), port: BoxPortSchema, host: z2.string() })).optional(),
|
|
802
810
|
/**
|
|
803
811
|
* The integrations turned on for the box (#205, `github`): names only, the credential is fetched by the box
|
|
804
812
|
* each time it is needed. Absent: none. A host before integrations never sends it.
|
|
@@ -1102,12 +1110,22 @@ var CapacitySchema = z2.object({
|
|
|
1102
1110
|
fromBackup: z2.boolean().optional(),
|
|
1103
1111
|
/** True on a kvbox-server that keeps a box's `integrations` (#205); an older one drops the field without a word. */
|
|
1104
1112
|
integrations: z2.boolean().optional(),
|
|
1105
|
-
/**
|
|
1106
|
-
|
|
1113
|
+
/**
|
|
1114
|
+
* The other hosts this one has a tunnel to, by name (#241): what its network carries a link across hosts to.
|
|
1115
|
+
* The control plane links two boxes on different hosts only when each host names the other. Absent on a
|
|
1116
|
+
* host without the tunnel (an older kvbox-server, a root step not run, no box range).
|
|
1117
|
+
*/
|
|
1118
|
+
mesh: z2.array(z2.string()).optional(),
|
|
1107
1119
|
/** True on a host whose network puts the boxes of one cluster in reach of each other (#215); the control plane places a cluster's box only on such a host. */
|
|
1108
1120
|
clusters: z2.boolean().optional(),
|
|
1109
1121
|
/** The integrations this kvbox-server knows (`hostKnowsIntegrations`). Absent with `integrations`: the first one's, `github` alone. */
|
|
1110
|
-
integrationIds: z2.array(z2.string()).optional()
|
|
1122
|
+
integrationIds: z2.array(z2.string()).optional(),
|
|
1123
|
+
/** True on a host that can take a box range of its own (#240): its privileged network script widens a network that is up. */
|
|
1124
|
+
ranges: z2.boolean().optional(),
|
|
1125
|
+
/** The range the host gives its boxes now (`172.30.4.0/24`, config.json `boxRange`); absent while it has none. */
|
|
1126
|
+
boxRange: z2.string().optional(),
|
|
1127
|
+
/** Boxes of the host whose address is still outside `boxRange`: each moves at its next cold start. Absent without a range. */
|
|
1128
|
+
offRange: z2.number().int().optional()
|
|
1111
1129
|
});
|
|
1112
1130
|
var ImageSchema = z2.object({ name: z2.string(), version: z2.string().nullable() });
|
|
1113
1131
|
var ImageIndexSchema = z2.object({
|
|
@@ -1299,6 +1317,8 @@ var UsageDaySchema = z2.object({
|
|
|
1299
1317
|
volumes: z2.array(UsageDayItemSchema),
|
|
1300
1318
|
/** Object storage that existed that day (#182); absent on a day without any. */
|
|
1301
1319
|
storage: z2.array(UsageDayItemSchema).optional(),
|
|
1320
|
+
/** A container registry that existed that day (#234); absent on a day without any. */
|
|
1321
|
+
registry: z2.array(UsageDayItemSchema).optional(),
|
|
1302
1322
|
/** Cron services that existed that day (#190); absent on a day without any. */
|
|
1303
1323
|
cron: z2.array(UsageDayItemSchema).optional(),
|
|
1304
1324
|
/** Kubernetes clusters that existed that day (#222), each with its master and nodes together; absent on a day without any. */
|
|
@@ -1317,6 +1337,11 @@ var UsageReportSchema = z2.object({
|
|
|
1317
1337
|
* included ones, `sizeGib` its whole size. Absent when there is none.
|
|
1318
1338
|
*/
|
|
1319
1339
|
storage: z2.array(VolumeUsageSchema).optional(),
|
|
1340
|
+
/**
|
|
1341
|
+
* Container registries (#234, control plane only): one row per registry a slug has or had, shaped and
|
|
1342
|
+
* priced like `storage` with the registry's prices. Absent when there is none.
|
|
1343
|
+
*/
|
|
1344
|
+
registry: z2.array(VolumeUsageSchema).optional(),
|
|
1320
1345
|
/** Cron services (#190, control plane only): one row per service a slug has or had. Absent when there is none. */
|
|
1321
1346
|
cron: z2.array(CronUsageSchema).optional(),
|
|
1322
1347
|
/**
|
|
@@ -1335,7 +1360,7 @@ var UsageReportSchema = z2.object({
|
|
|
1335
1360
|
diskGibHours: z2.number(),
|
|
1336
1361
|
volumeHours: z2.number().optional(),
|
|
1337
1362
|
volumeGibHours: z2.number().optional(),
|
|
1338
|
-
/** Boxes, volumes, object storage, cron services, Kubernetes clusters and paid backups together; the hours above are those of `boxes` and `volumes` alone. */
|
|
1363
|
+
/** Boxes, volumes, object storage, container registries, cron services, Kubernetes clusters and paid backups together; the hours above are those of `boxes` and `volumes` alone. */
|
|
1339
1364
|
cost: z2.object({ amount: z2.number(), currency: z2.string() }).optional()
|
|
1340
1365
|
})
|
|
1341
1366
|
});
|
|
@@ -1607,6 +1632,21 @@ var SshCaResponseSchema = z2.object({
|
|
|
1607
1632
|
var HostSshCaResponseSchema = z2.object({
|
|
1608
1633
|
publicKey: z2.string()
|
|
1609
1634
|
});
|
|
1635
|
+
var HostRangeResponseSchema = z2.object({
|
|
1636
|
+
range: z2.string().nullable()
|
|
1637
|
+
});
|
|
1638
|
+
var HOST_NAME_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,62}$/;
|
|
1639
|
+
var MeshPeerSchema = z2.object({
|
|
1640
|
+
name: z2.string().regex(HOST_NAME_RE),
|
|
1641
|
+
publicKey: z2.string().regex(/^[A-Za-z0-9+/]{43}=$/),
|
|
1642
|
+
endpoint: z2.string().regex(/^[0-9a-zA-Z.-]+:\d{1,5}$/),
|
|
1643
|
+
range: z2.string()
|
|
1644
|
+
});
|
|
1645
|
+
var MeshRegisterRequest = z2.object({
|
|
1646
|
+
publicKey: MeshPeerSchema.shape.publicKey,
|
|
1647
|
+
port: z2.number().int().min(1).max(65535)
|
|
1648
|
+
});
|
|
1649
|
+
var MeshResponseSchema = z2.object({ peers: z2.array(MeshPeerSchema) });
|
|
1610
1650
|
var CloudCaSchema = z2.object({
|
|
1611
1651
|
controlPlane: z2.string(),
|
|
1612
1652
|
publicKey: z2.string(),
|
|
@@ -1631,12 +1671,17 @@ var TrustCaReportSchema = z2.object({
|
|
|
1631
1671
|
});
|
|
1632
1672
|
var HostJoinRequestSchema = z2.object({
|
|
1633
1673
|
token: z2.string().min(1),
|
|
1634
|
-
name: z2.string().
|
|
1674
|
+
name: z2.string().regex(HOST_NAME_RE, "a host name is letters, digits, '.', '_' and '-', at most 63"),
|
|
1635
1675
|
url: z2.string().url(),
|
|
1636
1676
|
fingerprint: z2.string().regex(/^([0-9A-F]{2}:){31}[0-9A-F]{2}$/),
|
|
1637
1677
|
publicAddress: z2.string().min(1),
|
|
1638
1678
|
/** Where the host is (`kvbox-server join --country`): a code or an English name. */
|
|
1639
|
-
country: z2.string().optional()
|
|
1679
|
+
country: z2.string().optional(),
|
|
1680
|
+
/**
|
|
1681
|
+
* The box range this host already has boxes on (config.json `boxRange`, kept across a leave), which it
|
|
1682
|
+
* never gives up: the join gives it back, or is refused while it is another host's (#240).
|
|
1683
|
+
*/
|
|
1684
|
+
boxRange: z2.string().optional()
|
|
1640
1685
|
});
|
|
1641
1686
|
var HostJoinResponseSchema = z2.object({
|
|
1642
1687
|
hostSecret: z2.string(),
|
|
@@ -1654,14 +1699,20 @@ var CloudHostSchema = z2.object({
|
|
|
1654
1699
|
/** The S3 region a storage made on this host answers to (`ro-west-1`); null: it takes no storage. */
|
|
1655
1700
|
region: z2.string().nullable(),
|
|
1656
1701
|
/** kvbox-server's version as of the poller's last look (`capacity.version`); null before one, or for a server older than 0.5.45. */
|
|
1657
|
-
version: z2.string().nullable()
|
|
1702
|
+
version: z2.string().nullable(),
|
|
1703
|
+
/**
|
|
1704
|
+
* The range of box addresses that is this host's alone (#240, `172.30.4.0/24`): the next free one at join,
|
|
1705
|
+
* or the admin's. Null: a host from before ranges that nobody gave one; its boxes are on `172.30.0.x` like
|
|
1706
|
+
* every such host's. What the host has taken of it is `capacity.boxRange`.
|
|
1707
|
+
*/
|
|
1708
|
+
boxRange: z2.string().nullable()
|
|
1658
1709
|
});
|
|
1659
1710
|
var HostInfoSchema = z2.object({
|
|
1660
1711
|
host: CloudHostSchema,
|
|
1661
1712
|
health: HealthSchema.nullable(),
|
|
1662
1713
|
error: z2.string().nullable()
|
|
1663
1714
|
});
|
|
1664
|
-
var HostPatchRequest = z2.object({ country: z2.string().nullable().optional(), region: z2.string().nullable().optional() }).refine((b) => b.country !== void 0 || b.region !== void 0, { message: "give country, region or
|
|
1715
|
+
var HostPatchRequest = z2.object({ country: z2.string().nullable().optional(), region: z2.string().nullable().optional(), boxRange: z2.string().nullable().optional() }).refine((b) => b.country !== void 0 || b.region !== void 0 || b.boxRange !== void 0, { message: "give country, region or boxRange" });
|
|
1665
1716
|
var CountrySchema = z2.object({ code: z2.string(), name: z2.string() });
|
|
1666
1717
|
|
|
1667
1718
|
// src/session.ts
|
|
@@ -1867,6 +1918,14 @@ var PricingSchema = z4.object({
|
|
|
1867
1918
|
storageHour: z4.number().nonnegative().default(0),
|
|
1868
1919
|
storageGibHour: z4.number().nonnegative().default(0),
|
|
1869
1920
|
storageIncludedGib: z4.number().int().nonnegative().default(0),
|
|
1921
|
+
/**
|
|
1922
|
+
* The container registry (#234): priced as object storage is. An hour of a slug's registry existing,
|
|
1923
|
+
* whatever it holds, covers its hidden box and the first `registryIncludedGib` of its size; each GiB
|
|
1924
|
+
* above that is `registryGibHour`. A price list from before the registry charges nothing for it.
|
|
1925
|
+
*/
|
|
1926
|
+
registryHour: z4.number().nonnegative().default(0),
|
|
1927
|
+
registryGibHour: z4.number().nonnegative().default(0),
|
|
1928
|
+
registryIncludedGib: z4.number().int().nonnegative().default(0),
|
|
1870
1929
|
/** The cron service (#190): an hour of one cron service existing, whatever it holds or fires. A price list from before it charges nothing. */
|
|
1871
1930
|
cronHour: z4.number().nonnegative().default(0),
|
|
1872
1931
|
/**
|
|
@@ -3019,7 +3078,7 @@ var Kvbox = class {
|
|
|
3019
3078
|
};
|
|
3020
3079
|
|
|
3021
3080
|
// src/client.ts
|
|
3022
|
-
import { z as
|
|
3081
|
+
import { z as z18 } from "zod";
|
|
3023
3082
|
|
|
3024
3083
|
// ../shared/src/cron.ts
|
|
3025
3084
|
import { z as z15 } from "zod";
|
|
@@ -3274,6 +3333,47 @@ var DeletedObjectsSchema = z16.object({
|
|
|
3274
3333
|
var MoveObjectRequest = z16.object({ from: z16.string(), to: z16.string(), overwrite: z16.boolean().optional() });
|
|
3275
3334
|
var CreateFolderRequest = z16.object({ prefix: z16.string() });
|
|
3276
3335
|
|
|
3336
|
+
// ../shared/src/registry.ts
|
|
3337
|
+
import { z as z17 } from "zod";
|
|
3338
|
+
var RegistrySchema = z17.object({
|
|
3339
|
+
owner: z17.string(),
|
|
3340
|
+
ownerKind: z17.enum(["user", "org"]),
|
|
3341
|
+
/** `cr-<slug>.<domain>`: what `docker login` and an image's name take (no scheme). Null while the address is not claimed. */
|
|
3342
|
+
address: z17.string().nullable(),
|
|
3343
|
+
/** The login's user name. */
|
|
3344
|
+
user: z17.string(),
|
|
3345
|
+
/** The most it may hold. */
|
|
3346
|
+
sizeGib: z17.number().int(),
|
|
3347
|
+
/** `running` when it answers; `unknown` while its host is not heard from. */
|
|
3348
|
+
status: BoxStatusSchema,
|
|
3349
|
+
/** With `?live=1` or on `GET /registry/info`, when the registry answered: what is on its disk, and the disk's real size. */
|
|
3350
|
+
usedBytes: z17.number().optional(),
|
|
3351
|
+
totalBytes: z17.number().optional(),
|
|
3352
|
+
/** The same, when it answered: every repository with how many tags it has. */
|
|
3353
|
+
repositories: z17.array(z17.object({ name: z17.string(), tags: z17.number().int() })).optional(),
|
|
3354
|
+
/** There are more repositories than `repositories` lists. */
|
|
3355
|
+
repositoriesTruncated: z17.boolean().optional(),
|
|
3356
|
+
/** zot's version, when it answered. */
|
|
3357
|
+
version: z17.string().optional(),
|
|
3358
|
+
host: z17.string(),
|
|
3359
|
+
country: z17.string().optional(),
|
|
3360
|
+
price: z17.object({ perMonth: z17.number(), currency: z17.string() }),
|
|
3361
|
+
createdBy: z17.string().nullable(),
|
|
3362
|
+
createdAt: z17.string()
|
|
3363
|
+
});
|
|
3364
|
+
var CreateRegistryRequest = z17.object({
|
|
3365
|
+
sizeGib: z17.number().int().optional(),
|
|
3366
|
+
near: z17.string().optional()
|
|
3367
|
+
});
|
|
3368
|
+
var RegistrySecretSchema = z17.object({
|
|
3369
|
+
address: z17.string().nullable(),
|
|
3370
|
+
user: z17.string(),
|
|
3371
|
+
password: z17.string()
|
|
3372
|
+
});
|
|
3373
|
+
var CreatedRegistrySchema = RegistrySchema.extend({ secret: RegistrySecretSchema, ready: z17.boolean() });
|
|
3374
|
+
var ResetRegistryPasswordRequest = z17.object({}).strict();
|
|
3375
|
+
var GrowRegistryRequest = z17.object({ sizeGib: z17.number().int() });
|
|
3376
|
+
|
|
3277
3377
|
// src/kvm.ts
|
|
3278
3378
|
import { accessSync, constants, readFileSync, statSync } from "fs";
|
|
3279
3379
|
import { userInfo } from "os";
|
|
@@ -3442,7 +3542,7 @@ var ServerClient = class {
|
|
|
3442
3542
|
* `all`: every box on the platform (platform admins only, #78).
|
|
3443
3543
|
*/
|
|
3444
3544
|
listMachines(opts = {}) {
|
|
3445
|
-
return this.call("GET", `/machines${allQuery(opts)}`,
|
|
3545
|
+
return this.call("GET", `/machines${allQuery(opts)}`, z18.array(MachineSchema), void 0, opts.org);
|
|
3446
3546
|
}
|
|
3447
3547
|
createMachine(req) {
|
|
3448
3548
|
return this.call("POST", "/machines", MachineSchema, req, void 0, req.fromBackup !== void 0 ? 2 * 36e5 : void 0);
|
|
@@ -3500,10 +3600,10 @@ var ServerClient = class {
|
|
|
3500
3600
|
}
|
|
3501
3601
|
/** Backups, the control plane's only: a box's disk in object storage. Newest first. */
|
|
3502
3602
|
listBackups() {
|
|
3503
|
-
return this.call("GET", "/backups",
|
|
3603
|
+
return this.call("GET", "/backups", z18.array(BackupSchema));
|
|
3504
3604
|
}
|
|
3505
3605
|
boxBackups(name) {
|
|
3506
|
-
return this.call("GET", `/machines/${encodeURIComponent(name)}/backups`,
|
|
3606
|
+
return this.call("GET", `/machines/${encodeURIComponent(name)}/backups`, z18.array(BackupSchema));
|
|
3507
3607
|
}
|
|
3508
3608
|
boxBackup(name, id) {
|
|
3509
3609
|
return this.call("GET", `/machines/${encodeURIComponent(name)}/backups/${encodeURIComponent(id)}`, BackupSchema);
|
|
@@ -3525,14 +3625,14 @@ var ServerClient = class {
|
|
|
3525
3625
|
* later. Works for a backup whose box, volume or database is gone too.
|
|
3526
3626
|
*/
|
|
3527
3627
|
removeBackup(id) {
|
|
3528
|
-
return this.call("DELETE", `/backups/${encodeURIComponent(id)}`,
|
|
3628
|
+
return this.call("DELETE", `/backups/${encodeURIComponent(id)}`, z18.undefined());
|
|
3529
3629
|
}
|
|
3530
3630
|
/** A volume's backups (#168): the same as a box's, of the volume's disk. Newest first. */
|
|
3531
3631
|
listVolumeBackups() {
|
|
3532
|
-
return this.call("GET", "/backups?kind=volume",
|
|
3632
|
+
return this.call("GET", "/backups?kind=volume", z18.array(VolumeBackupSchema));
|
|
3533
3633
|
}
|
|
3534
3634
|
volumeBackups(name) {
|
|
3535
|
-
return this.call("GET", `/volumes/${encodeURIComponent(name)}/backups`,
|
|
3635
|
+
return this.call("GET", `/volumes/${encodeURIComponent(name)}/backups`, z18.array(VolumeBackupSchema));
|
|
3536
3636
|
}
|
|
3537
3637
|
volumeBackup(name, id) {
|
|
3538
3638
|
return this.call("GET", `/volumes/${encodeURIComponent(name)}/backups/${encodeURIComponent(id)}`, VolumeBackupSchema);
|
|
@@ -3558,7 +3658,7 @@ var ServerClient = class {
|
|
|
3558
3658
|
}
|
|
3559
3659
|
/** Wake hooks (#101), the control plane's only: a URL and a secret that wake the box. */
|
|
3560
3660
|
boxHooks(name) {
|
|
3561
|
-
return this.call("GET", `/machines/${encodeURIComponent(name)}/hooks`,
|
|
3661
|
+
return this.call("GET", `/machines/${encodeURIComponent(name)}/hooks`, z18.array(WakeHookSchema));
|
|
3562
3662
|
}
|
|
3563
3663
|
createBoxHook(name) {
|
|
3564
3664
|
return this.call("POST", `/machines/${encodeURIComponent(name)}/hooks`, CreatedWakeHookSchema);
|
|
@@ -3586,7 +3686,7 @@ var ServerClient = class {
|
|
|
3586
3686
|
}
|
|
3587
3687
|
/** Every readable box's subdomains, one entry each. */
|
|
3588
3688
|
listSubdomains() {
|
|
3589
|
-
return this.call("GET", "/subdomains",
|
|
3689
|
+
return this.call("GET", "/subdomains", z18.array(SubdomainSchema));
|
|
3590
3690
|
}
|
|
3591
3691
|
/** Custom domains (#89), the control plane's only: serve the box at the user's own name. */
|
|
3592
3692
|
addDomain(name, req) {
|
|
@@ -3597,7 +3697,7 @@ var ServerClient = class {
|
|
|
3597
3697
|
}
|
|
3598
3698
|
/** Every readable box's custom domains. */
|
|
3599
3699
|
listDomains() {
|
|
3600
|
-
return this.call("GET", "/domains",
|
|
3700
|
+
return this.call("GET", "/domains", z18.array(DomainSchema));
|
|
3601
3701
|
}
|
|
3602
3702
|
/** A running box's own load, memory and disk, asked of its guest (#67). */
|
|
3603
3703
|
machineStats(name) {
|
|
@@ -3638,22 +3738,22 @@ var ServerClient = class {
|
|
|
3638
3738
|
return this.call("POST", "/billing/redeem", RedeemResponseSchema, { code });
|
|
3639
3739
|
}
|
|
3640
3740
|
deleteMachine(name) {
|
|
3641
|
-
return this.call("DELETE", `/machines/${encodeURIComponent(name)}`,
|
|
3741
|
+
return this.call("DELETE", `/machines/${encodeURIComponent(name)}`, z18.undefined());
|
|
3642
3742
|
}
|
|
3643
3743
|
/** Like `listMachines`, for snapshots. */
|
|
3644
3744
|
listSnapshots(opts = {}) {
|
|
3645
|
-
return this.call("GET", `/snapshots${allQuery(opts)}`,
|
|
3745
|
+
return this.call("GET", `/snapshots${allQuery(opts)}`, z18.array(SnapshotSchema), void 0, opts.org);
|
|
3646
3746
|
}
|
|
3647
3747
|
createSnapshot(req) {
|
|
3648
3748
|
return this.call("POST", "/snapshots", SnapshotSchema, req);
|
|
3649
3749
|
}
|
|
3650
3750
|
deleteSnapshot(name) {
|
|
3651
|
-
return this.call("DELETE", `/snapshots/${encodeURIComponent(name)}`,
|
|
3751
|
+
return this.call("DELETE", `/snapshots/${encodeURIComponent(name)}`, z18.undefined());
|
|
3652
3752
|
}
|
|
3653
3753
|
// ---- environment variables (#88), a control plane only: the caller's slug, or `--org`'s ----
|
|
3654
3754
|
/** `org`: that org's list instead of `--org`'s (or the caller's own). */
|
|
3655
3755
|
listEnv(org) {
|
|
3656
|
-
return this.call("GET", "/vars",
|
|
3756
|
+
return this.call("GET", "/vars", z18.array(EnvVarSchema), void 0, org);
|
|
3657
3757
|
}
|
|
3658
3758
|
setEnv(name, req) {
|
|
3659
3759
|
return this.call("PUT", `/vars/${encodeURIComponent(name)}`, EnvChangeSchema, req);
|
|
@@ -3673,13 +3773,13 @@ var ServerClient = class {
|
|
|
3673
3773
|
}
|
|
3674
3774
|
// ---- volumes (#52) ----
|
|
3675
3775
|
listVolumes(opts = {}) {
|
|
3676
|
-
return this.call("GET", `/volumes${allQuery(opts)}`,
|
|
3776
|
+
return this.call("GET", `/volumes${allQuery(opts)}`, z18.array(VolumeSchema), void 0, opts.org);
|
|
3677
3777
|
}
|
|
3678
3778
|
createVolume(req) {
|
|
3679
3779
|
return this.call("POST", "/volumes", VolumeSchema, req);
|
|
3680
3780
|
}
|
|
3681
3781
|
deleteVolume(name) {
|
|
3682
|
-
return this.call("DELETE", `/volumes/${encodeURIComponent(name)}`,
|
|
3782
|
+
return this.call("DELETE", `/volumes/${encodeURIComponent(name)}`, z18.undefined());
|
|
3683
3783
|
}
|
|
3684
3784
|
/** Both answer with the box as it is afterwards (restarted when it was running). */
|
|
3685
3785
|
attachVolume(name, req) {
|
|
@@ -3694,7 +3794,7 @@ var ServerClient = class {
|
|
|
3694
3794
|
}
|
|
3695
3795
|
// ---- cron service (#190): the control plane's alone ----
|
|
3696
3796
|
listCronServices(opts = {}) {
|
|
3697
|
-
return this.call("GET", `/cron${allQuery(opts)}`,
|
|
3797
|
+
return this.call("GET", `/cron${allQuery(opts)}`, z18.array(CronServiceSchema), void 0, opts.org);
|
|
3698
3798
|
}
|
|
3699
3799
|
createCronService(name) {
|
|
3700
3800
|
return this.call("POST", "/cron", CronServiceSchema, { name });
|
|
@@ -3703,10 +3803,10 @@ var ServerClient = class {
|
|
|
3703
3803
|
return this.call("GET", `/cron/${encodeURIComponent(name)}`, CronServiceSchema);
|
|
3704
3804
|
}
|
|
3705
3805
|
deleteCronService(name) {
|
|
3706
|
-
return this.call("DELETE", `/cron/${encodeURIComponent(name)}`,
|
|
3806
|
+
return this.call("DELETE", `/cron/${encodeURIComponent(name)}`, z18.undefined());
|
|
3707
3807
|
}
|
|
3708
3808
|
listCronTriggers(service) {
|
|
3709
|
-
return this.call("GET", `/cron/${encodeURIComponent(service)}/triggers`,
|
|
3809
|
+
return this.call("GET", `/cron/${encodeURIComponent(service)}/triggers`, z18.array(CronTriggerSchema));
|
|
3710
3810
|
}
|
|
3711
3811
|
addCronTrigger(service, req) {
|
|
3712
3812
|
return this.call("POST", `/cron/${encodeURIComponent(service)}/triggers`, CronTriggerSchema, req);
|
|
@@ -3716,18 +3816,18 @@ var ServerClient = class {
|
|
|
3716
3816
|
return this.call("PATCH", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}`, CronTriggerSchema, { enabled: enabled2 });
|
|
3717
3817
|
}
|
|
3718
3818
|
deleteCronTrigger(service, id) {
|
|
3719
|
-
return this.call("DELETE", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}`,
|
|
3819
|
+
return this.call("DELETE", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}`, z18.undefined());
|
|
3720
3820
|
}
|
|
3721
3821
|
/** Marks it due: kvbox-cron fires it within a few seconds. */
|
|
3722
3822
|
runCronTrigger(service, id) {
|
|
3723
3823
|
return this.call("POST", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}/run`, CronTriggerSchema);
|
|
3724
3824
|
}
|
|
3725
3825
|
listCronRuns(service, id, limit) {
|
|
3726
|
-
return this.call("GET", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}/runs${limit === void 0 ? "" : `?limit=${limit}`}`,
|
|
3826
|
+
return this.call("GET", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}/runs${limit === void 0 ? "" : `?limit=${limit}`}`, z18.array(CronRunSchema));
|
|
3727
3827
|
}
|
|
3728
3828
|
// ---- Kubernetes clusters (#216): the control plane's alone ----
|
|
3729
3829
|
listClusters(opts = {}) {
|
|
3730
|
-
return this.call("GET", `/k8s${allQuery(opts)}`,
|
|
3830
|
+
return this.call("GET", `/k8s${allQuery(opts)}`, z18.array(ClusterSchema), void 0, opts.org);
|
|
3731
3831
|
}
|
|
3732
3832
|
/** The master boots twice (its volume is attached after it is made), so this may take a minute. */
|
|
3733
3833
|
createCluster(req) {
|
|
@@ -3768,7 +3868,7 @@ var ServerClient = class {
|
|
|
3768
3868
|
}
|
|
3769
3869
|
/** A cluster's HTTPS addresses (#219): `kvbox.app` names and custom domains, all to its Traefik. */
|
|
3770
3870
|
listClusterSubdomains(cluster2) {
|
|
3771
|
-
return this.call("GET", `/k8s/${encodeURIComponent(cluster2)}/subdomains`,
|
|
3871
|
+
return this.call("GET", `/k8s/${encodeURIComponent(cluster2)}/subdomains`, z18.array(SubdomainSchema));
|
|
3772
3872
|
}
|
|
3773
3873
|
claimClusterSubdomain(cluster2, name) {
|
|
3774
3874
|
return this.call("POST", `/k8s/${encodeURIComponent(cluster2)}/subdomains`, SubdomainSchema, { name });
|
|
@@ -3777,7 +3877,7 @@ var ServerClient = class {
|
|
|
3777
3877
|
return this.call("DELETE", `/k8s/${encodeURIComponent(cluster2)}/subdomains/${encodeURIComponent(name)}`, SubdomainSchema);
|
|
3778
3878
|
}
|
|
3779
3879
|
listClusterDomains(cluster2) {
|
|
3780
|
-
return this.call("GET", `/k8s/${encodeURIComponent(cluster2)}/domains`,
|
|
3880
|
+
return this.call("GET", `/k8s/${encodeURIComponent(cluster2)}/domains`, z18.array(DomainSchema));
|
|
3781
3881
|
}
|
|
3782
3882
|
addClusterDomain(cluster2, domain) {
|
|
3783
3883
|
return this.call("POST", `/k8s/${encodeURIComponent(cluster2)}/domains`, DomainSchema, { domain });
|
|
@@ -3787,7 +3887,7 @@ var ServerClient = class {
|
|
|
3787
3887
|
}
|
|
3788
3888
|
/** What a cluster reaches (#220): a database or a box, from every one of its boxes. */
|
|
3789
3889
|
listClusterLinks(cluster2) {
|
|
3790
|
-
return this.call("GET", `/k8s/${encodeURIComponent(cluster2)}/links`,
|
|
3890
|
+
return this.call("GET", `/k8s/${encodeURIComponent(cluster2)}/links`, z18.array(ClusterLinkSchema));
|
|
3791
3891
|
}
|
|
3792
3892
|
linkCluster(cluster2, req) {
|
|
3793
3893
|
return this.call("POST", `/k8s/${encodeURIComponent(cluster2)}/links`, ClusterLinkSchema, req);
|
|
@@ -3797,10 +3897,10 @@ var ServerClient = class {
|
|
|
3797
3897
|
}
|
|
3798
3898
|
/** A cluster's backups (#221): its master's state, by the engine a database's uses. Every cluster's, removed ones' too. */
|
|
3799
3899
|
listClusterBackups() {
|
|
3800
|
-
return this.call("GET", "/backups?managed=k8s",
|
|
3900
|
+
return this.call("GET", "/backups?managed=k8s", z18.array(ManagedBackupSchema));
|
|
3801
3901
|
}
|
|
3802
3902
|
clusterBackups(cluster2) {
|
|
3803
|
-
return this.call("GET", `/k8s/${encodeURIComponent(cluster2)}/backups`,
|
|
3903
|
+
return this.call("GET", `/k8s/${encodeURIComponent(cluster2)}/backups`, z18.array(ManagedBackupSchema));
|
|
3804
3904
|
}
|
|
3805
3905
|
clusterBackup(cluster2, id) {
|
|
3806
3906
|
return this.call("GET", `/k8s/${encodeURIComponent(cluster2)}/backups/${encodeURIComponent(id)}`, ManagedBackupSchema);
|
|
@@ -3824,11 +3924,11 @@ var ServerClient = class {
|
|
|
3824
3924
|
return this.call("PUT", `/k8s/${encodeURIComponent(cluster2)}/backup-schedule`, BackupScheduleSchema, change);
|
|
3825
3925
|
}
|
|
3826
3926
|
deleteCluster(name) {
|
|
3827
|
-
return this.call("DELETE", `/k8s/${encodeURIComponent(name)}`,
|
|
3927
|
+
return this.call("DELETE", `/k8s/${encodeURIComponent(name)}`, z18.undefined());
|
|
3828
3928
|
}
|
|
3829
3929
|
// ---- object storage (#182): the control plane's alone ----
|
|
3830
3930
|
listBuckets(opts = {}) {
|
|
3831
|
-
return this.call("GET", `/buckets${allQuery(opts)}`,
|
|
3931
|
+
return this.call("GET", `/buckets${allQuery(opts)}`, z18.array(BucketSchema), void 0, opts.org);
|
|
3832
3932
|
}
|
|
3833
3933
|
/** The first bucket of a slug also makes its storage: a box boots twice, so this may take a couple of minutes. */
|
|
3834
3934
|
createBucket(req) {
|
|
@@ -3842,26 +3942,47 @@ var ServerClient = class {
|
|
|
3842
3942
|
return this.call("PUT", `/buckets/${encodeURIComponent(name)}/public`, BucketSchema, req);
|
|
3843
3943
|
}
|
|
3844
3944
|
deleteBucket(name, force = false) {
|
|
3845
|
-
return this.call("DELETE", `/buckets/${encodeURIComponent(name)}${force ? "?force=1" : ""}`,
|
|
3945
|
+
return this.call("DELETE", `/buckets/${encodeURIComponent(name)}${force ? "?force=1" : ""}`, z18.undefined());
|
|
3846
3946
|
}
|
|
3847
3947
|
listBucketKeys(name) {
|
|
3848
|
-
return this.call("GET", `/buckets/${encodeURIComponent(name)}/keys`,
|
|
3948
|
+
return this.call("GET", `/buckets/${encodeURIComponent(name)}/keys`, z18.array(BucketKeySchema));
|
|
3849
3949
|
}
|
|
3850
3950
|
createBucketKey(name, req) {
|
|
3851
3951
|
return this.call("POST", `/buckets/${encodeURIComponent(name)}/keys`, CreatedBucketKeySchema, req);
|
|
3852
3952
|
}
|
|
3853
3953
|
deleteBucketKey(name, id) {
|
|
3854
|
-
return this.call("DELETE", `/buckets/${encodeURIComponent(name)}/keys/${encodeURIComponent(id)}`,
|
|
3954
|
+
return this.call("DELETE", `/buckets/${encodeURIComponent(name)}/keys/${encodeURIComponent(id)}`, z18.undefined());
|
|
3855
3955
|
}
|
|
3856
3956
|
listStorage(opts = {}) {
|
|
3857
|
-
return this.call("GET", `/storage${allQuery(opts)}`,
|
|
3957
|
+
return this.call("GET", `/storage${allQuery(opts)}`, z18.array(ObjectStorageSchema), void 0, opts.org);
|
|
3858
3958
|
}
|
|
3859
3959
|
growStorage(sizeGib) {
|
|
3860
3960
|
return this.call("POST", "/storage/grow", ObjectStorageSchema, { sizeGib });
|
|
3861
3961
|
}
|
|
3962
|
+
// ---- the container registry (#234): control plane only, one per slug ----
|
|
3963
|
+
/** A hidden box boots twice (the volume's attach restarts it), so this may take a couple of minutes. */
|
|
3964
|
+
createRegistry(req) {
|
|
3965
|
+
return this.call("POST", "/registry", CreatedRegistrySchema, req);
|
|
3966
|
+
}
|
|
3967
|
+
/** The caller's (or `--org`'s) registry, with how full it is and its repositories when it answers. */
|
|
3968
|
+
registryInfo() {
|
|
3969
|
+
return this.call("GET", "/registry/info", RegistrySchema);
|
|
3970
|
+
}
|
|
3971
|
+
registryPassword() {
|
|
3972
|
+
return this.call("GET", "/registry/password", RegistrySecretSchema);
|
|
3973
|
+
}
|
|
3974
|
+
resetRegistryPassword() {
|
|
3975
|
+
return this.call("POST", "/registry/password", RegistrySecretSchema, {});
|
|
3976
|
+
}
|
|
3977
|
+
growRegistry(sizeGib) {
|
|
3978
|
+
return this.call("POST", "/registry/grow", RegistrySchema, { sizeGib });
|
|
3979
|
+
}
|
|
3980
|
+
deleteRegistry() {
|
|
3981
|
+
return this.call("DELETE", "/registry", z18.undefined());
|
|
3982
|
+
}
|
|
3862
3983
|
/** Backups of the slug's whole object storage (#186 slice 3), newest first. */
|
|
3863
3984
|
storageBackups() {
|
|
3864
|
-
return this.call("GET", "/storage/backups",
|
|
3985
|
+
return this.call("GET", "/storage/backups", z18.array(StorageBackupSchema));
|
|
3865
3986
|
}
|
|
3866
3987
|
storageBackup(id) {
|
|
3867
3988
|
return this.call("GET", `/storage/backups/${encodeURIComponent(id)}`, StorageBackupSchema);
|
|
@@ -3889,11 +4010,11 @@ var ServerClient = class {
|
|
|
3889
4010
|
return `/managed/${encodeURIComponent(kind)}${name === void 0 ? "" : `/${encodeURIComponent(name)}`}${rest}`;
|
|
3890
4011
|
}
|
|
3891
4012
|
managedCatalog() {
|
|
3892
|
-
return this.call("GET", "/managed/catalog",
|
|
4013
|
+
return this.call("GET", "/managed/catalog", z18.array(ManagedCatalogEntrySchema));
|
|
3893
4014
|
}
|
|
3894
4015
|
/** One kind's services, or every kind's when `kind` is left out. */
|
|
3895
4016
|
listManaged(kind, opts = {}) {
|
|
3896
|
-
return this.call("GET", `${kind === void 0 ? "/managed" : this.managedPath(kind)}${allQuery(opts)}`,
|
|
4017
|
+
return this.call("GET", `${kind === void 0 ? "/managed" : this.managedPath(kind)}${allQuery(opts)}`, z18.array(ManagedSchema), void 0, opts.org);
|
|
3897
4018
|
}
|
|
3898
4019
|
/** From a backup (`fromBackup`) it waits for the restore too: the control plane gives its host 2 h for the download. */
|
|
3899
4020
|
createManaged(kind, req) {
|
|
@@ -3904,7 +4025,7 @@ var ServerClient = class {
|
|
|
3904
4025
|
return this.call("GET", this.managedPath(kind, name), ManagedSchema);
|
|
3905
4026
|
}
|
|
3906
4027
|
deleteManaged(kind, name) {
|
|
3907
|
-
return this.call("DELETE", this.managedPath(kind, name),
|
|
4028
|
+
return this.call("DELETE", this.managedPath(kind, name), z18.undefined());
|
|
3908
4029
|
}
|
|
3909
4030
|
managedPassword(kind, name) {
|
|
3910
4031
|
return this.call("GET", this.managedPath(kind, name, "/password"), ManagedSecretSchema);
|
|
@@ -3926,10 +4047,10 @@ var ServerClient = class {
|
|
|
3926
4047
|
}
|
|
3927
4048
|
/** A managed service's backups (#186): its storage's, by the volume backup engine. Every one of a kind, those of removed services too. */
|
|
3928
4049
|
listManagedBackups(kind) {
|
|
3929
|
-
return this.call("GET", `/backups?managed=${encodeURIComponent(kind)}`,
|
|
4050
|
+
return this.call("GET", `/backups?managed=${encodeURIComponent(kind)}`, z18.array(ManagedBackupSchema));
|
|
3930
4051
|
}
|
|
3931
4052
|
managedBackups(kind, name) {
|
|
3932
|
-
return this.call("GET", this.managedPath(kind, name, "/backups"),
|
|
4053
|
+
return this.call("GET", this.managedPath(kind, name, "/backups"), z18.array(ManagedBackupSchema));
|
|
3933
4054
|
}
|
|
3934
4055
|
managedBackup(kind, name, id) {
|
|
3935
4056
|
return this.call("GET", this.managedPath(kind, name, `/backups/${encodeURIComponent(id)}`), ManagedBackupSchema);
|
|
@@ -3971,7 +4092,7 @@ var ServerClient = class {
|
|
|
3971
4092
|
return this.call("POST", "/login/device/token", DeviceLoginPollSchema, { deviceCode });
|
|
3972
4093
|
}
|
|
3973
4094
|
logout() {
|
|
3974
|
-
return this.call("POST", "/logout",
|
|
4095
|
+
return this.call("POST", "/logout", z18.unknown()).then(() => void 0);
|
|
3975
4096
|
}
|
|
3976
4097
|
me() {
|
|
3977
4098
|
return this.call("GET", "/me", MeResponseSchema);
|
|
@@ -3982,25 +4103,25 @@ var ServerClient = class {
|
|
|
3982
4103
|
* credential. Null: each readable slug whatever `--org` says, which is how the caller's own slug is read.
|
|
3983
4104
|
*/
|
|
3984
4105
|
listIntegrations(org) {
|
|
3985
|
-
return this.call("GET", "/integrations",
|
|
4106
|
+
return this.call("GET", "/integrations", z18.array(IntegrationSchema), void 0, org);
|
|
3986
4107
|
}
|
|
3987
4108
|
/** What can be connected on this control plane, and by which kind of slug. */
|
|
3988
4109
|
integrationCatalog() {
|
|
3989
|
-
return this.call("GET", "/integrations/catalog",
|
|
4110
|
+
return this.call("GET", "/integrations/catalog", z18.array(IntegrationCatalogEntrySchema), void 0, null);
|
|
3990
4111
|
}
|
|
3991
4112
|
// ---- API keys (`kvbox key …`, #189) ----
|
|
3992
4113
|
listApiKeys() {
|
|
3993
|
-
return this.call("GET", "/keys",
|
|
4114
|
+
return this.call("GET", "/keys", z18.array(ApiKeySchema));
|
|
3994
4115
|
}
|
|
3995
4116
|
createApiKey(req) {
|
|
3996
4117
|
return this.call("POST", "/keys", CreatedApiKeySchema, req);
|
|
3997
4118
|
}
|
|
3998
4119
|
deleteApiKey(name) {
|
|
3999
|
-
return this.call("DELETE", `/keys/${encodeURIComponent(name)}`,
|
|
4120
|
+
return this.call("DELETE", `/keys/${encodeURIComponent(name)}`, z18.unknown()).then(() => void 0);
|
|
4000
4121
|
}
|
|
4001
4122
|
// ---- orgs (`kvbox org …`) ----
|
|
4002
4123
|
listOrgs() {
|
|
4003
|
-
return this.call("GET", "/orgs",
|
|
4124
|
+
return this.call("GET", "/orgs", z18.array(OrgMembershipSchema));
|
|
4004
4125
|
}
|
|
4005
4126
|
createOrg(req) {
|
|
4006
4127
|
return this.call("POST", "/orgs", CloudOrgSchema, req);
|
|
@@ -4009,16 +4130,16 @@ var ServerClient = class {
|
|
|
4009
4130
|
return this.call("GET", `/orgs/${encodeURIComponent(slug)}`, OrgDetailSchema);
|
|
4010
4131
|
}
|
|
4011
4132
|
deleteOrg(slug) {
|
|
4012
|
-
return this.call("DELETE", `/orgs/${encodeURIComponent(slug)}`,
|
|
4133
|
+
return this.call("DELETE", `/orgs/${encodeURIComponent(slug)}`, z18.undefined());
|
|
4013
4134
|
}
|
|
4014
4135
|
addMember(slug, req) {
|
|
4015
|
-
return this.call("POST", `/orgs/${encodeURIComponent(slug)}/members`,
|
|
4136
|
+
return this.call("POST", `/orgs/${encodeURIComponent(slug)}/members`, z18.undefined(), req);
|
|
4016
4137
|
}
|
|
4017
4138
|
setRole(slug, username, role) {
|
|
4018
|
-
return this.call("PATCH", `/orgs/${encodeURIComponent(slug)}/members/${encodeURIComponent(username)}`,
|
|
4139
|
+
return this.call("PATCH", `/orgs/${encodeURIComponent(slug)}/members/${encodeURIComponent(username)}`, z18.unknown(), { role }).then(() => void 0);
|
|
4019
4140
|
}
|
|
4020
4141
|
removeMember(slug, username) {
|
|
4021
|
-
return this.call("DELETE", `/orgs/${encodeURIComponent(slug)}/members/${encodeURIComponent(username)}`,
|
|
4142
|
+
return this.call("DELETE", `/orgs/${encodeURIComponent(slug)}/members/${encodeURIComponent(username)}`, z18.undefined());
|
|
4022
4143
|
}
|
|
4023
4144
|
/** Sign this machine's key again (#51); the key must be one the user logged in with. */
|
|
4024
4145
|
sshCert(req) {
|
|
@@ -5079,6 +5200,16 @@ import { Command as Command12 } from "commander";
|
|
|
5079
5200
|
// ../shared/src/names.ts
|
|
5080
5201
|
import { createHmac } from "crypto";
|
|
5081
5202
|
var DEFAULT_PROXY_DOMAIN = "kvbox.app";
|
|
5203
|
+
var STORAGE_SUBDOMAIN_PREFIX = "s3-";
|
|
5204
|
+
var REGISTRY_SUBDOMAIN_PREFIX = "cr-";
|
|
5205
|
+
var KEPT_SUBDOMAIN_PREFIXES = [
|
|
5206
|
+
{ prefix: STORAGE_SUBDOMAIN_PREFIX, for: "object storage" },
|
|
5207
|
+
{ prefix: REGISTRY_SUBDOMAIN_PREFIX, for: "container registries" }
|
|
5208
|
+
];
|
|
5209
|
+
function keptPrefixOf(name) {
|
|
5210
|
+
const lower = name.trim().toLowerCase();
|
|
5211
|
+
return KEPT_SUBDOMAIN_PREFIXES.find((k) => lower.startsWith(k.prefix));
|
|
5212
|
+
}
|
|
5082
5213
|
var MAX_BOX_SUBDOMAINS = 5;
|
|
5083
5214
|
var LABEL_RE = /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/;
|
|
5084
5215
|
var RESERVED_SUBDOMAINS = /* @__PURE__ */ new Set([
|
|
@@ -6812,10 +6943,11 @@ var usageCommand2 = new Command64("usage").description("what your boxes and volu
|
|
|
6812
6943
|
info(`${day2(report.window.from)} to ${day2(report.window.to)}`);
|
|
6813
6944
|
const volumes = report.volumes ?? [];
|
|
6814
6945
|
const storage = report.storage ?? [];
|
|
6946
|
+
const registry = report.registry ?? [];
|
|
6815
6947
|
const cron = report.cron ?? [];
|
|
6816
6948
|
const clusters = report.clusters ?? [];
|
|
6817
6949
|
const backups = report.backups ?? [];
|
|
6818
|
-
if (report.boxes.length === 0 && volumes.length === 0 && storage.length === 0 && cron.length === 0 && clusters.length === 0 && backups.length === 0) info("no usage in this window");
|
|
6950
|
+
if (report.boxes.length === 0 && volumes.length === 0 && storage.length === 0 && registry.length === 0 && cron.length === 0 && clusters.length === 0 && backups.length === 0) info("no usage in this window");
|
|
6819
6951
|
else if (report.boxes.length > 0) table(perUser ? userRows(perUser) : usageRows(report, cloud));
|
|
6820
6952
|
if (volumes.length > 0) {
|
|
6821
6953
|
info(volumes.length === 1 ? "1 volume" : `${volumes.length} volumes`);
|
|
@@ -6825,6 +6957,10 @@ var usageCommand2 = new Command64("usage").description("what your boxes and volu
|
|
|
6825
6957
|
info("object storage");
|
|
6826
6958
|
table(storageRows(report, cloud));
|
|
6827
6959
|
}
|
|
6960
|
+
if (registry.length > 0) {
|
|
6961
|
+
info("container registry");
|
|
6962
|
+
table(storageRows({ ...report, storage: registry }, cloud));
|
|
6963
|
+
}
|
|
6828
6964
|
if (cron.length > 0) {
|
|
6829
6965
|
info(cron.length === 1 ? "1 cron service" : `${cron.length} cron services`);
|
|
6830
6966
|
table(cronRows(report, cloud));
|
|
@@ -6838,8 +6974,8 @@ var usageCommand2 = new Command64("usage").description("what your boxes and volu
|
|
|
6838
6974
|
info(taken === 1 ? "1 paid backup" : `${taken} paid backups`);
|
|
6839
6975
|
table(backupRows(report, cloud));
|
|
6840
6976
|
}
|
|
6841
|
-
if ((volumes.length > 0 || storage.length > 0 || cron.length > 0 || clusters.length > 0 || backups.length > 0) && report.totals.cost !== void 0) {
|
|
6842
|
-
const what = ["boxes", ...volumes.length > 0 ? ["volumes"] : [], ...storage.length > 0 ? ["object storage"] : [], ...cron.length > 0 ? ["cron services"] : [], ...clusters.length > 0 ? ["Kubernetes clusters"] : [], ...backups.length > 0 ? ["backups"] : []];
|
|
6977
|
+
if ((volumes.length > 0 || storage.length > 0 || registry.length > 0 || cron.length > 0 || clusters.length > 0 || backups.length > 0) && report.totals.cost !== void 0) {
|
|
6978
|
+
const what = ["boxes", ...volumes.length > 0 ? ["volumes"] : [], ...storage.length > 0 ? ["object storage"] : [], ...registry.length > 0 ? ["the container registry"] : [], ...cron.length > 0 ? ["cron services"] : [], ...clusters.length > 0 ? ["Kubernetes clusters"] : [], ...backups.length > 0 ? ["backups"] : []];
|
|
6843
6979
|
info(`total: ${money(report.totals.cost.amount, report.totals.cost.currency)} ${color.dim(`(${what.slice(0, -1).join(", ")} and ${what.at(-1)}, estimated)`)}`);
|
|
6844
6980
|
}
|
|
6845
6981
|
if (cloud) {
|
|
@@ -6999,7 +7135,7 @@ function byUser(report) {
|
|
|
6999
7135
|
return u;
|
|
7000
7136
|
});
|
|
7001
7137
|
users.sort((a, b) => a.user === null ? 1 : b.user === null ? -1 : a.user.localeCompare(b.user));
|
|
7002
|
-
return { window: report.window, users, ...report.volumes === void 0 ? {} : { volumes: report.volumes }, ...report.storage === void 0 ? {} : { storage: report.storage }, ...report.cron === void 0 ? {} : { cron: report.cron }, ...report.clusters === void 0 ? {} : { clusters: report.clusters }, ...report.backups === void 0 ? {} : { backups: report.backups }, totals: report.totals };
|
|
7138
|
+
return { window: report.window, users, ...report.volumes === void 0 ? {} : { volumes: report.volumes }, ...report.storage === void 0 ? {} : { storage: report.storage }, ...report.registry === void 0 ? {} : { registry: report.registry }, ...report.cron === void 0 ? {} : { cron: report.cron }, ...report.clusters === void 0 ? {} : { clusters: report.clusters }, ...report.backups === void 0 ? {} : { backups: report.backups }, totals: report.totals };
|
|
7003
7139
|
}
|
|
7004
7140
|
function userRows(r) {
|
|
7005
7141
|
const priced = r.totals.cost !== void 0;
|
|
@@ -7090,7 +7226,7 @@ import { Command as Command67, InvalidArgumentError as InvalidArgumentError2, Op
|
|
|
7090
7226
|
// src/commands/deploy/config.ts
|
|
7091
7227
|
import { readFile as readFile5, writeFile as writeFile3 } from "fs/promises";
|
|
7092
7228
|
import { isAbsolute, join as join6, normalize, relative as relative2 } from "path";
|
|
7093
|
-
import { z as
|
|
7229
|
+
import { z as z19 } from "zod";
|
|
7094
7230
|
|
|
7095
7231
|
// src/commands/deploy/templates/docker.ts
|
|
7096
7232
|
import { readFile as readFile4 } from "fs/promises";
|
|
@@ -7514,21 +7650,21 @@ function detectTemplates(pkg, dir = NO_FACTS) {
|
|
|
7514
7650
|
var DEPLOY_AUTO_HIBERNATE_SEC = 3600;
|
|
7515
7651
|
var CONFIG_FILE = "kvbox.json";
|
|
7516
7652
|
var BOX_NAME_RE = /^[a-z0-9][a-z0-9-]{0,11}$/;
|
|
7517
|
-
var DeployConfigSchema =
|
|
7518
|
-
template:
|
|
7519
|
-
name:
|
|
7653
|
+
var DeployConfigSchema = z19.object({
|
|
7654
|
+
template: z19.enum(TEMPLATE_IDS),
|
|
7655
|
+
name: z19.string().regex(BOX_NAME_RE, "1-12 chars, lowercase letters, digits and '-', starting with a letter or digit"),
|
|
7520
7656
|
/** The org whose box it is; absent for the user's own. */
|
|
7521
|
-
org:
|
|
7657
|
+
org: z19.string().regex(ORG_SLUG_RE, "not an org slug").optional(),
|
|
7522
7658
|
/** The HTTPS name (`<subdomain>.kvbox.app`); absent when deploying to this machine's own host. */
|
|
7523
|
-
subdomain:
|
|
7659
|
+
subdomain: z19.string().check((ctx) => {
|
|
7524
7660
|
const problem = subdomainProblem(ctx.value);
|
|
7525
7661
|
if (problem) ctx.issues.push({ code: "custom", message: problem, input: ctx.value });
|
|
7526
7662
|
}).optional(),
|
|
7527
|
-
size:
|
|
7663
|
+
size: z19.enum(SIZE_NAMES).optional(),
|
|
7528
7664
|
/** The build output directory, relative to the app; the template's default when absent. */
|
|
7529
|
-
dist:
|
|
7665
|
+
dist: z19.string().optional(),
|
|
7530
7666
|
/** The port a Next.js app or Node server serves; the template's (3000) when absent. */
|
|
7531
|
-
port:
|
|
7667
|
+
port: z19.number().int().min(1).max(65535).optional()
|
|
7532
7668
|
});
|
|
7533
7669
|
var SERVICE_KEY_RE = /^[a-z][a-z0-9-]{0,19}$/;
|
|
7534
7670
|
var RESERVED_SERVICE_KEYS = ["app", "agent", "init", "volumes"];
|
|
@@ -7540,38 +7676,38 @@ var POSTGRES_PORT = 5432;
|
|
|
7540
7676
|
var POSTGRES_IMAGE = "postgres:17";
|
|
7541
7677
|
var POSTGRES_ENV = "DATABASE_URL";
|
|
7542
7678
|
var IMAGE_RE = /^[a-z0-9][a-z0-9._/:@-]*$/;
|
|
7543
|
-
var ServiceSchema =
|
|
7544
|
-
template:
|
|
7679
|
+
var ServiceSchema = z19.strictObject({
|
|
7680
|
+
template: z19.enum([...TEMPLATE_IDS, POSTGRES]),
|
|
7545
7681
|
/** The service's directory, relative to the one holding kvbox.json; every template but postgres has one. */
|
|
7546
|
-
dir:
|
|
7682
|
+
dir: z19.string().min(1).optional(),
|
|
7547
7683
|
/** A postgres service's image, `postgres:17` when absent (`pgvector/pgvector:pg17` for vectors). */
|
|
7548
|
-
image:
|
|
7684
|
+
image: z19.string().regex(IMAGE_RE, "an image name like postgres:17").optional(),
|
|
7549
7685
|
/** The volume (a key of `volumes`) a postgres service keeps its data on. */
|
|
7550
|
-
volume:
|
|
7686
|
+
volume: z19.string().optional(),
|
|
7551
7687
|
/** The box variable a postgres service's URL is written to, `DATABASE_URL` when absent. */
|
|
7552
|
-
env:
|
|
7688
|
+
env: z19.string().optional(),
|
|
7553
7689
|
/** A docker service's build context, relative to kvbox.json, when it is not `dir` (a monorepo built from its root); the Dockerfile stays in `dir`. */
|
|
7554
|
-
context:
|
|
7555
|
-
dist:
|
|
7690
|
+
context: z19.string().min(1).optional(),
|
|
7691
|
+
dist: z19.string().optional(),
|
|
7556
7692
|
/**
|
|
7557
7693
|
* A command run once per deploy in the service's new version (a docker service: in a container of
|
|
7558
7694
|
* the new image; node, nextjs: in the new source, installed and built), with the box's variables,
|
|
7559
7695
|
* before it replaces the running one. Migrations, mostly. A failing one stops that service's deploy.
|
|
7560
7696
|
*/
|
|
7561
|
-
release:
|
|
7697
|
+
release: z19.string().optional(),
|
|
7562
7698
|
/** The box port of a service with its own server; the template's (3000) when absent. */
|
|
7563
|
-
port:
|
|
7699
|
+
port: z19.number().int().min(1).max(65535).optional(),
|
|
7564
7700
|
/** The URL paths that go to this service, each with everything under it; the prefix is kept. */
|
|
7565
|
-
paths:
|
|
7701
|
+
paths: z19.array(z19.string().regex(ROUTE_RE, "a path like / or /api, no trailing slash")).min(1).optional()
|
|
7566
7702
|
});
|
|
7567
|
-
var StackConfigSchema =
|
|
7703
|
+
var StackConfigSchema = z19.strictObject({
|
|
7568
7704
|
name: DeployConfigSchema.shape.name.optional(),
|
|
7569
7705
|
org: DeployConfigSchema.shape.org,
|
|
7570
7706
|
subdomain: DeployConfigSchema.shape.subdomain,
|
|
7571
7707
|
size: DeployConfigSchema.shape.size,
|
|
7572
7708
|
/** The stack's volumes, name to size ("10GB"): made for its box and attached to it on the first deploy that needs one. */
|
|
7573
|
-
volumes:
|
|
7574
|
-
services:
|
|
7709
|
+
volumes: z19.record(z19.string(), z19.string()).optional(),
|
|
7710
|
+
services: z19.record(z19.string(), ServiceSchema)
|
|
7575
7711
|
});
|
|
7576
7712
|
function volumeGib(text2) {
|
|
7577
7713
|
const mib2 = parseMib(text2);
|
|
@@ -7698,6 +7834,8 @@ function nameFromDir(dirName) {
|
|
|
7698
7834
|
return slug === "" ? "app" : slug;
|
|
7699
7835
|
}
|
|
7700
7836
|
function subdomainFor(name) {
|
|
7837
|
+
const kept = keptPrefixOf(name);
|
|
7838
|
+
if (kept) return subdomainFor(name.slice(kept.prefix.length) || "app");
|
|
7701
7839
|
return subdomainProblem(name) === null ? name : `${name}-site`;
|
|
7702
7840
|
}
|
|
7703
7841
|
|
|
@@ -8478,7 +8616,9 @@ async function settle2(dir, pkg, facts, saved, opts, orgFlag, cloud) {
|
|
|
8478
8616
|
default: subdomainFor(name),
|
|
8479
8617
|
validate: (a) => {
|
|
8480
8618
|
const problem = subdomainProblem(a);
|
|
8481
|
-
|
|
8619
|
+
if (problem) return `that name ${problem}`;
|
|
8620
|
+
const kept = keptPrefixOf(a);
|
|
8621
|
+
return kept ? `names starting with ${kept.prefix} are kept for ${kept.for}` : void 0;
|
|
8482
8622
|
}
|
|
8483
8623
|
});
|
|
8484
8624
|
info(` ${color.dim(`https://${subdomain}.kvbox.app`)}`);
|
|
@@ -9185,14 +9325,158 @@ for (const cmd of bucketCommand.commands) {
|
|
|
9185
9325
|
else withOrg2(cmd);
|
|
9186
9326
|
}
|
|
9187
9327
|
|
|
9328
|
+
// src/commands/registry/index.ts
|
|
9329
|
+
import { Command as Command103 } from "commander";
|
|
9330
|
+
|
|
9331
|
+
// src/commands/registry/create.ts
|
|
9332
|
+
import { Command as Command98 } from "commander";
|
|
9333
|
+
|
|
9334
|
+
// src/commands/registry/shared.ts
|
|
9335
|
+
async function registryClient(cmd) {
|
|
9336
|
+
const client = await clientFor(cmd.optsWithGlobals());
|
|
9337
|
+
if (client.target.kind !== "cloud") {
|
|
9338
|
+
await client.close();
|
|
9339
|
+
throw new KvboxError("the container registry runs on the kvbox cloud: kvbox login first (this host's own socket has none)");
|
|
9340
|
+
}
|
|
9341
|
+
return client;
|
|
9342
|
+
}
|
|
9343
|
+
var fullness2 = (r) => r.usedBytes !== void 0 ? `${gb(r.usedBytes)} of ${r.sizeGib} GB used` : `${r.sizeGib} GB`;
|
|
9344
|
+
var nearlyFull2 = (r) => r.usedBytes !== void 0 && r.totalBytes !== void 0 && r.totalBytes > 0 && r.usedBytes / r.totalBytes >= 0.9;
|
|
9345
|
+
var priceText2 = (r) => `${money(r.price.perMonth, r.price.currency)} a month ${color.dim("(estimated)")}`;
|
|
9346
|
+
var addressText = (address2) => address2 ?? color.yellow("no address yet (asked for again at the next kvbox registry info)");
|
|
9347
|
+
function loginLines(secret) {
|
|
9348
|
+
if (secret.address === null) return [];
|
|
9349
|
+
return [`docker login ${secret.address} -u ${secret.user}`, `docker tag myapp ${secret.address}/myapp:1.0`, `docker push ${secret.address}/myapp:1.0`];
|
|
9350
|
+
}
|
|
9351
|
+
function printRows2(rows2) {
|
|
9352
|
+
const width2 = Math.max(...rows2.map(([label]) => label.length));
|
|
9353
|
+
for (const [label, value] of rows2) process.stdout.write(`${color.dim(label.padEnd(width2))} ${value}
|
|
9354
|
+
`);
|
|
9355
|
+
}
|
|
9356
|
+
|
|
9357
|
+
// src/commands/registry/create.ts
|
|
9358
|
+
var createCommand9 = new Command98("create").description("make your container registry: a private place for your docker images (one per account)").option("--size <GB>", "how much it may hold (default 20)").option("--near <box>", "put it on the host of this box").option("--json", "print as JSON").action(async (opts, cmd) => {
|
|
9359
|
+
const sizeGib = opts.size === void 0 ? void 0 : parseGib2(opts.size);
|
|
9360
|
+
const client = await registryClient(cmd);
|
|
9361
|
+
try {
|
|
9362
|
+
const made = await spin("making your container registry (a minute or two)\u2026", client.createRegistry({ ...sizeGib !== void 0 ? { sizeGib } : {}, ...opts.near !== void 0 ? { near: opts.near } : {} }));
|
|
9363
|
+
if (opts.json) {
|
|
9364
|
+
json(made);
|
|
9365
|
+
return;
|
|
9366
|
+
}
|
|
9367
|
+
info(`${color.green("\u2713")} container registry made for ${color.bold(made.owner)}: ${made.sizeGib} GB, ${priceText2(made)}`);
|
|
9368
|
+
printRows2([
|
|
9369
|
+
["address", addressText(made.secret.address)],
|
|
9370
|
+
["user", made.secret.user],
|
|
9371
|
+
["password", made.secret.password]
|
|
9372
|
+
]);
|
|
9373
|
+
if (!made.ready) info(color.yellow(" it is still starting: give it a minute before the first docker login (kvbox registry info shows when it answers)"));
|
|
9374
|
+
const lines = loginLines(made.secret);
|
|
9375
|
+
if (lines.length > 0) info(color.dim(`
|
|
9376
|
+
${lines.join("\n")}`));
|
|
9377
|
+
info(color.dim("the password is shown again by: kvbox registry password"));
|
|
9378
|
+
} finally {
|
|
9379
|
+
await client.close();
|
|
9380
|
+
}
|
|
9381
|
+
});
|
|
9382
|
+
|
|
9383
|
+
// src/commands/registry/grow.ts
|
|
9384
|
+
import { Command as Command99 } from "commander";
|
|
9385
|
+
var growCommand3 = new Command99("grow").description("make your container registry larger (it restarts once)").argument("<GB>", "the new size in GB, larger than what it has").option("--json", "print the registry as JSON").action(async (size, opts, cmd) => {
|
|
9386
|
+
const sizeGib = parseGib2(size, "size");
|
|
9387
|
+
const client = await registryClient(cmd);
|
|
9388
|
+
try {
|
|
9389
|
+
const r = await spin(`growing your container registry to ${sizeGib} GB\u2026`, client.growRegistry(sizeGib));
|
|
9390
|
+
if (opts.json) json(r);
|
|
9391
|
+
else info(`${color.green("\u2713")} the container registry of ${r.owner} is ${r.sizeGib} GB, ${priceText2(r)}`);
|
|
9392
|
+
} finally {
|
|
9393
|
+
await client.close();
|
|
9394
|
+
}
|
|
9395
|
+
});
|
|
9396
|
+
|
|
9397
|
+
// src/commands/registry/info.ts
|
|
9398
|
+
import { Command as Command100 } from "commander";
|
|
9399
|
+
var SHOWN_REPOSITORIES = 20;
|
|
9400
|
+
var infoCommand2 = new Command100("info").description("your container registry: its address, how full it is, what is in it").option("--json", "print as JSON").action(async (opts, cmd) => {
|
|
9401
|
+
const client = await registryClient(cmd);
|
|
9402
|
+
try {
|
|
9403
|
+
const r = await client.registryInfo();
|
|
9404
|
+
if (opts.json) {
|
|
9405
|
+
json(r);
|
|
9406
|
+
return;
|
|
9407
|
+
}
|
|
9408
|
+
const repos = r.repositories;
|
|
9409
|
+
const rows2 = [
|
|
9410
|
+
["owner", color.bold(r.owner)],
|
|
9411
|
+
["address", addressText(r.address)],
|
|
9412
|
+
["user", `${r.user} ${color.dim("(password: kvbox registry password)")}`],
|
|
9413
|
+
["status", r.status === "running" ? repos === void 0 ? color.dim("running, not answering yet") : "running" : r.status],
|
|
9414
|
+
["size", `${fullness2(r)}${nearlyFull2(r) ? color.yellow(" almost full: kvbox registry grow <GB>") : ""}`],
|
|
9415
|
+
["holds", repos === void 0 ? color.dim("unknown") : repos.length === 0 ? color.dim("nothing yet") : `${repos.length}${r.repositoriesTruncated ? "+" : ""} ${repos.length === 1 ? "repository" : "repositories"}`],
|
|
9416
|
+
["cost", priceText2(r)],
|
|
9417
|
+
["created", `${age(r.createdAt)}${r.createdBy ? ` by ${r.createdBy}` : ""}`]
|
|
9418
|
+
];
|
|
9419
|
+
printRows2(rows2);
|
|
9420
|
+
for (const repo of (repos ?? []).slice(0, SHOWN_REPOSITORIES)) info(` ${repo.name} ${color.dim(`${repo.tags} ${repo.tags === 1 ? "tag" : "tags"}`)}`);
|
|
9421
|
+
if (repos !== void 0 && repos.length > SHOWN_REPOSITORIES) info(color.dim(` and ${repos.length - SHOWN_REPOSITORIES} more (--json lists them all)`));
|
|
9422
|
+
const lines = loginLines(r);
|
|
9423
|
+
if (lines.length > 0) info(color.dim(`
|
|
9424
|
+
${lines.join("\n")}`));
|
|
9425
|
+
} finally {
|
|
9426
|
+
await client.close();
|
|
9427
|
+
}
|
|
9428
|
+
});
|
|
9429
|
+
|
|
9430
|
+
// src/commands/registry/password.ts
|
|
9431
|
+
import { Command as Command101 } from "commander";
|
|
9432
|
+
var passwordCommand = new Command101("password").description("show your container registry's login, or set a new password with --reset").option("--reset", "make a new password; the old one stops working").option("--json", "print as JSON").action(async (opts, cmd) => {
|
|
9433
|
+
const client = await registryClient(cmd);
|
|
9434
|
+
try {
|
|
9435
|
+
const secret = opts.reset ? await spin("setting a new password on your container registry\u2026", client.resetRegistryPassword()) : await client.registryPassword();
|
|
9436
|
+
if (opts.json) {
|
|
9437
|
+
json(secret);
|
|
9438
|
+
return;
|
|
9439
|
+
}
|
|
9440
|
+
if (opts.reset) info(`${color.green("\u2713")} your container registry has a new password; the old one no longer works`);
|
|
9441
|
+
printRows2([
|
|
9442
|
+
["address", addressText(secret.address)],
|
|
9443
|
+
["user", secret.user],
|
|
9444
|
+
["password", secret.password]
|
|
9445
|
+
]);
|
|
9446
|
+
} finally {
|
|
9447
|
+
await client.close();
|
|
9448
|
+
}
|
|
9449
|
+
});
|
|
9450
|
+
|
|
9451
|
+
// src/commands/registry/rm.ts
|
|
9452
|
+
import { Command as Command102 } from "commander";
|
|
9453
|
+
var rmCommand14 = new Command102("rm").alias("remove").description("delete your container registry with every image in it").option("-y, --yes", "do not ask for confirmation").action(async (opts, cmd) => {
|
|
9454
|
+
const client = await registryClient(cmd);
|
|
9455
|
+
try {
|
|
9456
|
+
if (!await confirm("Delete your container registry with every image in it?", opts.yes ?? false)) {
|
|
9457
|
+
info("cancelled");
|
|
9458
|
+
process.exitCode = 1;
|
|
9459
|
+
return;
|
|
9460
|
+
}
|
|
9461
|
+
await spin("deleting your container registry\u2026", client.deleteRegistry());
|
|
9462
|
+
info(`${color.green("\u2713")} container registry deleted ${color.dim("(no longer charged)")}`);
|
|
9463
|
+
} finally {
|
|
9464
|
+
await client.close();
|
|
9465
|
+
}
|
|
9466
|
+
});
|
|
9467
|
+
|
|
9468
|
+
// src/commands/registry/index.ts
|
|
9469
|
+
var registryCommand = new Command103("registry").description("container registry: a private place for your docker images (docker push and pull)").addCommand(createCommand9).addCommand(infoCommand2).addCommand(passwordCommand).addCommand(growCommand3).addCommand(rmCommand14);
|
|
9470
|
+
for (const cmd of registryCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal registry)");
|
|
9471
|
+
|
|
9188
9472
|
// src/commands/k8s/index.ts
|
|
9189
|
-
import { Command as
|
|
9473
|
+
import { Command as Command135 } from "commander";
|
|
9190
9474
|
|
|
9191
9475
|
// src/commands/k8s/backup/index.ts
|
|
9192
|
-
import { Command as
|
|
9476
|
+
import { Command as Command109 } from "commander";
|
|
9193
9477
|
|
|
9194
9478
|
// src/commands/k8s/backup/create.ts
|
|
9195
|
-
import { Command as
|
|
9479
|
+
import { Command as Command104 } from "commander";
|
|
9196
9480
|
|
|
9197
9481
|
// src/commands/k8s/shared.ts
|
|
9198
9482
|
async function k8sClient(cmd) {
|
|
@@ -9208,14 +9492,14 @@ function shownName2(c2, client) {
|
|
|
9208
9492
|
return c2.owner === context ? c2.name : `${c2.owner}/${c2.name}`;
|
|
9209
9493
|
}
|
|
9210
9494
|
var apiText = (c2) => c2.api === null ? color.yellow("not reachable from outside (its port is closed)") : `https://${c2.api.host.includes(":") ? `[${c2.api.host}]` : c2.api.host}:${c2.api.port}`;
|
|
9211
|
-
function
|
|
9495
|
+
function priceText3(c2) {
|
|
9212
9496
|
const { perMonth, nodesPerMonth, totalPerMonth, currency } = c2.price;
|
|
9213
9497
|
if (nodesPerMonth === void 0 || totalPerMonth === void 0) return `${money(perMonth, currency)} a month for the cluster itself ${color.dim("(estimated)")}, plus its nodes, each at a box's price`;
|
|
9214
9498
|
const nodes = c2.pools.reduce((n2, p) => n2 + p.boxes.length, 0);
|
|
9215
9499
|
return `${money(totalPerMonth, currency)} a month ${color.dim(`(estimated: ${money(perMonth, currency)} the cluster itself, ${money(nodesPerMonth, currency)} its ${nodes === 1 ? "node" : `${nodes} nodes`})`)}`;
|
|
9216
9500
|
}
|
|
9217
9501
|
var poolsText = (c2) => c2.pools.length === 0 ? color.dim("none") : c2.pools.map((p) => `${p.boxes.length} \xD7 ${p.size}${p.boxes.length > 0 ? color.dim(` (${p.boxes.join(", ")})`) : ""}`).join(", ");
|
|
9218
|
-
function
|
|
9502
|
+
function printRows3(rows2) {
|
|
9219
9503
|
const width2 = Math.max(...rows2.map(([label]) => label.length));
|
|
9220
9504
|
for (const [label, value] of rows2) process.stdout.write(`${color.dim(label.padEnd(width2))} ${value}
|
|
9221
9505
|
`);
|
|
@@ -9244,7 +9528,7 @@ function nodeCount(text2) {
|
|
|
9244
9528
|
var roomText = (room) => room.s === 0 ? color.yellow("its host is full: no node of any size fits") : `${NODE_SIZES.filter((size) => room[size] > 0).map((size) => `${room[size]} \xD7 ${size}`).join(", ").replace(/, ([^,]*)$/, " or $1")} more ${color.dim("(as its host has room now; nothing is reserved)")}`;
|
|
9245
9529
|
|
|
9246
9530
|
// src/commands/k8s/backup/create.ts
|
|
9247
|
-
var
|
|
9531
|
+
var createCommand10 = new Command104("create").description("back up what a cluster knows to the kvbox cloud (encrypted)").argument("<cluster>", "cluster name").option("--wait", "stay until the backup is ready (by default it runs in the background)").option("--json", "print the backup as JSON").action(async (name, opts, cmd) => {
|
|
9248
9532
|
const client = await k8sClient(cmd);
|
|
9249
9533
|
const ls = `kvbox k8s backup ls ${name}`;
|
|
9250
9534
|
try {
|
|
@@ -9271,8 +9555,8 @@ var createCommand9 = new Command98("create").description("back up what a cluster
|
|
|
9271
9555
|
});
|
|
9272
9556
|
|
|
9273
9557
|
// src/commands/k8s/backup/ls.ts
|
|
9274
|
-
import { Command as
|
|
9275
|
-
var lsCommand15 = new
|
|
9558
|
+
import { Command as Command105 } from "commander";
|
|
9559
|
+
var lsCommand15 = new Command105("ls").alias("list").description("list backups: every cluster's, or one cluster's").argument("[cluster]", "cluster name (default: every cluster)").option("--json", "print as JSON").action(async (name, opts, cmd) => {
|
|
9276
9560
|
const client = await k8sClient(cmd);
|
|
9277
9561
|
const removedOnes = async (err, name2) => {
|
|
9278
9562
|
if (!(err instanceof CallError && err.status === 404)) throw err;
|
|
@@ -9318,8 +9602,8 @@ var lsCommand15 = new Command99("ls").alias("list").description("list backups: e
|
|
|
9318
9602
|
});
|
|
9319
9603
|
|
|
9320
9604
|
// src/commands/k8s/backup/restore.ts
|
|
9321
|
-
import { Command as
|
|
9322
|
-
var restoreCommand4 = new
|
|
9605
|
+
import { Command as Command106 } from "commander";
|
|
9606
|
+
var restoreCommand4 = new Command106("restore").description("put a backup back: what the cluster knows becomes the backup's (its master restarts)").argument("<cluster>", "cluster name").argument("<id>", "the backup's id (kvbox k8s backup ls <cluster>)").option("-y, --yes", "do not ask for confirmation").option("--no-wait", "do not wait for the nodes to be Ready again").option("--json", "print what changed as JSON").action(async (name, id, opts, cmd) => {
|
|
9323
9607
|
const client = await k8sClient(cmd);
|
|
9324
9608
|
try {
|
|
9325
9609
|
const backup = await client.clusterBackup(name, id);
|
|
@@ -9350,8 +9634,8 @@ var restoreCommand4 = new Command100("restore").description("put a backup back:
|
|
|
9350
9634
|
});
|
|
9351
9635
|
|
|
9352
9636
|
// src/commands/k8s/backup/rm.ts
|
|
9353
|
-
import { Command as
|
|
9354
|
-
var
|
|
9637
|
+
import { Command as Command107 } from "commander";
|
|
9638
|
+
var rmCommand15 = new Command107("rm").alias("remove").description("remove a backup for good (a cluster's that is gone too)").argument("<cluster>", "cluster name").argument("<id>", "the backup's id (kvbox k8s backup ls <cluster>)").option("-y, --yes", "do not ask for confirmation").action(async (name, id, opts, cmd) => {
|
|
9355
9639
|
const client = await k8sClient(cmd);
|
|
9356
9640
|
try {
|
|
9357
9641
|
await removeListed(client, await client.listClusterBackups(), (b) => b.name, name, id, `cluster ${name}`, opts.yes ?? false);
|
|
@@ -9361,8 +9645,8 @@ var rmCommand14 = new Command101("rm").alias("remove").description("remove a bac
|
|
|
9361
9645
|
});
|
|
9362
9646
|
|
|
9363
9647
|
// src/commands/k8s/backup/schedule.ts
|
|
9364
|
-
import { Command as
|
|
9365
|
-
var scheduleCommand4 = scheduleFlags(new
|
|
9648
|
+
import { Command as Command108 } from "commander";
|
|
9649
|
+
var scheduleCommand4 = scheduleFlags(new Command108("schedule").description("show or change when a cluster is backed up on its own (daily, UTC)").argument("<cluster>", "cluster name")).action(
|
|
9366
9650
|
async (name, flags, cmd) => {
|
|
9367
9651
|
const change = changeOf(flags);
|
|
9368
9652
|
const client = await k8sClient(cmd);
|
|
@@ -9377,11 +9661,11 @@ var scheduleCommand4 = scheduleFlags(new Command102("schedule").description("sho
|
|
|
9377
9661
|
);
|
|
9378
9662
|
|
|
9379
9663
|
// src/commands/k8s/backup/index.ts
|
|
9380
|
-
var backupCommand4 = new
|
|
9664
|
+
var backupCommand4 = new Command109("backup").description("back up what a cluster knows, list backups, restore or remove one, or change its nightly schedule").addCommand(createCommand10).addCommand(lsCommand15).addCommand(restoreCommand4).addCommand(rmCommand15).addCommand(scheduleCommand4);
|
|
9381
9665
|
|
|
9382
9666
|
// src/commands/k8s/create.ts
|
|
9383
|
-
import { Command as
|
|
9384
|
-
var
|
|
9667
|
+
import { Command as Command110 } from "commander";
|
|
9668
|
+
var createCommand11 = new Command110("create").description("make a Kubernetes cluster with its first nodes (a few minutes)").argument("<name>", "cluster name: 1-8 lowercase letters, digits and '-' (not at either end)").requiredOption("--size <size>", `what each node is sized at: ${NODE_SIZES.join(", ")}`).option("--nodes <n>", `how many nodes (1-${MAX_POOL_NODES})`, String(DEFAULT_POOL_NODES)).option("--near <box>", "put it on the host of this box").option("--no-wait", "do not wait for the cluster to be ready").option("--json", "print as JSON").action(async (name, opts, cmd) => {
|
|
9385
9669
|
if (!NODE_SIZES.includes(opts.size)) throw new KvboxError(`--size ${opts.size}: a node is one of ${NODE_SIZES.join(", ")}`);
|
|
9386
9670
|
const nodes = nodeCount(opts.nodes);
|
|
9387
9671
|
const client = await k8sClient(cmd);
|
|
@@ -9393,7 +9677,7 @@ var createCommand10 = new Command104("create").description("make a Kubernetes cl
|
|
|
9393
9677
|
return;
|
|
9394
9678
|
}
|
|
9395
9679
|
const shown = shownName2(cluster2, client);
|
|
9396
|
-
info(`${color.green("\u2713")} cluster ${color.bold(shown)} made on ${cluster2.host}: Kubernetes ${cluster2.version}, ${
|
|
9680
|
+
info(`${color.green("\u2713")} cluster ${color.bold(shown)} made on ${cluster2.host}: Kubernetes ${cluster2.version}, ${priceText3(cluster2)}`);
|
|
9397
9681
|
info(` API: ${apiText(cluster2)}`);
|
|
9398
9682
|
info(` nodes: ${poolsText(cluster2)}`);
|
|
9399
9683
|
if (opts.wait && !allReady(cluster2)) warn(`it is not all ready yet; look again with: kvbox k8s info ${shown}`);
|
|
@@ -9404,10 +9688,10 @@ var createCommand10 = new Command104("create").description("make a Kubernetes cl
|
|
|
9404
9688
|
});
|
|
9405
9689
|
|
|
9406
9690
|
// src/commands/k8s/domain/index.ts
|
|
9407
|
-
import { Command as
|
|
9691
|
+
import { Command as Command114 } from "commander";
|
|
9408
9692
|
|
|
9409
9693
|
// src/commands/k8s/domain/add.ts
|
|
9410
|
-
import { Command as
|
|
9694
|
+
import { Command as Command111 } from "commander";
|
|
9411
9695
|
|
|
9412
9696
|
// src/commands/domain/shared.ts
|
|
9413
9697
|
function requireCloud4(client) {
|
|
@@ -9428,7 +9712,7 @@ function hostIn(name, zone) {
|
|
|
9428
9712
|
|
|
9429
9713
|
// src/commands/k8s/domain/add.ts
|
|
9430
9714
|
var clusterDomainJson = (d, cluster2) => ({ domain: d.domain, cluster: cluster2, status: d.status, www: d.www, url: d.url, error: d.error, records: d.records, createdAt: d.createdAt });
|
|
9431
|
-
var addCommand3 = new
|
|
9715
|
+
var addCommand3 = new Command111("add").description("serve a cluster at a domain of your own, https://<domain>, with its certificate made for you; an Ingress for that host picks the app").argument("<cluster>", "cluster name").argument("<domain>", "a domain you control, like example.com or app.example.com").option("--json", "print the domain as JSON").action(async (cluster2, domainArg, opts, cmd) => {
|
|
9432
9716
|
const domain = assertDomain(domainArg.trim().toLowerCase());
|
|
9433
9717
|
const client = await k8sClient(cmd);
|
|
9434
9718
|
try {
|
|
@@ -9465,8 +9749,8 @@ kvbox checks every minute; ${domain} is served at ${d.url} once its records are
|
|
|
9465
9749
|
});
|
|
9466
9750
|
|
|
9467
9751
|
// src/commands/k8s/domain/ls.ts
|
|
9468
|
-
import { Command as
|
|
9469
|
-
var lsCommand16 = new
|
|
9752
|
+
import { Command as Command112 } from "commander";
|
|
9753
|
+
var lsCommand16 = new Command112("ls").alias("list").description("list a cluster's custom domains and whether they are live").argument("<cluster>", "cluster name").option("--json", "print as JSON").action(async (cluster2, opts, cmd) => {
|
|
9470
9754
|
const client = await k8sClient(cmd);
|
|
9471
9755
|
try {
|
|
9472
9756
|
const domains = await client.listClusterDomains(cluster2);
|
|
@@ -9485,8 +9769,8 @@ var lsCommand16 = new Command106("ls").alias("list").description("list a cluster
|
|
|
9485
9769
|
});
|
|
9486
9770
|
|
|
9487
9771
|
// src/commands/k8s/domain/rm.ts
|
|
9488
|
-
import { Command as
|
|
9489
|
-
var
|
|
9772
|
+
import { Command as Command113 } from "commander";
|
|
9773
|
+
var rmCommand16 = new Command113("rm").alias("remove").description("stop serving a cluster at a custom domain").argument("<cluster>", "cluster name").argument("<domain>", "the domain").option("-y, --yes", "do not ask for confirmation").action(async (cluster2, domainArg, opts, cmd) => {
|
|
9490
9774
|
const domain = domainArg.trim().toLowerCase();
|
|
9491
9775
|
const client = await k8sClient(cmd);
|
|
9492
9776
|
try {
|
|
@@ -9503,11 +9787,11 @@ var rmCommand15 = new Command107("rm").alias("remove").description("stop serving
|
|
|
9503
9787
|
});
|
|
9504
9788
|
|
|
9505
9789
|
// src/commands/k8s/domain/index.ts
|
|
9506
|
-
var domainCommand = new
|
|
9790
|
+
var domainCommand = new Command114("domain").description("serve a cluster at domains of your own: add one, list them, remove one").addCommand(addCommand3).addCommand(lsCommand16).addCommand(rmCommand16);
|
|
9507
9791
|
|
|
9508
9792
|
// src/commands/k8s/info.ts
|
|
9509
|
-
import { Command as
|
|
9510
|
-
var
|
|
9793
|
+
import { Command as Command115 } from "commander";
|
|
9794
|
+
var infoCommand3 = new Command115("info").description("one cluster: its API address, whether it is ready, its nodes").argument("<name>", "cluster name").option("--json", "print as JSON").action(async (name, opts, cmd) => {
|
|
9511
9795
|
const client = await k8sClient(cmd);
|
|
9512
9796
|
try {
|
|
9513
9797
|
const c2 = await client.getCluster(name);
|
|
@@ -9538,18 +9822,18 @@ var infoCommand2 = new Command109("info").description("one cluster: its API addr
|
|
|
9538
9822
|
...c2.backupSchedule ? [["backups", scheduleLine(`kvbox k8s backup schedule ${shown}`, c2.backupSchedule)]] : [],
|
|
9539
9823
|
["host", `${c2.host}${c2.country ? ` (${c2.country})` : ""}`],
|
|
9540
9824
|
...c2.room ? [["room", roomText(c2.room)]] : [],
|
|
9541
|
-
["cost",
|
|
9825
|
+
["cost", priceText3(c2)],
|
|
9542
9826
|
["created", `${age(c2.createdAt)}${c2.createdBy ? ` by ${c2.createdBy}` : ""}`]
|
|
9543
9827
|
];
|
|
9544
|
-
|
|
9828
|
+
printRows3(rows2);
|
|
9545
9829
|
} finally {
|
|
9546
9830
|
await client.close();
|
|
9547
9831
|
}
|
|
9548
9832
|
});
|
|
9549
9833
|
|
|
9550
9834
|
// src/commands/k8s/kubeconfig.ts
|
|
9551
|
-
import { Command as
|
|
9552
|
-
var kubeconfigCommand = new
|
|
9835
|
+
import { Command as Command116 } from "commander";
|
|
9836
|
+
var kubeconfigCommand = new Command116("kubeconfig").description("print the cluster's kubeconfig (it is the cluster's admin: keep it like a password)").argument("<name>", "cluster name").option("--json", "print as JSON").action(async (name, opts, cmd) => {
|
|
9553
9837
|
const client = await k8sClient(cmd);
|
|
9554
9838
|
try {
|
|
9555
9839
|
const made = await client.getKubeconfig(name);
|
|
@@ -9562,10 +9846,10 @@ var kubeconfigCommand = new Command110("kubeconfig").description("print the clus
|
|
|
9562
9846
|
});
|
|
9563
9847
|
|
|
9564
9848
|
// src/commands/k8s/link.ts
|
|
9565
|
-
import { Command as
|
|
9849
|
+
import { Command as Command117 } from "commander";
|
|
9566
9850
|
var reachedText = (l) => `${l.kind} ${l.to}`;
|
|
9567
9851
|
var linkJson = (l, cluster2) => ({ cluster: cluster2, to: l.to, owner: l.owner, kind: l.kind, port: l.port, host: l.host, ...l.boxes ? { boxes: l.boxes } : {} });
|
|
9568
|
-
var linkCommand2 = new
|
|
9852
|
+
var linkCommand2 = new Command117("link").description("let every pod of a cluster reach a database or a box's port (private; never public)").argument("<cluster>", "cluster name").argument("<target>", "a database (kvbox pg, kvbox redis) or a box; <slug>/<name> for another account's").option("-p, --port <port>", "the port, for a box (a database has its own)").option("--json", "print the link as JSON").action(async (cluster2, target, opts, cmd) => {
|
|
9569
9853
|
const port = opts.port === void 0 ? void 0 : parseLinkPort(opts.port);
|
|
9570
9854
|
const client = await k8sClient(cmd);
|
|
9571
9855
|
try {
|
|
@@ -9583,8 +9867,8 @@ var linkCommand2 = new Command111("link").description("let every pod of a cluste
|
|
|
9583
9867
|
});
|
|
9584
9868
|
|
|
9585
9869
|
// src/commands/k8s/links.ts
|
|
9586
|
-
import { Command as
|
|
9587
|
-
var linksCommand2 = new
|
|
9870
|
+
import { Command as Command118 } from "commander";
|
|
9871
|
+
var linksCommand2 = new Command118("links").description("list what a cluster reaches (kvbox k8s link)").argument("<cluster>", "cluster name").option("--json", "print as JSON").action(async (cluster2, opts, cmd) => {
|
|
9588
9872
|
const client = await k8sClient(cmd);
|
|
9589
9873
|
try {
|
|
9590
9874
|
const links = await client.listClusterLinks(cluster2);
|
|
@@ -9600,8 +9884,8 @@ var linksCommand2 = new Command112("links").description("list what a cluster rea
|
|
|
9600
9884
|
});
|
|
9601
9885
|
|
|
9602
9886
|
// src/commands/k8s/ls.ts
|
|
9603
|
-
import { Command as
|
|
9604
|
-
var lsCommand17 = new
|
|
9887
|
+
import { Command as Command119 } from "commander";
|
|
9888
|
+
var lsCommand17 = new Command119("ls").alias("list").description("list Kubernetes clusters").option("-a, --all", "every cluster on the platform (platform admins only)").option("--json", "print as JSON").action(async (opts, cmd) => {
|
|
9605
9889
|
const client = await k8sClient(cmd);
|
|
9606
9890
|
try {
|
|
9607
9891
|
const clusters = await client.listClusters({ all: opts.all });
|
|
@@ -9632,11 +9916,11 @@ var lsCommand17 = new Command113("ls").alias("list").description("list Kubernete
|
|
|
9632
9916
|
});
|
|
9633
9917
|
|
|
9634
9918
|
// src/commands/k8s/node/index.ts
|
|
9635
|
-
import { Command as
|
|
9919
|
+
import { Command as Command121 } from "commander";
|
|
9636
9920
|
|
|
9637
9921
|
// src/commands/k8s/node/restart.ts
|
|
9638
|
-
import { Command as
|
|
9639
|
-
var restartCommand2 = new
|
|
9922
|
+
import { Command as Command120 } from "commander";
|
|
9923
|
+
var restartCommand2 = new Command120("restart").description("stop and boot one node of a cluster again (the cluster's own name restarts its master)").argument("<cluster>", "cluster name").argument("<node>", "the node's name, as kvbox k8s info lists it; the cluster's name for its master").option("--json", "print as JSON").action(async (name, node, opts, cmd) => {
|
|
9640
9924
|
const client = await k8sClient(cmd);
|
|
9641
9925
|
try {
|
|
9642
9926
|
const c2 = await spin(`restarting ${node}\u2026`, client.restartClusterNode(name, node));
|
|
@@ -9648,13 +9932,13 @@ var restartCommand2 = new Command114("restart").description("stop and boot one n
|
|
|
9648
9932
|
});
|
|
9649
9933
|
|
|
9650
9934
|
// src/commands/k8s/node/index.ts
|
|
9651
|
-
var nodeCommand = new
|
|
9935
|
+
var nodeCommand = new Command121("node").description("one node of a cluster: restart it").addCommand(restartCommand2);
|
|
9652
9936
|
|
|
9653
9937
|
// src/commands/k8s/pool/index.ts
|
|
9654
|
-
import { Command as
|
|
9938
|
+
import { Command as Command126 } from "commander";
|
|
9655
9939
|
|
|
9656
9940
|
// src/commands/k8s/pool/add.ts
|
|
9657
|
-
import { Command as
|
|
9941
|
+
import { Command as Command122 } from "commander";
|
|
9658
9942
|
|
|
9659
9943
|
// src/commands/k8s/pool/shared.ts
|
|
9660
9944
|
function poolReady(c2, pool) {
|
|
@@ -9706,7 +9990,7 @@ function printPool(client, c2, pool, done, waited) {
|
|
|
9706
9990
|
}
|
|
9707
9991
|
|
|
9708
9992
|
// src/commands/k8s/pool/add.ts
|
|
9709
|
-
var addCommand4 = new
|
|
9993
|
+
var addCommand4 = new Command122("add").description("add a pool of nodes to a cluster").argument("<cluster>", "cluster name").requiredOption("--size <size>", `what each node is sized at: ${NODE_SIZES.join(", ")}`).option("--nodes <n>", `how many nodes (1-${MAX_POOL_NODES})`, String(DEFAULT_POOL_NODES)).option("--name <pool>", "the pool's name (default: its size)").option("--no-wait", "do not wait for the nodes to join").option("--json", "print as JSON").action(async (cluster2, opts, cmd) => {
|
|
9710
9994
|
if (!NODE_SIZES.includes(opts.size)) throw new KvboxError(`--size ${opts.size}: a node is one of ${NODE_SIZES.join(", ")}`);
|
|
9711
9995
|
const nodes = nodeCount(opts.nodes);
|
|
9712
9996
|
const pool = opts.name ?? opts.size;
|
|
@@ -9723,8 +10007,8 @@ var addCommand4 = new Command116("add").description("add a pool of nodes to a cl
|
|
|
9723
10007
|
});
|
|
9724
10008
|
|
|
9725
10009
|
// src/commands/k8s/pool/ls.ts
|
|
9726
|
-
import { Command as
|
|
9727
|
-
var lsCommand18 = new
|
|
10010
|
+
import { Command as Command123 } from "commander";
|
|
10011
|
+
var lsCommand18 = new Command123("ls").alias("list").description("list a cluster's pools").argument("<cluster>", "cluster name").option("--json", "print as JSON").action(async (cluster2, opts, cmd) => {
|
|
9728
10012
|
const client = await k8sClient(cmd);
|
|
9729
10013
|
try {
|
|
9730
10014
|
const c2 = await client.getCluster(cluster2);
|
|
@@ -9743,8 +10027,8 @@ var lsCommand18 = new Command117("ls").alias("list").description("list a cluster
|
|
|
9743
10027
|
});
|
|
9744
10028
|
|
|
9745
10029
|
// src/commands/k8s/pool/resize.ts
|
|
9746
|
-
import { Command as
|
|
9747
|
-
var resizeCommand = new
|
|
10030
|
+
import { Command as Command124 } from "commander";
|
|
10031
|
+
var resizeCommand = new Command124("resize").description("change how many nodes a pool has").argument("<cluster>", "cluster name").argument("<pool>", "pool name (kvbox k8s pool ls <cluster>)").requiredOption("--nodes <n>", "how many nodes the pool should have").option("--force", "fewer nodes: remove them at once, undrained, with what they keep on their disks").option("-y, --yes", "do not ask for confirmation (fewer nodes)").option("--no-wait", "do not wait for new nodes to join, or for removed ones to drain").option("--json", "print as JSON").action(async (cluster2, pool, opts, cmd) => {
|
|
9748
10032
|
const nodes = nodeCount(opts.nodes);
|
|
9749
10033
|
const client = await k8sClient(cmd);
|
|
9750
10034
|
try {
|
|
@@ -9771,8 +10055,8 @@ var resizeCommand = new Command118("resize").description("change how many nodes
|
|
|
9771
10055
|
});
|
|
9772
10056
|
|
|
9773
10057
|
// src/commands/k8s/pool/rm.ts
|
|
9774
|
-
import { Command as
|
|
9775
|
-
var
|
|
10058
|
+
import { Command as Command125 } from "commander";
|
|
10059
|
+
var rmCommand17 = new Command125("rm").alias("remove").description("remove a pool and its nodes from a cluster").argument("<cluster>", "cluster name").argument("<pool>", "pool name (kvbox k8s pool ls <cluster>)").option("--force", "remove the nodes at once, undrained, with what they keep on their disks").option("-y, --yes", "do not ask for confirmation").option("--no-wait", "do not wait for the nodes to drain").option("--json", "print as JSON").action(async (cluster2, pool, opts, cmd) => {
|
|
9776
10060
|
const client = await k8sClient(cmd);
|
|
9777
10061
|
try {
|
|
9778
10062
|
if (!await confirm(`Remove pool ${pool} of cluster ${cluster2} and its nodes${opts.force ? " without draining them, with whatever they keep on their disks" : ""}?`, opts.yes ?? false)) {
|
|
@@ -9795,14 +10079,14 @@ var rmCommand16 = new Command119("rm").alias("remove").description("remove a poo
|
|
|
9795
10079
|
});
|
|
9796
10080
|
|
|
9797
10081
|
// src/commands/k8s/pool/index.ts
|
|
9798
|
-
var poolCommand = new
|
|
10082
|
+
var poolCommand = new Command126("pool").description("a cluster's node pools: add one, list them, change how many nodes one has, remove one").addCommand(addCommand4).addCommand(lsCommand18).addCommand(resizeCommand).addCommand(rmCommand17);
|
|
9799
10083
|
|
|
9800
10084
|
// src/commands/k8s/proxy/index.ts
|
|
9801
|
-
import { Command as
|
|
10085
|
+
import { Command as Command130 } from "commander";
|
|
9802
10086
|
|
|
9803
10087
|
// src/commands/k8s/proxy/claim.ts
|
|
9804
|
-
import { Command as
|
|
9805
|
-
var claimCommand2 = new
|
|
10088
|
+
import { Command as Command127 } from "commander";
|
|
10089
|
+
var claimCommand2 = new Command127("claim").description(`give a cluster an HTTPS address, https://<subdomain>.kvbox.app (up to ${MAX_BOX_SUBDOMAINS} per cluster); an Ingress for that host picks the app`).argument("<cluster>", "cluster name").argument("<subdomain>", "3-63 lowercase letters, digits and '-'; must be free").option("--json", "print the address as JSON").action(async (cluster2, subArg, opts, cmd) => {
|
|
9806
10090
|
const subdomain = assertSubdomain(subArg);
|
|
9807
10091
|
const client = await k8sClient(cmd);
|
|
9808
10092
|
try {
|
|
@@ -9820,8 +10104,8 @@ var claimCommand2 = new Command121("claim").description(`give a cluster an HTTPS
|
|
|
9820
10104
|
});
|
|
9821
10105
|
|
|
9822
10106
|
// src/commands/k8s/proxy/ls.ts
|
|
9823
|
-
import { Command as
|
|
9824
|
-
var lsCommand19 = new
|
|
10107
|
+
import { Command as Command128 } from "commander";
|
|
10108
|
+
var lsCommand19 = new Command128("ls").alias("list").description("list a cluster's kvbox.app addresses").argument("<cluster>", "cluster name").option("--json", "print as JSON").action(async (cluster2, opts, cmd) => {
|
|
9825
10109
|
const client = await k8sClient(cmd);
|
|
9826
10110
|
try {
|
|
9827
10111
|
const subs = await client.listClusterSubdomains(cluster2);
|
|
@@ -9837,8 +10121,8 @@ var lsCommand19 = new Command122("ls").alias("list").description("list a cluster
|
|
|
9837
10121
|
});
|
|
9838
10122
|
|
|
9839
10123
|
// src/commands/k8s/proxy/release.ts
|
|
9840
|
-
import { Command as
|
|
9841
|
-
var releaseCommand2 = new
|
|
10124
|
+
import { Command as Command129 } from "commander";
|
|
10125
|
+
var releaseCommand2 = new Command129("release").description("give up one of a cluster's kvbox.app addresses").argument("<cluster>", "cluster name").argument("<subdomain>", "the subdomain (kvbox k8s proxy ls <cluster>)").option("-y, --yes", "do not ask for confirmation").action(async (cluster2, subdomain, opts, cmd) => {
|
|
9842
10126
|
const client = await k8sClient(cmd);
|
|
9843
10127
|
try {
|
|
9844
10128
|
if (!await confirm(`Give up ${subdomain}, one of cluster ${cluster2}'s HTTPS addresses? Anyone may claim it after.`, opts.yes ?? false)) {
|
|
@@ -9854,11 +10138,11 @@ var releaseCommand2 = new Command123("release").description("give up one of a cl
|
|
|
9854
10138
|
});
|
|
9855
10139
|
|
|
9856
10140
|
// src/commands/k8s/proxy/index.ts
|
|
9857
|
-
var proxyCommand2 = new
|
|
10141
|
+
var proxyCommand2 = new Command130("proxy").description("a cluster's HTTPS addresses, https://<name>.kvbox.app: claim one, list them, give one up").addCommand(claimCommand2).addCommand(lsCommand19).addCommand(releaseCommand2);
|
|
9858
10142
|
|
|
9859
10143
|
// src/commands/k8s/rm.ts
|
|
9860
|
-
import { Command as
|
|
9861
|
-
var
|
|
10144
|
+
import { Command as Command131 } from "commander";
|
|
10145
|
+
var rmCommand18 = new Command131("rm").alias("remove").description("delete a cluster with everything running in it").argument("<name>", "cluster name").option("-y, --yes", "do not ask for confirmation").action(async (name, opts, cmd) => {
|
|
9862
10146
|
const client = await k8sClient(cmd);
|
|
9863
10147
|
try {
|
|
9864
10148
|
if (!await confirm(`Delete cluster ${name} with everything running in it?`, opts.yes ?? false)) {
|
|
@@ -9874,9 +10158,9 @@ var rmCommand17 = new Command125("rm").alias("remove").description("delete a clu
|
|
|
9874
10158
|
});
|
|
9875
10159
|
|
|
9876
10160
|
// src/commands/k8s/rotate.ts
|
|
9877
|
-
import { Command as
|
|
10161
|
+
import { Command as Command132 } from "commander";
|
|
9878
10162
|
var ROTATE_WAIT_MS = 30 * 6e4;
|
|
9879
|
-
var rotateCommand = new
|
|
10163
|
+
var rotateCommand = new Command132("rotate").description("give a cluster new credentials: every kubeconfig handed out so far stops working").argument("<cluster>", "cluster name").option("-y, --yes", "do not ask for confirmation").option("--no-wait", "do not wait for the master and the nodes to restart").option("--json", "print as JSON").action(async (name, opts, cmd) => {
|
|
9880
10164
|
const client = await k8sClient(cmd);
|
|
9881
10165
|
try {
|
|
9882
10166
|
if (!await confirm(`Give cluster ${name} new credentials? Every kubeconfig handed out so far stops working, and its master, then its nodes, restart: apps on it are down for a few minutes.`, opts.yes ?? false)) {
|
|
@@ -9902,8 +10186,8 @@ var rotateCommand = new Command126("rotate").description("give a cluster new cre
|
|
|
9902
10186
|
});
|
|
9903
10187
|
|
|
9904
10188
|
// src/commands/k8s/start.ts
|
|
9905
|
-
import { Command as
|
|
9906
|
-
var startCommand2 = new
|
|
10189
|
+
import { Command as Command133 } from "commander";
|
|
10190
|
+
var startCommand2 = new Command133("start").description("run a cluster's master and nodes again after they stopped").argument("<name>", "cluster name").option("--json", "print as JSON").action(async (name, opts, cmd) => {
|
|
9907
10191
|
const client = await k8sClient(cmd);
|
|
9908
10192
|
try {
|
|
9909
10193
|
const c2 = await spin(`starting cluster ${name}\u2026`, client.startCluster(name));
|
|
@@ -9915,8 +10199,8 @@ var startCommand2 = new Command127("start").description("run a cluster's master
|
|
|
9915
10199
|
});
|
|
9916
10200
|
|
|
9917
10201
|
// src/commands/k8s/unlink.ts
|
|
9918
|
-
import { Command as
|
|
9919
|
-
var unlinkCommand2 = new
|
|
10202
|
+
import { Command as Command134 } from "commander";
|
|
10203
|
+
var unlinkCommand2 = new Command134("unlink").description("take a cluster's link away (kvbox k8s link)").argument("<cluster>", "cluster name").argument("<target>", "the database or box it reaches").option("-p, --port <port>", "the port, when the cluster reaches several of that box's").option("-y, --yes", "do not ask for confirmation").option("--json", "print the removed link as JSON").action(async (cluster2, target, opts, cmd) => {
|
|
9920
10204
|
const port = opts.port === void 0 ? void 0 : parseLinkPort(opts.port);
|
|
9921
10205
|
if (!await confirm(`Cut cluster ${cluster2} off from ${target}${port !== void 0 ? ` port ${port}` : ""}? Its pods' open connections close too.`, opts.yes ?? false)) {
|
|
9922
10206
|
info("cancelled");
|
|
@@ -9937,7 +10221,7 @@ var unlinkCommand2 = new Command128("unlink").description("take a cluster's link
|
|
|
9937
10221
|
});
|
|
9938
10222
|
|
|
9939
10223
|
// src/commands/k8s/index.ts
|
|
9940
|
-
var k8sCommand = new
|
|
10224
|
+
var k8sCommand = new Command135("k8s").description("Kubernetes clusters kvbox runs for you").addCommand(createCommand11).addCommand(lsCommand17).addCommand(infoCommand3).addCommand(kubeconfigCommand).addCommand(poolCommand).addCommand(nodeCommand).addCommand(proxyCommand2).addCommand(domainCommand).addCommand(linkCommand2).addCommand(unlinkCommand2).addCommand(linksCommand2).addCommand(backupCommand4).addCommand(startCommand2).addCommand(rotateCommand).addCommand(rmCommand18);
|
|
9941
10225
|
var withOrg3 = (cmd) => cmd.option("--org <slug>", "act in this org (- for your personal clusters)");
|
|
9942
10226
|
for (const cmd of k8sCommand.commands) {
|
|
9943
10227
|
if (cmd.commands.length > 0) cmd.commands.forEach(withOrg3);
|
|
@@ -9945,10 +10229,10 @@ for (const cmd of k8sCommand.commands) {
|
|
|
9945
10229
|
}
|
|
9946
10230
|
|
|
9947
10231
|
// src/commands/cron/index.ts
|
|
9948
|
-
import { Command as
|
|
10232
|
+
import { Command as Command148 } from "commander";
|
|
9949
10233
|
|
|
9950
10234
|
// src/commands/cron/create.ts
|
|
9951
|
-
import { Command as
|
|
10235
|
+
import { Command as Command136 } from "commander";
|
|
9952
10236
|
|
|
9953
10237
|
// src/commands/cron/shared.ts
|
|
9954
10238
|
async function cronClient(cmd) {
|
|
@@ -10001,7 +10285,7 @@ function printTriggers(triggers) {
|
|
|
10001
10285
|
}))
|
|
10002
10286
|
);
|
|
10003
10287
|
}
|
|
10004
|
-
function
|
|
10288
|
+
function printRows4(rows2) {
|
|
10005
10289
|
const width2 = Math.max(...rows2.map(([label]) => label.length));
|
|
10006
10290
|
for (const [label, value] of rows2) process.stdout.write(`${color.dim(label.padEnd(width2))} ${value}
|
|
10007
10291
|
`);
|
|
@@ -10009,7 +10293,7 @@ function printRows3(rows2) {
|
|
|
10009
10293
|
var noTriggers = (service) => info(`cron service ${service} has no triggers yet; add one with: kvbox cron trigger add ${service} <box> "0 6 * * *" --port 3000 (or --run "<command>")`);
|
|
10010
10294
|
|
|
10011
10295
|
// src/commands/cron/create.ts
|
|
10012
|
-
var
|
|
10296
|
+
var createCommand12 = new Command136("create").description("make a cron service: a named set of triggers").argument("<name>", "what to call it (lowercase letters, digits and '-')").option("--json", "print as JSON").action(async (name, opts, cmd) => {
|
|
10013
10297
|
const client = await cronClient(cmd);
|
|
10014
10298
|
try {
|
|
10015
10299
|
const service = await client.createCronService(name);
|
|
@@ -10026,8 +10310,8 @@ var createCommand11 = new Command130("create").description("make a cron service:
|
|
|
10026
10310
|
});
|
|
10027
10311
|
|
|
10028
10312
|
// src/commands/cron/info.ts
|
|
10029
|
-
import { Command as
|
|
10030
|
-
var
|
|
10313
|
+
import { Command as Command137 } from "commander";
|
|
10314
|
+
var infoCommand4 = new Command137("info").alias("get").description("show a cron service and its triggers").argument("<name>", "cron service name").option("--json", "print as JSON").action(async (name, opts, cmd) => {
|
|
10031
10315
|
const client = await cronClient(cmd);
|
|
10032
10316
|
try {
|
|
10033
10317
|
const service = await client.getCronService(name);
|
|
@@ -10036,7 +10320,7 @@ var infoCommand3 = new Command131("info").alias("get").description("show a cron
|
|
|
10036
10320
|
json({ ...service, triggerList: triggers });
|
|
10037
10321
|
return;
|
|
10038
10322
|
}
|
|
10039
|
-
|
|
10323
|
+
printRows4([
|
|
10040
10324
|
["name", shownName3(service, client)],
|
|
10041
10325
|
["triggers", String(service.triggers)],
|
|
10042
10326
|
["runs kept", `the last ${service.keepRuns} of each trigger`],
|
|
@@ -10051,8 +10335,8 @@ var infoCommand3 = new Command131("info").alias("get").description("show a cron
|
|
|
10051
10335
|
});
|
|
10052
10336
|
|
|
10053
10337
|
// src/commands/cron/ls.ts
|
|
10054
|
-
import { Command as
|
|
10055
|
-
var lsCommand20 = new
|
|
10338
|
+
import { Command as Command138 } from "commander";
|
|
10339
|
+
var lsCommand20 = new Command138("ls").alias("list").description("list cron services").option("-a, --all", "every cron service on the platform (platform admins only)").option("--json", "print as JSON").action(async (opts, cmd) => {
|
|
10056
10340
|
const client = await cronClient(cmd);
|
|
10057
10341
|
try {
|
|
10058
10342
|
const services = await client.listCronServices({ all: opts.all });
|
|
@@ -10072,8 +10356,8 @@ var lsCommand20 = new Command132("ls").alias("list").description("list cron serv
|
|
|
10072
10356
|
});
|
|
10073
10357
|
|
|
10074
10358
|
// src/commands/cron/rm.ts
|
|
10075
|
-
import { Command as
|
|
10076
|
-
var
|
|
10359
|
+
import { Command as Command139 } from "commander";
|
|
10360
|
+
var rmCommand19 = new Command139("rm").alias("remove").description("delete a cron service, its triggers and their run history").argument("<name>", "cron service name").option("-y, --yes", "do not ask for confirmation").action(async (name, opts, cmd) => {
|
|
10077
10361
|
const client = await cronClient(cmd);
|
|
10078
10362
|
try {
|
|
10079
10363
|
if (!await confirm(`Delete cron service ${name}? Its triggers stop firing and their run history is deleted.`, opts.yes ?? false)) {
|
|
@@ -10089,10 +10373,10 @@ var rmCommand18 = new Command133("rm").alias("remove").description("delete a cro
|
|
|
10089
10373
|
});
|
|
10090
10374
|
|
|
10091
10375
|
// src/commands/cron/trigger/index.ts
|
|
10092
|
-
import { Command as
|
|
10376
|
+
import { Command as Command147 } from "commander";
|
|
10093
10377
|
|
|
10094
10378
|
// src/commands/cron/trigger/add.ts
|
|
10095
|
-
import { Command as
|
|
10379
|
+
import { Command as Command140 } from "commander";
|
|
10096
10380
|
function portOf(value) {
|
|
10097
10381
|
const n2 = Number(value);
|
|
10098
10382
|
if (!Number.isInteger(n2) || n2 < 1 || n2 > 65535) throw new KvboxError(`--port ${value}: a port is a number from 1 to 65535`);
|
|
@@ -10112,7 +10396,7 @@ function timeoutOf(value) {
|
|
|
10112
10396
|
if (sec > MAX_CRON_COMMAND_TIMEOUT_SEC) throw new KvboxError(`--timeout ${value}: a command may run for ${MAX_CRON_COMMAND_TIMEOUT_SEC / 60} minutes at most`);
|
|
10113
10397
|
return sec;
|
|
10114
10398
|
}
|
|
10115
|
-
var addCommand5 = new
|
|
10399
|
+
var addCommand5 = new Command140("add").description("add a trigger: on a schedule, call a port of a box or run a command in it").argument("<service>", "cron service name").argument("<box>", "the box it acts on").argument("<expr>", 'cron expression in quotes, five fields: "0 6 * * *" is every day at 06:00').option("--port <n>", "call this port, the one your app listens on in the box").option("--path <path>", "with --port: path and query to request (default: /)").option("--method <method>", `with --port: HTTP method, ${CRON_METHODS.join(" or ")} (default: POST)`).option("--run <command>", 'or run this command in the box, in quotes: "node ~/app/embed.js"').option("--timeout <duration>", `with --run: stop the command after this long (90s, 10m, 1h; default: ${DEFAULT_CRON_COMMAND_TIMEOUT_SEC / 60}m)`).option("--tz <zone>", "time zone the schedule is read in, like Europe/Bucharest", "UTC").option("--json", "print as JSON").action(async (service, box2, expr, opts, cmd) => {
|
|
10116
10400
|
let action;
|
|
10117
10401
|
if (opts.run !== void 0) {
|
|
10118
10402
|
if (opts.port !== void 0 || opts.path !== void 0 || opts.method !== void 0) throw new KvboxError("a trigger runs a command or calls a port: use --run, or --port with --path and --method, not both");
|
|
@@ -10139,8 +10423,8 @@ var addCommand5 = new Command134("add").description("add a trigger: on a schedul
|
|
|
10139
10423
|
});
|
|
10140
10424
|
|
|
10141
10425
|
// src/commands/cron/trigger/ls.ts
|
|
10142
|
-
import { Command as
|
|
10143
|
-
var lsCommand21 = new
|
|
10426
|
+
import { Command as Command141 } from "commander";
|
|
10427
|
+
var lsCommand21 = new Command141("ls").alias("list").description("list a cron service's triggers").argument("<service>", "cron service name").option("--json", "print as JSON").action(async (service, opts, cmd) => {
|
|
10144
10428
|
const client = await cronClient(cmd);
|
|
10145
10429
|
try {
|
|
10146
10430
|
const triggers = await client.listCronTriggers(service);
|
|
@@ -10156,8 +10440,8 @@ var lsCommand21 = new Command135("ls").alias("list").description("list a cron se
|
|
|
10156
10440
|
});
|
|
10157
10441
|
|
|
10158
10442
|
// src/commands/cron/trigger/pause.ts
|
|
10159
|
-
import { Command as
|
|
10160
|
-
var pauseCommand2 = new
|
|
10443
|
+
import { Command as Command142 } from "commander";
|
|
10444
|
+
var pauseCommand2 = new Command142("pause").description("stop a trigger from firing until it is resumed").argument("<service>", "cron service name").argument("<id>", "trigger id (kvbox cron trigger ls)").option("--json", "print as JSON").action(async (service, id, opts, cmd) => {
|
|
10161
10445
|
const client = await cronClient(cmd);
|
|
10162
10446
|
try {
|
|
10163
10447
|
const trigger = await client.setCronTriggerEnabled(service, id, false);
|
|
@@ -10172,8 +10456,8 @@ var pauseCommand2 = new Command136("pause").description("stop a trigger from fir
|
|
|
10172
10456
|
});
|
|
10173
10457
|
|
|
10174
10458
|
// src/commands/cron/trigger/resume.ts
|
|
10175
|
-
import { Command as
|
|
10176
|
-
var resumeCommand2 = new
|
|
10459
|
+
import { Command as Command143 } from "commander";
|
|
10460
|
+
var resumeCommand2 = new Command143("resume").description("let a paused trigger fire again").argument("<service>", "cron service name").argument("<id>", "trigger id (kvbox cron trigger ls)").option("--json", "print as JSON").action(async (service, id, opts, cmd) => {
|
|
10177
10461
|
const client = await cronClient(cmd);
|
|
10178
10462
|
try {
|
|
10179
10463
|
const trigger = await client.setCronTriggerEnabled(service, id, true);
|
|
@@ -10188,8 +10472,8 @@ var resumeCommand2 = new Command137("resume").description("let a paused trigger
|
|
|
10188
10472
|
});
|
|
10189
10473
|
|
|
10190
10474
|
// src/commands/cron/trigger/rm.ts
|
|
10191
|
-
import { Command as
|
|
10192
|
-
var
|
|
10475
|
+
import { Command as Command144 } from "commander";
|
|
10476
|
+
var rmCommand20 = new Command144("rm").alias("remove").description("delete a trigger and its run history").argument("<service>", "cron service name").argument("<id>", "trigger id (kvbox cron trigger ls)").option("-y, --yes", "do not ask for confirmation").action(async (service, id, opts, cmd) => {
|
|
10193
10477
|
const client = await cronClient(cmd);
|
|
10194
10478
|
try {
|
|
10195
10479
|
if (!await confirm(`Delete trigger ${id} of cron service ${service}? Its run history is deleted too.`, opts.yes ?? false)) {
|
|
@@ -10205,8 +10489,8 @@ var rmCommand19 = new Command138("rm").alias("remove").description("delete a tri
|
|
|
10205
10489
|
});
|
|
10206
10490
|
|
|
10207
10491
|
// src/commands/cron/trigger/run.ts
|
|
10208
|
-
import { Command as
|
|
10209
|
-
var runCommand = new
|
|
10492
|
+
import { Command as Command145 } from "commander";
|
|
10493
|
+
var runCommand = new Command145("run").description("fire a trigger now, once, besides its schedule").argument("<service>", "cron service name").argument("<id>", "trigger id (kvbox cron trigger ls)").option("--json", "print as JSON").action(async (service, id, opts, cmd) => {
|
|
10210
10494
|
const client = await cronClient(cmd);
|
|
10211
10495
|
try {
|
|
10212
10496
|
const trigger = await client.runCronTrigger(service, id);
|
|
@@ -10222,13 +10506,13 @@ var runCommand = new Command139("run").description("fire a trigger now, once, be
|
|
|
10222
10506
|
});
|
|
10223
10507
|
|
|
10224
10508
|
// src/commands/cron/trigger/runs.ts
|
|
10225
|
-
import { Command as
|
|
10509
|
+
import { Command as Command146 } from "commander";
|
|
10226
10510
|
function limitOf(value) {
|
|
10227
10511
|
const n2 = Number(value);
|
|
10228
10512
|
if (!Number.isInteger(n2) || n2 < 1) throw new KvboxError(`-n ${value}: a number of runs, 1 or more`);
|
|
10229
10513
|
return n2;
|
|
10230
10514
|
}
|
|
10231
|
-
var runsCommand = new
|
|
10515
|
+
var runsCommand = new Command146("runs").aliases(["logs"]).description("show how a trigger's last runs ended").argument("<service>", "cron service name").argument("<id>", "trigger id (kvbox cron trigger ls)").option("-n, --limit <count>", "how many runs to show", "20").option("--json", "print as JSON").action(async (service, id, opts, cmd) => {
|
|
10232
10516
|
const limit = limitOf(opts.limit);
|
|
10233
10517
|
const client = await cronClient(cmd);
|
|
10234
10518
|
try {
|
|
@@ -10258,10 +10542,10 @@ var runsCommand = new Command140("runs").aliases(["logs"]).description("show how
|
|
|
10258
10542
|
});
|
|
10259
10543
|
|
|
10260
10544
|
// src/commands/cron/trigger/index.ts
|
|
10261
|
-
var triggerCommand = new
|
|
10545
|
+
var triggerCommand = new Command147("trigger").aliases(["triggers"]).description("a cron service's triggers: a schedule and the request it sends to a box").addCommand(addCommand5).addCommand(lsCommand21).addCommand(runsCommand).addCommand(runCommand).addCommand(pauseCommand2).addCommand(resumeCommand2).addCommand(rmCommand20);
|
|
10262
10546
|
|
|
10263
10547
|
// src/commands/cron/index.ts
|
|
10264
|
-
var cronCommand = new
|
|
10548
|
+
var cronCommand = new Command148("cron").description("cron: call a box on a schedule, waking it first if it sleeps").addCommand(createCommand12).addCommand(lsCommand20).addCommand(infoCommand4).addCommand(rmCommand19).addCommand(triggerCommand);
|
|
10265
10549
|
var withOrg4 = (cmd) => cmd.option("--org <slug>", "act in this org (- for your personal cron services)");
|
|
10266
10550
|
for (const cmd of cronCommand.commands) {
|
|
10267
10551
|
if (cmd === triggerCommand) cmd.commands.forEach(withOrg4);
|
|
@@ -10269,13 +10553,13 @@ for (const cmd of cronCommand.commands) {
|
|
|
10269
10553
|
}
|
|
10270
10554
|
|
|
10271
10555
|
// src/commands/managed/kind.ts
|
|
10272
|
-
import { Command as
|
|
10556
|
+
import { Command as Command167 } from "commander";
|
|
10273
10557
|
|
|
10274
10558
|
// src/commands/managed/backup/index.ts
|
|
10275
|
-
import { Command as
|
|
10559
|
+
import { Command as Command155 } from "commander";
|
|
10276
10560
|
|
|
10277
10561
|
// src/commands/managed/backup/create.ts
|
|
10278
|
-
import { Command as
|
|
10562
|
+
import { Command as Command150 } from "commander";
|
|
10279
10563
|
|
|
10280
10564
|
// src/commands/managed/shared.ts
|
|
10281
10565
|
import "commander";
|
|
@@ -10309,7 +10593,7 @@ async function managedClient(cmd) {
|
|
|
10309
10593
|
}
|
|
10310
10594
|
var shownName4 = (m, user) => m.owner === user ? m.name : `${m.owner}/${m.name}`;
|
|
10311
10595
|
var storageText = (m) => m.health?.storageUsedBytes !== void 0 ? `${gb(m.health.storageUsedBytes)} of ${m.storageGib} GB used` : `${m.storageGib} GB`;
|
|
10312
|
-
var
|
|
10596
|
+
var nearlyFull3 = (m) => m.health?.storageUsedBytes !== void 0 && m.health.storageTotalBytes !== void 0 && m.health.storageTotalBytes > 0 && m.health.storageUsedBytes / m.health.storageTotalBytes >= 0.9;
|
|
10313
10597
|
function stateText(m) {
|
|
10314
10598
|
if (m.status === "stopped") return `${status(m.status)} ${color.dim("(only its storage is charged)")}`;
|
|
10315
10599
|
if (m.status !== "running" || m.health === void 0) return status(m.status);
|
|
@@ -10326,7 +10610,7 @@ function infoRows(spec, m, user) {
|
|
|
10326
10610
|
];
|
|
10327
10611
|
if (user !== void 0 && m.owner !== user) rows2.push(["owner", m.owner]);
|
|
10328
10612
|
for (const fact of m.health?.facts ?? []) rows2.push([fact.title.toLowerCase(), fact.value]);
|
|
10329
|
-
rows2.push(["storage", `${storageText(m)}${
|
|
10613
|
+
rows2.push(["storage", `${storageText(m)}${nearlyFull3(m) ? color.yellow(` almost full: kvbox ${spec.command} grow ${name} <GB>`) : ""}`]);
|
|
10330
10614
|
rows2.push(...settingRows(spec, m.settings), ["password", color.dim(`kvbox ${spec.command} password ${name}`)]);
|
|
10331
10615
|
rows2.push(["private", `${m.urls.private} ${color.dim(m.links.length > 0 ? `(from ${m.links.join(", ")})` : `(no box is linked: kvbox ${spec.command} link ${name} <box>)`)}`]);
|
|
10332
10616
|
rows2.push(["public", m.urls.public ?? color.dim(`off (kvbox ${spec.command} public ${name} on)`)]);
|
|
@@ -10338,7 +10622,7 @@ function infoRows(spec, m, user) {
|
|
|
10338
10622
|
function scheduleText2(spec, name, s, now = Date.now()) {
|
|
10339
10623
|
return scheduleLine(`kvbox ${spec.command} backup schedule ${name}`, s, now);
|
|
10340
10624
|
}
|
|
10341
|
-
function
|
|
10625
|
+
function printRows5(rows2) {
|
|
10342
10626
|
const width2 = Math.max(...rows2.map(([label]) => label.length));
|
|
10343
10627
|
for (const [label, value] of rows2) process.stdout.write(`${color.dim(label.padEnd(width2))} ${value}
|
|
10344
10628
|
`);
|
|
@@ -10362,7 +10646,7 @@ function parseStorage(text2, flag) {
|
|
|
10362
10646
|
}
|
|
10363
10647
|
|
|
10364
10648
|
// src/commands/managed/backup/create.ts
|
|
10365
|
-
var
|
|
10649
|
+
var createCommand13 = (spec) => new Command150("create").description("back up a database to the kvbox cloud (encrypted)").argument("<db>", "its name").option("--wait", "stay until the backup is ready (by default it runs in the background)").option("--json", "print the backup as JSON").action(async (name, opts, cmd) => {
|
|
10366
10650
|
const client = await managedClient(cmd);
|
|
10367
10651
|
const ls = `kvbox ${spec.command} backup ls ${name}`;
|
|
10368
10652
|
try {
|
|
@@ -10389,7 +10673,7 @@ var createCommand12 = (spec) => new Command144("create").description("back up a
|
|
|
10389
10673
|
});
|
|
10390
10674
|
|
|
10391
10675
|
// src/commands/managed/backup/ls.ts
|
|
10392
|
-
import { Command as
|
|
10676
|
+
import { Command as Command151 } from "commander";
|
|
10393
10677
|
var lsCommand22 = (spec) => {
|
|
10394
10678
|
const removedOnes = async (err, name, client) => {
|
|
10395
10679
|
if (!(err instanceof CallError && err.status === 404)) throw err;
|
|
@@ -10398,7 +10682,7 @@ var lsCommand22 = (spec) => {
|
|
|
10398
10682
|
const own = name.includes("/") ? [] : gone.filter((b) => b.owner === me(client));
|
|
10399
10683
|
return own.length > 0 ? own : gone;
|
|
10400
10684
|
};
|
|
10401
|
-
return new
|
|
10685
|
+
return new Command151("ls").alias("list").description("list backups: every database's, or one database's").argument("[db]", "its name (default: every database)").option("--json", "print as JSON").action(async (name, opts, cmd) => {
|
|
10402
10686
|
const client = await managedClient(cmd);
|
|
10403
10687
|
try {
|
|
10404
10688
|
const list = name === void 0 ? await client.listManagedBackups(spec.kind) : await client.managedBackups(spec.kind, name).catch((err) => removedOnes(err, name, client));
|
|
@@ -10441,8 +10725,8 @@ var lsCommand22 = (spec) => {
|
|
|
10441
10725
|
};
|
|
10442
10726
|
|
|
10443
10727
|
// src/commands/managed/backup/restore.ts
|
|
10444
|
-
import { Command as
|
|
10445
|
-
var restoreCommand5 = (spec) => new
|
|
10728
|
+
import { Command as Command152 } from "commander";
|
|
10729
|
+
var restoreCommand5 = (spec) => new Command152("restore").description("put a backup back: the database's data becomes the backup's (it restarts)").argument("<db>", "its name").argument("<id>", `the backup's id (kvbox ${spec.command} backup ls <db>)`).option("-y, --yes", "do not ask for confirmation").option("--json", "print the database as JSON").action(async (name, id, opts, cmd) => {
|
|
10446
10730
|
const client = await managedClient(cmd);
|
|
10447
10731
|
try {
|
|
10448
10732
|
const backup = await client.managedBackup(spec.kind, name, id);
|
|
@@ -10464,8 +10748,8 @@ var restoreCommand5 = (spec) => new Command146("restore").description("put a bac
|
|
|
10464
10748
|
});
|
|
10465
10749
|
|
|
10466
10750
|
// src/commands/managed/backup/rm.ts
|
|
10467
|
-
import { Command as
|
|
10468
|
-
var
|
|
10751
|
+
import { Command as Command153 } from "commander";
|
|
10752
|
+
var rmCommand21 = (spec) => new Command153("rm").alias("remove").description("remove a backup for good (a database's that is gone too)").argument("<db>", "its name").argument("<id>", `the backup's id (kvbox ${spec.command} backup ls <db>)`).option("-y, --yes", "do not ask for confirmation").action(async (name, id, opts, cmd) => {
|
|
10469
10753
|
const client = await managedClient(cmd);
|
|
10470
10754
|
try {
|
|
10471
10755
|
await removeListed(client, await client.listManagedBackups(spec.kind), (b) => b.name, name, id, `database ${name}`, opts.yes ?? false);
|
|
@@ -10475,8 +10759,8 @@ var rmCommand20 = (spec) => new Command147("rm").alias("remove").description("re
|
|
|
10475
10759
|
});
|
|
10476
10760
|
|
|
10477
10761
|
// src/commands/managed/backup/schedule.ts
|
|
10478
|
-
import { Command as
|
|
10479
|
-
var scheduleCommand5 = (spec) => scheduleFlags(new
|
|
10762
|
+
import { Command as Command154 } from "commander";
|
|
10763
|
+
var scheduleCommand5 = (spec) => scheduleFlags(new Command154("schedule").description("show or change when a database is backed up on its own (daily, UTC)").argument("<db>", "its name")).action(
|
|
10480
10764
|
async (name, flags, cmd) => {
|
|
10481
10765
|
const change = changeOf(flags);
|
|
10482
10766
|
const client = await managedClient(cmd);
|
|
@@ -10492,18 +10776,18 @@ var scheduleCommand5 = (spec) => scheduleFlags(new Command148("schedule").descri
|
|
|
10492
10776
|
|
|
10493
10777
|
// src/commands/managed/backup/index.ts
|
|
10494
10778
|
var backupCommand5 = (spec) => {
|
|
10495
|
-
const command = new
|
|
10496
|
-
for (const make of [
|
|
10779
|
+
const command = new Command155("backup").description("back up a database to the kvbox cloud, list backups, restore or remove one, or change its nightly schedule");
|
|
10780
|
+
for (const make of [createCommand13, lsCommand22, restoreCommand5, rmCommand21, scheduleCommand5]) command.addCommand(make(spec).option("--org <slug>", "act in this org (- for your personal databases)"));
|
|
10497
10781
|
return command;
|
|
10498
10782
|
};
|
|
10499
10783
|
|
|
10500
10784
|
// src/commands/managed/create.ts
|
|
10501
|
-
import { Command as
|
|
10785
|
+
import { Command as Command156 } from "commander";
|
|
10502
10786
|
import { setTimeout as sleep5 } from "timers/promises";
|
|
10503
10787
|
var READY_WAIT_MS2 = 9e4;
|
|
10504
10788
|
var READY_STEP_MS = 2e3;
|
|
10505
|
-
var
|
|
10506
|
-
const command = new
|
|
10789
|
+
var createCommand14 = (spec) => {
|
|
10790
|
+
const command = new Command156("create").alias("new").description(`create a ${spec.title} database: a name is all it needs`).argument("<name>", "its name (1-12 chars, lowercase letters, digits and '-'); a linked box reaches it at <name>.<account>.kvbox");
|
|
10507
10791
|
for (const o of spec.options) command.option(`--${o.name} <${o.arg}>`, o.help);
|
|
10508
10792
|
return command.option("--password <password>", "its password (default: generated)").option("--storage <gb>", `storage for the data in GB (default: ${spec.storageGib}; it can grow later)`).option("--near <box>", "run it on the host of this box, so a link between them stays on that host").option("--from-backup <id>", `start it on this backup's data, a removed database's too (kvbox ${spec.command} backup ls)`).option("--json", "print it as JSON, password included").action(async (name, opts, cmd) => {
|
|
10509
10793
|
const options = Object.fromEntries(spec.options.flatMap((o) => typeof opts[o.name] === "string" ? [[o.name, opts[o.name]]] : []));
|
|
@@ -10538,7 +10822,7 @@ var createCommand13 = (spec) => {
|
|
|
10538
10822
|
}
|
|
10539
10823
|
const restored = made.fromBackup === void 0 ? "" : `, the data of backup ${made.fromBackup}`;
|
|
10540
10824
|
info(`${color.green("\u2713")} database ${color.bold(shown)} ${ready ? "is ready" : "is created and still starting"} ${color.dim(`(${spec.title} ${made.version}, ${made.storageGib} GB of storage${restored})`)}`);
|
|
10541
|
-
|
|
10825
|
+
printRows5([...settingRows(spec, made.settings), ...secretRows(made.secret)].map(([label, value]) => [` ${label}`, value]));
|
|
10542
10826
|
info("");
|
|
10543
10827
|
info("Nobody can reach it yet. To let something in:");
|
|
10544
10828
|
info(` a box of yours kvbox ${spec.command} link ${shown} <box> ${color.dim(`(a new one right next to it: kvbox new <box> --near ${shown})`)}`);
|
|
@@ -10552,8 +10836,8 @@ var createCommand13 = (spec) => {
|
|
|
10552
10836
|
};
|
|
10553
10837
|
|
|
10554
10838
|
// src/commands/managed/grow.ts
|
|
10555
|
-
import { Command as
|
|
10556
|
-
var
|
|
10839
|
+
import { Command as Command157 } from "commander";
|
|
10840
|
+
var growCommand4 = (spec) => new Command157("grow").description("give a database more storage (it restarts once)").argument("<db>", "its name").argument("<GB>", "the new size in GB, larger than what it has").option("--json", "print as JSON").action(async (name, size, opts, cmd) => {
|
|
10557
10841
|
const storageGib = parseStorage(size, "size");
|
|
10558
10842
|
const client = await managedClient(cmd);
|
|
10559
10843
|
try {
|
|
@@ -10566,21 +10850,21 @@ var growCommand3 = (spec) => new Command151("grow").description("give a database
|
|
|
10566
10850
|
});
|
|
10567
10851
|
|
|
10568
10852
|
// src/commands/managed/info.ts
|
|
10569
|
-
import { Command as
|
|
10570
|
-
var
|
|
10853
|
+
import { Command as Command158 } from "commander";
|
|
10854
|
+
var infoCommand5 = (spec) => new Command158("info").alias("get").description("show one database: status, storage used, how to connect").argument("<db>", "its name").option("--json", "print as JSON").action(async (name, opts, cmd) => {
|
|
10571
10855
|
const client = await managedClient(cmd);
|
|
10572
10856
|
try {
|
|
10573
10857
|
const m = await client.getManaged(spec.kind, name);
|
|
10574
10858
|
if (opts.json) json(m);
|
|
10575
|
-
else
|
|
10859
|
+
else printRows5(infoRows(spec, m, me(client)));
|
|
10576
10860
|
} finally {
|
|
10577
10861
|
await client.close();
|
|
10578
10862
|
}
|
|
10579
10863
|
});
|
|
10580
10864
|
|
|
10581
10865
|
// src/commands/managed/link.ts
|
|
10582
|
-
import { Command as
|
|
10583
|
-
var linkCommand3 = (spec) => new
|
|
10866
|
+
import { Command as Command159 } from "commander";
|
|
10867
|
+
var linkCommand3 = (spec) => new Command159("link").description("let a box reach a database privately").argument("<db>", "the database").argument("<box>", "the box that connects to it").option("--json", "print as JSON").action(async (name, box2, opts, cmd) => {
|
|
10584
10868
|
const client = await managedClient(cmd);
|
|
10585
10869
|
try {
|
|
10586
10870
|
const m = await spin(`linking ${box2} to ${name}\u2026`, client.linkManaged(spec.kind, name, box2));
|
|
@@ -10596,7 +10880,7 @@ var linkCommand3 = (spec) => new Command153("link").description("let a box reach
|
|
|
10596
10880
|
});
|
|
10597
10881
|
|
|
10598
10882
|
// src/commands/managed/ls.ts
|
|
10599
|
-
import { Command as
|
|
10883
|
+
import { Command as Command160 } from "commander";
|
|
10600
10884
|
function listRows(items, user, kindColumn) {
|
|
10601
10885
|
return items.map((m) => ({
|
|
10602
10886
|
owner: m.owner === user ? "private" : m.owner,
|
|
@@ -10610,7 +10894,7 @@ function listRows(items, user, kindColumn) {
|
|
|
10610
10894
|
created: age(m.createdAt)
|
|
10611
10895
|
}));
|
|
10612
10896
|
}
|
|
10613
|
-
var lsCommand23 = (spec) => new
|
|
10897
|
+
var lsCommand23 = (spec) => new Command160("ls").alias("list").description(spec ? `list your ${spec.title} databases` : "list every managed database, whatever its kind").option("-a, --all", "every one on the platform (platform admins only)").option("--json", "print as JSON").action(async (opts, cmd) => {
|
|
10614
10898
|
const client = await managedClient(cmd);
|
|
10615
10899
|
try {
|
|
10616
10900
|
const items = await client.listManaged(spec?.kind, { all: opts.all });
|
|
@@ -10630,8 +10914,8 @@ var lsCommand23 = (spec) => new Command154("ls").alias("list").description(spec
|
|
|
10630
10914
|
});
|
|
10631
10915
|
|
|
10632
10916
|
// src/commands/managed/password.ts
|
|
10633
|
-
import { Command as
|
|
10634
|
-
var
|
|
10917
|
+
import { Command as Command161 } from "commander";
|
|
10918
|
+
var passwordCommand2 = (spec) => new Command161("password").description("show a database's password, or set a new one with --reset").argument("<db>", "its name").option("--reset", "make a new password; the old one stops working").option("--json", "print as JSON").action(async (name, opts, cmd) => {
|
|
10635
10919
|
const client = await managedClient(cmd);
|
|
10636
10920
|
try {
|
|
10637
10921
|
const secret = opts.reset ? await spin(`setting a new password on ${name}\u2026`, client.resetManagedPassword(spec.kind, name)) : await client.managedPassword(spec.kind, name);
|
|
@@ -10640,15 +10924,15 @@ var passwordCommand = (spec) => new Command155("password").description("show a d
|
|
|
10640
10924
|
return;
|
|
10641
10925
|
}
|
|
10642
10926
|
if (opts.reset) info(`${color.green("\u2713")} database ${name} has a new password; the old one no longer works`);
|
|
10643
|
-
|
|
10927
|
+
printRows5(secretRows(secret));
|
|
10644
10928
|
} finally {
|
|
10645
10929
|
await client.close();
|
|
10646
10930
|
}
|
|
10647
10931
|
});
|
|
10648
10932
|
|
|
10649
10933
|
// src/commands/managed/public.ts
|
|
10650
|
-
import { Command as
|
|
10651
|
-
var publicCommand2 = (spec) => new
|
|
10934
|
+
import { Command as Command162 } from "commander";
|
|
10935
|
+
var publicCommand2 = (spec) => new Command162("public").description("open a database to the internet, or close it again").argument("<db>", "its name").argument("<state>", "on: reachable from anywhere with the password; off: only linked boxes").option("--json", "print as JSON").action(async (name, state, opts, cmd) => {
|
|
10652
10936
|
if (state !== "on" && state !== "off") throw new KvboxError(`write on or off: kvbox ${spec.command} public ${name} on`);
|
|
10653
10937
|
const client = await managedClient(cmd);
|
|
10654
10938
|
try {
|
|
@@ -10669,8 +10953,8 @@ var publicCommand2 = (spec) => new Command156("public").description("open a data
|
|
|
10669
10953
|
});
|
|
10670
10954
|
|
|
10671
10955
|
// src/commands/managed/rm.ts
|
|
10672
|
-
import { Command as
|
|
10673
|
-
var
|
|
10956
|
+
import { Command as Command163 } from "commander";
|
|
10957
|
+
var rmCommand22 = (spec) => new Command163("rm").alias("remove").description("delete a database and all its data").argument("<db>", "its name").option("-y, --yes", "do not ask for confirmation").action(async (name, opts, cmd) => {
|
|
10674
10958
|
const client = await managedClient(cmd);
|
|
10675
10959
|
try {
|
|
10676
10960
|
if (!await confirm(`Delete database ${name} and all its data? There is no backup.`, opts.yes ?? false)) {
|
|
@@ -10686,8 +10970,8 @@ var rmCommand21 = (spec) => new Command157("rm").alias("remove").description("de
|
|
|
10686
10970
|
});
|
|
10687
10971
|
|
|
10688
10972
|
// src/commands/managed/start.ts
|
|
10689
|
-
import { Command as
|
|
10690
|
-
var startCommand3 = (spec) => new
|
|
10973
|
+
import { Command as Command164 } from "commander";
|
|
10974
|
+
var startCommand3 = (spec) => new Command164("start").description("run a stopped database again").argument("<db>", "its name").option("--json", "print as JSON").action(async (name, opts, cmd) => {
|
|
10691
10975
|
const client = await managedClient(cmd);
|
|
10692
10976
|
try {
|
|
10693
10977
|
const m = await spin(`starting ${name}\u2026`, client.startManaged(spec.kind, name));
|
|
@@ -10699,8 +10983,8 @@ var startCommand3 = (spec) => new Command158("start").description("run a stopped
|
|
|
10699
10983
|
});
|
|
10700
10984
|
|
|
10701
10985
|
// src/commands/managed/stop.ts
|
|
10702
|
-
import { Command as
|
|
10703
|
-
var stopCommand2 = (spec) => new
|
|
10986
|
+
import { Command as Command165 } from "commander";
|
|
10987
|
+
var stopCommand2 = (spec) => new Command165("stop").description("shut a database down, keeping its data (only its storage is charged)").argument("<db>", "its name").option("--json", "print as JSON").action(async (name, opts, cmd) => {
|
|
10704
10988
|
const client = await managedClient(cmd);
|
|
10705
10989
|
try {
|
|
10706
10990
|
const m = await spin(`stopping ${name}\u2026`, client.stopManaged(spec.kind, name));
|
|
@@ -10712,8 +10996,8 @@ var stopCommand2 = (spec) => new Command159("stop").description("shut a database
|
|
|
10712
10996
|
});
|
|
10713
10997
|
|
|
10714
10998
|
// src/commands/managed/unlink.ts
|
|
10715
|
-
import { Command as
|
|
10716
|
-
var unlinkCommand3 = (spec) => new
|
|
10999
|
+
import { Command as Command166 } from "commander";
|
|
11000
|
+
var unlinkCommand3 = (spec) => new Command166("unlink").description("stop a box from reaching a database").argument("<db>", "the database").argument("<box>", "the box that was linked to it").option("--json", "print as JSON").action(async (name, box2, opts, cmd) => {
|
|
10717
11001
|
const client = await managedClient(cmd);
|
|
10718
11002
|
try {
|
|
10719
11003
|
const m = await spin(`unlinking ${box2} from ${name}\u2026`, client.unlinkManaged(spec.kind, name, box2));
|
|
@@ -10726,8 +11010,8 @@ var unlinkCommand3 = (spec) => new Command160("unlink").description("stop a box
|
|
|
10726
11010
|
|
|
10727
11011
|
// src/commands/managed/kind.ts
|
|
10728
11012
|
function kindCommand(spec, description) {
|
|
10729
|
-
const command = new
|
|
10730
|
-
for (const make of [
|
|
11013
|
+
const command = new Command167(spec.command).aliases(spec.aliases).description(description);
|
|
11014
|
+
for (const make of [createCommand14, lsCommand23, infoCommand5, passwordCommand2, publicCommand2, linkCommand3, unlinkCommand3, growCommand4, stopCommand2, startCommand3, rmCommand22]) {
|
|
10731
11015
|
command.addCommand(make(spec).option("--org <slug>", "act in this org (- for your personal databases)"));
|
|
10732
11016
|
}
|
|
10733
11017
|
command.addCommand(backupCommand5(spec));
|
|
@@ -10741,14 +11025,14 @@ var pgCommand = kindCommand(POSTGRES2, "managed PostgreSQL: a database kvbox run
|
|
|
10741
11025
|
var redisCommand = kindCommand(REDIS, "managed Redis (Valkey): a Redis kvbox runs for you, private until you link a box or make it public");
|
|
10742
11026
|
|
|
10743
11027
|
// src/commands/managed/index.ts
|
|
10744
|
-
import { Command as
|
|
10745
|
-
var managedCommand = new
|
|
11028
|
+
import { Command as Command168 } from "commander";
|
|
11029
|
+
var managedCommand = new Command168("managed").description(`databases kvbox runs for you, every kind together (${KINDS.map((k) => `${k.title}: kvbox ${k.command}`).join(", ")})`).addCommand(lsCommand23().option("--org <slug>", "act in this org (- for your personal databases)"));
|
|
10746
11030
|
|
|
10747
11031
|
// src/commands/env/index.ts
|
|
10748
|
-
import { Command as
|
|
11032
|
+
import { Command as Command172 } from "commander";
|
|
10749
11033
|
|
|
10750
11034
|
// src/commands/env/ls.ts
|
|
10751
|
-
import { Command as
|
|
11035
|
+
import { Command as Command169 } from "commander";
|
|
10752
11036
|
|
|
10753
11037
|
// src/commands/env/shared.ts
|
|
10754
11038
|
function requireCloud5(client) {
|
|
@@ -10775,7 +11059,7 @@ function firstBootHint(box2, name) {
|
|
|
10775
11059
|
}
|
|
10776
11060
|
|
|
10777
11061
|
// src/commands/env/ls.ts
|
|
10778
|
-
var lsCommand24 = new
|
|
11062
|
+
var lsCommand24 = new Command169("ls").alias("list").description("list the variables (a secret shows as (sealed))").option("--box <box>", "what this box gets: its own variables and the ones it inherits").option("--json", "print as JSON").action(async (opts, cmd) => {
|
|
10779
11063
|
const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
|
|
10780
11064
|
try {
|
|
10781
11065
|
if (opts.box !== void 0) {
|
|
@@ -10814,8 +11098,8 @@ var lsCommand24 = new Command163("ls").alias("list").description("list the varia
|
|
|
10814
11098
|
});
|
|
10815
11099
|
|
|
10816
11100
|
// src/commands/env/rm.ts
|
|
10817
|
-
import { Command as
|
|
10818
|
-
var
|
|
11101
|
+
import { Command as Command170 } from "commander";
|
|
11102
|
+
var rmCommand23 = new Command170("rm").alias("remove").description("remove variables; boxes lose them when they next start").argument("<names...>", "variable names").option("-y, --yes", "do not ask for confirmation").option("--box <box>", "remove this box's own variables (yours, or the org's, of the same name come back)").option("--json", "print as JSON").action(async (names2, opts, cmd) => {
|
|
10819
11103
|
const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
|
|
10820
11104
|
try {
|
|
10821
11105
|
const target = opts.box === void 0 ? void 0 : await findBox2(client, opts.box);
|
|
@@ -10852,8 +11136,8 @@ var rmCommand22 = new Command164("rm").alias("remove").description("remove varia
|
|
|
10852
11136
|
});
|
|
10853
11137
|
|
|
10854
11138
|
// src/commands/env/set.ts
|
|
10855
|
-
import { Command as
|
|
10856
|
-
var setCommand2 = new
|
|
11139
|
+
import { Command as Command171 } from "commander";
|
|
11140
|
+
var setCommand2 = new Command171("set").description("add or change a variable; boxes get it when they next start").argument("[name]", "variable name, e.g. DATABASE_URL (asked for when left out)").argument("[value]", "its value (asked for when left out; hidden with --secret)").option("--secret", "write-only: the value is never shown again, by any command").option("--box <box>", "this box's own variable, over yours (or the org's) of the same name").option("--json", "print as JSON").action(async (nameArg, valueArg, opts, cmd) => {
|
|
10857
11141
|
const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
|
|
10858
11142
|
try {
|
|
10859
11143
|
const owner = opts.box === void 0 ? requireCloud5(client) : void 0;
|
|
@@ -10890,15 +11174,15 @@ var setCommand2 = new Command165("set").description("add or change a variable; b
|
|
|
10890
11174
|
});
|
|
10891
11175
|
|
|
10892
11176
|
// src/commands/env/index.ts
|
|
10893
|
-
var envCommand = new
|
|
11177
|
+
var envCommand = new Command172("env").description("environment variables every box of yours gets when it starts (secrets too)").addCommand(lsCommand24, { isDefault: true }).addCommand(setCommand2).addCommand(rmCommand23);
|
|
10894
11178
|
for (const cmd of envCommand.commands) cmd.option("--org <slug>", "the org's variables instead of yours");
|
|
10895
11179
|
|
|
10896
11180
|
// src/commands/domain/index.ts
|
|
10897
|
-
import { Command as
|
|
11181
|
+
import { Command as Command176 } from "commander";
|
|
10898
11182
|
|
|
10899
11183
|
// src/commands/domain/add.ts
|
|
10900
|
-
import { Command as
|
|
10901
|
-
var addCommand6 = new
|
|
11184
|
+
import { Command as Command173 } from "commander";
|
|
11185
|
+
var addCommand6 = new Command173("add").description("serve a box at a domain of your own, https://<domain>, with its certificate made for you").argument("<domain>", "a domain you control, like example.com or app.example.com").argument("<box>", "box name").option("--port <port>", "the box port the domain serves (default: the port of its kvbox.app address)").option("--json", "print the domain as JSON").action(async (domainArg, name, opts, cmd) => {
|
|
10902
11186
|
const domain = assertDomain(domainArg.trim().toLowerCase());
|
|
10903
11187
|
const port = opts.port === void 0 ? void 0 : parsePorts([opts.port])[0];
|
|
10904
11188
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
@@ -10934,8 +11218,8 @@ kvbox checks every minute; ${domain} is served at ${d.url} once its records are
|
|
|
10934
11218
|
});
|
|
10935
11219
|
|
|
10936
11220
|
// src/commands/domain/ls.ts
|
|
10937
|
-
import { Command as
|
|
10938
|
-
var lsCommand25 = new
|
|
11221
|
+
import { Command as Command174 } from "commander";
|
|
11222
|
+
var lsCommand25 = new Command174("ls").alias("list").description("list your custom domains and whether they are live").option("--json", "print as JSON").action(async (opts, cmd) => {
|
|
10939
11223
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
10940
11224
|
try {
|
|
10941
11225
|
requireCloud4(client);
|
|
@@ -10964,8 +11248,8 @@ var lsCommand25 = new Command168("ls").alias("list").description("list your cust
|
|
|
10964
11248
|
});
|
|
10965
11249
|
|
|
10966
11250
|
// src/commands/domain/rm.ts
|
|
10967
|
-
import { Command as
|
|
10968
|
-
var
|
|
11251
|
+
import { Command as Command175 } from "commander";
|
|
11252
|
+
var rmCommand24 = new Command175("rm").alias("remove").description("stop serving a box at a custom domain").argument("<domain>", "the domain").option("-y, --yes", "do not ask for confirmation").action(async (domainArg, opts, cmd) => {
|
|
10969
11253
|
const domain = domainArg.trim().toLowerCase();
|
|
10970
11254
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
10971
11255
|
try {
|
|
@@ -10986,7 +11270,7 @@ var rmCommand23 = new Command169("rm").alias("remove").description("stop serving
|
|
|
10986
11270
|
});
|
|
10987
11271
|
|
|
10988
11272
|
// src/commands/domain/index.ts
|
|
10989
|
-
var domainCommand2 = new
|
|
11273
|
+
var domainCommand2 = new Command176("domain").alias("domains").description("serve a box at a domain of your own").addCommand(addCommand6).addCommand(lsCommand25).addCommand(rmCommand24);
|
|
10990
11274
|
for (const cmd of domainCommand2.commands) cmd.option("--org <slug>", "act in this org (- for your personal boxes)");
|
|
10991
11275
|
|
|
10992
11276
|
// src/commands/update.ts
|
|
@@ -10994,7 +11278,7 @@ import { spawn as spawn8 } from "child_process";
|
|
|
10994
11278
|
import { mkdtempSync, rmSync, writeFileSync as writeFileSync2 } from "fs";
|
|
10995
11279
|
import { tmpdir } from "os";
|
|
10996
11280
|
import { join as join9 } from "path";
|
|
10997
|
-
import { Command as
|
|
11281
|
+
import { Command as Command177 } from "commander";
|
|
10998
11282
|
|
|
10999
11283
|
// src/update.ts
|
|
11000
11284
|
import { mkdirSync, readFileSync as readFileSync3, writeFileSync } from "fs";
|
|
@@ -11113,7 +11397,7 @@ function run2(cmd, args) {
|
|
|
11113
11397
|
child.on("exit", (code, signal) => resolve4(code ?? (signal ? 1 : 0)));
|
|
11114
11398
|
});
|
|
11115
11399
|
}
|
|
11116
|
-
var selfUpdateCommand = new
|
|
11400
|
+
var selfUpdateCommand = new Command177("update").description("update kvbox to the latest version (reruns the installer from kvbox.sh, agent skill included)").action(async () => {
|
|
11117
11401
|
suppressUpdateNotice();
|
|
11118
11402
|
const inst = installerFor(process.platform, process.env["KVBOX_INSTALL_URL"] || INSTALL_BASE);
|
|
11119
11403
|
let code;
|
|
@@ -11137,7 +11421,7 @@ var selfUpdateCommand = new Command171("update").description("update kvbox to th
|
|
|
11137
11421
|
import { chmod as chmod2, mkdir as mkdir4, readFile as readFile9, writeFile as writeFile5 } from "fs/promises";
|
|
11138
11422
|
import { homedir as homedir2 } from "os";
|
|
11139
11423
|
import { dirname as dirname2, join as join11 } from "path";
|
|
11140
|
-
import { Command as
|
|
11424
|
+
import { Command as Command178 } from "commander";
|
|
11141
11425
|
|
|
11142
11426
|
// src/sshConfig.ts
|
|
11143
11427
|
import { spawnSync as spawnSync4 } from "child_process";
|
|
@@ -11259,7 +11543,7 @@ async function forgetReplacedBox(alias, id, p) {
|
|
|
11259
11543
|
}
|
|
11260
11544
|
|
|
11261
11545
|
// src/commands/sshConfig.ts
|
|
11262
|
-
var sshConfigCommand = new
|
|
11546
|
+
var sshConfigCommand = new Command178("ssh-config").description("add your boxes to ~/.ssh/config, so ssh and VS Code Remote-SSH reach them as <box>.kvbox").argument("[box...]", "only these boxes, added to the ones listed already (default: every box)").option("--remove", "take these boxes off the list; with no box, take the whole kvbox block out").option("--file <path>", "the ssh config file to write (default: ~/.ssh/config)").option("--json", "print the result as JSON").action(async (boxes, opts, cmd) => {
|
|
11263
11547
|
const file = opts.file ?? join11(homedir2(), ".ssh", "config");
|
|
11264
11548
|
const before = await readFile9(file, "utf8").catch((err) => {
|
|
11265
11549
|
if (err.code === "ENOENT") return "";
|
|
@@ -11325,8 +11609,8 @@ async function aliasesOf(client, boxes, gone) {
|
|
|
11325
11609
|
|
|
11326
11610
|
// src/commands/sshProxy.ts
|
|
11327
11611
|
import { connect } from "net";
|
|
11328
|
-
import { Command as
|
|
11329
|
-
var sshProxyCommand = new
|
|
11612
|
+
import { Command as Command179 } from "commander";
|
|
11613
|
+
var sshProxyCommand = new Command179("ssh-proxy").description("connect ssh to a box (used by kvbox ssh-config)").argument("<host>", "the ssh name: <box>.kvbox or <box>.<org>.kvbox").option("--renew", "only renew the SSH certificate if it is about to expire").action(async (host, opts, cmd) => {
|
|
11330
11614
|
const ref = parseAlias(host);
|
|
11331
11615
|
if (ref === void 0) throw new KvboxError(`${host}: not a kvbox name (<box>.kvbox or <box>.<org>.kvbox)`);
|
|
11332
11616
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
@@ -11424,6 +11708,7 @@ var HELP_GROUPS = [
|
|
|
11424
11708
|
["snapshots", "freeze a running box into a snapshot, start new boxes from it"],
|
|
11425
11709
|
["volume", "disks of their own that move between boxes"],
|
|
11426
11710
|
["bucket", "object storage: S3 buckets for your files"],
|
|
11711
|
+
["registry", "container registry: a private place for your docker images"],
|
|
11427
11712
|
["pg", "managed PostgreSQL: a database kvbox runs for you"],
|
|
11428
11713
|
["redis", "managed Redis (Valkey): a Redis kvbox runs for you"],
|
|
11429
11714
|
["k8s", "managed Kubernetes: a cluster kvbox runs for you, its nodes your boxes"],
|
|
@@ -11489,11 +11774,12 @@ function installRootHelp(program) {
|
|
|
11489
11774
|
|
|
11490
11775
|
// src/program.ts
|
|
11491
11776
|
function buildProgram() {
|
|
11492
|
-
const program = new
|
|
11777
|
+
const program = new Command180("kvbox").description("self-hosted Firecracker microVMs with Docker-like ergonomics").version(VERSION, "-v, --version").option("--local", "use this machine's kvbox-server over its socket, ignoring kvbox login and KVBOX_TOKEN").option("--org <slug>", "the org: where kvbox new creates, and which box a name means when it is not one of yours; before the command here, or after it").showHelpAfterError().enablePositionalOptions();
|
|
11493
11778
|
program.addCommand(vmCommand);
|
|
11494
11779
|
program.addCommand(snapshotsCommand);
|
|
11495
11780
|
program.addCommand(volumeCommand);
|
|
11496
11781
|
program.addCommand(bucketCommand);
|
|
11782
|
+
program.addCommand(registryCommand);
|
|
11497
11783
|
program.addCommand(pgCommand);
|
|
11498
11784
|
program.addCommand(redisCommand);
|
|
11499
11785
|
program.addCommand(managedCommand);
|