@kvbox/cli 0.6.24 → 0.6.26
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 +563 -251
- 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.26" : void 0);
|
|
174
174
|
|
|
175
175
|
// src/commands/vm/index.ts
|
|
176
176
|
import { Command as Command44 } from "commander";
|
|
@@ -1107,7 +1107,13 @@ var CapacitySchema = z2.object({
|
|
|
1107
1107
|
/** 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
1108
|
clusters: z2.boolean().optional(),
|
|
1109
1109
|
/** The integrations this kvbox-server knows (`hostKnowsIntegrations`). Absent with `integrations`: the first one's, `github` alone. */
|
|
1110
|
-
integrationIds: z2.array(z2.string()).optional()
|
|
1110
|
+
integrationIds: z2.array(z2.string()).optional(),
|
|
1111
|
+
/** True on a host that can take a box range of its own (#240): its privileged network script widens a network that is up. */
|
|
1112
|
+
ranges: z2.boolean().optional(),
|
|
1113
|
+
/** The range the host gives its boxes now (`172.30.4.0/24`, config.json `boxRange`); absent while it has none. */
|
|
1114
|
+
boxRange: z2.string().optional(),
|
|
1115
|
+
/** Boxes of the host whose address is still outside `boxRange`: each moves at its next cold start. Absent without a range. */
|
|
1116
|
+
offRange: z2.number().int().optional()
|
|
1111
1117
|
});
|
|
1112
1118
|
var ImageSchema = z2.object({ name: z2.string(), version: z2.string().nullable() });
|
|
1113
1119
|
var ImageIndexSchema = z2.object({
|
|
@@ -1299,6 +1305,8 @@ var UsageDaySchema = z2.object({
|
|
|
1299
1305
|
volumes: z2.array(UsageDayItemSchema),
|
|
1300
1306
|
/** Object storage that existed that day (#182); absent on a day without any. */
|
|
1301
1307
|
storage: z2.array(UsageDayItemSchema).optional(),
|
|
1308
|
+
/** A container registry that existed that day (#234); absent on a day without any. */
|
|
1309
|
+
registry: z2.array(UsageDayItemSchema).optional(),
|
|
1302
1310
|
/** Cron services that existed that day (#190); absent on a day without any. */
|
|
1303
1311
|
cron: z2.array(UsageDayItemSchema).optional(),
|
|
1304
1312
|
/** Kubernetes clusters that existed that day (#222), each with its master and nodes together; absent on a day without any. */
|
|
@@ -1317,6 +1325,11 @@ var UsageReportSchema = z2.object({
|
|
|
1317
1325
|
* included ones, `sizeGib` its whole size. Absent when there is none.
|
|
1318
1326
|
*/
|
|
1319
1327
|
storage: z2.array(VolumeUsageSchema).optional(),
|
|
1328
|
+
/**
|
|
1329
|
+
* Container registries (#234, control plane only): one row per registry a slug has or had, shaped and
|
|
1330
|
+
* priced like `storage` with the registry's prices. Absent when there is none.
|
|
1331
|
+
*/
|
|
1332
|
+
registry: z2.array(VolumeUsageSchema).optional(),
|
|
1320
1333
|
/** Cron services (#190, control plane only): one row per service a slug has or had. Absent when there is none. */
|
|
1321
1334
|
cron: z2.array(CronUsageSchema).optional(),
|
|
1322
1335
|
/**
|
|
@@ -1335,7 +1348,7 @@ var UsageReportSchema = z2.object({
|
|
|
1335
1348
|
diskGibHours: z2.number(),
|
|
1336
1349
|
volumeHours: z2.number().optional(),
|
|
1337
1350
|
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. */
|
|
1351
|
+
/** 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
1352
|
cost: z2.object({ amount: z2.number(), currency: z2.string() }).optional()
|
|
1340
1353
|
})
|
|
1341
1354
|
});
|
|
@@ -1607,6 +1620,9 @@ var SshCaResponseSchema = z2.object({
|
|
|
1607
1620
|
var HostSshCaResponseSchema = z2.object({
|
|
1608
1621
|
publicKey: z2.string()
|
|
1609
1622
|
});
|
|
1623
|
+
var HostRangeResponseSchema = z2.object({
|
|
1624
|
+
range: z2.string().nullable()
|
|
1625
|
+
});
|
|
1610
1626
|
var CloudCaSchema = z2.object({
|
|
1611
1627
|
controlPlane: z2.string(),
|
|
1612
1628
|
publicKey: z2.string(),
|
|
@@ -1636,7 +1652,12 @@ var HostJoinRequestSchema = z2.object({
|
|
|
1636
1652
|
fingerprint: z2.string().regex(/^([0-9A-F]{2}:){31}[0-9A-F]{2}$/),
|
|
1637
1653
|
publicAddress: z2.string().min(1),
|
|
1638
1654
|
/** Where the host is (`kvbox-server join --country`): a code or an English name. */
|
|
1639
|
-
country: z2.string().optional()
|
|
1655
|
+
country: z2.string().optional(),
|
|
1656
|
+
/**
|
|
1657
|
+
* The box range this host already has boxes on (config.json `boxRange`, kept across a leave), which it
|
|
1658
|
+
* never gives up: the join gives it back, or is refused while it is another host's (#240).
|
|
1659
|
+
*/
|
|
1660
|
+
boxRange: z2.string().optional()
|
|
1640
1661
|
});
|
|
1641
1662
|
var HostJoinResponseSchema = z2.object({
|
|
1642
1663
|
hostSecret: z2.string(),
|
|
@@ -1654,14 +1675,20 @@ var CloudHostSchema = z2.object({
|
|
|
1654
1675
|
/** The S3 region a storage made on this host answers to (`ro-west-1`); null: it takes no storage. */
|
|
1655
1676
|
region: z2.string().nullable(),
|
|
1656
1677
|
/** 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()
|
|
1678
|
+
version: z2.string().nullable(),
|
|
1679
|
+
/**
|
|
1680
|
+
* The range of box addresses that is this host's alone (#240, `172.30.4.0/24`): the next free one at join,
|
|
1681
|
+
* or the admin's. Null: a host from before ranges that nobody gave one; its boxes are on `172.30.0.x` like
|
|
1682
|
+
* every such host's. What the host has taken of it is `capacity.boxRange`.
|
|
1683
|
+
*/
|
|
1684
|
+
boxRange: z2.string().nullable()
|
|
1658
1685
|
});
|
|
1659
1686
|
var HostInfoSchema = z2.object({
|
|
1660
1687
|
host: CloudHostSchema,
|
|
1661
1688
|
health: HealthSchema.nullable(),
|
|
1662
1689
|
error: z2.string().nullable()
|
|
1663
1690
|
});
|
|
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
|
|
1691
|
+
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
1692
|
var CountrySchema = z2.object({ code: z2.string(), name: z2.string() });
|
|
1666
1693
|
|
|
1667
1694
|
// src/session.ts
|
|
@@ -1867,6 +1894,14 @@ var PricingSchema = z4.object({
|
|
|
1867
1894
|
storageHour: z4.number().nonnegative().default(0),
|
|
1868
1895
|
storageGibHour: z4.number().nonnegative().default(0),
|
|
1869
1896
|
storageIncludedGib: z4.number().int().nonnegative().default(0),
|
|
1897
|
+
/**
|
|
1898
|
+
* The container registry (#234): priced as object storage is. An hour of a slug's registry existing,
|
|
1899
|
+
* whatever it holds, covers its hidden box and the first `registryIncludedGib` of its size; each GiB
|
|
1900
|
+
* above that is `registryGibHour`. A price list from before the registry charges nothing for it.
|
|
1901
|
+
*/
|
|
1902
|
+
registryHour: z4.number().nonnegative().default(0),
|
|
1903
|
+
registryGibHour: z4.number().nonnegative().default(0),
|
|
1904
|
+
registryIncludedGib: z4.number().int().nonnegative().default(0),
|
|
1870
1905
|
/** 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
1906
|
cronHour: z4.number().nonnegative().default(0),
|
|
1872
1907
|
/**
|
|
@@ -2104,6 +2139,8 @@ var ClusterNodeSchema = z6.object({
|
|
|
2104
2139
|
roles: z6.array(z6.string()),
|
|
2105
2140
|
version: z6.string().nullable().optional(),
|
|
2106
2141
|
address: z6.string().optional(),
|
|
2142
|
+
/** The node's boot id, new at every boot of its box (k3s image v0.1.5): a Ready under an older one is from before a restart. */
|
|
2143
|
+
bootId: z6.string().optional(),
|
|
2107
2144
|
/** Bound persistent volumes kept on this node's own disk: what removing the node would lose. */
|
|
2108
2145
|
volumes: z6.number().int(),
|
|
2109
2146
|
/** Those volumes by their claim, `namespace/name` (k3s image v0.1.2 and later). */
|
|
@@ -2116,6 +2153,11 @@ var ClusterHealthSchema = z6.object({
|
|
|
2116
2153
|
ingress: z6.boolean(),
|
|
2117
2154
|
/** k3s's own version: `v1.37.2+k3s1`. */
|
|
2118
2155
|
version: z6.string().optional(),
|
|
2156
|
+
/**
|
|
2157
|
+
* When the first of the master's own certificates ends (k3s image v0.1.5; #230). They last a year and
|
|
2158
|
+
* are renewed only when k3s starts within 120 days of that: a master that never restarts runs out.
|
|
2159
|
+
*/
|
|
2160
|
+
certificatesEndAt: z6.string().optional(),
|
|
2119
2161
|
nodes: z6.array(ClusterNodeSchema)
|
|
2120
2162
|
});
|
|
2121
2163
|
var CLUSTER_STATES = ["ready", "starting", "degraded", "down", "unknown"];
|
|
@@ -2167,8 +2209,8 @@ var ClusterSchema = z6.object({
|
|
|
2167
2209
|
*/
|
|
2168
2210
|
room: z6.object({ s: z6.number().int(), m: z6.number().int(), l: z6.number().int() }).nullable().optional(),
|
|
2169
2211
|
/**
|
|
2170
|
-
* What is changing it right now (one thing at a time); absent when nothing is. `since` is the
|
|
2171
|
-
*
|
|
2212
|
+
* What is changing it right now (one thing at a time); absent when nothing is. `since` is when the
|
|
2213
|
+
* change began, the same for as long as it goes on: a client tells its own change from the next by it.
|
|
2172
2214
|
*/
|
|
2173
2215
|
operation: z6.object({ what: z6.string(), since: z6.string() }).optional(),
|
|
2174
2216
|
/**
|
|
@@ -2865,6 +2907,17 @@ var Clusters = class {
|
|
|
2865
2907
|
restartNode(name, node, opts = {}) {
|
|
2866
2908
|
return this.transport.request("POST", cluster(name, `/nodes/${encodeURIComponent(node)}/restart`), ClusterSchema, { org: opts.org });
|
|
2867
2909
|
}
|
|
2910
|
+
/**
|
|
2911
|
+
* New credentials for the cluster, for when somebody who had them should no longer: every kubeconfig
|
|
2912
|
+
* handed out so far stops working (`kubeconfig` gives the new one), and so do the tokens its boxes join
|
|
2913
|
+
* with. Answered once the master has stored them; the master then restarts and every node after it,
|
|
2914
|
+
* together, so apps on the cluster are down for a few minutes (`waitUntilSettled` resolves when that is over, or throws what could not be done; the same
|
|
2915
|
+
* call starts over). Every box of the cluster must be running. What was made inside the cluster (a
|
|
2916
|
+
* service account's token) is not ended.
|
|
2917
|
+
*/
|
|
2918
|
+
rotate(name, opts = {}) {
|
|
2919
|
+
return this.transport.request("POST", cluster(name, "/rotate"), ClusterSchema, { org: opts.org });
|
|
2920
|
+
}
|
|
2868
2921
|
/** Remove the cluster: its nodes (undrained), its master and everything in it. Its backups stay listed. */
|
|
2869
2922
|
async remove(name, opts = {}) {
|
|
2870
2923
|
await this.transport.request("DELETE", cluster(name), z13.undefined(), { org: opts.org });
|
|
@@ -3001,7 +3054,7 @@ var Kvbox = class {
|
|
|
3001
3054
|
};
|
|
3002
3055
|
|
|
3003
3056
|
// src/client.ts
|
|
3004
|
-
import { z as
|
|
3057
|
+
import { z as z18 } from "zod";
|
|
3005
3058
|
|
|
3006
3059
|
// ../shared/src/cron.ts
|
|
3007
3060
|
import { z as z15 } from "zod";
|
|
@@ -3256,6 +3309,47 @@ var DeletedObjectsSchema = z16.object({
|
|
|
3256
3309
|
var MoveObjectRequest = z16.object({ from: z16.string(), to: z16.string(), overwrite: z16.boolean().optional() });
|
|
3257
3310
|
var CreateFolderRequest = z16.object({ prefix: z16.string() });
|
|
3258
3311
|
|
|
3312
|
+
// ../shared/src/registry.ts
|
|
3313
|
+
import { z as z17 } from "zod";
|
|
3314
|
+
var RegistrySchema = z17.object({
|
|
3315
|
+
owner: z17.string(),
|
|
3316
|
+
ownerKind: z17.enum(["user", "org"]),
|
|
3317
|
+
/** `cr-<slug>.<domain>`: what `docker login` and an image's name take (no scheme). Null while the address is not claimed. */
|
|
3318
|
+
address: z17.string().nullable(),
|
|
3319
|
+
/** The login's user name. */
|
|
3320
|
+
user: z17.string(),
|
|
3321
|
+
/** The most it may hold. */
|
|
3322
|
+
sizeGib: z17.number().int(),
|
|
3323
|
+
/** `running` when it answers; `unknown` while its host is not heard from. */
|
|
3324
|
+
status: BoxStatusSchema,
|
|
3325
|
+
/** With `?live=1` or on `GET /registry/info`, when the registry answered: what is on its disk, and the disk's real size. */
|
|
3326
|
+
usedBytes: z17.number().optional(),
|
|
3327
|
+
totalBytes: z17.number().optional(),
|
|
3328
|
+
/** The same, when it answered: every repository with how many tags it has. */
|
|
3329
|
+
repositories: z17.array(z17.object({ name: z17.string(), tags: z17.number().int() })).optional(),
|
|
3330
|
+
/** There are more repositories than `repositories` lists. */
|
|
3331
|
+
repositoriesTruncated: z17.boolean().optional(),
|
|
3332
|
+
/** zot's version, when it answered. */
|
|
3333
|
+
version: z17.string().optional(),
|
|
3334
|
+
host: z17.string(),
|
|
3335
|
+
country: z17.string().optional(),
|
|
3336
|
+
price: z17.object({ perMonth: z17.number(), currency: z17.string() }),
|
|
3337
|
+
createdBy: z17.string().nullable(),
|
|
3338
|
+
createdAt: z17.string()
|
|
3339
|
+
});
|
|
3340
|
+
var CreateRegistryRequest = z17.object({
|
|
3341
|
+
sizeGib: z17.number().int().optional(),
|
|
3342
|
+
near: z17.string().optional()
|
|
3343
|
+
});
|
|
3344
|
+
var RegistrySecretSchema = z17.object({
|
|
3345
|
+
address: z17.string().nullable(),
|
|
3346
|
+
user: z17.string(),
|
|
3347
|
+
password: z17.string()
|
|
3348
|
+
});
|
|
3349
|
+
var CreatedRegistrySchema = RegistrySchema.extend({ secret: RegistrySecretSchema, ready: z17.boolean() });
|
|
3350
|
+
var ResetRegistryPasswordRequest = z17.object({}).strict();
|
|
3351
|
+
var GrowRegistryRequest = z17.object({ sizeGib: z17.number().int() });
|
|
3352
|
+
|
|
3259
3353
|
// src/kvm.ts
|
|
3260
3354
|
import { accessSync, constants, readFileSync, statSync } from "fs";
|
|
3261
3355
|
import { userInfo } from "os";
|
|
@@ -3424,7 +3518,7 @@ var ServerClient = class {
|
|
|
3424
3518
|
* `all`: every box on the platform (platform admins only, #78).
|
|
3425
3519
|
*/
|
|
3426
3520
|
listMachines(opts = {}) {
|
|
3427
|
-
return this.call("GET", `/machines${allQuery(opts)}`,
|
|
3521
|
+
return this.call("GET", `/machines${allQuery(opts)}`, z18.array(MachineSchema), void 0, opts.org);
|
|
3428
3522
|
}
|
|
3429
3523
|
createMachine(req) {
|
|
3430
3524
|
return this.call("POST", "/machines", MachineSchema, req, void 0, req.fromBackup !== void 0 ? 2 * 36e5 : void 0);
|
|
@@ -3482,10 +3576,10 @@ var ServerClient = class {
|
|
|
3482
3576
|
}
|
|
3483
3577
|
/** Backups, the control plane's only: a box's disk in object storage. Newest first. */
|
|
3484
3578
|
listBackups() {
|
|
3485
|
-
return this.call("GET", "/backups",
|
|
3579
|
+
return this.call("GET", "/backups", z18.array(BackupSchema));
|
|
3486
3580
|
}
|
|
3487
3581
|
boxBackups(name) {
|
|
3488
|
-
return this.call("GET", `/machines/${encodeURIComponent(name)}/backups`,
|
|
3582
|
+
return this.call("GET", `/machines/${encodeURIComponent(name)}/backups`, z18.array(BackupSchema));
|
|
3489
3583
|
}
|
|
3490
3584
|
boxBackup(name, id) {
|
|
3491
3585
|
return this.call("GET", `/machines/${encodeURIComponent(name)}/backups/${encodeURIComponent(id)}`, BackupSchema);
|
|
@@ -3507,14 +3601,14 @@ var ServerClient = class {
|
|
|
3507
3601
|
* later. Works for a backup whose box, volume or database is gone too.
|
|
3508
3602
|
*/
|
|
3509
3603
|
removeBackup(id) {
|
|
3510
|
-
return this.call("DELETE", `/backups/${encodeURIComponent(id)}`,
|
|
3604
|
+
return this.call("DELETE", `/backups/${encodeURIComponent(id)}`, z18.undefined());
|
|
3511
3605
|
}
|
|
3512
3606
|
/** A volume's backups (#168): the same as a box's, of the volume's disk. Newest first. */
|
|
3513
3607
|
listVolumeBackups() {
|
|
3514
|
-
return this.call("GET", "/backups?kind=volume",
|
|
3608
|
+
return this.call("GET", "/backups?kind=volume", z18.array(VolumeBackupSchema));
|
|
3515
3609
|
}
|
|
3516
3610
|
volumeBackups(name) {
|
|
3517
|
-
return this.call("GET", `/volumes/${encodeURIComponent(name)}/backups`,
|
|
3611
|
+
return this.call("GET", `/volumes/${encodeURIComponent(name)}/backups`, z18.array(VolumeBackupSchema));
|
|
3518
3612
|
}
|
|
3519
3613
|
volumeBackup(name, id) {
|
|
3520
3614
|
return this.call("GET", `/volumes/${encodeURIComponent(name)}/backups/${encodeURIComponent(id)}`, VolumeBackupSchema);
|
|
@@ -3540,7 +3634,7 @@ var ServerClient = class {
|
|
|
3540
3634
|
}
|
|
3541
3635
|
/** Wake hooks (#101), the control plane's only: a URL and a secret that wake the box. */
|
|
3542
3636
|
boxHooks(name) {
|
|
3543
|
-
return this.call("GET", `/machines/${encodeURIComponent(name)}/hooks`,
|
|
3637
|
+
return this.call("GET", `/machines/${encodeURIComponent(name)}/hooks`, z18.array(WakeHookSchema));
|
|
3544
3638
|
}
|
|
3545
3639
|
createBoxHook(name) {
|
|
3546
3640
|
return this.call("POST", `/machines/${encodeURIComponent(name)}/hooks`, CreatedWakeHookSchema);
|
|
@@ -3568,7 +3662,7 @@ var ServerClient = class {
|
|
|
3568
3662
|
}
|
|
3569
3663
|
/** Every readable box's subdomains, one entry each. */
|
|
3570
3664
|
listSubdomains() {
|
|
3571
|
-
return this.call("GET", "/subdomains",
|
|
3665
|
+
return this.call("GET", "/subdomains", z18.array(SubdomainSchema));
|
|
3572
3666
|
}
|
|
3573
3667
|
/** Custom domains (#89), the control plane's only: serve the box at the user's own name. */
|
|
3574
3668
|
addDomain(name, req) {
|
|
@@ -3579,7 +3673,7 @@ var ServerClient = class {
|
|
|
3579
3673
|
}
|
|
3580
3674
|
/** Every readable box's custom domains. */
|
|
3581
3675
|
listDomains() {
|
|
3582
|
-
return this.call("GET", "/domains",
|
|
3676
|
+
return this.call("GET", "/domains", z18.array(DomainSchema));
|
|
3583
3677
|
}
|
|
3584
3678
|
/** A running box's own load, memory and disk, asked of its guest (#67). */
|
|
3585
3679
|
machineStats(name) {
|
|
@@ -3620,22 +3714,22 @@ var ServerClient = class {
|
|
|
3620
3714
|
return this.call("POST", "/billing/redeem", RedeemResponseSchema, { code });
|
|
3621
3715
|
}
|
|
3622
3716
|
deleteMachine(name) {
|
|
3623
|
-
return this.call("DELETE", `/machines/${encodeURIComponent(name)}`,
|
|
3717
|
+
return this.call("DELETE", `/machines/${encodeURIComponent(name)}`, z18.undefined());
|
|
3624
3718
|
}
|
|
3625
3719
|
/** Like `listMachines`, for snapshots. */
|
|
3626
3720
|
listSnapshots(opts = {}) {
|
|
3627
|
-
return this.call("GET", `/snapshots${allQuery(opts)}`,
|
|
3721
|
+
return this.call("GET", `/snapshots${allQuery(opts)}`, z18.array(SnapshotSchema), void 0, opts.org);
|
|
3628
3722
|
}
|
|
3629
3723
|
createSnapshot(req) {
|
|
3630
3724
|
return this.call("POST", "/snapshots", SnapshotSchema, req);
|
|
3631
3725
|
}
|
|
3632
3726
|
deleteSnapshot(name) {
|
|
3633
|
-
return this.call("DELETE", `/snapshots/${encodeURIComponent(name)}`,
|
|
3727
|
+
return this.call("DELETE", `/snapshots/${encodeURIComponent(name)}`, z18.undefined());
|
|
3634
3728
|
}
|
|
3635
3729
|
// ---- environment variables (#88), a control plane only: the caller's slug, or `--org`'s ----
|
|
3636
3730
|
/** `org`: that org's list instead of `--org`'s (or the caller's own). */
|
|
3637
3731
|
listEnv(org) {
|
|
3638
|
-
return this.call("GET", "/vars",
|
|
3732
|
+
return this.call("GET", "/vars", z18.array(EnvVarSchema), void 0, org);
|
|
3639
3733
|
}
|
|
3640
3734
|
setEnv(name, req) {
|
|
3641
3735
|
return this.call("PUT", `/vars/${encodeURIComponent(name)}`, EnvChangeSchema, req);
|
|
@@ -3655,13 +3749,13 @@ var ServerClient = class {
|
|
|
3655
3749
|
}
|
|
3656
3750
|
// ---- volumes (#52) ----
|
|
3657
3751
|
listVolumes(opts = {}) {
|
|
3658
|
-
return this.call("GET", `/volumes${allQuery(opts)}`,
|
|
3752
|
+
return this.call("GET", `/volumes${allQuery(opts)}`, z18.array(VolumeSchema), void 0, opts.org);
|
|
3659
3753
|
}
|
|
3660
3754
|
createVolume(req) {
|
|
3661
3755
|
return this.call("POST", "/volumes", VolumeSchema, req);
|
|
3662
3756
|
}
|
|
3663
3757
|
deleteVolume(name) {
|
|
3664
|
-
return this.call("DELETE", `/volumes/${encodeURIComponent(name)}`,
|
|
3758
|
+
return this.call("DELETE", `/volumes/${encodeURIComponent(name)}`, z18.undefined());
|
|
3665
3759
|
}
|
|
3666
3760
|
/** Both answer with the box as it is afterwards (restarted when it was running). */
|
|
3667
3761
|
attachVolume(name, req) {
|
|
@@ -3676,7 +3770,7 @@ var ServerClient = class {
|
|
|
3676
3770
|
}
|
|
3677
3771
|
// ---- cron service (#190): the control plane's alone ----
|
|
3678
3772
|
listCronServices(opts = {}) {
|
|
3679
|
-
return this.call("GET", `/cron${allQuery(opts)}`,
|
|
3773
|
+
return this.call("GET", `/cron${allQuery(opts)}`, z18.array(CronServiceSchema), void 0, opts.org);
|
|
3680
3774
|
}
|
|
3681
3775
|
createCronService(name) {
|
|
3682
3776
|
return this.call("POST", "/cron", CronServiceSchema, { name });
|
|
@@ -3685,10 +3779,10 @@ var ServerClient = class {
|
|
|
3685
3779
|
return this.call("GET", `/cron/${encodeURIComponent(name)}`, CronServiceSchema);
|
|
3686
3780
|
}
|
|
3687
3781
|
deleteCronService(name) {
|
|
3688
|
-
return this.call("DELETE", `/cron/${encodeURIComponent(name)}`,
|
|
3782
|
+
return this.call("DELETE", `/cron/${encodeURIComponent(name)}`, z18.undefined());
|
|
3689
3783
|
}
|
|
3690
3784
|
listCronTriggers(service) {
|
|
3691
|
-
return this.call("GET", `/cron/${encodeURIComponent(service)}/triggers`,
|
|
3785
|
+
return this.call("GET", `/cron/${encodeURIComponent(service)}/triggers`, z18.array(CronTriggerSchema));
|
|
3692
3786
|
}
|
|
3693
3787
|
addCronTrigger(service, req) {
|
|
3694
3788
|
return this.call("POST", `/cron/${encodeURIComponent(service)}/triggers`, CronTriggerSchema, req);
|
|
@@ -3698,18 +3792,18 @@ var ServerClient = class {
|
|
|
3698
3792
|
return this.call("PATCH", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}`, CronTriggerSchema, { enabled: enabled2 });
|
|
3699
3793
|
}
|
|
3700
3794
|
deleteCronTrigger(service, id) {
|
|
3701
|
-
return this.call("DELETE", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}`,
|
|
3795
|
+
return this.call("DELETE", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}`, z18.undefined());
|
|
3702
3796
|
}
|
|
3703
3797
|
/** Marks it due: kvbox-cron fires it within a few seconds. */
|
|
3704
3798
|
runCronTrigger(service, id) {
|
|
3705
3799
|
return this.call("POST", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}/run`, CronTriggerSchema);
|
|
3706
3800
|
}
|
|
3707
3801
|
listCronRuns(service, id, limit) {
|
|
3708
|
-
return this.call("GET", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}/runs${limit === void 0 ? "" : `?limit=${limit}`}`,
|
|
3802
|
+
return this.call("GET", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}/runs${limit === void 0 ? "" : `?limit=${limit}`}`, z18.array(CronRunSchema));
|
|
3709
3803
|
}
|
|
3710
3804
|
// ---- Kubernetes clusters (#216): the control plane's alone ----
|
|
3711
3805
|
listClusters(opts = {}) {
|
|
3712
|
-
return this.call("GET", `/k8s${allQuery(opts)}`,
|
|
3806
|
+
return this.call("GET", `/k8s${allQuery(opts)}`, z18.array(ClusterSchema), void 0, opts.org);
|
|
3713
3807
|
}
|
|
3714
3808
|
/** The master boots twice (its volume is attached after it is made), so this may take a minute. */
|
|
3715
3809
|
createCluster(req) {
|
|
@@ -3729,6 +3823,10 @@ var ServerClient = class {
|
|
|
3729
3823
|
restartClusterNode(cluster2, node) {
|
|
3730
3824
|
return this.call("POST", `/k8s/${encodeURIComponent(cluster2)}/nodes/${encodeURIComponent(node)}/restart`, ClusterSchema);
|
|
3731
3825
|
}
|
|
3826
|
+
/** New credentials for a cluster (#230): answered once its master has stored them, its boxes restart after. */
|
|
3827
|
+
rotateCluster(name) {
|
|
3828
|
+
return this.call("POST", `/k8s/${encodeURIComponent(name)}/rotate`, ClusterSchema);
|
|
3829
|
+
}
|
|
3732
3830
|
/** One more pool with its nodes (#217): each node is a box the host makes, so a few seconds a node. */
|
|
3733
3831
|
addPool(cluster2, req) {
|
|
3734
3832
|
return this.call("POST", `/k8s/${encodeURIComponent(cluster2)}/pools`, ClusterSchema, req);
|
|
@@ -3746,7 +3844,7 @@ var ServerClient = class {
|
|
|
3746
3844
|
}
|
|
3747
3845
|
/** A cluster's HTTPS addresses (#219): `kvbox.app` names and custom domains, all to its Traefik. */
|
|
3748
3846
|
listClusterSubdomains(cluster2) {
|
|
3749
|
-
return this.call("GET", `/k8s/${encodeURIComponent(cluster2)}/subdomains`,
|
|
3847
|
+
return this.call("GET", `/k8s/${encodeURIComponent(cluster2)}/subdomains`, z18.array(SubdomainSchema));
|
|
3750
3848
|
}
|
|
3751
3849
|
claimClusterSubdomain(cluster2, name) {
|
|
3752
3850
|
return this.call("POST", `/k8s/${encodeURIComponent(cluster2)}/subdomains`, SubdomainSchema, { name });
|
|
@@ -3755,7 +3853,7 @@ var ServerClient = class {
|
|
|
3755
3853
|
return this.call("DELETE", `/k8s/${encodeURIComponent(cluster2)}/subdomains/${encodeURIComponent(name)}`, SubdomainSchema);
|
|
3756
3854
|
}
|
|
3757
3855
|
listClusterDomains(cluster2) {
|
|
3758
|
-
return this.call("GET", `/k8s/${encodeURIComponent(cluster2)}/domains`,
|
|
3856
|
+
return this.call("GET", `/k8s/${encodeURIComponent(cluster2)}/domains`, z18.array(DomainSchema));
|
|
3759
3857
|
}
|
|
3760
3858
|
addClusterDomain(cluster2, domain) {
|
|
3761
3859
|
return this.call("POST", `/k8s/${encodeURIComponent(cluster2)}/domains`, DomainSchema, { domain });
|
|
@@ -3765,7 +3863,7 @@ var ServerClient = class {
|
|
|
3765
3863
|
}
|
|
3766
3864
|
/** What a cluster reaches (#220): a database or a box, from every one of its boxes. */
|
|
3767
3865
|
listClusterLinks(cluster2) {
|
|
3768
|
-
return this.call("GET", `/k8s/${encodeURIComponent(cluster2)}/links`,
|
|
3866
|
+
return this.call("GET", `/k8s/${encodeURIComponent(cluster2)}/links`, z18.array(ClusterLinkSchema));
|
|
3769
3867
|
}
|
|
3770
3868
|
linkCluster(cluster2, req) {
|
|
3771
3869
|
return this.call("POST", `/k8s/${encodeURIComponent(cluster2)}/links`, ClusterLinkSchema, req);
|
|
@@ -3775,10 +3873,10 @@ var ServerClient = class {
|
|
|
3775
3873
|
}
|
|
3776
3874
|
/** A cluster's backups (#221): its master's state, by the engine a database's uses. Every cluster's, removed ones' too. */
|
|
3777
3875
|
listClusterBackups() {
|
|
3778
|
-
return this.call("GET", "/backups?managed=k8s",
|
|
3876
|
+
return this.call("GET", "/backups?managed=k8s", z18.array(ManagedBackupSchema));
|
|
3779
3877
|
}
|
|
3780
3878
|
clusterBackups(cluster2) {
|
|
3781
|
-
return this.call("GET", `/k8s/${encodeURIComponent(cluster2)}/backups`,
|
|
3879
|
+
return this.call("GET", `/k8s/${encodeURIComponent(cluster2)}/backups`, z18.array(ManagedBackupSchema));
|
|
3782
3880
|
}
|
|
3783
3881
|
clusterBackup(cluster2, id) {
|
|
3784
3882
|
return this.call("GET", `/k8s/${encodeURIComponent(cluster2)}/backups/${encodeURIComponent(id)}`, ManagedBackupSchema);
|
|
@@ -3802,11 +3900,11 @@ var ServerClient = class {
|
|
|
3802
3900
|
return this.call("PUT", `/k8s/${encodeURIComponent(cluster2)}/backup-schedule`, BackupScheduleSchema, change);
|
|
3803
3901
|
}
|
|
3804
3902
|
deleteCluster(name) {
|
|
3805
|
-
return this.call("DELETE", `/k8s/${encodeURIComponent(name)}`,
|
|
3903
|
+
return this.call("DELETE", `/k8s/${encodeURIComponent(name)}`, z18.undefined());
|
|
3806
3904
|
}
|
|
3807
3905
|
// ---- object storage (#182): the control plane's alone ----
|
|
3808
3906
|
listBuckets(opts = {}) {
|
|
3809
|
-
return this.call("GET", `/buckets${allQuery(opts)}`,
|
|
3907
|
+
return this.call("GET", `/buckets${allQuery(opts)}`, z18.array(BucketSchema), void 0, opts.org);
|
|
3810
3908
|
}
|
|
3811
3909
|
/** The first bucket of a slug also makes its storage: a box boots twice, so this may take a couple of minutes. */
|
|
3812
3910
|
createBucket(req) {
|
|
@@ -3820,26 +3918,47 @@ var ServerClient = class {
|
|
|
3820
3918
|
return this.call("PUT", `/buckets/${encodeURIComponent(name)}/public`, BucketSchema, req);
|
|
3821
3919
|
}
|
|
3822
3920
|
deleteBucket(name, force = false) {
|
|
3823
|
-
return this.call("DELETE", `/buckets/${encodeURIComponent(name)}${force ? "?force=1" : ""}`,
|
|
3921
|
+
return this.call("DELETE", `/buckets/${encodeURIComponent(name)}${force ? "?force=1" : ""}`, z18.undefined());
|
|
3824
3922
|
}
|
|
3825
3923
|
listBucketKeys(name) {
|
|
3826
|
-
return this.call("GET", `/buckets/${encodeURIComponent(name)}/keys`,
|
|
3924
|
+
return this.call("GET", `/buckets/${encodeURIComponent(name)}/keys`, z18.array(BucketKeySchema));
|
|
3827
3925
|
}
|
|
3828
3926
|
createBucketKey(name, req) {
|
|
3829
3927
|
return this.call("POST", `/buckets/${encodeURIComponent(name)}/keys`, CreatedBucketKeySchema, req);
|
|
3830
3928
|
}
|
|
3831
3929
|
deleteBucketKey(name, id) {
|
|
3832
|
-
return this.call("DELETE", `/buckets/${encodeURIComponent(name)}/keys/${encodeURIComponent(id)}`,
|
|
3930
|
+
return this.call("DELETE", `/buckets/${encodeURIComponent(name)}/keys/${encodeURIComponent(id)}`, z18.undefined());
|
|
3833
3931
|
}
|
|
3834
3932
|
listStorage(opts = {}) {
|
|
3835
|
-
return this.call("GET", `/storage${allQuery(opts)}`,
|
|
3933
|
+
return this.call("GET", `/storage${allQuery(opts)}`, z18.array(ObjectStorageSchema), void 0, opts.org);
|
|
3836
3934
|
}
|
|
3837
3935
|
growStorage(sizeGib) {
|
|
3838
3936
|
return this.call("POST", "/storage/grow", ObjectStorageSchema, { sizeGib });
|
|
3839
3937
|
}
|
|
3938
|
+
// ---- the container registry (#234): control plane only, one per slug ----
|
|
3939
|
+
/** A hidden box boots twice (the volume's attach restarts it), so this may take a couple of minutes. */
|
|
3940
|
+
createRegistry(req) {
|
|
3941
|
+
return this.call("POST", "/registry", CreatedRegistrySchema, req);
|
|
3942
|
+
}
|
|
3943
|
+
/** The caller's (or `--org`'s) registry, with how full it is and its repositories when it answers. */
|
|
3944
|
+
registryInfo() {
|
|
3945
|
+
return this.call("GET", "/registry/info", RegistrySchema);
|
|
3946
|
+
}
|
|
3947
|
+
registryPassword() {
|
|
3948
|
+
return this.call("GET", "/registry/password", RegistrySecretSchema);
|
|
3949
|
+
}
|
|
3950
|
+
resetRegistryPassword() {
|
|
3951
|
+
return this.call("POST", "/registry/password", RegistrySecretSchema, {});
|
|
3952
|
+
}
|
|
3953
|
+
growRegistry(sizeGib) {
|
|
3954
|
+
return this.call("POST", "/registry/grow", RegistrySchema, { sizeGib });
|
|
3955
|
+
}
|
|
3956
|
+
deleteRegistry() {
|
|
3957
|
+
return this.call("DELETE", "/registry", z18.undefined());
|
|
3958
|
+
}
|
|
3840
3959
|
/** Backups of the slug's whole object storage (#186 slice 3), newest first. */
|
|
3841
3960
|
storageBackups() {
|
|
3842
|
-
return this.call("GET", "/storage/backups",
|
|
3961
|
+
return this.call("GET", "/storage/backups", z18.array(StorageBackupSchema));
|
|
3843
3962
|
}
|
|
3844
3963
|
storageBackup(id) {
|
|
3845
3964
|
return this.call("GET", `/storage/backups/${encodeURIComponent(id)}`, StorageBackupSchema);
|
|
@@ -3867,11 +3986,11 @@ var ServerClient = class {
|
|
|
3867
3986
|
return `/managed/${encodeURIComponent(kind)}${name === void 0 ? "" : `/${encodeURIComponent(name)}`}${rest}`;
|
|
3868
3987
|
}
|
|
3869
3988
|
managedCatalog() {
|
|
3870
|
-
return this.call("GET", "/managed/catalog",
|
|
3989
|
+
return this.call("GET", "/managed/catalog", z18.array(ManagedCatalogEntrySchema));
|
|
3871
3990
|
}
|
|
3872
3991
|
/** One kind's services, or every kind's when `kind` is left out. */
|
|
3873
3992
|
listManaged(kind, opts = {}) {
|
|
3874
|
-
return this.call("GET", `${kind === void 0 ? "/managed" : this.managedPath(kind)}${allQuery(opts)}`,
|
|
3993
|
+
return this.call("GET", `${kind === void 0 ? "/managed" : this.managedPath(kind)}${allQuery(opts)}`, z18.array(ManagedSchema), void 0, opts.org);
|
|
3875
3994
|
}
|
|
3876
3995
|
/** From a backup (`fromBackup`) it waits for the restore too: the control plane gives its host 2 h for the download. */
|
|
3877
3996
|
createManaged(kind, req) {
|
|
@@ -3882,7 +4001,7 @@ var ServerClient = class {
|
|
|
3882
4001
|
return this.call("GET", this.managedPath(kind, name), ManagedSchema);
|
|
3883
4002
|
}
|
|
3884
4003
|
deleteManaged(kind, name) {
|
|
3885
|
-
return this.call("DELETE", this.managedPath(kind, name),
|
|
4004
|
+
return this.call("DELETE", this.managedPath(kind, name), z18.undefined());
|
|
3886
4005
|
}
|
|
3887
4006
|
managedPassword(kind, name) {
|
|
3888
4007
|
return this.call("GET", this.managedPath(kind, name, "/password"), ManagedSecretSchema);
|
|
@@ -3904,10 +4023,10 @@ var ServerClient = class {
|
|
|
3904
4023
|
}
|
|
3905
4024
|
/** A managed service's backups (#186): its storage's, by the volume backup engine. Every one of a kind, those of removed services too. */
|
|
3906
4025
|
listManagedBackups(kind) {
|
|
3907
|
-
return this.call("GET", `/backups?managed=${encodeURIComponent(kind)}`,
|
|
4026
|
+
return this.call("GET", `/backups?managed=${encodeURIComponent(kind)}`, z18.array(ManagedBackupSchema));
|
|
3908
4027
|
}
|
|
3909
4028
|
managedBackups(kind, name) {
|
|
3910
|
-
return this.call("GET", this.managedPath(kind, name, "/backups"),
|
|
4029
|
+
return this.call("GET", this.managedPath(kind, name, "/backups"), z18.array(ManagedBackupSchema));
|
|
3911
4030
|
}
|
|
3912
4031
|
managedBackup(kind, name, id) {
|
|
3913
4032
|
return this.call("GET", this.managedPath(kind, name, `/backups/${encodeURIComponent(id)}`), ManagedBackupSchema);
|
|
@@ -3949,7 +4068,7 @@ var ServerClient = class {
|
|
|
3949
4068
|
return this.call("POST", "/login/device/token", DeviceLoginPollSchema, { deviceCode });
|
|
3950
4069
|
}
|
|
3951
4070
|
logout() {
|
|
3952
|
-
return this.call("POST", "/logout",
|
|
4071
|
+
return this.call("POST", "/logout", z18.unknown()).then(() => void 0);
|
|
3953
4072
|
}
|
|
3954
4073
|
me() {
|
|
3955
4074
|
return this.call("GET", "/me", MeResponseSchema);
|
|
@@ -3960,25 +4079,25 @@ var ServerClient = class {
|
|
|
3960
4079
|
* credential. Null: each readable slug whatever `--org` says, which is how the caller's own slug is read.
|
|
3961
4080
|
*/
|
|
3962
4081
|
listIntegrations(org) {
|
|
3963
|
-
return this.call("GET", "/integrations",
|
|
4082
|
+
return this.call("GET", "/integrations", z18.array(IntegrationSchema), void 0, org);
|
|
3964
4083
|
}
|
|
3965
4084
|
/** What can be connected on this control plane, and by which kind of slug. */
|
|
3966
4085
|
integrationCatalog() {
|
|
3967
|
-
return this.call("GET", "/integrations/catalog",
|
|
4086
|
+
return this.call("GET", "/integrations/catalog", z18.array(IntegrationCatalogEntrySchema), void 0, null);
|
|
3968
4087
|
}
|
|
3969
4088
|
// ---- API keys (`kvbox key …`, #189) ----
|
|
3970
4089
|
listApiKeys() {
|
|
3971
|
-
return this.call("GET", "/keys",
|
|
4090
|
+
return this.call("GET", "/keys", z18.array(ApiKeySchema));
|
|
3972
4091
|
}
|
|
3973
4092
|
createApiKey(req) {
|
|
3974
4093
|
return this.call("POST", "/keys", CreatedApiKeySchema, req);
|
|
3975
4094
|
}
|
|
3976
4095
|
deleteApiKey(name) {
|
|
3977
|
-
return this.call("DELETE", `/keys/${encodeURIComponent(name)}`,
|
|
4096
|
+
return this.call("DELETE", `/keys/${encodeURIComponent(name)}`, z18.unknown()).then(() => void 0);
|
|
3978
4097
|
}
|
|
3979
4098
|
// ---- orgs (`kvbox org …`) ----
|
|
3980
4099
|
listOrgs() {
|
|
3981
|
-
return this.call("GET", "/orgs",
|
|
4100
|
+
return this.call("GET", "/orgs", z18.array(OrgMembershipSchema));
|
|
3982
4101
|
}
|
|
3983
4102
|
createOrg(req) {
|
|
3984
4103
|
return this.call("POST", "/orgs", CloudOrgSchema, req);
|
|
@@ -3987,16 +4106,16 @@ var ServerClient = class {
|
|
|
3987
4106
|
return this.call("GET", `/orgs/${encodeURIComponent(slug)}`, OrgDetailSchema);
|
|
3988
4107
|
}
|
|
3989
4108
|
deleteOrg(slug) {
|
|
3990
|
-
return this.call("DELETE", `/orgs/${encodeURIComponent(slug)}`,
|
|
4109
|
+
return this.call("DELETE", `/orgs/${encodeURIComponent(slug)}`, z18.undefined());
|
|
3991
4110
|
}
|
|
3992
4111
|
addMember(slug, req) {
|
|
3993
|
-
return this.call("POST", `/orgs/${encodeURIComponent(slug)}/members`,
|
|
4112
|
+
return this.call("POST", `/orgs/${encodeURIComponent(slug)}/members`, z18.undefined(), req);
|
|
3994
4113
|
}
|
|
3995
4114
|
setRole(slug, username, role) {
|
|
3996
|
-
return this.call("PATCH", `/orgs/${encodeURIComponent(slug)}/members/${encodeURIComponent(username)}`,
|
|
4115
|
+
return this.call("PATCH", `/orgs/${encodeURIComponent(slug)}/members/${encodeURIComponent(username)}`, z18.unknown(), { role }).then(() => void 0);
|
|
3997
4116
|
}
|
|
3998
4117
|
removeMember(slug, username) {
|
|
3999
|
-
return this.call("DELETE", `/orgs/${encodeURIComponent(slug)}/members/${encodeURIComponent(username)}`,
|
|
4118
|
+
return this.call("DELETE", `/orgs/${encodeURIComponent(slug)}/members/${encodeURIComponent(username)}`, z18.undefined());
|
|
4000
4119
|
}
|
|
4001
4120
|
/** Sign this machine's key again (#51); the key must be one the user logged in with. */
|
|
4002
4121
|
sshCert(req) {
|
|
@@ -5057,6 +5176,16 @@ import { Command as Command12 } from "commander";
|
|
|
5057
5176
|
// ../shared/src/names.ts
|
|
5058
5177
|
import { createHmac } from "crypto";
|
|
5059
5178
|
var DEFAULT_PROXY_DOMAIN = "kvbox.app";
|
|
5179
|
+
var STORAGE_SUBDOMAIN_PREFIX = "s3-";
|
|
5180
|
+
var REGISTRY_SUBDOMAIN_PREFIX = "cr-";
|
|
5181
|
+
var KEPT_SUBDOMAIN_PREFIXES = [
|
|
5182
|
+
{ prefix: STORAGE_SUBDOMAIN_PREFIX, for: "object storage" },
|
|
5183
|
+
{ prefix: REGISTRY_SUBDOMAIN_PREFIX, for: "container registries" }
|
|
5184
|
+
];
|
|
5185
|
+
function keptPrefixOf(name) {
|
|
5186
|
+
const lower = name.trim().toLowerCase();
|
|
5187
|
+
return KEPT_SUBDOMAIN_PREFIXES.find((k) => lower.startsWith(k.prefix));
|
|
5188
|
+
}
|
|
5060
5189
|
var MAX_BOX_SUBDOMAINS = 5;
|
|
5061
5190
|
var LABEL_RE = /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/;
|
|
5062
5191
|
var RESERVED_SUBDOMAINS = /* @__PURE__ */ new Set([
|
|
@@ -6790,10 +6919,11 @@ var usageCommand2 = new Command64("usage").description("what your boxes and volu
|
|
|
6790
6919
|
info(`${day2(report.window.from)} to ${day2(report.window.to)}`);
|
|
6791
6920
|
const volumes = report.volumes ?? [];
|
|
6792
6921
|
const storage = report.storage ?? [];
|
|
6922
|
+
const registry = report.registry ?? [];
|
|
6793
6923
|
const cron = report.cron ?? [];
|
|
6794
6924
|
const clusters = report.clusters ?? [];
|
|
6795
6925
|
const backups = report.backups ?? [];
|
|
6796
|
-
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");
|
|
6926
|
+
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");
|
|
6797
6927
|
else if (report.boxes.length > 0) table(perUser ? userRows(perUser) : usageRows(report, cloud));
|
|
6798
6928
|
if (volumes.length > 0) {
|
|
6799
6929
|
info(volumes.length === 1 ? "1 volume" : `${volumes.length} volumes`);
|
|
@@ -6803,6 +6933,10 @@ var usageCommand2 = new Command64("usage").description("what your boxes and volu
|
|
|
6803
6933
|
info("object storage");
|
|
6804
6934
|
table(storageRows(report, cloud));
|
|
6805
6935
|
}
|
|
6936
|
+
if (registry.length > 0) {
|
|
6937
|
+
info("container registry");
|
|
6938
|
+
table(storageRows({ ...report, storage: registry }, cloud));
|
|
6939
|
+
}
|
|
6806
6940
|
if (cron.length > 0) {
|
|
6807
6941
|
info(cron.length === 1 ? "1 cron service" : `${cron.length} cron services`);
|
|
6808
6942
|
table(cronRows(report, cloud));
|
|
@@ -6816,8 +6950,8 @@ var usageCommand2 = new Command64("usage").description("what your boxes and volu
|
|
|
6816
6950
|
info(taken === 1 ? "1 paid backup" : `${taken} paid backups`);
|
|
6817
6951
|
table(backupRows(report, cloud));
|
|
6818
6952
|
}
|
|
6819
|
-
if ((volumes.length > 0 || storage.length > 0 || cron.length > 0 || clusters.length > 0 || backups.length > 0) && report.totals.cost !== void 0) {
|
|
6820
|
-
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"] : []];
|
|
6953
|
+
if ((volumes.length > 0 || storage.length > 0 || registry.length > 0 || cron.length > 0 || clusters.length > 0 || backups.length > 0) && report.totals.cost !== void 0) {
|
|
6954
|
+
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"] : []];
|
|
6821
6955
|
info(`total: ${money(report.totals.cost.amount, report.totals.cost.currency)} ${color.dim(`(${what.slice(0, -1).join(", ")} and ${what.at(-1)}, estimated)`)}`);
|
|
6822
6956
|
}
|
|
6823
6957
|
if (cloud) {
|
|
@@ -6977,7 +7111,7 @@ function byUser(report) {
|
|
|
6977
7111
|
return u;
|
|
6978
7112
|
});
|
|
6979
7113
|
users.sort((a, b) => a.user === null ? 1 : b.user === null ? -1 : a.user.localeCompare(b.user));
|
|
6980
|
-
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 };
|
|
7114
|
+
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 };
|
|
6981
7115
|
}
|
|
6982
7116
|
function userRows(r) {
|
|
6983
7117
|
const priced = r.totals.cost !== void 0;
|
|
@@ -7068,7 +7202,7 @@ import { Command as Command67, InvalidArgumentError as InvalidArgumentError2, Op
|
|
|
7068
7202
|
// src/commands/deploy/config.ts
|
|
7069
7203
|
import { readFile as readFile5, writeFile as writeFile3 } from "fs/promises";
|
|
7070
7204
|
import { isAbsolute, join as join6, normalize, relative as relative2 } from "path";
|
|
7071
|
-
import { z as
|
|
7205
|
+
import { z as z19 } from "zod";
|
|
7072
7206
|
|
|
7073
7207
|
// src/commands/deploy/templates/docker.ts
|
|
7074
7208
|
import { readFile as readFile4 } from "fs/promises";
|
|
@@ -7492,21 +7626,21 @@ function detectTemplates(pkg, dir = NO_FACTS) {
|
|
|
7492
7626
|
var DEPLOY_AUTO_HIBERNATE_SEC = 3600;
|
|
7493
7627
|
var CONFIG_FILE = "kvbox.json";
|
|
7494
7628
|
var BOX_NAME_RE = /^[a-z0-9][a-z0-9-]{0,11}$/;
|
|
7495
|
-
var DeployConfigSchema =
|
|
7496
|
-
template:
|
|
7497
|
-
name:
|
|
7629
|
+
var DeployConfigSchema = z19.object({
|
|
7630
|
+
template: z19.enum(TEMPLATE_IDS),
|
|
7631
|
+
name: z19.string().regex(BOX_NAME_RE, "1-12 chars, lowercase letters, digits and '-', starting with a letter or digit"),
|
|
7498
7632
|
/** The org whose box it is; absent for the user's own. */
|
|
7499
|
-
org:
|
|
7633
|
+
org: z19.string().regex(ORG_SLUG_RE, "not an org slug").optional(),
|
|
7500
7634
|
/** The HTTPS name (`<subdomain>.kvbox.app`); absent when deploying to this machine's own host. */
|
|
7501
|
-
subdomain:
|
|
7635
|
+
subdomain: z19.string().check((ctx) => {
|
|
7502
7636
|
const problem = subdomainProblem(ctx.value);
|
|
7503
7637
|
if (problem) ctx.issues.push({ code: "custom", message: problem, input: ctx.value });
|
|
7504
7638
|
}).optional(),
|
|
7505
|
-
size:
|
|
7639
|
+
size: z19.enum(SIZE_NAMES).optional(),
|
|
7506
7640
|
/** The build output directory, relative to the app; the template's default when absent. */
|
|
7507
|
-
dist:
|
|
7641
|
+
dist: z19.string().optional(),
|
|
7508
7642
|
/** The port a Next.js app or Node server serves; the template's (3000) when absent. */
|
|
7509
|
-
port:
|
|
7643
|
+
port: z19.number().int().min(1).max(65535).optional()
|
|
7510
7644
|
});
|
|
7511
7645
|
var SERVICE_KEY_RE = /^[a-z][a-z0-9-]{0,19}$/;
|
|
7512
7646
|
var RESERVED_SERVICE_KEYS = ["app", "agent", "init", "volumes"];
|
|
@@ -7518,38 +7652,38 @@ var POSTGRES_PORT = 5432;
|
|
|
7518
7652
|
var POSTGRES_IMAGE = "postgres:17";
|
|
7519
7653
|
var POSTGRES_ENV = "DATABASE_URL";
|
|
7520
7654
|
var IMAGE_RE = /^[a-z0-9][a-z0-9._/:@-]*$/;
|
|
7521
|
-
var ServiceSchema =
|
|
7522
|
-
template:
|
|
7655
|
+
var ServiceSchema = z19.strictObject({
|
|
7656
|
+
template: z19.enum([...TEMPLATE_IDS, POSTGRES]),
|
|
7523
7657
|
/** The service's directory, relative to the one holding kvbox.json; every template but postgres has one. */
|
|
7524
|
-
dir:
|
|
7658
|
+
dir: z19.string().min(1).optional(),
|
|
7525
7659
|
/** A postgres service's image, `postgres:17` when absent (`pgvector/pgvector:pg17` for vectors). */
|
|
7526
|
-
image:
|
|
7660
|
+
image: z19.string().regex(IMAGE_RE, "an image name like postgres:17").optional(),
|
|
7527
7661
|
/** The volume (a key of `volumes`) a postgres service keeps its data on. */
|
|
7528
|
-
volume:
|
|
7662
|
+
volume: z19.string().optional(),
|
|
7529
7663
|
/** The box variable a postgres service's URL is written to, `DATABASE_URL` when absent. */
|
|
7530
|
-
env:
|
|
7664
|
+
env: z19.string().optional(),
|
|
7531
7665
|
/** 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`. */
|
|
7532
|
-
context:
|
|
7533
|
-
dist:
|
|
7666
|
+
context: z19.string().min(1).optional(),
|
|
7667
|
+
dist: z19.string().optional(),
|
|
7534
7668
|
/**
|
|
7535
7669
|
* A command run once per deploy in the service's new version (a docker service: in a container of
|
|
7536
7670
|
* the new image; node, nextjs: in the new source, installed and built), with the box's variables,
|
|
7537
7671
|
* before it replaces the running one. Migrations, mostly. A failing one stops that service's deploy.
|
|
7538
7672
|
*/
|
|
7539
|
-
release:
|
|
7673
|
+
release: z19.string().optional(),
|
|
7540
7674
|
/** The box port of a service with its own server; the template's (3000) when absent. */
|
|
7541
|
-
port:
|
|
7675
|
+
port: z19.number().int().min(1).max(65535).optional(),
|
|
7542
7676
|
/** The URL paths that go to this service, each with everything under it; the prefix is kept. */
|
|
7543
|
-
paths:
|
|
7677
|
+
paths: z19.array(z19.string().regex(ROUTE_RE, "a path like / or /api, no trailing slash")).min(1).optional()
|
|
7544
7678
|
});
|
|
7545
|
-
var StackConfigSchema =
|
|
7679
|
+
var StackConfigSchema = z19.strictObject({
|
|
7546
7680
|
name: DeployConfigSchema.shape.name.optional(),
|
|
7547
7681
|
org: DeployConfigSchema.shape.org,
|
|
7548
7682
|
subdomain: DeployConfigSchema.shape.subdomain,
|
|
7549
7683
|
size: DeployConfigSchema.shape.size,
|
|
7550
7684
|
/** The stack's volumes, name to size ("10GB"): made for its box and attached to it on the first deploy that needs one. */
|
|
7551
|
-
volumes:
|
|
7552
|
-
services:
|
|
7685
|
+
volumes: z19.record(z19.string(), z19.string()).optional(),
|
|
7686
|
+
services: z19.record(z19.string(), ServiceSchema)
|
|
7553
7687
|
});
|
|
7554
7688
|
function volumeGib(text2) {
|
|
7555
7689
|
const mib2 = parseMib(text2);
|
|
@@ -7676,6 +7810,8 @@ function nameFromDir(dirName) {
|
|
|
7676
7810
|
return slug === "" ? "app" : slug;
|
|
7677
7811
|
}
|
|
7678
7812
|
function subdomainFor(name) {
|
|
7813
|
+
const kept = keptPrefixOf(name);
|
|
7814
|
+
if (kept) return subdomainFor(name.slice(kept.prefix.length) || "app");
|
|
7679
7815
|
return subdomainProblem(name) === null ? name : `${name}-site`;
|
|
7680
7816
|
}
|
|
7681
7817
|
|
|
@@ -8456,7 +8592,9 @@ async function settle2(dir, pkg, facts, saved, opts, orgFlag, cloud) {
|
|
|
8456
8592
|
default: subdomainFor(name),
|
|
8457
8593
|
validate: (a) => {
|
|
8458
8594
|
const problem = subdomainProblem(a);
|
|
8459
|
-
|
|
8595
|
+
if (problem) return `that name ${problem}`;
|
|
8596
|
+
const kept = keptPrefixOf(a);
|
|
8597
|
+
return kept ? `names starting with ${kept.prefix} are kept for ${kept.for}` : void 0;
|
|
8460
8598
|
}
|
|
8461
8599
|
});
|
|
8462
8600
|
info(` ${color.dim(`https://${subdomain}.kvbox.app`)}`);
|
|
@@ -9163,14 +9301,158 @@ for (const cmd of bucketCommand.commands) {
|
|
|
9163
9301
|
else withOrg2(cmd);
|
|
9164
9302
|
}
|
|
9165
9303
|
|
|
9304
|
+
// src/commands/registry/index.ts
|
|
9305
|
+
import { Command as Command103 } from "commander";
|
|
9306
|
+
|
|
9307
|
+
// src/commands/registry/create.ts
|
|
9308
|
+
import { Command as Command98 } from "commander";
|
|
9309
|
+
|
|
9310
|
+
// src/commands/registry/shared.ts
|
|
9311
|
+
async function registryClient(cmd) {
|
|
9312
|
+
const client = await clientFor(cmd.optsWithGlobals());
|
|
9313
|
+
if (client.target.kind !== "cloud") {
|
|
9314
|
+
await client.close();
|
|
9315
|
+
throw new KvboxError("the container registry runs on the kvbox cloud: kvbox login first (this host's own socket has none)");
|
|
9316
|
+
}
|
|
9317
|
+
return client;
|
|
9318
|
+
}
|
|
9319
|
+
var fullness2 = (r) => r.usedBytes !== void 0 ? `${gb(r.usedBytes)} of ${r.sizeGib} GB used` : `${r.sizeGib} GB`;
|
|
9320
|
+
var nearlyFull2 = (r) => r.usedBytes !== void 0 && r.totalBytes !== void 0 && r.totalBytes > 0 && r.usedBytes / r.totalBytes >= 0.9;
|
|
9321
|
+
var priceText2 = (r) => `${money(r.price.perMonth, r.price.currency)} a month ${color.dim("(estimated)")}`;
|
|
9322
|
+
var addressText = (address2) => address2 ?? color.yellow("no address yet (asked for again at the next kvbox registry info)");
|
|
9323
|
+
function loginLines(secret) {
|
|
9324
|
+
if (secret.address === null) return [];
|
|
9325
|
+
return [`docker login ${secret.address} -u ${secret.user}`, `docker tag myapp ${secret.address}/myapp:1.0`, `docker push ${secret.address}/myapp:1.0`];
|
|
9326
|
+
}
|
|
9327
|
+
function printRows2(rows2) {
|
|
9328
|
+
const width2 = Math.max(...rows2.map(([label]) => label.length));
|
|
9329
|
+
for (const [label, value] of rows2) process.stdout.write(`${color.dim(label.padEnd(width2))} ${value}
|
|
9330
|
+
`);
|
|
9331
|
+
}
|
|
9332
|
+
|
|
9333
|
+
// src/commands/registry/create.ts
|
|
9334
|
+
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) => {
|
|
9335
|
+
const sizeGib = opts.size === void 0 ? void 0 : parseGib2(opts.size);
|
|
9336
|
+
const client = await registryClient(cmd);
|
|
9337
|
+
try {
|
|
9338
|
+
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 } : {} }));
|
|
9339
|
+
if (opts.json) {
|
|
9340
|
+
json(made);
|
|
9341
|
+
return;
|
|
9342
|
+
}
|
|
9343
|
+
info(`${color.green("\u2713")} container registry made for ${color.bold(made.owner)}: ${made.sizeGib} GB, ${priceText2(made)}`);
|
|
9344
|
+
printRows2([
|
|
9345
|
+
["address", addressText(made.secret.address)],
|
|
9346
|
+
["user", made.secret.user],
|
|
9347
|
+
["password", made.secret.password]
|
|
9348
|
+
]);
|
|
9349
|
+
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)"));
|
|
9350
|
+
const lines = loginLines(made.secret);
|
|
9351
|
+
if (lines.length > 0) info(color.dim(`
|
|
9352
|
+
${lines.join("\n")}`));
|
|
9353
|
+
info(color.dim("the password is shown again by: kvbox registry password"));
|
|
9354
|
+
} finally {
|
|
9355
|
+
await client.close();
|
|
9356
|
+
}
|
|
9357
|
+
});
|
|
9358
|
+
|
|
9359
|
+
// src/commands/registry/grow.ts
|
|
9360
|
+
import { Command as Command99 } from "commander";
|
|
9361
|
+
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) => {
|
|
9362
|
+
const sizeGib = parseGib2(size, "size");
|
|
9363
|
+
const client = await registryClient(cmd);
|
|
9364
|
+
try {
|
|
9365
|
+
const r = await spin(`growing your container registry to ${sizeGib} GB\u2026`, client.growRegistry(sizeGib));
|
|
9366
|
+
if (opts.json) json(r);
|
|
9367
|
+
else info(`${color.green("\u2713")} the container registry of ${r.owner} is ${r.sizeGib} GB, ${priceText2(r)}`);
|
|
9368
|
+
} finally {
|
|
9369
|
+
await client.close();
|
|
9370
|
+
}
|
|
9371
|
+
});
|
|
9372
|
+
|
|
9373
|
+
// src/commands/registry/info.ts
|
|
9374
|
+
import { Command as Command100 } from "commander";
|
|
9375
|
+
var SHOWN_REPOSITORIES = 20;
|
|
9376
|
+
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) => {
|
|
9377
|
+
const client = await registryClient(cmd);
|
|
9378
|
+
try {
|
|
9379
|
+
const r = await client.registryInfo();
|
|
9380
|
+
if (opts.json) {
|
|
9381
|
+
json(r);
|
|
9382
|
+
return;
|
|
9383
|
+
}
|
|
9384
|
+
const repos = r.repositories;
|
|
9385
|
+
const rows2 = [
|
|
9386
|
+
["owner", color.bold(r.owner)],
|
|
9387
|
+
["address", addressText(r.address)],
|
|
9388
|
+
["user", `${r.user} ${color.dim("(password: kvbox registry password)")}`],
|
|
9389
|
+
["status", r.status === "running" ? repos === void 0 ? color.dim("running, not answering yet") : "running" : r.status],
|
|
9390
|
+
["size", `${fullness2(r)}${nearlyFull2(r) ? color.yellow(" almost full: kvbox registry grow <GB>") : ""}`],
|
|
9391
|
+
["holds", repos === void 0 ? color.dim("unknown") : repos.length === 0 ? color.dim("nothing yet") : `${repos.length}${r.repositoriesTruncated ? "+" : ""} ${repos.length === 1 ? "repository" : "repositories"}`],
|
|
9392
|
+
["cost", priceText2(r)],
|
|
9393
|
+
["created", `${age(r.createdAt)}${r.createdBy ? ` by ${r.createdBy}` : ""}`]
|
|
9394
|
+
];
|
|
9395
|
+
printRows2(rows2);
|
|
9396
|
+
for (const repo of (repos ?? []).slice(0, SHOWN_REPOSITORIES)) info(` ${repo.name} ${color.dim(`${repo.tags} ${repo.tags === 1 ? "tag" : "tags"}`)}`);
|
|
9397
|
+
if (repos !== void 0 && repos.length > SHOWN_REPOSITORIES) info(color.dim(` and ${repos.length - SHOWN_REPOSITORIES} more (--json lists them all)`));
|
|
9398
|
+
const lines = loginLines(r);
|
|
9399
|
+
if (lines.length > 0) info(color.dim(`
|
|
9400
|
+
${lines.join("\n")}`));
|
|
9401
|
+
} finally {
|
|
9402
|
+
await client.close();
|
|
9403
|
+
}
|
|
9404
|
+
});
|
|
9405
|
+
|
|
9406
|
+
// src/commands/registry/password.ts
|
|
9407
|
+
import { Command as Command101 } from "commander";
|
|
9408
|
+
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) => {
|
|
9409
|
+
const client = await registryClient(cmd);
|
|
9410
|
+
try {
|
|
9411
|
+
const secret = opts.reset ? await spin("setting a new password on your container registry\u2026", client.resetRegistryPassword()) : await client.registryPassword();
|
|
9412
|
+
if (opts.json) {
|
|
9413
|
+
json(secret);
|
|
9414
|
+
return;
|
|
9415
|
+
}
|
|
9416
|
+
if (opts.reset) info(`${color.green("\u2713")} your container registry has a new password; the old one no longer works`);
|
|
9417
|
+
printRows2([
|
|
9418
|
+
["address", addressText(secret.address)],
|
|
9419
|
+
["user", secret.user],
|
|
9420
|
+
["password", secret.password]
|
|
9421
|
+
]);
|
|
9422
|
+
} finally {
|
|
9423
|
+
await client.close();
|
|
9424
|
+
}
|
|
9425
|
+
});
|
|
9426
|
+
|
|
9427
|
+
// src/commands/registry/rm.ts
|
|
9428
|
+
import { Command as Command102 } from "commander";
|
|
9429
|
+
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) => {
|
|
9430
|
+
const client = await registryClient(cmd);
|
|
9431
|
+
try {
|
|
9432
|
+
if (!await confirm("Delete your container registry with every image in it?", opts.yes ?? false)) {
|
|
9433
|
+
info("cancelled");
|
|
9434
|
+
process.exitCode = 1;
|
|
9435
|
+
return;
|
|
9436
|
+
}
|
|
9437
|
+
await spin("deleting your container registry\u2026", client.deleteRegistry());
|
|
9438
|
+
info(`${color.green("\u2713")} container registry deleted ${color.dim("(no longer charged)")}`);
|
|
9439
|
+
} finally {
|
|
9440
|
+
await client.close();
|
|
9441
|
+
}
|
|
9442
|
+
});
|
|
9443
|
+
|
|
9444
|
+
// src/commands/registry/index.ts
|
|
9445
|
+
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);
|
|
9446
|
+
for (const cmd of registryCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal registry)");
|
|
9447
|
+
|
|
9166
9448
|
// src/commands/k8s/index.ts
|
|
9167
|
-
import { Command as
|
|
9449
|
+
import { Command as Command135 } from "commander";
|
|
9168
9450
|
|
|
9169
9451
|
// src/commands/k8s/backup/index.ts
|
|
9170
|
-
import { Command as
|
|
9452
|
+
import { Command as Command109 } from "commander";
|
|
9171
9453
|
|
|
9172
9454
|
// src/commands/k8s/backup/create.ts
|
|
9173
|
-
import { Command as
|
|
9455
|
+
import { Command as Command104 } from "commander";
|
|
9174
9456
|
|
|
9175
9457
|
// src/commands/k8s/shared.ts
|
|
9176
9458
|
async function k8sClient(cmd) {
|
|
@@ -9186,14 +9468,14 @@ function shownName2(c2, client) {
|
|
|
9186
9468
|
return c2.owner === context ? c2.name : `${c2.owner}/${c2.name}`;
|
|
9187
9469
|
}
|
|
9188
9470
|
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}`;
|
|
9189
|
-
function
|
|
9471
|
+
function priceText3(c2) {
|
|
9190
9472
|
const { perMonth, nodesPerMonth, totalPerMonth, currency } = c2.price;
|
|
9191
9473
|
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`;
|
|
9192
9474
|
const nodes = c2.pools.reduce((n2, p) => n2 + p.boxes.length, 0);
|
|
9193
9475
|
return `${money(totalPerMonth, currency)} a month ${color.dim(`(estimated: ${money(perMonth, currency)} the cluster itself, ${money(nodesPerMonth, currency)} its ${nodes === 1 ? "node" : `${nodes} nodes`})`)}`;
|
|
9194
9476
|
}
|
|
9195
9477
|
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(", ");
|
|
9196
|
-
function
|
|
9478
|
+
function printRows3(rows2) {
|
|
9197
9479
|
const width2 = Math.max(...rows2.map(([label]) => label.length));
|
|
9198
9480
|
for (const [label, value] of rows2) process.stdout.write(`${color.dim(label.padEnd(width2))} ${value}
|
|
9199
9481
|
`);
|
|
@@ -9222,7 +9504,7 @@ function nodeCount(text2) {
|
|
|
9222
9504
|
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)")}`;
|
|
9223
9505
|
|
|
9224
9506
|
// src/commands/k8s/backup/create.ts
|
|
9225
|
-
var
|
|
9507
|
+
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) => {
|
|
9226
9508
|
const client = await k8sClient(cmd);
|
|
9227
9509
|
const ls = `kvbox k8s backup ls ${name}`;
|
|
9228
9510
|
try {
|
|
@@ -9249,8 +9531,8 @@ var createCommand9 = new Command98("create").description("back up what a cluster
|
|
|
9249
9531
|
});
|
|
9250
9532
|
|
|
9251
9533
|
// src/commands/k8s/backup/ls.ts
|
|
9252
|
-
import { Command as
|
|
9253
|
-
var lsCommand15 = new
|
|
9534
|
+
import { Command as Command105 } from "commander";
|
|
9535
|
+
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) => {
|
|
9254
9536
|
const client = await k8sClient(cmd);
|
|
9255
9537
|
const removedOnes = async (err, name2) => {
|
|
9256
9538
|
if (!(err instanceof CallError && err.status === 404)) throw err;
|
|
@@ -9296,8 +9578,8 @@ var lsCommand15 = new Command99("ls").alias("list").description("list backups: e
|
|
|
9296
9578
|
});
|
|
9297
9579
|
|
|
9298
9580
|
// src/commands/k8s/backup/restore.ts
|
|
9299
|
-
import { Command as
|
|
9300
|
-
var restoreCommand4 = new
|
|
9581
|
+
import { Command as Command106 } from "commander";
|
|
9582
|
+
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) => {
|
|
9301
9583
|
const client = await k8sClient(cmd);
|
|
9302
9584
|
try {
|
|
9303
9585
|
const backup = await client.clusterBackup(name, id);
|
|
@@ -9328,8 +9610,8 @@ var restoreCommand4 = new Command100("restore").description("put a backup back:
|
|
|
9328
9610
|
});
|
|
9329
9611
|
|
|
9330
9612
|
// src/commands/k8s/backup/rm.ts
|
|
9331
|
-
import { Command as
|
|
9332
|
-
var
|
|
9613
|
+
import { Command as Command107 } from "commander";
|
|
9614
|
+
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) => {
|
|
9333
9615
|
const client = await k8sClient(cmd);
|
|
9334
9616
|
try {
|
|
9335
9617
|
await removeListed(client, await client.listClusterBackups(), (b) => b.name, name, id, `cluster ${name}`, opts.yes ?? false);
|
|
@@ -9339,8 +9621,8 @@ var rmCommand14 = new Command101("rm").alias("remove").description("remove a bac
|
|
|
9339
9621
|
});
|
|
9340
9622
|
|
|
9341
9623
|
// src/commands/k8s/backup/schedule.ts
|
|
9342
|
-
import { Command as
|
|
9343
|
-
var scheduleCommand4 = scheduleFlags(new
|
|
9624
|
+
import { Command as Command108 } from "commander";
|
|
9625
|
+
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(
|
|
9344
9626
|
async (name, flags, cmd) => {
|
|
9345
9627
|
const change = changeOf(flags);
|
|
9346
9628
|
const client = await k8sClient(cmd);
|
|
@@ -9355,11 +9637,11 @@ var scheduleCommand4 = scheduleFlags(new Command102("schedule").description("sho
|
|
|
9355
9637
|
);
|
|
9356
9638
|
|
|
9357
9639
|
// src/commands/k8s/backup/index.ts
|
|
9358
|
-
var backupCommand4 = new
|
|
9640
|
+
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);
|
|
9359
9641
|
|
|
9360
9642
|
// src/commands/k8s/create.ts
|
|
9361
|
-
import { Command as
|
|
9362
|
-
var
|
|
9643
|
+
import { Command as Command110 } from "commander";
|
|
9644
|
+
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) => {
|
|
9363
9645
|
if (!NODE_SIZES.includes(opts.size)) throw new KvboxError(`--size ${opts.size}: a node is one of ${NODE_SIZES.join(", ")}`);
|
|
9364
9646
|
const nodes = nodeCount(opts.nodes);
|
|
9365
9647
|
const client = await k8sClient(cmd);
|
|
@@ -9371,7 +9653,7 @@ var createCommand10 = new Command104("create").description("make a Kubernetes cl
|
|
|
9371
9653
|
return;
|
|
9372
9654
|
}
|
|
9373
9655
|
const shown = shownName2(cluster2, client);
|
|
9374
|
-
info(`${color.green("\u2713")} cluster ${color.bold(shown)} made on ${cluster2.host}: Kubernetes ${cluster2.version}, ${
|
|
9656
|
+
info(`${color.green("\u2713")} cluster ${color.bold(shown)} made on ${cluster2.host}: Kubernetes ${cluster2.version}, ${priceText3(cluster2)}`);
|
|
9375
9657
|
info(` API: ${apiText(cluster2)}`);
|
|
9376
9658
|
info(` nodes: ${poolsText(cluster2)}`);
|
|
9377
9659
|
if (opts.wait && !allReady(cluster2)) warn(`it is not all ready yet; look again with: kvbox k8s info ${shown}`);
|
|
@@ -9382,10 +9664,10 @@ var createCommand10 = new Command104("create").description("make a Kubernetes cl
|
|
|
9382
9664
|
});
|
|
9383
9665
|
|
|
9384
9666
|
// src/commands/k8s/domain/index.ts
|
|
9385
|
-
import { Command as
|
|
9667
|
+
import { Command as Command114 } from "commander";
|
|
9386
9668
|
|
|
9387
9669
|
// src/commands/k8s/domain/add.ts
|
|
9388
|
-
import { Command as
|
|
9670
|
+
import { Command as Command111 } from "commander";
|
|
9389
9671
|
|
|
9390
9672
|
// src/commands/domain/shared.ts
|
|
9391
9673
|
function requireCloud4(client) {
|
|
@@ -9406,7 +9688,7 @@ function hostIn(name, zone) {
|
|
|
9406
9688
|
|
|
9407
9689
|
// src/commands/k8s/domain/add.ts
|
|
9408
9690
|
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 });
|
|
9409
|
-
var addCommand3 = new
|
|
9691
|
+
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) => {
|
|
9410
9692
|
const domain = assertDomain(domainArg.trim().toLowerCase());
|
|
9411
9693
|
const client = await k8sClient(cmd);
|
|
9412
9694
|
try {
|
|
@@ -9443,8 +9725,8 @@ kvbox checks every minute; ${domain} is served at ${d.url} once its records are
|
|
|
9443
9725
|
});
|
|
9444
9726
|
|
|
9445
9727
|
// src/commands/k8s/domain/ls.ts
|
|
9446
|
-
import { Command as
|
|
9447
|
-
var lsCommand16 = new
|
|
9728
|
+
import { Command as Command112 } from "commander";
|
|
9729
|
+
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) => {
|
|
9448
9730
|
const client = await k8sClient(cmd);
|
|
9449
9731
|
try {
|
|
9450
9732
|
const domains = await client.listClusterDomains(cluster2);
|
|
@@ -9463,8 +9745,8 @@ var lsCommand16 = new Command106("ls").alias("list").description("list a cluster
|
|
|
9463
9745
|
});
|
|
9464
9746
|
|
|
9465
9747
|
// src/commands/k8s/domain/rm.ts
|
|
9466
|
-
import { Command as
|
|
9467
|
-
var
|
|
9748
|
+
import { Command as Command113 } from "commander";
|
|
9749
|
+
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) => {
|
|
9468
9750
|
const domain = domainArg.trim().toLowerCase();
|
|
9469
9751
|
const client = await k8sClient(cmd);
|
|
9470
9752
|
try {
|
|
@@ -9481,11 +9763,11 @@ var rmCommand15 = new Command107("rm").alias("remove").description("stop serving
|
|
|
9481
9763
|
});
|
|
9482
9764
|
|
|
9483
9765
|
// src/commands/k8s/domain/index.ts
|
|
9484
|
-
var domainCommand = new
|
|
9766
|
+
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);
|
|
9485
9767
|
|
|
9486
9768
|
// src/commands/k8s/info.ts
|
|
9487
|
-
import { Command as
|
|
9488
|
-
var
|
|
9769
|
+
import { Command as Command115 } from "commander";
|
|
9770
|
+
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) => {
|
|
9489
9771
|
const client = await k8sClient(cmd);
|
|
9490
9772
|
try {
|
|
9491
9773
|
const c2 = await client.getCluster(name);
|
|
@@ -9516,18 +9798,18 @@ var infoCommand2 = new Command109("info").description("one cluster: its API addr
|
|
|
9516
9798
|
...c2.backupSchedule ? [["backups", scheduleLine(`kvbox k8s backup schedule ${shown}`, c2.backupSchedule)]] : [],
|
|
9517
9799
|
["host", `${c2.host}${c2.country ? ` (${c2.country})` : ""}`],
|
|
9518
9800
|
...c2.room ? [["room", roomText(c2.room)]] : [],
|
|
9519
|
-
["cost",
|
|
9801
|
+
["cost", priceText3(c2)],
|
|
9520
9802
|
["created", `${age(c2.createdAt)}${c2.createdBy ? ` by ${c2.createdBy}` : ""}`]
|
|
9521
9803
|
];
|
|
9522
|
-
|
|
9804
|
+
printRows3(rows2);
|
|
9523
9805
|
} finally {
|
|
9524
9806
|
await client.close();
|
|
9525
9807
|
}
|
|
9526
9808
|
});
|
|
9527
9809
|
|
|
9528
9810
|
// src/commands/k8s/kubeconfig.ts
|
|
9529
|
-
import { Command as
|
|
9530
|
-
var kubeconfigCommand = new
|
|
9811
|
+
import { Command as Command116 } from "commander";
|
|
9812
|
+
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) => {
|
|
9531
9813
|
const client = await k8sClient(cmd);
|
|
9532
9814
|
try {
|
|
9533
9815
|
const made = await client.getKubeconfig(name);
|
|
@@ -9540,10 +9822,10 @@ var kubeconfigCommand = new Command110("kubeconfig").description("print the clus
|
|
|
9540
9822
|
});
|
|
9541
9823
|
|
|
9542
9824
|
// src/commands/k8s/link.ts
|
|
9543
|
-
import { Command as
|
|
9825
|
+
import { Command as Command117 } from "commander";
|
|
9544
9826
|
var reachedText = (l) => `${l.kind} ${l.to}`;
|
|
9545
9827
|
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 } : {} });
|
|
9546
|
-
var linkCommand2 = new
|
|
9828
|
+
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) => {
|
|
9547
9829
|
const port = opts.port === void 0 ? void 0 : parseLinkPort(opts.port);
|
|
9548
9830
|
const client = await k8sClient(cmd);
|
|
9549
9831
|
try {
|
|
@@ -9561,8 +9843,8 @@ var linkCommand2 = new Command111("link").description("let every pod of a cluste
|
|
|
9561
9843
|
});
|
|
9562
9844
|
|
|
9563
9845
|
// src/commands/k8s/links.ts
|
|
9564
|
-
import { Command as
|
|
9565
|
-
var linksCommand2 = new
|
|
9846
|
+
import { Command as Command118 } from "commander";
|
|
9847
|
+
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) => {
|
|
9566
9848
|
const client = await k8sClient(cmd);
|
|
9567
9849
|
try {
|
|
9568
9850
|
const links = await client.listClusterLinks(cluster2);
|
|
@@ -9578,8 +9860,8 @@ var linksCommand2 = new Command112("links").description("list what a cluster rea
|
|
|
9578
9860
|
});
|
|
9579
9861
|
|
|
9580
9862
|
// src/commands/k8s/ls.ts
|
|
9581
|
-
import { Command as
|
|
9582
|
-
var lsCommand17 = new
|
|
9863
|
+
import { Command as Command119 } from "commander";
|
|
9864
|
+
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) => {
|
|
9583
9865
|
const client = await k8sClient(cmd);
|
|
9584
9866
|
try {
|
|
9585
9867
|
const clusters = await client.listClusters({ all: opts.all });
|
|
@@ -9610,11 +9892,11 @@ var lsCommand17 = new Command113("ls").alias("list").description("list Kubernete
|
|
|
9610
9892
|
});
|
|
9611
9893
|
|
|
9612
9894
|
// src/commands/k8s/node/index.ts
|
|
9613
|
-
import { Command as
|
|
9895
|
+
import { Command as Command121 } from "commander";
|
|
9614
9896
|
|
|
9615
9897
|
// src/commands/k8s/node/restart.ts
|
|
9616
|
-
import { Command as
|
|
9617
|
-
var restartCommand2 = new
|
|
9898
|
+
import { Command as Command120 } from "commander";
|
|
9899
|
+
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) => {
|
|
9618
9900
|
const client = await k8sClient(cmd);
|
|
9619
9901
|
try {
|
|
9620
9902
|
const c2 = await spin(`restarting ${node}\u2026`, client.restartClusterNode(name, node));
|
|
@@ -9626,13 +9908,13 @@ var restartCommand2 = new Command114("restart").description("stop and boot one n
|
|
|
9626
9908
|
});
|
|
9627
9909
|
|
|
9628
9910
|
// src/commands/k8s/node/index.ts
|
|
9629
|
-
var nodeCommand = new
|
|
9911
|
+
var nodeCommand = new Command121("node").description("one node of a cluster: restart it").addCommand(restartCommand2);
|
|
9630
9912
|
|
|
9631
9913
|
// src/commands/k8s/pool/index.ts
|
|
9632
|
-
import { Command as
|
|
9914
|
+
import { Command as Command126 } from "commander";
|
|
9633
9915
|
|
|
9634
9916
|
// src/commands/k8s/pool/add.ts
|
|
9635
|
-
import { Command as
|
|
9917
|
+
import { Command as Command122 } from "commander";
|
|
9636
9918
|
|
|
9637
9919
|
// src/commands/k8s/pool/shared.ts
|
|
9638
9920
|
function poolReady(c2, pool) {
|
|
@@ -9684,7 +9966,7 @@ function printPool(client, c2, pool, done, waited) {
|
|
|
9684
9966
|
}
|
|
9685
9967
|
|
|
9686
9968
|
// src/commands/k8s/pool/add.ts
|
|
9687
|
-
var addCommand4 = new
|
|
9969
|
+
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) => {
|
|
9688
9970
|
if (!NODE_SIZES.includes(opts.size)) throw new KvboxError(`--size ${opts.size}: a node is one of ${NODE_SIZES.join(", ")}`);
|
|
9689
9971
|
const nodes = nodeCount(opts.nodes);
|
|
9690
9972
|
const pool = opts.name ?? opts.size;
|
|
@@ -9701,8 +9983,8 @@ var addCommand4 = new Command116("add").description("add a pool of nodes to a cl
|
|
|
9701
9983
|
});
|
|
9702
9984
|
|
|
9703
9985
|
// src/commands/k8s/pool/ls.ts
|
|
9704
|
-
import { Command as
|
|
9705
|
-
var lsCommand18 = new
|
|
9986
|
+
import { Command as Command123 } from "commander";
|
|
9987
|
+
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) => {
|
|
9706
9988
|
const client = await k8sClient(cmd);
|
|
9707
9989
|
try {
|
|
9708
9990
|
const c2 = await client.getCluster(cluster2);
|
|
@@ -9721,8 +10003,8 @@ var lsCommand18 = new Command117("ls").alias("list").description("list a cluster
|
|
|
9721
10003
|
});
|
|
9722
10004
|
|
|
9723
10005
|
// src/commands/k8s/pool/resize.ts
|
|
9724
|
-
import { Command as
|
|
9725
|
-
var resizeCommand = new
|
|
10006
|
+
import { Command as Command124 } from "commander";
|
|
10007
|
+
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) => {
|
|
9726
10008
|
const nodes = nodeCount(opts.nodes);
|
|
9727
10009
|
const client = await k8sClient(cmd);
|
|
9728
10010
|
try {
|
|
@@ -9749,8 +10031,8 @@ var resizeCommand = new Command118("resize").description("change how many nodes
|
|
|
9749
10031
|
});
|
|
9750
10032
|
|
|
9751
10033
|
// src/commands/k8s/pool/rm.ts
|
|
9752
|
-
import { Command as
|
|
9753
|
-
var
|
|
10034
|
+
import { Command as Command125 } from "commander";
|
|
10035
|
+
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) => {
|
|
9754
10036
|
const client = await k8sClient(cmd);
|
|
9755
10037
|
try {
|
|
9756
10038
|
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)) {
|
|
@@ -9773,14 +10055,14 @@ var rmCommand16 = new Command119("rm").alias("remove").description("remove a poo
|
|
|
9773
10055
|
});
|
|
9774
10056
|
|
|
9775
10057
|
// src/commands/k8s/pool/index.ts
|
|
9776
|
-
var poolCommand = new
|
|
10058
|
+
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);
|
|
9777
10059
|
|
|
9778
10060
|
// src/commands/k8s/proxy/index.ts
|
|
9779
|
-
import { Command as
|
|
10061
|
+
import { Command as Command130 } from "commander";
|
|
9780
10062
|
|
|
9781
10063
|
// src/commands/k8s/proxy/claim.ts
|
|
9782
|
-
import { Command as
|
|
9783
|
-
var claimCommand2 = new
|
|
10064
|
+
import { Command as Command127 } from "commander";
|
|
10065
|
+
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) => {
|
|
9784
10066
|
const subdomain = assertSubdomain(subArg);
|
|
9785
10067
|
const client = await k8sClient(cmd);
|
|
9786
10068
|
try {
|
|
@@ -9798,8 +10080,8 @@ var claimCommand2 = new Command121("claim").description(`give a cluster an HTTPS
|
|
|
9798
10080
|
});
|
|
9799
10081
|
|
|
9800
10082
|
// src/commands/k8s/proxy/ls.ts
|
|
9801
|
-
import { Command as
|
|
9802
|
-
var lsCommand19 = new
|
|
10083
|
+
import { Command as Command128 } from "commander";
|
|
10084
|
+
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) => {
|
|
9803
10085
|
const client = await k8sClient(cmd);
|
|
9804
10086
|
try {
|
|
9805
10087
|
const subs = await client.listClusterSubdomains(cluster2);
|
|
@@ -9815,8 +10097,8 @@ var lsCommand19 = new Command122("ls").alias("list").description("list a cluster
|
|
|
9815
10097
|
});
|
|
9816
10098
|
|
|
9817
10099
|
// src/commands/k8s/proxy/release.ts
|
|
9818
|
-
import { Command as
|
|
9819
|
-
var releaseCommand2 = new
|
|
10100
|
+
import { Command as Command129 } from "commander";
|
|
10101
|
+
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) => {
|
|
9820
10102
|
const client = await k8sClient(cmd);
|
|
9821
10103
|
try {
|
|
9822
10104
|
if (!await confirm(`Give up ${subdomain}, one of cluster ${cluster2}'s HTTPS addresses? Anyone may claim it after.`, opts.yes ?? false)) {
|
|
@@ -9832,11 +10114,11 @@ var releaseCommand2 = new Command123("release").description("give up one of a cl
|
|
|
9832
10114
|
});
|
|
9833
10115
|
|
|
9834
10116
|
// src/commands/k8s/proxy/index.ts
|
|
9835
|
-
var proxyCommand2 = new
|
|
10117
|
+
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);
|
|
9836
10118
|
|
|
9837
10119
|
// src/commands/k8s/rm.ts
|
|
9838
|
-
import { Command as
|
|
9839
|
-
var
|
|
10120
|
+
import { Command as Command131 } from "commander";
|
|
10121
|
+
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) => {
|
|
9840
10122
|
const client = await k8sClient(cmd);
|
|
9841
10123
|
try {
|
|
9842
10124
|
if (!await confirm(`Delete cluster ${name} with everything running in it?`, opts.yes ?? false)) {
|
|
@@ -9851,9 +10133,37 @@ var rmCommand17 = new Command125("rm").alias("remove").description("delete a clu
|
|
|
9851
10133
|
}
|
|
9852
10134
|
});
|
|
9853
10135
|
|
|
10136
|
+
// src/commands/k8s/rotate.ts
|
|
10137
|
+
import { Command as Command132 } from "commander";
|
|
10138
|
+
var ROTATE_WAIT_MS = 30 * 6e4;
|
|
10139
|
+
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) => {
|
|
10140
|
+
const client = await k8sClient(cmd);
|
|
10141
|
+
try {
|
|
10142
|
+
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)) {
|
|
10143
|
+
info("cancelled");
|
|
10144
|
+
process.exitCode = 1;
|
|
10145
|
+
return;
|
|
10146
|
+
}
|
|
10147
|
+
const changed = await spin(`storing new credentials in ${name}\u2026`, client.rotateCluster(name));
|
|
10148
|
+
const ours = changed.operation?.since;
|
|
10149
|
+
const waitMs = process.env["KVBOX_K8S_WAIT_MS"] !== void 0 ? readyWait() : ROTATE_WAIT_MS;
|
|
10150
|
+
const refused2 = (err) => !(err instanceof CallError) || err.status >= 400 && err.status < 500;
|
|
10151
|
+
const now = opts.wait && ours !== void 0 ? await spin("restarting its master, then its nodes\u2026", untilReady(client, name, changed, waitMs, void 0, (c2) => c2.operation === void 0 || c2.operation.since !== ours, refused2)) : changed;
|
|
10152
|
+
if (opts.json) json(now);
|
|
10153
|
+
failIfNot(now, void 0, opts.wait ? changed.operation : void 0);
|
|
10154
|
+
if (opts.json) return;
|
|
10155
|
+
const shown = shownName2(now, client);
|
|
10156
|
+
if (now.operation !== void 0) info(`cluster ${shown} is taking its new credentials: its master and nodes are still restarting; look again with: kvbox k8s info ${shown}`);
|
|
10157
|
+
else info(`${color.green("\u2713")} cluster ${shown} has new credentials; every kubeconfig from before is refused`);
|
|
10158
|
+
info(color.dim(` next: kvbox k8s kubeconfig ${shown} > ${now.name}.yaml`));
|
|
10159
|
+
} finally {
|
|
10160
|
+
await client.close();
|
|
10161
|
+
}
|
|
10162
|
+
});
|
|
10163
|
+
|
|
9854
10164
|
// src/commands/k8s/start.ts
|
|
9855
|
-
import { Command as
|
|
9856
|
-
var startCommand2 = new
|
|
10165
|
+
import { Command as Command133 } from "commander";
|
|
10166
|
+
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) => {
|
|
9857
10167
|
const client = await k8sClient(cmd);
|
|
9858
10168
|
try {
|
|
9859
10169
|
const c2 = await spin(`starting cluster ${name}\u2026`, client.startCluster(name));
|
|
@@ -9865,8 +10175,8 @@ var startCommand2 = new Command126("start").description("run a cluster's master
|
|
|
9865
10175
|
});
|
|
9866
10176
|
|
|
9867
10177
|
// src/commands/k8s/unlink.ts
|
|
9868
|
-
import { Command as
|
|
9869
|
-
var unlinkCommand2 = new
|
|
10178
|
+
import { Command as Command134 } from "commander";
|
|
10179
|
+
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) => {
|
|
9870
10180
|
const port = opts.port === void 0 ? void 0 : parseLinkPort(opts.port);
|
|
9871
10181
|
if (!await confirm(`Cut cluster ${cluster2} off from ${target}${port !== void 0 ? ` port ${port}` : ""}? Its pods' open connections close too.`, opts.yes ?? false)) {
|
|
9872
10182
|
info("cancelled");
|
|
@@ -9887,7 +10197,7 @@ var unlinkCommand2 = new Command127("unlink").description("take a cluster's link
|
|
|
9887
10197
|
});
|
|
9888
10198
|
|
|
9889
10199
|
// src/commands/k8s/index.ts
|
|
9890
|
-
var k8sCommand = new
|
|
10200
|
+
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);
|
|
9891
10201
|
var withOrg3 = (cmd) => cmd.option("--org <slug>", "act in this org (- for your personal clusters)");
|
|
9892
10202
|
for (const cmd of k8sCommand.commands) {
|
|
9893
10203
|
if (cmd.commands.length > 0) cmd.commands.forEach(withOrg3);
|
|
@@ -9895,10 +10205,10 @@ for (const cmd of k8sCommand.commands) {
|
|
|
9895
10205
|
}
|
|
9896
10206
|
|
|
9897
10207
|
// src/commands/cron/index.ts
|
|
9898
|
-
import { Command as
|
|
10208
|
+
import { Command as Command148 } from "commander";
|
|
9899
10209
|
|
|
9900
10210
|
// src/commands/cron/create.ts
|
|
9901
|
-
import { Command as
|
|
10211
|
+
import { Command as Command136 } from "commander";
|
|
9902
10212
|
|
|
9903
10213
|
// src/commands/cron/shared.ts
|
|
9904
10214
|
async function cronClient(cmd) {
|
|
@@ -9951,7 +10261,7 @@ function printTriggers(triggers) {
|
|
|
9951
10261
|
}))
|
|
9952
10262
|
);
|
|
9953
10263
|
}
|
|
9954
|
-
function
|
|
10264
|
+
function printRows4(rows2) {
|
|
9955
10265
|
const width2 = Math.max(...rows2.map(([label]) => label.length));
|
|
9956
10266
|
for (const [label, value] of rows2) process.stdout.write(`${color.dim(label.padEnd(width2))} ${value}
|
|
9957
10267
|
`);
|
|
@@ -9959,7 +10269,7 @@ function printRows3(rows2) {
|
|
|
9959
10269
|
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>")`);
|
|
9960
10270
|
|
|
9961
10271
|
// src/commands/cron/create.ts
|
|
9962
|
-
var
|
|
10272
|
+
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) => {
|
|
9963
10273
|
const client = await cronClient(cmd);
|
|
9964
10274
|
try {
|
|
9965
10275
|
const service = await client.createCronService(name);
|
|
@@ -9976,8 +10286,8 @@ var createCommand11 = new Command129("create").description("make a cron service:
|
|
|
9976
10286
|
});
|
|
9977
10287
|
|
|
9978
10288
|
// src/commands/cron/info.ts
|
|
9979
|
-
import { Command as
|
|
9980
|
-
var
|
|
10289
|
+
import { Command as Command137 } from "commander";
|
|
10290
|
+
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) => {
|
|
9981
10291
|
const client = await cronClient(cmd);
|
|
9982
10292
|
try {
|
|
9983
10293
|
const service = await client.getCronService(name);
|
|
@@ -9986,7 +10296,7 @@ var infoCommand3 = new Command130("info").alias("get").description("show a cron
|
|
|
9986
10296
|
json({ ...service, triggerList: triggers });
|
|
9987
10297
|
return;
|
|
9988
10298
|
}
|
|
9989
|
-
|
|
10299
|
+
printRows4([
|
|
9990
10300
|
["name", shownName3(service, client)],
|
|
9991
10301
|
["triggers", String(service.triggers)],
|
|
9992
10302
|
["runs kept", `the last ${service.keepRuns} of each trigger`],
|
|
@@ -10001,8 +10311,8 @@ var infoCommand3 = new Command130("info").alias("get").description("show a cron
|
|
|
10001
10311
|
});
|
|
10002
10312
|
|
|
10003
10313
|
// src/commands/cron/ls.ts
|
|
10004
|
-
import { Command as
|
|
10005
|
-
var lsCommand20 = new
|
|
10314
|
+
import { Command as Command138 } from "commander";
|
|
10315
|
+
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) => {
|
|
10006
10316
|
const client = await cronClient(cmd);
|
|
10007
10317
|
try {
|
|
10008
10318
|
const services = await client.listCronServices({ all: opts.all });
|
|
@@ -10022,8 +10332,8 @@ var lsCommand20 = new Command131("ls").alias("list").description("list cron serv
|
|
|
10022
10332
|
});
|
|
10023
10333
|
|
|
10024
10334
|
// src/commands/cron/rm.ts
|
|
10025
|
-
import { Command as
|
|
10026
|
-
var
|
|
10335
|
+
import { Command as Command139 } from "commander";
|
|
10336
|
+
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) => {
|
|
10027
10337
|
const client = await cronClient(cmd);
|
|
10028
10338
|
try {
|
|
10029
10339
|
if (!await confirm(`Delete cron service ${name}? Its triggers stop firing and their run history is deleted.`, opts.yes ?? false)) {
|
|
@@ -10039,10 +10349,10 @@ var rmCommand18 = new Command132("rm").alias("remove").description("delete a cro
|
|
|
10039
10349
|
});
|
|
10040
10350
|
|
|
10041
10351
|
// src/commands/cron/trigger/index.ts
|
|
10042
|
-
import { Command as
|
|
10352
|
+
import { Command as Command147 } from "commander";
|
|
10043
10353
|
|
|
10044
10354
|
// src/commands/cron/trigger/add.ts
|
|
10045
|
-
import { Command as
|
|
10355
|
+
import { Command as Command140 } from "commander";
|
|
10046
10356
|
function portOf(value) {
|
|
10047
10357
|
const n2 = Number(value);
|
|
10048
10358
|
if (!Number.isInteger(n2) || n2 < 1 || n2 > 65535) throw new KvboxError(`--port ${value}: a port is a number from 1 to 65535`);
|
|
@@ -10062,7 +10372,7 @@ function timeoutOf(value) {
|
|
|
10062
10372
|
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`);
|
|
10063
10373
|
return sec;
|
|
10064
10374
|
}
|
|
10065
|
-
var addCommand5 = new
|
|
10375
|
+
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) => {
|
|
10066
10376
|
let action;
|
|
10067
10377
|
if (opts.run !== void 0) {
|
|
10068
10378
|
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");
|
|
@@ -10089,8 +10399,8 @@ var addCommand5 = new Command133("add").description("add a trigger: on a schedul
|
|
|
10089
10399
|
});
|
|
10090
10400
|
|
|
10091
10401
|
// src/commands/cron/trigger/ls.ts
|
|
10092
|
-
import { Command as
|
|
10093
|
-
var lsCommand21 = new
|
|
10402
|
+
import { Command as Command141 } from "commander";
|
|
10403
|
+
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) => {
|
|
10094
10404
|
const client = await cronClient(cmd);
|
|
10095
10405
|
try {
|
|
10096
10406
|
const triggers = await client.listCronTriggers(service);
|
|
@@ -10106,8 +10416,8 @@ var lsCommand21 = new Command134("ls").alias("list").description("list a cron se
|
|
|
10106
10416
|
});
|
|
10107
10417
|
|
|
10108
10418
|
// src/commands/cron/trigger/pause.ts
|
|
10109
|
-
import { Command as
|
|
10110
|
-
var pauseCommand2 = new
|
|
10419
|
+
import { Command as Command142 } from "commander";
|
|
10420
|
+
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) => {
|
|
10111
10421
|
const client = await cronClient(cmd);
|
|
10112
10422
|
try {
|
|
10113
10423
|
const trigger = await client.setCronTriggerEnabled(service, id, false);
|
|
@@ -10122,8 +10432,8 @@ var pauseCommand2 = new Command135("pause").description("stop a trigger from fir
|
|
|
10122
10432
|
});
|
|
10123
10433
|
|
|
10124
10434
|
// src/commands/cron/trigger/resume.ts
|
|
10125
|
-
import { Command as
|
|
10126
|
-
var resumeCommand2 = new
|
|
10435
|
+
import { Command as Command143 } from "commander";
|
|
10436
|
+
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) => {
|
|
10127
10437
|
const client = await cronClient(cmd);
|
|
10128
10438
|
try {
|
|
10129
10439
|
const trigger = await client.setCronTriggerEnabled(service, id, true);
|
|
@@ -10138,8 +10448,8 @@ var resumeCommand2 = new Command136("resume").description("let a paused trigger
|
|
|
10138
10448
|
});
|
|
10139
10449
|
|
|
10140
10450
|
// src/commands/cron/trigger/rm.ts
|
|
10141
|
-
import { Command as
|
|
10142
|
-
var
|
|
10451
|
+
import { Command as Command144 } from "commander";
|
|
10452
|
+
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) => {
|
|
10143
10453
|
const client = await cronClient(cmd);
|
|
10144
10454
|
try {
|
|
10145
10455
|
if (!await confirm(`Delete trigger ${id} of cron service ${service}? Its run history is deleted too.`, opts.yes ?? false)) {
|
|
@@ -10155,8 +10465,8 @@ var rmCommand19 = new Command137("rm").alias("remove").description("delete a tri
|
|
|
10155
10465
|
});
|
|
10156
10466
|
|
|
10157
10467
|
// src/commands/cron/trigger/run.ts
|
|
10158
|
-
import { Command as
|
|
10159
|
-
var runCommand = new
|
|
10468
|
+
import { Command as Command145 } from "commander";
|
|
10469
|
+
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) => {
|
|
10160
10470
|
const client = await cronClient(cmd);
|
|
10161
10471
|
try {
|
|
10162
10472
|
const trigger = await client.runCronTrigger(service, id);
|
|
@@ -10172,13 +10482,13 @@ var runCommand = new Command138("run").description("fire a trigger now, once, be
|
|
|
10172
10482
|
});
|
|
10173
10483
|
|
|
10174
10484
|
// src/commands/cron/trigger/runs.ts
|
|
10175
|
-
import { Command as
|
|
10485
|
+
import { Command as Command146 } from "commander";
|
|
10176
10486
|
function limitOf(value) {
|
|
10177
10487
|
const n2 = Number(value);
|
|
10178
10488
|
if (!Number.isInteger(n2) || n2 < 1) throw new KvboxError(`-n ${value}: a number of runs, 1 or more`);
|
|
10179
10489
|
return n2;
|
|
10180
10490
|
}
|
|
10181
|
-
var runsCommand = new
|
|
10491
|
+
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) => {
|
|
10182
10492
|
const limit = limitOf(opts.limit);
|
|
10183
10493
|
const client = await cronClient(cmd);
|
|
10184
10494
|
try {
|
|
@@ -10208,10 +10518,10 @@ var runsCommand = new Command139("runs").aliases(["logs"]).description("show how
|
|
|
10208
10518
|
});
|
|
10209
10519
|
|
|
10210
10520
|
// src/commands/cron/trigger/index.ts
|
|
10211
|
-
var triggerCommand = new
|
|
10521
|
+
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);
|
|
10212
10522
|
|
|
10213
10523
|
// src/commands/cron/index.ts
|
|
10214
|
-
var cronCommand = new
|
|
10524
|
+
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);
|
|
10215
10525
|
var withOrg4 = (cmd) => cmd.option("--org <slug>", "act in this org (- for your personal cron services)");
|
|
10216
10526
|
for (const cmd of cronCommand.commands) {
|
|
10217
10527
|
if (cmd === triggerCommand) cmd.commands.forEach(withOrg4);
|
|
@@ -10219,13 +10529,13 @@ for (const cmd of cronCommand.commands) {
|
|
|
10219
10529
|
}
|
|
10220
10530
|
|
|
10221
10531
|
// src/commands/managed/kind.ts
|
|
10222
|
-
import { Command as
|
|
10532
|
+
import { Command as Command167 } from "commander";
|
|
10223
10533
|
|
|
10224
10534
|
// src/commands/managed/backup/index.ts
|
|
10225
|
-
import { Command as
|
|
10535
|
+
import { Command as Command155 } from "commander";
|
|
10226
10536
|
|
|
10227
10537
|
// src/commands/managed/backup/create.ts
|
|
10228
|
-
import { Command as
|
|
10538
|
+
import { Command as Command150 } from "commander";
|
|
10229
10539
|
|
|
10230
10540
|
// src/commands/managed/shared.ts
|
|
10231
10541
|
import "commander";
|
|
@@ -10259,7 +10569,7 @@ async function managedClient(cmd) {
|
|
|
10259
10569
|
}
|
|
10260
10570
|
var shownName4 = (m, user) => m.owner === user ? m.name : `${m.owner}/${m.name}`;
|
|
10261
10571
|
var storageText = (m) => m.health?.storageUsedBytes !== void 0 ? `${gb(m.health.storageUsedBytes)} of ${m.storageGib} GB used` : `${m.storageGib} GB`;
|
|
10262
|
-
var
|
|
10572
|
+
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;
|
|
10263
10573
|
function stateText(m) {
|
|
10264
10574
|
if (m.status === "stopped") return `${status(m.status)} ${color.dim("(only its storage is charged)")}`;
|
|
10265
10575
|
if (m.status !== "running" || m.health === void 0) return status(m.status);
|
|
@@ -10276,7 +10586,7 @@ function infoRows(spec, m, user) {
|
|
|
10276
10586
|
];
|
|
10277
10587
|
if (user !== void 0 && m.owner !== user) rows2.push(["owner", m.owner]);
|
|
10278
10588
|
for (const fact of m.health?.facts ?? []) rows2.push([fact.title.toLowerCase(), fact.value]);
|
|
10279
|
-
rows2.push(["storage", `${storageText(m)}${
|
|
10589
|
+
rows2.push(["storage", `${storageText(m)}${nearlyFull3(m) ? color.yellow(` almost full: kvbox ${spec.command} grow ${name} <GB>`) : ""}`]);
|
|
10280
10590
|
rows2.push(...settingRows(spec, m.settings), ["password", color.dim(`kvbox ${spec.command} password ${name}`)]);
|
|
10281
10591
|
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>)`)}`]);
|
|
10282
10592
|
rows2.push(["public", m.urls.public ?? color.dim(`off (kvbox ${spec.command} public ${name} on)`)]);
|
|
@@ -10288,7 +10598,7 @@ function infoRows(spec, m, user) {
|
|
|
10288
10598
|
function scheduleText2(spec, name, s, now = Date.now()) {
|
|
10289
10599
|
return scheduleLine(`kvbox ${spec.command} backup schedule ${name}`, s, now);
|
|
10290
10600
|
}
|
|
10291
|
-
function
|
|
10601
|
+
function printRows5(rows2) {
|
|
10292
10602
|
const width2 = Math.max(...rows2.map(([label]) => label.length));
|
|
10293
10603
|
for (const [label, value] of rows2) process.stdout.write(`${color.dim(label.padEnd(width2))} ${value}
|
|
10294
10604
|
`);
|
|
@@ -10312,7 +10622,7 @@ function parseStorage(text2, flag) {
|
|
|
10312
10622
|
}
|
|
10313
10623
|
|
|
10314
10624
|
// src/commands/managed/backup/create.ts
|
|
10315
|
-
var
|
|
10625
|
+
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) => {
|
|
10316
10626
|
const client = await managedClient(cmd);
|
|
10317
10627
|
const ls = `kvbox ${spec.command} backup ls ${name}`;
|
|
10318
10628
|
try {
|
|
@@ -10339,7 +10649,7 @@ var createCommand12 = (spec) => new Command143("create").description("back up a
|
|
|
10339
10649
|
});
|
|
10340
10650
|
|
|
10341
10651
|
// src/commands/managed/backup/ls.ts
|
|
10342
|
-
import { Command as
|
|
10652
|
+
import { Command as Command151 } from "commander";
|
|
10343
10653
|
var lsCommand22 = (spec) => {
|
|
10344
10654
|
const removedOnes = async (err, name, client) => {
|
|
10345
10655
|
if (!(err instanceof CallError && err.status === 404)) throw err;
|
|
@@ -10348,7 +10658,7 @@ var lsCommand22 = (spec) => {
|
|
|
10348
10658
|
const own = name.includes("/") ? [] : gone.filter((b) => b.owner === me(client));
|
|
10349
10659
|
return own.length > 0 ? own : gone;
|
|
10350
10660
|
};
|
|
10351
|
-
return new
|
|
10661
|
+
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) => {
|
|
10352
10662
|
const client = await managedClient(cmd);
|
|
10353
10663
|
try {
|
|
10354
10664
|
const list = name === void 0 ? await client.listManagedBackups(spec.kind) : await client.managedBackups(spec.kind, name).catch((err) => removedOnes(err, name, client));
|
|
@@ -10391,8 +10701,8 @@ var lsCommand22 = (spec) => {
|
|
|
10391
10701
|
};
|
|
10392
10702
|
|
|
10393
10703
|
// src/commands/managed/backup/restore.ts
|
|
10394
|
-
import { Command as
|
|
10395
|
-
var restoreCommand5 = (spec) => new
|
|
10704
|
+
import { Command as Command152 } from "commander";
|
|
10705
|
+
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) => {
|
|
10396
10706
|
const client = await managedClient(cmd);
|
|
10397
10707
|
try {
|
|
10398
10708
|
const backup = await client.managedBackup(spec.kind, name, id);
|
|
@@ -10414,8 +10724,8 @@ var restoreCommand5 = (spec) => new Command145("restore").description("put a bac
|
|
|
10414
10724
|
});
|
|
10415
10725
|
|
|
10416
10726
|
// src/commands/managed/backup/rm.ts
|
|
10417
|
-
import { Command as
|
|
10418
|
-
var
|
|
10727
|
+
import { Command as Command153 } from "commander";
|
|
10728
|
+
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) => {
|
|
10419
10729
|
const client = await managedClient(cmd);
|
|
10420
10730
|
try {
|
|
10421
10731
|
await removeListed(client, await client.listManagedBackups(spec.kind), (b) => b.name, name, id, `database ${name}`, opts.yes ?? false);
|
|
@@ -10425,8 +10735,8 @@ var rmCommand20 = (spec) => new Command146("rm").alias("remove").description("re
|
|
|
10425
10735
|
});
|
|
10426
10736
|
|
|
10427
10737
|
// src/commands/managed/backup/schedule.ts
|
|
10428
|
-
import { Command as
|
|
10429
|
-
var scheduleCommand5 = (spec) => scheduleFlags(new
|
|
10738
|
+
import { Command as Command154 } from "commander";
|
|
10739
|
+
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(
|
|
10430
10740
|
async (name, flags, cmd) => {
|
|
10431
10741
|
const change = changeOf(flags);
|
|
10432
10742
|
const client = await managedClient(cmd);
|
|
@@ -10442,18 +10752,18 @@ var scheduleCommand5 = (spec) => scheduleFlags(new Command147("schedule").descri
|
|
|
10442
10752
|
|
|
10443
10753
|
// src/commands/managed/backup/index.ts
|
|
10444
10754
|
var backupCommand5 = (spec) => {
|
|
10445
|
-
const command = new
|
|
10446
|
-
for (const make of [
|
|
10755
|
+
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");
|
|
10756
|
+
for (const make of [createCommand13, lsCommand22, restoreCommand5, rmCommand21, scheduleCommand5]) command.addCommand(make(spec).option("--org <slug>", "act in this org (- for your personal databases)"));
|
|
10447
10757
|
return command;
|
|
10448
10758
|
};
|
|
10449
10759
|
|
|
10450
10760
|
// src/commands/managed/create.ts
|
|
10451
|
-
import { Command as
|
|
10761
|
+
import { Command as Command156 } from "commander";
|
|
10452
10762
|
import { setTimeout as sleep5 } from "timers/promises";
|
|
10453
10763
|
var READY_WAIT_MS2 = 9e4;
|
|
10454
10764
|
var READY_STEP_MS = 2e3;
|
|
10455
|
-
var
|
|
10456
|
-
const command = new
|
|
10765
|
+
var createCommand14 = (spec) => {
|
|
10766
|
+
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");
|
|
10457
10767
|
for (const o of spec.options) command.option(`--${o.name} <${o.arg}>`, o.help);
|
|
10458
10768
|
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) => {
|
|
10459
10769
|
const options = Object.fromEntries(spec.options.flatMap((o) => typeof opts[o.name] === "string" ? [[o.name, opts[o.name]]] : []));
|
|
@@ -10488,7 +10798,7 @@ var createCommand13 = (spec) => {
|
|
|
10488
10798
|
}
|
|
10489
10799
|
const restored = made.fromBackup === void 0 ? "" : `, the data of backup ${made.fromBackup}`;
|
|
10490
10800
|
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})`)}`);
|
|
10491
|
-
|
|
10801
|
+
printRows5([...settingRows(spec, made.settings), ...secretRows(made.secret)].map(([label, value]) => [` ${label}`, value]));
|
|
10492
10802
|
info("");
|
|
10493
10803
|
info("Nobody can reach it yet. To let something in:");
|
|
10494
10804
|
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})`)}`);
|
|
@@ -10502,8 +10812,8 @@ var createCommand13 = (spec) => {
|
|
|
10502
10812
|
};
|
|
10503
10813
|
|
|
10504
10814
|
// src/commands/managed/grow.ts
|
|
10505
|
-
import { Command as
|
|
10506
|
-
var
|
|
10815
|
+
import { Command as Command157 } from "commander";
|
|
10816
|
+
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) => {
|
|
10507
10817
|
const storageGib = parseStorage(size, "size");
|
|
10508
10818
|
const client = await managedClient(cmd);
|
|
10509
10819
|
try {
|
|
@@ -10516,21 +10826,21 @@ var growCommand3 = (spec) => new Command150("grow").description("give a database
|
|
|
10516
10826
|
});
|
|
10517
10827
|
|
|
10518
10828
|
// src/commands/managed/info.ts
|
|
10519
|
-
import { Command as
|
|
10520
|
-
var
|
|
10829
|
+
import { Command as Command158 } from "commander";
|
|
10830
|
+
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) => {
|
|
10521
10831
|
const client = await managedClient(cmd);
|
|
10522
10832
|
try {
|
|
10523
10833
|
const m = await client.getManaged(spec.kind, name);
|
|
10524
10834
|
if (opts.json) json(m);
|
|
10525
|
-
else
|
|
10835
|
+
else printRows5(infoRows(spec, m, me(client)));
|
|
10526
10836
|
} finally {
|
|
10527
10837
|
await client.close();
|
|
10528
10838
|
}
|
|
10529
10839
|
});
|
|
10530
10840
|
|
|
10531
10841
|
// src/commands/managed/link.ts
|
|
10532
|
-
import { Command as
|
|
10533
|
-
var linkCommand3 = (spec) => new
|
|
10842
|
+
import { Command as Command159 } from "commander";
|
|
10843
|
+
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) => {
|
|
10534
10844
|
const client = await managedClient(cmd);
|
|
10535
10845
|
try {
|
|
10536
10846
|
const m = await spin(`linking ${box2} to ${name}\u2026`, client.linkManaged(spec.kind, name, box2));
|
|
@@ -10546,7 +10856,7 @@ var linkCommand3 = (spec) => new Command152("link").description("let a box reach
|
|
|
10546
10856
|
});
|
|
10547
10857
|
|
|
10548
10858
|
// src/commands/managed/ls.ts
|
|
10549
|
-
import { Command as
|
|
10859
|
+
import { Command as Command160 } from "commander";
|
|
10550
10860
|
function listRows(items, user, kindColumn) {
|
|
10551
10861
|
return items.map((m) => ({
|
|
10552
10862
|
owner: m.owner === user ? "private" : m.owner,
|
|
@@ -10560,7 +10870,7 @@ function listRows(items, user, kindColumn) {
|
|
|
10560
10870
|
created: age(m.createdAt)
|
|
10561
10871
|
}));
|
|
10562
10872
|
}
|
|
10563
|
-
var lsCommand23 = (spec) => new
|
|
10873
|
+
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) => {
|
|
10564
10874
|
const client = await managedClient(cmd);
|
|
10565
10875
|
try {
|
|
10566
10876
|
const items = await client.listManaged(spec?.kind, { all: opts.all });
|
|
@@ -10580,8 +10890,8 @@ var lsCommand23 = (spec) => new Command153("ls").alias("list").description(spec
|
|
|
10580
10890
|
});
|
|
10581
10891
|
|
|
10582
10892
|
// src/commands/managed/password.ts
|
|
10583
|
-
import { Command as
|
|
10584
|
-
var
|
|
10893
|
+
import { Command as Command161 } from "commander";
|
|
10894
|
+
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) => {
|
|
10585
10895
|
const client = await managedClient(cmd);
|
|
10586
10896
|
try {
|
|
10587
10897
|
const secret = opts.reset ? await spin(`setting a new password on ${name}\u2026`, client.resetManagedPassword(spec.kind, name)) : await client.managedPassword(spec.kind, name);
|
|
@@ -10590,15 +10900,15 @@ var passwordCommand = (spec) => new Command154("password").description("show a d
|
|
|
10590
10900
|
return;
|
|
10591
10901
|
}
|
|
10592
10902
|
if (opts.reset) info(`${color.green("\u2713")} database ${name} has a new password; the old one no longer works`);
|
|
10593
|
-
|
|
10903
|
+
printRows5(secretRows(secret));
|
|
10594
10904
|
} finally {
|
|
10595
10905
|
await client.close();
|
|
10596
10906
|
}
|
|
10597
10907
|
});
|
|
10598
10908
|
|
|
10599
10909
|
// src/commands/managed/public.ts
|
|
10600
|
-
import { Command as
|
|
10601
|
-
var publicCommand2 = (spec) => new
|
|
10910
|
+
import { Command as Command162 } from "commander";
|
|
10911
|
+
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) => {
|
|
10602
10912
|
if (state !== "on" && state !== "off") throw new KvboxError(`write on or off: kvbox ${spec.command} public ${name} on`);
|
|
10603
10913
|
const client = await managedClient(cmd);
|
|
10604
10914
|
try {
|
|
@@ -10619,8 +10929,8 @@ var publicCommand2 = (spec) => new Command155("public").description("open a data
|
|
|
10619
10929
|
});
|
|
10620
10930
|
|
|
10621
10931
|
// src/commands/managed/rm.ts
|
|
10622
|
-
import { Command as
|
|
10623
|
-
var
|
|
10932
|
+
import { Command as Command163 } from "commander";
|
|
10933
|
+
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) => {
|
|
10624
10934
|
const client = await managedClient(cmd);
|
|
10625
10935
|
try {
|
|
10626
10936
|
if (!await confirm(`Delete database ${name} and all its data? There is no backup.`, opts.yes ?? false)) {
|
|
@@ -10636,8 +10946,8 @@ var rmCommand21 = (spec) => new Command156("rm").alias("remove").description("de
|
|
|
10636
10946
|
});
|
|
10637
10947
|
|
|
10638
10948
|
// src/commands/managed/start.ts
|
|
10639
|
-
import { Command as
|
|
10640
|
-
var startCommand3 = (spec) => new
|
|
10949
|
+
import { Command as Command164 } from "commander";
|
|
10950
|
+
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) => {
|
|
10641
10951
|
const client = await managedClient(cmd);
|
|
10642
10952
|
try {
|
|
10643
10953
|
const m = await spin(`starting ${name}\u2026`, client.startManaged(spec.kind, name));
|
|
@@ -10649,8 +10959,8 @@ var startCommand3 = (spec) => new Command157("start").description("run a stopped
|
|
|
10649
10959
|
});
|
|
10650
10960
|
|
|
10651
10961
|
// src/commands/managed/stop.ts
|
|
10652
|
-
import { Command as
|
|
10653
|
-
var stopCommand2 = (spec) => new
|
|
10962
|
+
import { Command as Command165 } from "commander";
|
|
10963
|
+
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) => {
|
|
10654
10964
|
const client = await managedClient(cmd);
|
|
10655
10965
|
try {
|
|
10656
10966
|
const m = await spin(`stopping ${name}\u2026`, client.stopManaged(spec.kind, name));
|
|
@@ -10662,8 +10972,8 @@ var stopCommand2 = (spec) => new Command158("stop").description("shut a database
|
|
|
10662
10972
|
});
|
|
10663
10973
|
|
|
10664
10974
|
// src/commands/managed/unlink.ts
|
|
10665
|
-
import { Command as
|
|
10666
|
-
var unlinkCommand3 = (spec) => new
|
|
10975
|
+
import { Command as Command166 } from "commander";
|
|
10976
|
+
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) => {
|
|
10667
10977
|
const client = await managedClient(cmd);
|
|
10668
10978
|
try {
|
|
10669
10979
|
const m = await spin(`unlinking ${box2} from ${name}\u2026`, client.unlinkManaged(spec.kind, name, box2));
|
|
@@ -10676,8 +10986,8 @@ var unlinkCommand3 = (spec) => new Command159("unlink").description("stop a box
|
|
|
10676
10986
|
|
|
10677
10987
|
// src/commands/managed/kind.ts
|
|
10678
10988
|
function kindCommand(spec, description) {
|
|
10679
|
-
const command = new
|
|
10680
|
-
for (const make of [
|
|
10989
|
+
const command = new Command167(spec.command).aliases(spec.aliases).description(description);
|
|
10990
|
+
for (const make of [createCommand14, lsCommand23, infoCommand5, passwordCommand2, publicCommand2, linkCommand3, unlinkCommand3, growCommand4, stopCommand2, startCommand3, rmCommand22]) {
|
|
10681
10991
|
command.addCommand(make(spec).option("--org <slug>", "act in this org (- for your personal databases)"));
|
|
10682
10992
|
}
|
|
10683
10993
|
command.addCommand(backupCommand5(spec));
|
|
@@ -10691,14 +11001,14 @@ var pgCommand = kindCommand(POSTGRES2, "managed PostgreSQL: a database kvbox run
|
|
|
10691
11001
|
var redisCommand = kindCommand(REDIS, "managed Redis (Valkey): a Redis kvbox runs for you, private until you link a box or make it public");
|
|
10692
11002
|
|
|
10693
11003
|
// src/commands/managed/index.ts
|
|
10694
|
-
import { Command as
|
|
10695
|
-
var managedCommand = new
|
|
11004
|
+
import { Command as Command168 } from "commander";
|
|
11005
|
+
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)"));
|
|
10696
11006
|
|
|
10697
11007
|
// src/commands/env/index.ts
|
|
10698
|
-
import { Command as
|
|
11008
|
+
import { Command as Command172 } from "commander";
|
|
10699
11009
|
|
|
10700
11010
|
// src/commands/env/ls.ts
|
|
10701
|
-
import { Command as
|
|
11011
|
+
import { Command as Command169 } from "commander";
|
|
10702
11012
|
|
|
10703
11013
|
// src/commands/env/shared.ts
|
|
10704
11014
|
function requireCloud5(client) {
|
|
@@ -10725,7 +11035,7 @@ function firstBootHint(box2, name) {
|
|
|
10725
11035
|
}
|
|
10726
11036
|
|
|
10727
11037
|
// src/commands/env/ls.ts
|
|
10728
|
-
var lsCommand24 = new
|
|
11038
|
+
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) => {
|
|
10729
11039
|
const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
|
|
10730
11040
|
try {
|
|
10731
11041
|
if (opts.box !== void 0) {
|
|
@@ -10764,8 +11074,8 @@ var lsCommand24 = new Command162("ls").alias("list").description("list the varia
|
|
|
10764
11074
|
});
|
|
10765
11075
|
|
|
10766
11076
|
// src/commands/env/rm.ts
|
|
10767
|
-
import { Command as
|
|
10768
|
-
var
|
|
11077
|
+
import { Command as Command170 } from "commander";
|
|
11078
|
+
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) => {
|
|
10769
11079
|
const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
|
|
10770
11080
|
try {
|
|
10771
11081
|
const target = opts.box === void 0 ? void 0 : await findBox2(client, opts.box);
|
|
@@ -10802,8 +11112,8 @@ var rmCommand22 = new Command163("rm").alias("remove").description("remove varia
|
|
|
10802
11112
|
});
|
|
10803
11113
|
|
|
10804
11114
|
// src/commands/env/set.ts
|
|
10805
|
-
import { Command as
|
|
10806
|
-
var setCommand2 = new
|
|
11115
|
+
import { Command as Command171 } from "commander";
|
|
11116
|
+
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) => {
|
|
10807
11117
|
const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
|
|
10808
11118
|
try {
|
|
10809
11119
|
const owner = opts.box === void 0 ? requireCloud5(client) : void 0;
|
|
@@ -10840,15 +11150,15 @@ var setCommand2 = new Command164("set").description("add or change a variable; b
|
|
|
10840
11150
|
});
|
|
10841
11151
|
|
|
10842
11152
|
// src/commands/env/index.ts
|
|
10843
|
-
var envCommand = new
|
|
11153
|
+
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);
|
|
10844
11154
|
for (const cmd of envCommand.commands) cmd.option("--org <slug>", "the org's variables instead of yours");
|
|
10845
11155
|
|
|
10846
11156
|
// src/commands/domain/index.ts
|
|
10847
|
-
import { Command as
|
|
11157
|
+
import { Command as Command176 } from "commander";
|
|
10848
11158
|
|
|
10849
11159
|
// src/commands/domain/add.ts
|
|
10850
|
-
import { Command as
|
|
10851
|
-
var addCommand6 = new
|
|
11160
|
+
import { Command as Command173 } from "commander";
|
|
11161
|
+
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) => {
|
|
10852
11162
|
const domain = assertDomain(domainArg.trim().toLowerCase());
|
|
10853
11163
|
const port = opts.port === void 0 ? void 0 : parsePorts([opts.port])[0];
|
|
10854
11164
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
@@ -10884,8 +11194,8 @@ kvbox checks every minute; ${domain} is served at ${d.url} once its records are
|
|
|
10884
11194
|
});
|
|
10885
11195
|
|
|
10886
11196
|
// src/commands/domain/ls.ts
|
|
10887
|
-
import { Command as
|
|
10888
|
-
var lsCommand25 = new
|
|
11197
|
+
import { Command as Command174 } from "commander";
|
|
11198
|
+
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) => {
|
|
10889
11199
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
10890
11200
|
try {
|
|
10891
11201
|
requireCloud4(client);
|
|
@@ -10914,8 +11224,8 @@ var lsCommand25 = new Command167("ls").alias("list").description("list your cust
|
|
|
10914
11224
|
});
|
|
10915
11225
|
|
|
10916
11226
|
// src/commands/domain/rm.ts
|
|
10917
|
-
import { Command as
|
|
10918
|
-
var
|
|
11227
|
+
import { Command as Command175 } from "commander";
|
|
11228
|
+
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) => {
|
|
10919
11229
|
const domain = domainArg.trim().toLowerCase();
|
|
10920
11230
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
10921
11231
|
try {
|
|
@@ -10936,7 +11246,7 @@ var rmCommand23 = new Command168("rm").alias("remove").description("stop serving
|
|
|
10936
11246
|
});
|
|
10937
11247
|
|
|
10938
11248
|
// src/commands/domain/index.ts
|
|
10939
|
-
var domainCommand2 = new
|
|
11249
|
+
var domainCommand2 = new Command176("domain").alias("domains").description("serve a box at a domain of your own").addCommand(addCommand6).addCommand(lsCommand25).addCommand(rmCommand24);
|
|
10940
11250
|
for (const cmd of domainCommand2.commands) cmd.option("--org <slug>", "act in this org (- for your personal boxes)");
|
|
10941
11251
|
|
|
10942
11252
|
// src/commands/update.ts
|
|
@@ -10944,7 +11254,7 @@ import { spawn as spawn8 } from "child_process";
|
|
|
10944
11254
|
import { mkdtempSync, rmSync, writeFileSync as writeFileSync2 } from "fs";
|
|
10945
11255
|
import { tmpdir } from "os";
|
|
10946
11256
|
import { join as join9 } from "path";
|
|
10947
|
-
import { Command as
|
|
11257
|
+
import { Command as Command177 } from "commander";
|
|
10948
11258
|
|
|
10949
11259
|
// src/update.ts
|
|
10950
11260
|
import { mkdirSync, readFileSync as readFileSync3, writeFileSync } from "fs";
|
|
@@ -11063,7 +11373,7 @@ function run2(cmd, args) {
|
|
|
11063
11373
|
child.on("exit", (code, signal) => resolve4(code ?? (signal ? 1 : 0)));
|
|
11064
11374
|
});
|
|
11065
11375
|
}
|
|
11066
|
-
var selfUpdateCommand = new
|
|
11376
|
+
var selfUpdateCommand = new Command177("update").description("update kvbox to the latest version (reruns the installer from kvbox.sh, agent skill included)").action(async () => {
|
|
11067
11377
|
suppressUpdateNotice();
|
|
11068
11378
|
const inst = installerFor(process.platform, process.env["KVBOX_INSTALL_URL"] || INSTALL_BASE);
|
|
11069
11379
|
let code;
|
|
@@ -11087,7 +11397,7 @@ var selfUpdateCommand = new Command170("update").description("update kvbox to th
|
|
|
11087
11397
|
import { chmod as chmod2, mkdir as mkdir4, readFile as readFile9, writeFile as writeFile5 } from "fs/promises";
|
|
11088
11398
|
import { homedir as homedir2 } from "os";
|
|
11089
11399
|
import { dirname as dirname2, join as join11 } from "path";
|
|
11090
|
-
import { Command as
|
|
11400
|
+
import { Command as Command178 } from "commander";
|
|
11091
11401
|
|
|
11092
11402
|
// src/sshConfig.ts
|
|
11093
11403
|
import { spawnSync as spawnSync4 } from "child_process";
|
|
@@ -11209,7 +11519,7 @@ async function forgetReplacedBox(alias, id, p) {
|
|
|
11209
11519
|
}
|
|
11210
11520
|
|
|
11211
11521
|
// src/commands/sshConfig.ts
|
|
11212
|
-
var sshConfigCommand = new
|
|
11522
|
+
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) => {
|
|
11213
11523
|
const file = opts.file ?? join11(homedir2(), ".ssh", "config");
|
|
11214
11524
|
const before = await readFile9(file, "utf8").catch((err) => {
|
|
11215
11525
|
if (err.code === "ENOENT") return "";
|
|
@@ -11275,8 +11585,8 @@ async function aliasesOf(client, boxes, gone) {
|
|
|
11275
11585
|
|
|
11276
11586
|
// src/commands/sshProxy.ts
|
|
11277
11587
|
import { connect } from "net";
|
|
11278
|
-
import { Command as
|
|
11279
|
-
var sshProxyCommand = new
|
|
11588
|
+
import { Command as Command179 } from "commander";
|
|
11589
|
+
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) => {
|
|
11280
11590
|
const ref = parseAlias(host);
|
|
11281
11591
|
if (ref === void 0) throw new KvboxError(`${host}: not a kvbox name (<box>.kvbox or <box>.<org>.kvbox)`);
|
|
11282
11592
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
@@ -11374,6 +11684,7 @@ var HELP_GROUPS = [
|
|
|
11374
11684
|
["snapshots", "freeze a running box into a snapshot, start new boxes from it"],
|
|
11375
11685
|
["volume", "disks of their own that move between boxes"],
|
|
11376
11686
|
["bucket", "object storage: S3 buckets for your files"],
|
|
11687
|
+
["registry", "container registry: a private place for your docker images"],
|
|
11377
11688
|
["pg", "managed PostgreSQL: a database kvbox runs for you"],
|
|
11378
11689
|
["redis", "managed Redis (Valkey): a Redis kvbox runs for you"],
|
|
11379
11690
|
["k8s", "managed Kubernetes: a cluster kvbox runs for you, its nodes your boxes"],
|
|
@@ -11439,11 +11750,12 @@ function installRootHelp(program) {
|
|
|
11439
11750
|
|
|
11440
11751
|
// src/program.ts
|
|
11441
11752
|
function buildProgram() {
|
|
11442
|
-
const program = new
|
|
11753
|
+
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();
|
|
11443
11754
|
program.addCommand(vmCommand);
|
|
11444
11755
|
program.addCommand(snapshotsCommand);
|
|
11445
11756
|
program.addCommand(volumeCommand);
|
|
11446
11757
|
program.addCommand(bucketCommand);
|
|
11758
|
+
program.addCommand(registryCommand);
|
|
11447
11759
|
program.addCommand(pgCommand);
|
|
11448
11760
|
program.addCommand(redisCommand);
|
|
11449
11761
|
program.addCommand(managedCommand);
|