@kvbox/cli 0.6.22 → 0.6.23
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 +1778 -729
- 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 Command171 } 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.23" : void 0);
|
|
174
174
|
|
|
175
175
|
// src/commands/vm/index.ts
|
|
176
176
|
import { Command as Command44 } from "commander";
|
|
@@ -804,6 +804,14 @@ var MachineSchema = z2.object({
|
|
|
804
804
|
* each time it is needed. Absent: none. A host before integrations never sends it.
|
|
805
805
|
*/
|
|
806
806
|
integrations: z2.array(z2.string()).optional(),
|
|
807
|
+
/** The id of the cluster the box is a part of on its host (#215), as the host keeps it. Absent: none, or a host from before it said so. */
|
|
808
|
+
clusterId: z2.string().optional(),
|
|
809
|
+
/**
|
|
810
|
+
* The Kubernetes cluster the box is a node of, and its pool (#218). Only the control plane fills it in, on
|
|
811
|
+
* `GET /machines`. Such a box is opened like any other, but what would change it is its pool's to do
|
|
812
|
+
* (`kvbox k8s pool`): the control plane refuses it on the box.
|
|
813
|
+
*/
|
|
814
|
+
cluster: z2.object({ name: z2.string(), pool: z2.string() }).optional(),
|
|
807
815
|
/** How to reach what the box serves, its secrets masked (#87): `postgres://postgres:****@db.kvbox:5432/postgres`. */
|
|
808
816
|
url: z2.string().optional(),
|
|
809
817
|
/**
|
|
@@ -979,8 +987,11 @@ var CreateMachineRequest = z2.object({
|
|
|
979
987
|
host: z2.string().optional(),
|
|
980
988
|
/** The image to boot (#87, `kvbox new --base postgres`). Absent: the base image. */
|
|
981
989
|
image: z2.string().optional(),
|
|
982
|
-
/**
|
|
983
|
-
|
|
990
|
+
/**
|
|
991
|
+
* The box's own environment variables (#87, `kvbox new -e NAME=value`), over its owner's. `secret`: kept as a
|
|
992
|
+
* secret, whose value no route answers with (a cluster's join token, #216); a host from before it keeps it plain.
|
|
993
|
+
*/
|
|
994
|
+
env: z2.array(z2.object({ name: z2.string(), value: z2.string(), secret: z2.boolean().optional() })).optional(),
|
|
984
995
|
/**
|
|
985
996
|
* Start the box on this backup's disk (#141, `kvbox new --from-backup <id>`), a removed box's too: its image,
|
|
986
997
|
* version and variables come from the backup, its size too unless given. Only the control plane reads it.
|
|
@@ -1231,6 +1242,32 @@ var CronUsageSchema = z2.object({
|
|
|
1231
1242
|
/** When it was made. */
|
|
1232
1243
|
historyFrom: z2.string().nullable()
|
|
1233
1244
|
});
|
|
1245
|
+
var ClusterUsageSchema = z2.object({
|
|
1246
|
+
id: z2.string(),
|
|
1247
|
+
name: z2.string(),
|
|
1248
|
+
owner: z2.string(),
|
|
1249
|
+
ownerKind: z2.enum(["user", "org"]).optional(),
|
|
1250
|
+
/** `removed` once its master is. */
|
|
1251
|
+
status: z2.enum(["present", "removed"]),
|
|
1252
|
+
/** The hours its master existed in the window, running or not. */
|
|
1253
|
+
hours: z2.number(),
|
|
1254
|
+
master: z2.object({
|
|
1255
|
+
seconds: MachineUsageSchema.shape.seconds,
|
|
1256
|
+
vcpuHours: z2.number(),
|
|
1257
|
+
ramGibHours: z2.number(),
|
|
1258
|
+
diskGibHours: z2.number(),
|
|
1259
|
+
volumeHours: z2.number(),
|
|
1260
|
+
volumeGibHours: z2.number(),
|
|
1261
|
+
cost: z2.object({ amount: z2.number(), currency: z2.string() }).optional()
|
|
1262
|
+
}),
|
|
1263
|
+
nodes: z2.array(BoxUsageSchema.extend({
|
|
1264
|
+
/** The pool it is, or was, a node of. */
|
|
1265
|
+
pool: z2.string().optional()
|
|
1266
|
+
})),
|
|
1267
|
+
fee: z2.object({ amount: z2.number(), currency: z2.string() }).optional(),
|
|
1268
|
+
cost: z2.object({ amount: z2.number(), currency: z2.string() }).optional(),
|
|
1269
|
+
historyFrom: z2.string().nullable()
|
|
1270
|
+
});
|
|
1234
1271
|
var BackupUsageSchema = z2.object({
|
|
1235
1272
|
id: z2.string(),
|
|
1236
1273
|
kind: z2.string(),
|
|
@@ -1264,6 +1301,8 @@ var UsageDaySchema = z2.object({
|
|
|
1264
1301
|
storage: z2.array(UsageDayItemSchema).optional(),
|
|
1265
1302
|
/** Cron services that existed that day (#190); absent on a day without any. */
|
|
1266
1303
|
cron: z2.array(UsageDayItemSchema).optional(),
|
|
1304
|
+
/** Kubernetes clusters that existed that day (#222), each with its master and nodes together; absent on a day without any. */
|
|
1305
|
+
clusters: z2.array(UsageDayItemSchema).optional(),
|
|
1267
1306
|
/** Paid backups that turned ready that day, summed per thing backed up (`id` is `<owner>/<kind>:<name>`); absent on a day without any. */
|
|
1268
1307
|
backups: z2.array(UsageDayItemSchema).optional()
|
|
1269
1308
|
});
|
|
@@ -1280,6 +1319,11 @@ var UsageReportSchema = z2.object({
|
|
|
1280
1319
|
storage: z2.array(VolumeUsageSchema).optional(),
|
|
1281
1320
|
/** Cron services (#190, control plane only): one row per service a slug has or had. Absent when there is none. */
|
|
1282
1321
|
cron: z2.array(CronUsageSchema).optional(),
|
|
1322
|
+
/**
|
|
1323
|
+
* Kubernetes clusters (#222, control plane only): one row per cluster a slug has or had, with its master
|
|
1324
|
+
* and its nodes; those boxes are in no other list. Absent when there is none.
|
|
1325
|
+
*/
|
|
1326
|
+
clusters: z2.array(ClusterUsageSchema).optional(),
|
|
1283
1327
|
/** Paid backups (control plane only): one row per box, volume or service backed up by hand in the window. Absent when there is none. */
|
|
1284
1328
|
backups: z2.array(BackupUsageSchema).optional(),
|
|
1285
1329
|
/** With `?by=day` only, oldest day first. */
|
|
@@ -1291,7 +1335,7 @@ var UsageReportSchema = z2.object({
|
|
|
1291
1335
|
diskGibHours: z2.number(),
|
|
1292
1336
|
volumeHours: z2.number().optional(),
|
|
1293
1337
|
volumeGibHours: z2.number().optional(),
|
|
1294
|
-
/** Boxes, volumes, object storage, cron services and paid backups together. */
|
|
1338
|
+
/** Boxes, volumes, object storage, cron services, Kubernetes clusters and paid backups together; the hours above are those of `boxes` and `volumes` alone. */
|
|
1295
1339
|
cost: z2.object({ amount: z2.number(), currency: z2.string() }).optional()
|
|
1296
1340
|
})
|
|
1297
1341
|
});
|
|
@@ -1326,7 +1370,7 @@ var VolumeEventsResponseSchema = z2.object({
|
|
|
1326
1370
|
events: z2.array(VolumeEventRowSchema),
|
|
1327
1371
|
next: z2.number().int()
|
|
1328
1372
|
});
|
|
1329
|
-
var API_ERROR_CODES = ["account-inactive", "org-inactive", "out-of-credit", "box-outdated", "storage-outdated", "object-exists", "storage-waking"];
|
|
1373
|
+
var API_ERROR_CODES = ["account-inactive", "org-inactive", "out-of-credit", "box-outdated", "storage-outdated", "object-exists", "storage-waking", "cluster-busy", "node-has-data"];
|
|
1330
1374
|
var ApiErrorCodeSchema = z2.enum(API_ERROR_CODES);
|
|
1331
1375
|
var ApiErrorSchema = z2.object({
|
|
1332
1376
|
error: z2.string(),
|
|
@@ -1496,6 +1540,16 @@ var LoginResponseSchema = z2.object({
|
|
|
1496
1540
|
/** Whose boxes the certificate opens: `<slug>@<realm>` for the user and each org they are in (orgs phase 4). */
|
|
1497
1541
|
sshCertPrincipals: z2.array(z2.string()).optional()
|
|
1498
1542
|
});
|
|
1543
|
+
var PasswordResetRequestSchema = z2.object({
|
|
1544
|
+
email: z2.string().min(1).max(320)
|
|
1545
|
+
});
|
|
1546
|
+
var PasswordResetCheckSchema = z2.object({
|
|
1547
|
+
token: z2.string().min(1).max(200)
|
|
1548
|
+
});
|
|
1549
|
+
var PasswordResetConfirmSchema = z2.object({
|
|
1550
|
+
token: z2.string().min(1).max(200),
|
|
1551
|
+
password: z2.string().min(1)
|
|
1552
|
+
});
|
|
1499
1553
|
var DEVICE_LOGIN_PICKUP_SEC = 60;
|
|
1500
1554
|
var DeviceLoginRequestSchema = z2.object({
|
|
1501
1555
|
// Capped: anyone may open a login, and the key is stored until it expires (an RSA-16384 key is ~2.8 KB).
|
|
@@ -1789,6 +1843,353 @@ async function ensureCert(client, p = paths(), now = Date.now(), opts = {}) {
|
|
|
1789
1843
|
return "renewed";
|
|
1790
1844
|
}
|
|
1791
1845
|
|
|
1846
|
+
// ../shared/src/k8s.ts
|
|
1847
|
+
import { z as z6 } from "zod";
|
|
1848
|
+
|
|
1849
|
+
// ../shared/src/managed.ts
|
|
1850
|
+
import { z as z5 } from "zod";
|
|
1851
|
+
|
|
1852
|
+
// ../shared/src/usage.ts
|
|
1853
|
+
import { z as z4 } from "zod";
|
|
1854
|
+
var PricingSchema = z4.object({
|
|
1855
|
+
currency: z4.string().min(1),
|
|
1856
|
+
vcpuHour: z4.number().nonnegative(),
|
|
1857
|
+
ramGibHour: z4.number().nonnegative(),
|
|
1858
|
+
diskGibHour: z4.number().nonnegative(),
|
|
1859
|
+
volumeHour: z4.number().nonnegative().default(0),
|
|
1860
|
+
volumeGibHour: z4.number().nonnegative().default(0),
|
|
1861
|
+
diskIncludedGib: z4.number().int().nonnegative().default(0),
|
|
1862
|
+
/**
|
|
1863
|
+
* Object storage (#182): an hour of a slug's storage existing, whatever it holds, which covers its
|
|
1864
|
+
* hidden box and the first `storageIncludedGib` of its size; each GiB above that is `storageGibHour`.
|
|
1865
|
+
* A price list from before object storage charges nothing for it.
|
|
1866
|
+
*/
|
|
1867
|
+
storageHour: z4.number().nonnegative().default(0),
|
|
1868
|
+
storageGibHour: z4.number().nonnegative().default(0),
|
|
1869
|
+
storageIncludedGib: z4.number().int().nonnegative().default(0),
|
|
1870
|
+
/** 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
|
+
cronHour: z4.number().nonnegative().default(0),
|
|
1872
|
+
/**
|
|
1873
|
+
* One backup a person starts, of anything, charged once it is ready (decision "A backup taken by hand
|
|
1874
|
+
* costs a flat price…"); a failed one costs nothing. A price list from before it charges nothing.
|
|
1875
|
+
*/
|
|
1876
|
+
backup: z4.number().nonnegative().default(0),
|
|
1877
|
+
/**
|
|
1878
|
+
* One nightly backup of a box, a volume or the object storage, charged once it is ready (decision "A nightly
|
|
1879
|
+
* backup you switch on is charged…"): their switch is off until someone turns it on. A managed database's
|
|
1880
|
+
* nightly backup, on from its creation, is included in its price. A price list from before it charges nothing.
|
|
1881
|
+
*/
|
|
1882
|
+
scheduledBackup: z4.number().nonnegative().default(0),
|
|
1883
|
+
/**
|
|
1884
|
+
* A Kubernetes cluster (#222): an hour of one existing, on top of its boxes. A cluster is priced as the
|
|
1885
|
+
* boxes it is (its master and its nodes), so this is 0 until a flat fee is wanted.
|
|
1886
|
+
*/
|
|
1887
|
+
clusterHour: z4.number().nonnegative().default(0)
|
|
1888
|
+
});
|
|
1889
|
+
var PriceListSchema = PricingSchema.extend({ welcomeCredit: z4.number().nonnegative() });
|
|
1890
|
+
var HOUR_MS = 36e5;
|
|
1891
|
+
var round = (n2, places) => Math.round(n2 * 10 ** places) / 10 ** places;
|
|
1892
|
+
function costOf(t, pricing) {
|
|
1893
|
+
return t.vcpuHours * pricing.vcpuHour + t.ramGibHours * pricing.ramGibHour + t.diskGibHours * pricing.diskGibHour;
|
|
1894
|
+
}
|
|
1895
|
+
function sumUsage(items, pricing) {
|
|
1896
|
+
const sum = {
|
|
1897
|
+
seconds: { running: 0, standby: 0, hibernated: 0, stopped: 0 },
|
|
1898
|
+
vcpuHours: 0,
|
|
1899
|
+
ramGibHours: 0,
|
|
1900
|
+
diskGibHours: 0
|
|
1901
|
+
};
|
|
1902
|
+
for (const t of items) {
|
|
1903
|
+
for (const s of Object.keys(sum.seconds)) sum.seconds[s] += t.seconds[s];
|
|
1904
|
+
sum.vcpuHours += t.vcpuHours;
|
|
1905
|
+
sum.ramGibHours += t.ramGibHours;
|
|
1906
|
+
sum.diskGibHours += t.diskGibHours;
|
|
1907
|
+
}
|
|
1908
|
+
sum.vcpuHours = round(sum.vcpuHours, 3);
|
|
1909
|
+
sum.ramGibHours = round(sum.ramGibHours, 3);
|
|
1910
|
+
sum.diskGibHours = round(sum.diskGibHours, 3);
|
|
1911
|
+
if (pricing !== void 0) sum.cost = { amount: round(costOf(sum, pricing), 4), currency: pricing.currency };
|
|
1912
|
+
return sum;
|
|
1913
|
+
}
|
|
1914
|
+
var DAY_MS = 24 * HOUR_MS;
|
|
1915
|
+
|
|
1916
|
+
// ../shared/src/managed.ts
|
|
1917
|
+
var PriceSchema = z5.object({ perMonth: z5.number(), storagePerMonth: z5.number(), currency: z5.string() });
|
|
1918
|
+
var ManagedCatalogEntrySchema = z5.object({
|
|
1919
|
+
/** The kind, as in `/managed/<kind>`: `postgres`. */
|
|
1920
|
+
kind: z5.string(),
|
|
1921
|
+
/** The CLI command for it: `pg` (`kvbox pg create …`). */
|
|
1922
|
+
command: z5.string(),
|
|
1923
|
+
title: z5.string(),
|
|
1924
|
+
description: z5.string(),
|
|
1925
|
+
/** The version a new one runs, as shown: `18`. */
|
|
1926
|
+
version: z5.string(),
|
|
1927
|
+
/** The port a linked box reaches it on. */
|
|
1928
|
+
port: z5.number().int(),
|
|
1929
|
+
/** The port `public on` opens behind a host port: `port` again unless the kind serves TLS on another. */
|
|
1930
|
+
publicPort: z5.number().int(),
|
|
1931
|
+
/** Its guide, as a URL. */
|
|
1932
|
+
docs: z5.string().optional(),
|
|
1933
|
+
storage: z5.object({ defaultGib: z5.number().int(), minGib: z5.number().int(), maxGib: z5.number().int() }),
|
|
1934
|
+
/**
|
|
1935
|
+
* What create takes of this kind alone, beside what every kind takes (name, password, storage, near): a
|
|
1936
|
+
* flag and a form field each, all optional, `default` in words.
|
|
1937
|
+
*/
|
|
1938
|
+
options: z5.array(z5.object({ name: z5.string(), title: z5.string(), description: z5.string(), default: z5.string() })),
|
|
1939
|
+
/** A month of it running with the default storage, and each further GB of storage. */
|
|
1940
|
+
price: PriceSchema.extend({ storageGibPerMonth: z5.number() }),
|
|
1941
|
+
/** Whether a host answering now can run it. */
|
|
1942
|
+
available: z5.boolean()
|
|
1943
|
+
});
|
|
1944
|
+
var CreateManagedRequest = z5.object({
|
|
1945
|
+
name: z5.string(),
|
|
1946
|
+
/** The kind's own options by name (its catalog entry lists them); the kind checks them. */
|
|
1947
|
+
options: z5.record(z5.string(), z5.string()).optional(),
|
|
1948
|
+
password: z5.string().optional(),
|
|
1949
|
+
storageGib: z5.number().int().optional(),
|
|
1950
|
+
/** Place it on the host of this box, so the box can be linked to it. */
|
|
1951
|
+
near: z5.string().optional(),
|
|
1952
|
+
/**
|
|
1953
|
+
* A backup of a database of the same kind and major version, of the same account (#186): the new
|
|
1954
|
+
* service starts on its data, a removed service's included. Its settings (Postgres: database, user)
|
|
1955
|
+
* are the backup's; the password is the new one.
|
|
1956
|
+
*/
|
|
1957
|
+
fromBackup: z5.string().optional()
|
|
1958
|
+
});
|
|
1959
|
+
var ManagedHealthSchema = z5.object({
|
|
1960
|
+
/** Its first start has finished: it has set itself up on its storage. */
|
|
1961
|
+
ready: z5.boolean(),
|
|
1962
|
+
/** It accepts connections. */
|
|
1963
|
+
accepting: z5.boolean(),
|
|
1964
|
+
version: z5.string(),
|
|
1965
|
+
/** The storage volume: what is used of it and its size. */
|
|
1966
|
+
storageUsedBytes: z5.number().optional(),
|
|
1967
|
+
storageTotalBytes: z5.number().optional(),
|
|
1968
|
+
/** What else the kind reports, ready to show: `{title: "Connections", value: "3"}`. */
|
|
1969
|
+
facts: z5.array(z5.object({ title: z5.string(), value: z5.string() }))
|
|
1970
|
+
});
|
|
1971
|
+
var UrlsSchema = z5.object({ private: z5.string(), public: z5.string().optional() });
|
|
1972
|
+
var ManagedSchema = z5.object({
|
|
1973
|
+
kind: z5.string(),
|
|
1974
|
+
name: z5.string(),
|
|
1975
|
+
/** The owning slug, bare. */
|
|
1976
|
+
owner: z5.string(),
|
|
1977
|
+
ownerKind: z5.enum(["user", "org"]),
|
|
1978
|
+
/** `running`, `stopped` (storage only is charged), `hibernated` or `standby` (out of credit), `unknown` (its host does not answer). */
|
|
1979
|
+
status: BoxStatusSchema,
|
|
1980
|
+
/** The catalog version: `18`. */
|
|
1981
|
+
version: z5.string(),
|
|
1982
|
+
/** What the kind keeps of its create options, defaults filled in: `{database, user}` for Postgres, `{}` for a kind with none. */
|
|
1983
|
+
settings: z5.record(z5.string(), z5.string()),
|
|
1984
|
+
storageGib: z5.number().int(),
|
|
1985
|
+
/** Where a linked box reaches it: `<name>.<slug>.kvbox` (resolves from a box of any slug it is linked to) and the port. */
|
|
1986
|
+
private: z5.object({ host: z5.string(), port: z5.number().int() }),
|
|
1987
|
+
/** Where the internet reaches it, null while it is not public. The port is its own for its whole life. */
|
|
1988
|
+
public: z5.object({ host: z5.string(), port: z5.number().int() }).nullable(),
|
|
1989
|
+
/** The boxes linked to it, as the caller would name them. */
|
|
1990
|
+
links: z5.array(z5.string()),
|
|
1991
|
+
/** The name of the host it runs on, for `--near` and links. */
|
|
1992
|
+
host: z5.string(),
|
|
1993
|
+
country: z5.string().optional(),
|
|
1994
|
+
createdBy: z5.string().nullable(),
|
|
1995
|
+
createdAt: z5.string(),
|
|
1996
|
+
/** Connection strings with the password as `****`. */
|
|
1997
|
+
urls: UrlsSchema,
|
|
1998
|
+
price: PriceSchema,
|
|
1999
|
+
/** Its nightly backup (#186 slice 4): on from creation, `kvbox <kind> backup schedule` changes it. Null for a control plane from before schedules. */
|
|
2000
|
+
backupSchedule: BackupScheduleSchema.nullable().default(null),
|
|
2001
|
+
/** Only in `GET /managed/<kind>/<name>` (asked live): null when it is not running or did not answer. */
|
|
2002
|
+
health: ManagedHealthSchema.nullable().optional()
|
|
2003
|
+
});
|
|
2004
|
+
var ManagedSecretSchema = z5.object({ password: z5.string(), urls: UrlsSchema });
|
|
2005
|
+
var CreatedManagedSchema = ManagedSchema.extend({
|
|
2006
|
+
secret: ManagedSecretSchema,
|
|
2007
|
+
/** The backup it was made from (`fromBackup`), when it was. */
|
|
2008
|
+
fromBackup: z5.string().optional()
|
|
2009
|
+
});
|
|
2010
|
+
var ResetPasswordRequest = z5.object({ password: z5.string().optional() });
|
|
2011
|
+
var SetPublicRequest = z5.object({ on: z5.boolean() });
|
|
2012
|
+
var ManagedLinkRequest = z5.object({ box: z5.string() });
|
|
2013
|
+
var GrowManagedRequest = z5.object({ storageGib: z5.number().int() });
|
|
2014
|
+
var ManagedBackupSchema = z5.object({
|
|
2015
|
+
id: z5.string(),
|
|
2016
|
+
owner: z5.string(),
|
|
2017
|
+
kind: z5.string(),
|
|
2018
|
+
name: z5.string(),
|
|
2019
|
+
version: z5.string(),
|
|
2020
|
+
status: z5.enum(BACKUP_STATUSES),
|
|
2021
|
+
/** Why it failed; null otherwise. */
|
|
2022
|
+
error: z5.string().nullable(),
|
|
2023
|
+
/** The service's storage when taken. */
|
|
2024
|
+
diskBytes: z5.number().int().nullable(),
|
|
2025
|
+
/** What it holds: the slots that are not all zeros. */
|
|
2026
|
+
dataBytes: z5.number().int().nullable(),
|
|
2027
|
+
/** What this backup added to storage (encrypted, compressed): the chunks no earlier backup had. */
|
|
2028
|
+
uploadedBytes: z5.number().int().nullable(),
|
|
2029
|
+
/** Who asked for it; for a scheduled one, the database's creator. */
|
|
2030
|
+
createdBy: z5.string().nullable(),
|
|
2031
|
+
/** Started by the database's backup schedule, not by a person: it does not count toward the daily limit. */
|
|
2032
|
+
scheduled: z5.boolean().default(false),
|
|
2033
|
+
createdAt: z5.string(),
|
|
2034
|
+
finishedAt: z5.string().nullable()
|
|
2035
|
+
});
|
|
2036
|
+
|
|
2037
|
+
// ../shared/src/k8s.ts
|
|
2038
|
+
var ClaimClusterSubdomainRequest = z6.object({ name: z6.string() });
|
|
2039
|
+
var AddClusterDomainRequest = z6.object({ domain: z6.string() });
|
|
2040
|
+
var ClusterLinkRequest = z6.object({ to: z6.string().min(1), port: z6.number().int().min(1).max(65535).optional() });
|
|
2041
|
+
var ClusterLinkSchema = z6.object({
|
|
2042
|
+
/** The database's or the box's name, and its slug. */
|
|
2043
|
+
to: z6.string(),
|
|
2044
|
+
owner: z6.string(),
|
|
2045
|
+
/** `postgres`, `redis`, or `box`. */
|
|
2046
|
+
kind: z6.string(),
|
|
2047
|
+
port: z6.number().int(),
|
|
2048
|
+
/** Where a pod finds it: `<name>.<slug>.kvbox`. */
|
|
2049
|
+
host: z6.string(),
|
|
2050
|
+
/** The cluster's boxes that have the link now, by name (the master is the cluster's own name); only in the answer to a link or an unlink. */
|
|
2051
|
+
boxes: z6.array(z6.string()).optional()
|
|
2052
|
+
});
|
|
2053
|
+
var NODE_SIZES = ["s", "m", "l"];
|
|
2054
|
+
var DEFAULT_POOL_NODES = 2;
|
|
2055
|
+
var MAX_POOL_NODES = 9;
|
|
2056
|
+
var ClusterPriceSchema = z6.object({
|
|
2057
|
+
perMonth: z6.number(),
|
|
2058
|
+
/** Absent from a control plane older than #222. */
|
|
2059
|
+
nodesPerMonth: z6.number().optional(),
|
|
2060
|
+
totalPerMonth: z6.number().optional(),
|
|
2061
|
+
currency: z6.string()
|
|
2062
|
+
});
|
|
2063
|
+
var ClusterCatalogSchema = z6.object({
|
|
2064
|
+
/** The Kubernetes version a new cluster runs: `1.37`. */
|
|
2065
|
+
version: z6.string(),
|
|
2066
|
+
currency: z6.string(),
|
|
2067
|
+
/** Every cluster has one; its price is in every cluster's. */
|
|
2068
|
+
master: z6.object({ size: z6.string(), storageGib: z6.number().int(), perMonth: z6.number() }),
|
|
2069
|
+
/** What a node may be sized at, each with a month of one running. */
|
|
2070
|
+
nodes: z6.array(z6.object({ size: z6.enum(NODE_SIZES), vcpu: z6.number().int(), memMib: z6.number().int(), diskGib: z6.number().int(), perMonth: z6.number() })),
|
|
2071
|
+
/** The flat price per cluster a month, part of `master.perMonth`; 0 while there is none. */
|
|
2072
|
+
clusterPerMonth: z6.number(),
|
|
2073
|
+
/** The smallest cluster: its master and `defaultNodes` nodes of the smallest size. */
|
|
2074
|
+
fromPerMonth: z6.number(),
|
|
2075
|
+
limits: z6.object({ defaultNodes: z6.number().int(), maxPoolNodes: z6.number().int(), nameRule: z6.string() })
|
|
2076
|
+
});
|
|
2077
|
+
var CreateClusterRequest = z6.object({
|
|
2078
|
+
name: z6.string(),
|
|
2079
|
+
/** What each node of its first pool is sized at. */
|
|
2080
|
+
size: z6.enum(NODE_SIZES),
|
|
2081
|
+
/** How many nodes that pool starts with (`DEFAULT_POOL_NODES`). */
|
|
2082
|
+
nodes: z6.number().int().min(1).max(MAX_POOL_NODES).optional(),
|
|
2083
|
+
/** Place it on the host of this box. */
|
|
2084
|
+
near: z6.string().optional()
|
|
2085
|
+
});
|
|
2086
|
+
var AddPoolRequest = z6.object({
|
|
2087
|
+
/** Without one the pool is named after its size (`m`). */
|
|
2088
|
+
name: z6.string().optional(),
|
|
2089
|
+
size: z6.enum(NODE_SIZES),
|
|
2090
|
+
/** How many nodes it starts with (`DEFAULT_POOL_NODES`). */
|
|
2091
|
+
nodes: z6.number().int().min(1).max(MAX_POOL_NODES).optional()
|
|
2092
|
+
});
|
|
2093
|
+
var ResizePoolRequest = z6.object({
|
|
2094
|
+
nodes: z6.number().int().min(1).max(MAX_POOL_NODES),
|
|
2095
|
+
/** Fewer nodes only: they go at once, undrained, whatever they keep on their own disks. */
|
|
2096
|
+
force: z6.boolean().optional()
|
|
2097
|
+
});
|
|
2098
|
+
var ClusterNodeSchema = z6.object({
|
|
2099
|
+
name: z6.string(),
|
|
2100
|
+
ready: z6.boolean(),
|
|
2101
|
+
/** False for a cordoned node. */
|
|
2102
|
+
schedulable: z6.boolean(),
|
|
2103
|
+
/** `control-plane` on the master, none on a node. */
|
|
2104
|
+
roles: z6.array(z6.string()),
|
|
2105
|
+
version: z6.string().nullable().optional(),
|
|
2106
|
+
address: z6.string().optional(),
|
|
2107
|
+
/** Bound persistent volumes kept on this node's own disk: what removing the node would lose. */
|
|
2108
|
+
volumes: z6.number().int(),
|
|
2109
|
+
/** Those volumes by their claim, `namespace/name` (k3s image v0.1.2 and later). */
|
|
2110
|
+
claims: z6.array(z6.string()).optional()
|
|
2111
|
+
});
|
|
2112
|
+
var ClusterHealthSchema = z6.object({
|
|
2113
|
+
/** The master has set itself up and the API answers. */
|
|
2114
|
+
ready: z6.boolean(),
|
|
2115
|
+
/** Traefik runs: the cluster answers on ports 80 and 443. */
|
|
2116
|
+
ingress: z6.boolean(),
|
|
2117
|
+
/** k3s's own version: `v1.37.2+k3s1`. */
|
|
2118
|
+
version: z6.string().optional(),
|
|
2119
|
+
nodes: z6.array(ClusterNodeSchema)
|
|
2120
|
+
});
|
|
2121
|
+
var ClusterPoolSchema = z6.object({
|
|
2122
|
+
name: z6.string(),
|
|
2123
|
+
size: z6.enum(NODE_SIZES),
|
|
2124
|
+
/** How many nodes it is meant to have; 0 for a pool that is being removed. */
|
|
2125
|
+
nodes: z6.number().int(),
|
|
2126
|
+
/** The boxes that are its nodes, by name; a box's name is its node's name in the cluster. */
|
|
2127
|
+
boxes: z6.array(z6.string())
|
|
2128
|
+
});
|
|
2129
|
+
var ClusterSchema = z6.object({
|
|
2130
|
+
name: z6.string(),
|
|
2131
|
+
/** The owning slug, bare. */
|
|
2132
|
+
owner: z6.string(),
|
|
2133
|
+
ownerKind: z6.enum(["user", "org"]),
|
|
2134
|
+
/** The master's: `running`, `stopped`, `hibernated` or `standby` (out of credit), `unknown` (its host does not answer). */
|
|
2135
|
+
status: BoxStatusSchema,
|
|
2136
|
+
/** The Kubernetes version it was made with: `1.37`. */
|
|
2137
|
+
version: z6.string(),
|
|
2138
|
+
/** Where kubectl reaches the API, null when the port is not open. The port is the cluster's for its whole life. */
|
|
2139
|
+
api: z6.object({ host: z6.string(), port: z6.number().int() }).nullable(),
|
|
2140
|
+
/** The one host all of it runs on. */
|
|
2141
|
+
host: z6.string(),
|
|
2142
|
+
country: z6.string().optional(),
|
|
2143
|
+
createdBy: z6.string().nullable(),
|
|
2144
|
+
createdAt: z6.string(),
|
|
2145
|
+
/** Its node pools; none on a cluster from before pools, whose master runs nothing of its owner's. */
|
|
2146
|
+
pools: z6.array(ClusterPoolSchema).default([]),
|
|
2147
|
+
/** What a month of it costs: its master, its nodes as they are now, and both together. */
|
|
2148
|
+
price: ClusterPriceSchema,
|
|
2149
|
+
/**
|
|
2150
|
+
* Only in `GET /k8s/<name>`: how many more nodes of each size its host can take right now, as the host
|
|
2151
|
+
* last reported its room (nothing is reserved: another box may take it first); null when the host is not answering.
|
|
2152
|
+
*/
|
|
2153
|
+
room: z6.object({ s: z6.number().int(), m: z6.number().int(), l: z6.number().int() }).nullable().optional(),
|
|
2154
|
+
/**
|
|
2155
|
+
* What is changing it right now (one thing at a time); absent when nothing is. `since` is the lease's last
|
|
2156
|
+
* stamp, renewed while the change goes on: when it was last seen alive, not when it began.
|
|
2157
|
+
*/
|
|
2158
|
+
operation: z6.object({ what: z6.string(), since: z6.string() }).optional(),
|
|
2159
|
+
/**
|
|
2160
|
+
* What the last change could not do after its request was answered (a node that would not drain, a new
|
|
2161
|
+
* node that never joined), in words; gone when the next change starts.
|
|
2162
|
+
*/
|
|
2163
|
+
operationError: z6.string().optional(),
|
|
2164
|
+
/**
|
|
2165
|
+
* Only in `GET /k8s/<name>`: the HTTPS addresses that reach its Traefik (#219), the `kvbox.app` names it
|
|
2166
|
+
* claimed and its custom domains that are live. None until one is claimed or added.
|
|
2167
|
+
*/
|
|
2168
|
+
addresses: z6.array(z6.string()).optional(),
|
|
2169
|
+
/** Only in `GET /k8s/<name>` (asked live): null when the master is not running or did not answer. */
|
|
2170
|
+
health: ClusterHealthSchema.nullable().optional(),
|
|
2171
|
+
/**
|
|
2172
|
+
* When the cluster's state is backed up on its own (#221): nightly from its creation, included in its
|
|
2173
|
+
* price. Null for one whose create stopped before its schedule was written (the backup job gives it one).
|
|
2174
|
+
*/
|
|
2175
|
+
backupSchedule: BackupScheduleSchema.nullable().optional()
|
|
2176
|
+
});
|
|
2177
|
+
var ClusterRestoreSchema = z6.object({
|
|
2178
|
+
backup: z6.string(),
|
|
2179
|
+
cluster: ClusterSchema,
|
|
2180
|
+
nodes: z6.object({
|
|
2181
|
+
/** Nodes the backup knew whose boxes were removed since: taken out of the cluster's list again. */
|
|
2182
|
+
forgotten: z6.array(z6.string()),
|
|
2183
|
+
/** Nodes made since the backup, which it does not know: their boxes were restarted so they join again. */
|
|
2184
|
+
restarted: z6.array(z6.string())
|
|
2185
|
+
}),
|
|
2186
|
+
/** False when the master did not answer after the restore, so its nodes were not compared with the cluster's boxes. */
|
|
2187
|
+
checked: z6.boolean(),
|
|
2188
|
+
/** What could not be put right, in words. */
|
|
2189
|
+
warnings: z6.array(z6.string())
|
|
2190
|
+
});
|
|
2191
|
+
var KubeconfigSchema = z6.object({ kubeconfig: z6.string() });
|
|
2192
|
+
|
|
1792
2193
|
// src/client.ts
|
|
1793
2194
|
import { spawn } from "child_process";
|
|
1794
2195
|
import { openSync } from "fs";
|
|
@@ -1797,21 +2198,21 @@ import { setTimeout as sleep2 } from "timers/promises";
|
|
|
1797
2198
|
import { Agent, request } from "undici";
|
|
1798
2199
|
|
|
1799
2200
|
// ../sdk/src/machines.ts
|
|
1800
|
-
import { z as
|
|
2201
|
+
import { z as z9 } from "zod";
|
|
1801
2202
|
|
|
1802
2203
|
// ../shared/src/resources.ts
|
|
1803
|
-
import { z as
|
|
2204
|
+
import { z as z7 } from "zod";
|
|
1804
2205
|
var RESOURCE_SLOT_MS = 5 * 6e4;
|
|
1805
2206
|
var RESOURCE_KEEP_DAYS = 7;
|
|
1806
2207
|
var RESOURCE_KEEP_MS = RESOURCE_KEEP_DAYS * 864e5;
|
|
1807
|
-
var whole =
|
|
1808
|
-
var pct =
|
|
2208
|
+
var whole = z7.number().int().nonnegative();
|
|
2209
|
+
var pct = z7.number().min(0).max(100);
|
|
1809
2210
|
var small = whole.max(2 ** 31 - 1);
|
|
1810
|
-
var ResourceSlotRowSchema =
|
|
2211
|
+
var ResourceSlotRowSchema = z7.object({
|
|
1811
2212
|
/** The host's box id. */
|
|
1812
|
-
boxId:
|
|
1813
|
-
owner:
|
|
1814
|
-
name:
|
|
2213
|
+
boxId: z7.string(),
|
|
2214
|
+
owner: z7.string(),
|
|
2215
|
+
name: z7.string(),
|
|
1815
2216
|
/** The slot's start, ms since the epoch. */
|
|
1816
2217
|
slot: whole,
|
|
1817
2218
|
vcpu: small,
|
|
@@ -1827,11 +2228,11 @@ var ResourceSlotRowSchema = z4.object({
|
|
|
1827
2228
|
netInBytes: whole,
|
|
1828
2229
|
netOutBytes: whole
|
|
1829
2230
|
});
|
|
1830
|
-
var ResourceSlotsResponseSchema =
|
|
1831
|
-
slots:
|
|
2231
|
+
var ResourceSlotsResponseSchema = z7.object({
|
|
2232
|
+
slots: z7.array(ResourceSlotRowSchema),
|
|
1832
2233
|
next: whole
|
|
1833
2234
|
});
|
|
1834
|
-
var ResourceSlotsPageSchema =
|
|
2235
|
+
var ResourceSlotsPageSchema = z7.object({ slots: z7.array(z7.unknown()), next: whole });
|
|
1835
2236
|
var figures = {
|
|
1836
2237
|
/** Average and busiest minute, percent of the box's vCPUs; null when the CPU was not measured. */
|
|
1837
2238
|
cpuPct: pct.nullable(),
|
|
@@ -1846,27 +2247,27 @@ var figures = {
|
|
|
1846
2247
|
netInBytes: whole,
|
|
1847
2248
|
netOutBytes: whole
|
|
1848
2249
|
};
|
|
1849
|
-
var ResourcePointSchema =
|
|
1850
|
-
var ResourceReportSchema =
|
|
1851
|
-
box:
|
|
1852
|
-
owner:
|
|
1853
|
-
since:
|
|
1854
|
-
until:
|
|
1855
|
-
stepMin:
|
|
2250
|
+
var ResourcePointSchema = z7.object({ at: z7.string(), ...figures });
|
|
2251
|
+
var ResourceReportSchema = z7.object({
|
|
2252
|
+
box: z7.string(),
|
|
2253
|
+
owner: z7.string(),
|
|
2254
|
+
since: z7.string(),
|
|
2255
|
+
until: z7.string(),
|
|
2256
|
+
stepMin: z7.number().int().positive(),
|
|
1856
2257
|
/** The box's vCPUs as last measured; null without a row. */
|
|
1857
2258
|
vcpu: whole.nullable(),
|
|
1858
|
-
totals:
|
|
1859
|
-
points:
|
|
2259
|
+
totals: z7.object(figures),
|
|
2260
|
+
points: z7.array(ResourcePointSchema)
|
|
1860
2261
|
});
|
|
1861
2262
|
|
|
1862
2263
|
// ../shared/src/traffic.ts
|
|
1863
|
-
import { z as
|
|
2264
|
+
import { z as z8 } from "zod";
|
|
1864
2265
|
var TRAFFIC_SLOT_MS = 5 * 6e4;
|
|
1865
2266
|
var TRAFFIC_KEEP_DAYS = 7;
|
|
1866
2267
|
var TRAFFIC_KEEP_MS = TRAFFIC_KEEP_DAYS * 864e5;
|
|
1867
2268
|
var LATENCY_BUCKETS_MS = [5, 10, 25, 50, 100, 250, 500, 1e3, 2500, 5e3, 1e4, 3e4];
|
|
1868
2269
|
var LATENCY_BUCKET_COUNT = LATENCY_BUCKETS_MS.length + 1;
|
|
1869
|
-
var count =
|
|
2270
|
+
var count = z8.number().int().nonnegative();
|
|
1870
2271
|
var figures2 = {
|
|
1871
2272
|
requests: count,
|
|
1872
2273
|
s2xx: count,
|
|
@@ -1882,28 +2283,28 @@ var figures2 = {
|
|
|
1882
2283
|
p50Ms: count.nullable(),
|
|
1883
2284
|
p95Ms: count.nullable()
|
|
1884
2285
|
};
|
|
1885
|
-
var TrafficPointSchema =
|
|
1886
|
-
var TrafficReportSchema =
|
|
1887
|
-
box:
|
|
1888
|
-
owner:
|
|
1889
|
-
since:
|
|
1890
|
-
until:
|
|
1891
|
-
stepMin:
|
|
2286
|
+
var TrafficPointSchema = z8.object({ at: z8.string(), ...figures2 });
|
|
2287
|
+
var TrafficReportSchema = z8.object({
|
|
2288
|
+
box: z8.string(),
|
|
2289
|
+
owner: z8.string(),
|
|
2290
|
+
since: z8.string(),
|
|
2291
|
+
until: z8.string(),
|
|
2292
|
+
stepMin: z8.number().int().positive(),
|
|
1892
2293
|
/** The one host name asked for; null for all of the box's. */
|
|
1893
|
-
host:
|
|
2294
|
+
host: z8.string().nullable(),
|
|
1894
2295
|
/** Every host name of the box with traffic in the range, whatever `host` is: what a filter can offer. */
|
|
1895
|
-
hosts:
|
|
1896
|
-
totals:
|
|
1897
|
-
points:
|
|
2296
|
+
hosts: z8.array(z8.string()),
|
|
2297
|
+
totals: z8.object(figures2),
|
|
2298
|
+
points: z8.array(TrafficPointSchema)
|
|
1898
2299
|
});
|
|
1899
|
-
var BoxTrafficSchema =
|
|
1900
|
-
var TrafficOverviewSchema =
|
|
1901
|
-
since:
|
|
1902
|
-
until:
|
|
1903
|
-
stepMin:
|
|
1904
|
-
totals:
|
|
1905
|
-
points:
|
|
1906
|
-
boxes:
|
|
2300
|
+
var BoxTrafficSchema = z8.object({ box: z8.string(), owner: z8.string(), ...figures2 });
|
|
2301
|
+
var TrafficOverviewSchema = z8.object({
|
|
2302
|
+
since: z8.string(),
|
|
2303
|
+
until: z8.string(),
|
|
2304
|
+
stepMin: z8.number().int().positive(),
|
|
2305
|
+
totals: z8.object(figures2),
|
|
2306
|
+
points: z8.array(TrafficPointSchema),
|
|
2307
|
+
boxes: z8.array(BoxTrafficSchema)
|
|
1907
2308
|
});
|
|
1908
2309
|
|
|
1909
2310
|
// ../sdk/src/errors.ts
|
|
@@ -2016,7 +2417,7 @@ var Machines = class {
|
|
|
2016
2417
|
ports;
|
|
2017
2418
|
/** Every box the caller can read (their own and their orgs'), sorted by owner then name. */
|
|
2018
2419
|
list(opts = {}) {
|
|
2019
|
-
return this.transport.request("GET", `/machines${listQuery(opts)}`,
|
|
2420
|
+
return this.transport.request("GET", `/machines${listQuery(opts)}`, z9.array(MachineSchema), { org: opts.org });
|
|
2020
2421
|
}
|
|
2021
2422
|
/**
|
|
2022
2423
|
* One box, found in the listing (the API has no route for a single box). `slug/name` looks in that
|
|
@@ -2030,7 +2431,7 @@ var Machines = class {
|
|
|
2030
2431
|
async find(name, orgOpt, timeoutMs) {
|
|
2031
2432
|
const slash = name.indexOf("/");
|
|
2032
2433
|
const [org, bare] = slash === -1 ? [orgOpt, name] : [name.slice(0, slash), name.slice(slash + 1)];
|
|
2033
|
-
const listing = await this.transport.request("GET", "/machines",
|
|
2434
|
+
const listing = await this.transport.request("GET", "/machines", z9.array(MachineSchema), { org, timeoutMs });
|
|
2034
2435
|
const named = listing.filter((m) => m.name === bare && (slash === -1 || slugOf2(m.owner) === org));
|
|
2035
2436
|
if (named.length <= 1) {
|
|
2036
2437
|
if (named[0] !== void 0) return named[0];
|
|
@@ -2064,7 +2465,7 @@ var Machines = class {
|
|
|
2064
2465
|
}
|
|
2065
2466
|
/** Remove the box and its disk. */
|
|
2066
2467
|
async remove(name, opts = {}) {
|
|
2067
|
-
await this.transport.request("DELETE", box(name),
|
|
2468
|
+
await this.transport.request("DELETE", box(name), z9.undefined(), { org: opts.org });
|
|
2068
2469
|
}
|
|
2069
2470
|
/** Boot a stopped box. */
|
|
2070
2471
|
start(name, opts = {}) {
|
|
@@ -2249,7 +2650,7 @@ var slugOf2 = (owner) => {
|
|
|
2249
2650
|
};
|
|
2250
2651
|
|
|
2251
2652
|
// ../sdk/src/snapshots.ts
|
|
2252
|
-
import { z as
|
|
2653
|
+
import { z as z10 } from "zod";
|
|
2253
2654
|
var Snapshots = class {
|
|
2254
2655
|
constructor(transport) {
|
|
2255
2656
|
this.transport = transport;
|
|
@@ -2257,19 +2658,19 @@ var Snapshots = class {
|
|
|
2257
2658
|
transport;
|
|
2258
2659
|
/** Every snapshot the caller can read. */
|
|
2259
2660
|
list(opts = {}) {
|
|
2260
|
-
return this.transport.request("GET", `/snapshots${listQuery(opts)}`,
|
|
2661
|
+
return this.transport.request("GET", `/snapshots${listQuery(opts)}`, z10.array(SnapshotSchema), { org: opts.org });
|
|
2261
2662
|
}
|
|
2262
2663
|
/** Snapshot box `req.box` as `req.name` (`replace`: retake one that exists). The box is paused while it is taken. */
|
|
2263
2664
|
create(req, opts = {}) {
|
|
2264
2665
|
return this.transport.request("POST", "/snapshots", SnapshotSchema, { body: req, org: opts.org });
|
|
2265
2666
|
}
|
|
2266
2667
|
async remove(name, opts = {}) {
|
|
2267
|
-
await this.transport.request("DELETE", `/snapshots/${encodeURIComponent(name)}`,
|
|
2668
|
+
await this.transport.request("DELETE", `/snapshots/${encodeURIComponent(name)}`, z10.undefined(), { org: opts.org });
|
|
2268
2669
|
}
|
|
2269
2670
|
};
|
|
2270
2671
|
|
|
2271
2672
|
// ../sdk/src/transport.ts
|
|
2272
|
-
import { z as
|
|
2673
|
+
import { z as z11 } from "zod";
|
|
2273
2674
|
var Transport = class {
|
|
2274
2675
|
baseUrl;
|
|
2275
2676
|
org;
|
|
@@ -2343,7 +2744,7 @@ var Transport = class {
|
|
|
2343
2744
|
}
|
|
2344
2745
|
}
|
|
2345
2746
|
};
|
|
2346
|
-
var LooseApiErrorSchema =
|
|
2747
|
+
var LooseApiErrorSchema = z11.object({ error: z11.string(), code: z11.string().optional() });
|
|
2347
2748
|
function safeJson(text2) {
|
|
2348
2749
|
try {
|
|
2349
2750
|
return JSON.parse(text2);
|
|
@@ -2373,7 +2774,7 @@ var Hooks = class {
|
|
|
2373
2774
|
};
|
|
2374
2775
|
|
|
2375
2776
|
// ../sdk/src/integrations.ts
|
|
2376
|
-
import { z as
|
|
2777
|
+
import { z as z12 } from "zod";
|
|
2377
2778
|
var Integrations = class {
|
|
2378
2779
|
constructor(transport) {
|
|
2379
2780
|
this.transport = transport;
|
|
@@ -2381,12 +2782,12 @@ var Integrations = class {
|
|
|
2381
2782
|
transport;
|
|
2382
2783
|
/** Each readable slug's state for each integration (`org`: one org's), connected or not; never a credential. */
|
|
2383
2784
|
list(opts = {}) {
|
|
2384
|
-
return this.transport.request("GET", "/integrations",
|
|
2785
|
+
return this.transport.request("GET", "/integrations", z12.array(IntegrationSchema), { org: opts.org });
|
|
2385
2786
|
}
|
|
2386
2787
|
};
|
|
2387
2788
|
|
|
2388
2789
|
// ../sdk/src/volumes.ts
|
|
2389
|
-
import { z as
|
|
2790
|
+
import { z as z13 } from "zod";
|
|
2390
2791
|
var volume = (name, rest = "") => `/volumes/${encodeURIComponent(name)}${rest}`;
|
|
2391
2792
|
var Volumes = class {
|
|
2392
2793
|
constructor(transport) {
|
|
@@ -2394,7 +2795,7 @@ var Volumes = class {
|
|
|
2394
2795
|
}
|
|
2395
2796
|
transport;
|
|
2396
2797
|
list(opts = {}) {
|
|
2397
|
-
return this.transport.request("GET", `/volumes${listQuery(opts)}`,
|
|
2798
|
+
return this.transport.request("GET", `/volumes${listQuery(opts)}`, z13.array(VolumeSchema), { org: opts.org });
|
|
2398
2799
|
}
|
|
2399
2800
|
/**
|
|
2400
2801
|
* Make a volume of `sizeGib` GiB. Through the cloud `box` is required: the volume is made on that
|
|
@@ -2417,7 +2818,7 @@ var Volumes = class {
|
|
|
2417
2818
|
}
|
|
2418
2819
|
/** Remove the volume and its data; it must be detached first. */
|
|
2419
2820
|
async remove(name, opts = {}) {
|
|
2420
|
-
await this.transport.request("DELETE", volume(name),
|
|
2821
|
+
await this.transport.request("DELETE", volume(name), z13.undefined(), { org: opts.org });
|
|
2421
2822
|
}
|
|
2422
2823
|
};
|
|
2423
2824
|
|
|
@@ -2469,382 +2870,201 @@ var Kvbox = class {
|
|
|
2469
2870
|
};
|
|
2470
2871
|
|
|
2471
2872
|
// src/client.ts
|
|
2472
|
-
import { z as
|
|
2473
|
-
|
|
2474
|
-
// ../shared/src/usage.ts
|
|
2475
|
-
import { z as z11 } from "zod";
|
|
2476
|
-
var PricingSchema = z11.object({
|
|
2477
|
-
currency: z11.string().min(1),
|
|
2478
|
-
vcpuHour: z11.number().nonnegative(),
|
|
2479
|
-
ramGibHour: z11.number().nonnegative(),
|
|
2480
|
-
diskGibHour: z11.number().nonnegative(),
|
|
2481
|
-
volumeHour: z11.number().nonnegative().default(0),
|
|
2482
|
-
volumeGibHour: z11.number().nonnegative().default(0),
|
|
2483
|
-
diskIncludedGib: z11.number().int().nonnegative().default(0),
|
|
2484
|
-
/**
|
|
2485
|
-
* Object storage (#182): an hour of a slug's storage existing, whatever it holds, which covers its
|
|
2486
|
-
* hidden box and the first `storageIncludedGib` of its size; each GiB above that is `storageGibHour`.
|
|
2487
|
-
* A price list from before object storage charges nothing for it.
|
|
2488
|
-
*/
|
|
2489
|
-
storageHour: z11.number().nonnegative().default(0),
|
|
2490
|
-
storageGibHour: z11.number().nonnegative().default(0),
|
|
2491
|
-
storageIncludedGib: z11.number().int().nonnegative().default(0),
|
|
2492
|
-
/** The cron service (#190): an hour of one cron service existing, whatever it holds or fires. A price list from before it charges nothing. */
|
|
2493
|
-
cronHour: z11.number().nonnegative().default(0),
|
|
2494
|
-
/**
|
|
2495
|
-
* One backup a person starts, of anything, charged once it is ready (decision "A backup taken by hand
|
|
2496
|
-
* costs a flat price…"); a failed one costs nothing. A price list from before it charges nothing.
|
|
2497
|
-
*/
|
|
2498
|
-
backup: z11.number().nonnegative().default(0),
|
|
2499
|
-
/**
|
|
2500
|
-
* One nightly backup of a box, a volume or the object storage, charged once it is ready (decision "A nightly
|
|
2501
|
-
* backup you switch on is charged…"): their switch is off until someone turns it on. A managed database's
|
|
2502
|
-
* nightly backup, on from its creation, is included in its price. A price list from before it charges nothing.
|
|
2503
|
-
*/
|
|
2504
|
-
scheduledBackup: z11.number().nonnegative().default(0)
|
|
2505
|
-
});
|
|
2506
|
-
var PriceListSchema = PricingSchema.extend({ welcomeCredit: z11.number().nonnegative() });
|
|
2507
|
-
var HOUR_MS = 36e5;
|
|
2508
|
-
var round = (n2, places) => Math.round(n2 * 10 ** places) / 10 ** places;
|
|
2509
|
-
function costOf(t, pricing) {
|
|
2510
|
-
return t.vcpuHours * pricing.vcpuHour + t.ramGibHours * pricing.ramGibHour + t.diskGibHours * pricing.diskGibHour;
|
|
2511
|
-
}
|
|
2512
|
-
function sumUsage(items, pricing) {
|
|
2513
|
-
const sum = {
|
|
2514
|
-
seconds: { running: 0, standby: 0, hibernated: 0, stopped: 0 },
|
|
2515
|
-
vcpuHours: 0,
|
|
2516
|
-
ramGibHours: 0,
|
|
2517
|
-
diskGibHours: 0
|
|
2518
|
-
};
|
|
2519
|
-
for (const t of items) {
|
|
2520
|
-
for (const s of Object.keys(sum.seconds)) sum.seconds[s] += t.seconds[s];
|
|
2521
|
-
sum.vcpuHours += t.vcpuHours;
|
|
2522
|
-
sum.ramGibHours += t.ramGibHours;
|
|
2523
|
-
sum.diskGibHours += t.diskGibHours;
|
|
2524
|
-
}
|
|
2525
|
-
sum.vcpuHours = round(sum.vcpuHours, 3);
|
|
2526
|
-
sum.ramGibHours = round(sum.ramGibHours, 3);
|
|
2527
|
-
sum.diskGibHours = round(sum.diskGibHours, 3);
|
|
2528
|
-
if (pricing !== void 0) sum.cost = { amount: round(costOf(sum, pricing), 4), currency: pricing.currency };
|
|
2529
|
-
return sum;
|
|
2530
|
-
}
|
|
2531
|
-
var DAY_MS = 24 * HOUR_MS;
|
|
2873
|
+
import { z as z16 } from "zod";
|
|
2532
2874
|
|
|
2533
|
-
// ../shared/src/
|
|
2534
|
-
import { z as
|
|
2535
|
-
var
|
|
2536
|
-
var
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
/**
|
|
2550
|
-
|
|
2551
|
-
storage: z12.object({ defaultGib: z12.number().int(), minGib: z12.number().int(), maxGib: z12.number().int() }),
|
|
2552
|
-
/**
|
|
2553
|
-
* What create takes of this kind alone, beside what every kind takes (name, password, storage, near): a
|
|
2554
|
-
* flag and a form field each, all optional, `default` in words.
|
|
2555
|
-
*/
|
|
2556
|
-
options: z12.array(z12.object({ name: z12.string(), title: z12.string(), description: z12.string(), default: z12.string() })),
|
|
2557
|
-
/** A month of it running with the default storage, and each further GB of storage. */
|
|
2558
|
-
price: PriceSchema.extend({ storageGibPerMonth: z12.number() }),
|
|
2559
|
-
/** Whether a host answering now can run it. */
|
|
2560
|
-
available: z12.boolean()
|
|
2875
|
+
// ../shared/src/cron.ts
|
|
2876
|
+
import { z as z14 } from "zod";
|
|
2877
|
+
var DEFAULT_CRON_COMMAND_TIMEOUT_SEC = 600;
|
|
2878
|
+
var MAX_CRON_COMMAND_TIMEOUT_SEC = 3600;
|
|
2879
|
+
var CRON_RUN_LOG_DIR = "/var/log/kvbox/runs";
|
|
2880
|
+
var CRON_METHODS = ["GET", "POST"];
|
|
2881
|
+
var CRON_OUTCOMES = ["running", "ok", "failed", "timeout", "no-credit", "box-stopped", "host-down", "host-outdated", "lost", "still-running", "box-outdated"];
|
|
2882
|
+
var CronServiceSchema = z14.object({
|
|
2883
|
+
owner: z14.string(),
|
|
2884
|
+
ownerKind: z14.enum(["user", "org"]),
|
|
2885
|
+
name: z14.string(),
|
|
2886
|
+
/** Runs kept per trigger. */
|
|
2887
|
+
keepRuns: z14.number().int(),
|
|
2888
|
+
triggers: z14.number().int(),
|
|
2889
|
+
createdBy: z14.string().nullable(),
|
|
2890
|
+
createdAt: z14.string(),
|
|
2891
|
+
/** What it costs while it exists; on the answer to `POST /cron` only. */
|
|
2892
|
+
price: z14.object({ perMonth: z14.number(), currency: z14.string() }).optional()
|
|
2561
2893
|
});
|
|
2562
|
-
var
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
/**
|
|
2569
|
-
|
|
2570
|
-
/**
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2894
|
+
var triggerCommon = {
|
|
2895
|
+
id: z14.string(),
|
|
2896
|
+
service: z14.string(),
|
|
2897
|
+
owner: z14.string(),
|
|
2898
|
+
/** The box it acts on; a trigger is removed with its box. */
|
|
2899
|
+
box: z14.string(),
|
|
2900
|
+
/** Five fields, `minute hour day-of-month month day-of-week`. */
|
|
2901
|
+
expr: z14.string(),
|
|
2902
|
+
/** An IANA zone (`Europe/Bucharest`) the expression is read in; `UTC` unless said. */
|
|
2903
|
+
timezone: z14.string(),
|
|
2904
|
+
/** False: paused, it fires again when resumed. */
|
|
2905
|
+
enabled: z14.boolean(),
|
|
2906
|
+
/** When it fires next (ISO); null while paused. */
|
|
2907
|
+
nextRunAt: z14.string().nullable(),
|
|
2908
|
+
lastRunAt: z14.string().nullable(),
|
|
2909
|
+
lastOutcome: z14.enum(CRON_OUTCOMES).nullable(),
|
|
2910
|
+
createdBy: z14.string().nullable(),
|
|
2911
|
+
createdAt: z14.string()
|
|
2912
|
+
};
|
|
2913
|
+
var CronHttpTriggerSchema = z14.object({
|
|
2914
|
+
...triggerCommon,
|
|
2915
|
+
kind: z14.literal("http"),
|
|
2916
|
+
method: z14.enum(CRON_METHODS),
|
|
2917
|
+
port: z14.number().int(),
|
|
2918
|
+
/** Path and query, starting with `/`. */
|
|
2919
|
+
path: z14.string()
|
|
2576
2920
|
});
|
|
2577
|
-
var
|
|
2578
|
-
/** Its first start has finished: it has set itself up on its storage. */
|
|
2579
|
-
ready: z12.boolean(),
|
|
2580
|
-
/** It accepts connections. */
|
|
2581
|
-
accepting: z12.boolean(),
|
|
2582
|
-
version: z12.string(),
|
|
2583
|
-
/** The storage volume: what is used of it and its size. */
|
|
2584
|
-
storageUsedBytes: z12.number().optional(),
|
|
2585
|
-
storageTotalBytes: z12.number().optional(),
|
|
2586
|
-
/** What else the kind reports, ready to show: `{title: "Connections", value: "3"}`. */
|
|
2587
|
-
facts: z12.array(z12.object({ title: z12.string(), value: z12.string() }))
|
|
2588
|
-
});
|
|
2589
|
-
var UrlsSchema = z12.object({ private: z12.string(), public: z12.string().optional() });
|
|
2590
|
-
var ManagedSchema = z12.object({
|
|
2591
|
-
kind: z12.string(),
|
|
2592
|
-
name: z12.string(),
|
|
2593
|
-
/** The owning slug, bare. */
|
|
2594
|
-
owner: z12.string(),
|
|
2595
|
-
ownerKind: z12.enum(["user", "org"]),
|
|
2596
|
-
/** `running`, `stopped` (storage only is charged), `hibernated` or `standby` (out of credit), `unknown` (its host does not answer). */
|
|
2597
|
-
status: BoxStatusSchema,
|
|
2598
|
-
/** The catalog version: `18`. */
|
|
2599
|
-
version: z12.string(),
|
|
2600
|
-
/** What the kind keeps of its create options, defaults filled in: `{database, user}` for Postgres, `{}` for a kind with none. */
|
|
2601
|
-
settings: z12.record(z12.string(), z12.string()),
|
|
2602
|
-
storageGib: z12.number().int(),
|
|
2603
|
-
/** Where a linked box reaches it: `<name>.<slug>.kvbox` (resolves from a box of any slug it is linked to) and the port. */
|
|
2604
|
-
private: z12.object({ host: z12.string(), port: z12.number().int() }),
|
|
2605
|
-
/** Where the internet reaches it, null while it is not public. The port is its own for its whole life. */
|
|
2606
|
-
public: z12.object({ host: z12.string(), port: z12.number().int() }).nullable(),
|
|
2607
|
-
/** The boxes linked to it, as the caller would name them. */
|
|
2608
|
-
links: z12.array(z12.string()),
|
|
2609
|
-
/** The name of the host it runs on, for `--near` and links. */
|
|
2610
|
-
host: z12.string(),
|
|
2611
|
-
country: z12.string().optional(),
|
|
2612
|
-
createdBy: z12.string().nullable(),
|
|
2613
|
-
createdAt: z12.string(),
|
|
2614
|
-
/** Connection strings with the password as `****`. */
|
|
2615
|
-
urls: UrlsSchema,
|
|
2616
|
-
price: PriceSchema,
|
|
2617
|
-
/** Its nightly backup (#186 slice 4): on from creation, `kvbox <kind> backup schedule` changes it. Null for a control plane from before schedules. */
|
|
2618
|
-
backupSchedule: BackupScheduleSchema.nullable().default(null),
|
|
2619
|
-
/** Only in `GET /managed/<kind>/<name>` (asked live): null when it is not running or did not answer. */
|
|
2620
|
-
health: ManagedHealthSchema.nullable().optional()
|
|
2621
|
-
});
|
|
2622
|
-
var ManagedSecretSchema = z12.object({ password: z12.string(), urls: UrlsSchema });
|
|
2623
|
-
var CreatedManagedSchema = ManagedSchema.extend({
|
|
2624
|
-
secret: ManagedSecretSchema,
|
|
2625
|
-
/** The backup it was made from (`fromBackup`), when it was. */
|
|
2626
|
-
fromBackup: z12.string().optional()
|
|
2627
|
-
});
|
|
2628
|
-
var ResetPasswordRequest = z12.object({ password: z12.string().optional() });
|
|
2629
|
-
var SetPublicRequest = z12.object({ on: z12.boolean() });
|
|
2630
|
-
var ManagedLinkRequest = z12.object({ box: z12.string() });
|
|
2631
|
-
var GrowManagedRequest = z12.object({ storageGib: z12.number().int() });
|
|
2632
|
-
var ManagedBackupSchema = z12.object({
|
|
2633
|
-
id: z12.string(),
|
|
2634
|
-
owner: z12.string(),
|
|
2635
|
-
kind: z12.string(),
|
|
2636
|
-
name: z12.string(),
|
|
2637
|
-
version: z12.string(),
|
|
2638
|
-
status: z12.enum(BACKUP_STATUSES),
|
|
2639
|
-
/** Why it failed; null otherwise. */
|
|
2640
|
-
error: z12.string().nullable(),
|
|
2641
|
-
/** The service's storage when taken. */
|
|
2642
|
-
diskBytes: z12.number().int().nullable(),
|
|
2643
|
-
/** What it holds: the slots that are not all zeros. */
|
|
2644
|
-
dataBytes: z12.number().int().nullable(),
|
|
2645
|
-
/** What this backup added to storage (encrypted, compressed): the chunks no earlier backup had. */
|
|
2646
|
-
uploadedBytes: z12.number().int().nullable(),
|
|
2647
|
-
/** Who asked for it; for a scheduled one, the database's creator. */
|
|
2648
|
-
createdBy: z12.string().nullable(),
|
|
2649
|
-
/** Started by the database's backup schedule, not by a person: it does not count toward the daily limit. */
|
|
2650
|
-
scheduled: z12.boolean().default(false),
|
|
2651
|
-
createdAt: z12.string(),
|
|
2652
|
-
finishedAt: z12.string().nullable()
|
|
2653
|
-
});
|
|
2654
|
-
|
|
2655
|
-
// ../shared/src/cron.ts
|
|
2656
|
-
import { z as z13 } from "zod";
|
|
2657
|
-
var DEFAULT_CRON_COMMAND_TIMEOUT_SEC = 600;
|
|
2658
|
-
var MAX_CRON_COMMAND_TIMEOUT_SEC = 3600;
|
|
2659
|
-
var CRON_RUN_LOG_DIR = "/var/log/kvbox/runs";
|
|
2660
|
-
var CRON_METHODS = ["GET", "POST"];
|
|
2661
|
-
var CRON_OUTCOMES = ["running", "ok", "failed", "timeout", "no-credit", "box-stopped", "host-down", "host-outdated", "lost", "still-running", "box-outdated"];
|
|
2662
|
-
var CronServiceSchema = z13.object({
|
|
2663
|
-
owner: z13.string(),
|
|
2664
|
-
ownerKind: z13.enum(["user", "org"]),
|
|
2665
|
-
name: z13.string(),
|
|
2666
|
-
/** Runs kept per trigger. */
|
|
2667
|
-
keepRuns: z13.number().int(),
|
|
2668
|
-
triggers: z13.number().int(),
|
|
2669
|
-
createdBy: z13.string().nullable(),
|
|
2670
|
-
createdAt: z13.string(),
|
|
2671
|
-
/** What it costs while it exists; on the answer to `POST /cron` only. */
|
|
2672
|
-
price: z13.object({ perMonth: z13.number(), currency: z13.string() }).optional()
|
|
2673
|
-
});
|
|
2674
|
-
var triggerCommon = {
|
|
2675
|
-
id: z13.string(),
|
|
2676
|
-
service: z13.string(),
|
|
2677
|
-
owner: z13.string(),
|
|
2678
|
-
/** The box it acts on; a trigger is removed with its box. */
|
|
2679
|
-
box: z13.string(),
|
|
2680
|
-
/** Five fields, `minute hour day-of-month month day-of-week`. */
|
|
2681
|
-
expr: z13.string(),
|
|
2682
|
-
/** An IANA zone (`Europe/Bucharest`) the expression is read in; `UTC` unless said. */
|
|
2683
|
-
timezone: z13.string(),
|
|
2684
|
-
/** False: paused, it fires again when resumed. */
|
|
2685
|
-
enabled: z13.boolean(),
|
|
2686
|
-
/** When it fires next (ISO); null while paused. */
|
|
2687
|
-
nextRunAt: z13.string().nullable(),
|
|
2688
|
-
lastRunAt: z13.string().nullable(),
|
|
2689
|
-
lastOutcome: z13.enum(CRON_OUTCOMES).nullable(),
|
|
2690
|
-
createdBy: z13.string().nullable(),
|
|
2691
|
-
createdAt: z13.string()
|
|
2692
|
-
};
|
|
2693
|
-
var CronHttpTriggerSchema = z13.object({
|
|
2694
|
-
...triggerCommon,
|
|
2695
|
-
kind: z13.literal("http"),
|
|
2696
|
-
method: z13.enum(CRON_METHODS),
|
|
2697
|
-
port: z13.number().int(),
|
|
2698
|
-
/** Path and query, starting with `/`. */
|
|
2699
|
-
path: z13.string()
|
|
2700
|
-
});
|
|
2701
|
-
var CronCommandTriggerSchema = z13.object({
|
|
2921
|
+
var CronCommandTriggerSchema = z14.object({
|
|
2702
2922
|
...triggerCommon,
|
|
2703
|
-
kind:
|
|
2923
|
+
kind: z14.literal("command"),
|
|
2704
2924
|
/** Run by a login shell as the box's user, in its home. */
|
|
2705
|
-
command:
|
|
2925
|
+
command: z14.string(),
|
|
2706
2926
|
/** The command is stopped after this long. */
|
|
2707
|
-
timeoutSec:
|
|
2927
|
+
timeoutSec: z14.number().int()
|
|
2708
2928
|
});
|
|
2709
|
-
var CronTriggerSchema =
|
|
2710
|
-
var CronRunSchema =
|
|
2929
|
+
var CronTriggerSchema = z14.discriminatedUnion("kind", [CronHttpTriggerSchema, CronCommandTriggerSchema]);
|
|
2930
|
+
var CronRunSchema = z14.object({
|
|
2711
2931
|
/** The slot this run was for (ISO); a run asked for by hand has the moment it was asked. */
|
|
2712
|
-
scheduledFor:
|
|
2713
|
-
startedAt:
|
|
2932
|
+
scheduledFor: z14.string(),
|
|
2933
|
+
startedAt: z14.string(),
|
|
2714
2934
|
/** Null while `running`, and for a run that was never sent. */
|
|
2715
|
-
durationMs:
|
|
2935
|
+
durationMs: z14.number().int().nullable(),
|
|
2716
2936
|
/** The box's HTTP status; null when it never answered, and for a command. */
|
|
2717
|
-
status:
|
|
2937
|
+
status: z14.number().int().nullable(),
|
|
2718
2938
|
/** A command's exit code (128 + the signal when one ended it); null until it ends, and for a request. */
|
|
2719
|
-
exitCode:
|
|
2939
|
+
exitCode: z14.number().int().nullable(),
|
|
2720
2940
|
/** The files in the box that hold what a command printed (a shell pattern, `cron-<n>.*`); null for a request and for a command that never started. */
|
|
2721
|
-
output:
|
|
2722
|
-
outcome:
|
|
2941
|
+
output: z14.string().nullable(),
|
|
2942
|
+
outcome: z14.enum(CRON_OUTCOMES),
|
|
2723
2943
|
/** Why it did not end `ok`, in a line. */
|
|
2724
|
-
error:
|
|
2944
|
+
error: z14.string().nullable(),
|
|
2725
2945
|
/** The box was hibernated and this run woke it. */
|
|
2726
|
-
woke:
|
|
2946
|
+
woke: z14.boolean()
|
|
2727
2947
|
});
|
|
2728
|
-
var CronCatalogSchema =
|
|
2729
|
-
price:
|
|
2730
|
-
maxServices:
|
|
2731
|
-
maxTriggers:
|
|
2732
|
-
keepRuns:
|
|
2948
|
+
var CronCatalogSchema = z14.object({
|
|
2949
|
+
price: z14.object({ perMonth: z14.number(), currency: z14.string() }),
|
|
2950
|
+
maxServices: z14.number().int(),
|
|
2951
|
+
maxTriggers: z14.number().int(),
|
|
2952
|
+
keepRuns: z14.number().int(),
|
|
2733
2953
|
/** The shortest time between two runs of one trigger, in seconds. */
|
|
2734
|
-
minIntervalSeconds:
|
|
2954
|
+
minIntervalSeconds: z14.number().int(),
|
|
2735
2955
|
/** How long a box has to answer, in seconds. */
|
|
2736
|
-
timeoutSeconds:
|
|
2956
|
+
timeoutSeconds: z14.number().int(),
|
|
2737
2957
|
/** How long a command may run: unless the trigger says, and at most. */
|
|
2738
|
-
commandTimeoutSeconds:
|
|
2739
|
-
maxCommandTimeoutSeconds:
|
|
2740
|
-
docs:
|
|
2741
|
-
});
|
|
2742
|
-
var CreateCronServiceRequest =
|
|
2743
|
-
var CreateCronTriggerRequest =
|
|
2744
|
-
box:
|
|
2745
|
-
expr:
|
|
2746
|
-
timezone:
|
|
2958
|
+
commandTimeoutSeconds: z14.number().int(),
|
|
2959
|
+
maxCommandTimeoutSeconds: z14.number().int(),
|
|
2960
|
+
docs: z14.string().optional()
|
|
2961
|
+
});
|
|
2962
|
+
var CreateCronServiceRequest = z14.object({ name: z14.string() });
|
|
2963
|
+
var CreateCronTriggerRequest = z14.object({
|
|
2964
|
+
box: z14.string().min(1),
|
|
2965
|
+
expr: z14.string().min(1),
|
|
2966
|
+
timezone: z14.string().optional(),
|
|
2747
2967
|
/** A request: `port`, with `method` and `path`. */
|
|
2748
|
-
method:
|
|
2749
|
-
port:
|
|
2750
|
-
path:
|
|
2968
|
+
method: z14.enum(CRON_METHODS).optional(),
|
|
2969
|
+
port: z14.number().int().min(1).max(65535).optional(),
|
|
2970
|
+
path: z14.string().optional(),
|
|
2751
2971
|
/** Or a command, with `timeoutSec`; exactly one of `port` and `command`. */
|
|
2752
|
-
command:
|
|
2753
|
-
timeoutSec:
|
|
2972
|
+
command: z14.string().optional(),
|
|
2973
|
+
timeoutSec: z14.number().int().optional()
|
|
2754
2974
|
});
|
|
2755
|
-
var UpdateCronTriggerRequest =
|
|
2975
|
+
var UpdateCronTriggerRequest = z14.object({ enabled: z14.boolean() });
|
|
2756
2976
|
var cronTarget = (t) => t.kind === "command" ? `${t.box}$ ${t.command}` : `${t.method} ${t.box}:${t.port}${t.path}`;
|
|
2757
2977
|
|
|
2758
2978
|
// ../shared/src/storage.ts
|
|
2759
|
-
import { z as
|
|
2760
|
-
var RegionSchema =
|
|
2979
|
+
import { z as z15 } from "zod";
|
|
2980
|
+
var RegionSchema = z15.object({ name: z15.string(), country: z15.string().nullable() });
|
|
2761
2981
|
var MAX_PUBLIC_BUCKETS = 10;
|
|
2762
2982
|
var STORAGE_BOX_SUBDOMAINS = MAX_PUBLIC_BUCKETS + 2;
|
|
2763
|
-
var ObjectStorageSchema =
|
|
2764
|
-
owner:
|
|
2765
|
-
ownerKind:
|
|
2983
|
+
var ObjectStorageSchema = z15.object({
|
|
2984
|
+
owner: z15.string(),
|
|
2985
|
+
ownerKind: z15.enum(["user", "org"]),
|
|
2766
2986
|
/** `https://s3-<slug>.<domain>`: what an S3 client is given, with path-style addressing. Null while the address is not claimed. */
|
|
2767
|
-
endpoint:
|
|
2987
|
+
endpoint: z15.string().nullable(),
|
|
2768
2988
|
/** The S3 region every client of it signs with (`ro-west-1`): its host's when it was made. */
|
|
2769
|
-
region:
|
|
2989
|
+
region: z15.string(),
|
|
2770
2990
|
/** The most it may hold. */
|
|
2771
|
-
sizeGib:
|
|
2991
|
+
sizeGib: z15.number().int(),
|
|
2772
2992
|
/** `running` when it answers; `unknown` while its host is not heard from. */
|
|
2773
2993
|
status: BoxStatusSchema,
|
|
2774
2994
|
/** With `?live=1`, when the storage answered: what is on its disk, and the disk's real size. */
|
|
2775
|
-
usedBytes:
|
|
2776
|
-
totalBytes:
|
|
2995
|
+
usedBytes: z15.number().optional(),
|
|
2996
|
+
totalBytes: z15.number().optional(),
|
|
2777
2997
|
/** With `?live=1`, when the storage answered: what each bucket holds. */
|
|
2778
|
-
bucketUsage:
|
|
2779
|
-
host:
|
|
2780
|
-
country:
|
|
2781
|
-
buckets:
|
|
2782
|
-
price:
|
|
2783
|
-
createdAt:
|
|
2784
|
-
});
|
|
2785
|
-
var BucketSchema =
|
|
2786
|
-
name:
|
|
2787
|
-
owner:
|
|
2788
|
-
ownerKind:
|
|
2789
|
-
endpoint:
|
|
2790
|
-
publicUrl:
|
|
2791
|
-
region:
|
|
2792
|
-
keys:
|
|
2793
|
-
objects:
|
|
2794
|
-
bytes:
|
|
2795
|
-
createdBy:
|
|
2796
|
-
createdAt:
|
|
2797
|
-
});
|
|
2798
|
-
var CreateBucketRequest =
|
|
2799
|
-
name:
|
|
2800
|
-
sizeGib:
|
|
2801
|
-
near:
|
|
2802
|
-
region:
|
|
2803
|
-
});
|
|
2804
|
-
var CreatedBucketSchema = BucketSchema.extend({ storage: ObjectStorageSchema, storageCreated:
|
|
2998
|
+
bucketUsage: z15.array(z15.object({ name: z15.string(), objects: z15.number(), bytes: z15.number() })).optional(),
|
|
2999
|
+
host: z15.string(),
|
|
3000
|
+
country: z15.string().optional(),
|
|
3001
|
+
buckets: z15.number().int(),
|
|
3002
|
+
price: z15.object({ perMonth: z15.number(), currency: z15.string() }),
|
|
3003
|
+
createdAt: z15.string()
|
|
3004
|
+
});
|
|
3005
|
+
var BucketSchema = z15.object({
|
|
3006
|
+
name: z15.string(),
|
|
3007
|
+
owner: z15.string(),
|
|
3008
|
+
ownerKind: z15.enum(["user", "org"]),
|
|
3009
|
+
endpoint: z15.string().nullable(),
|
|
3010
|
+
publicUrl: z15.string().optional(),
|
|
3011
|
+
region: z15.string(),
|
|
3012
|
+
keys: z15.number().int(),
|
|
3013
|
+
objects: z15.number().optional(),
|
|
3014
|
+
bytes: z15.number().optional(),
|
|
3015
|
+
createdBy: z15.string().nullable(),
|
|
3016
|
+
createdAt: z15.string()
|
|
3017
|
+
});
|
|
3018
|
+
var CreateBucketRequest = z15.object({
|
|
3019
|
+
name: z15.string(),
|
|
3020
|
+
sizeGib: z15.number().int().optional(),
|
|
3021
|
+
near: z15.string().optional(),
|
|
3022
|
+
region: z15.string().optional()
|
|
3023
|
+
});
|
|
3024
|
+
var CreatedBucketSchema = BucketSchema.extend({ storage: ObjectStorageSchema, storageCreated: z15.boolean() });
|
|
2805
3025
|
var BucketInfoSchema = BucketSchema.extend({ storage: ObjectStorageSchema });
|
|
2806
|
-
var SetBucketPublicRequest =
|
|
2807
|
-
var BucketKeySchema =
|
|
2808
|
-
id:
|
|
2809
|
-
name:
|
|
2810
|
-
bucket:
|
|
2811
|
-
owner:
|
|
2812
|
-
readOnly:
|
|
2813
|
-
createdBy:
|
|
2814
|
-
createdAt:
|
|
2815
|
-
});
|
|
2816
|
-
var CreateBucketKeyRequest =
|
|
2817
|
-
var CreatedBucketKeySchema = BucketKeySchema.extend({ secret:
|
|
2818
|
-
var GrowStorageRequest =
|
|
2819
|
-
var StorageBackupSchema =
|
|
2820
|
-
id:
|
|
2821
|
-
owner:
|
|
2822
|
-
status:
|
|
3026
|
+
var SetBucketPublicRequest = z15.object({ on: z15.boolean(), sub: z15.string().optional() });
|
|
3027
|
+
var BucketKeySchema = z15.object({
|
|
3028
|
+
id: z15.string(),
|
|
3029
|
+
name: z15.string(),
|
|
3030
|
+
bucket: z15.string(),
|
|
3031
|
+
owner: z15.string(),
|
|
3032
|
+
readOnly: z15.boolean(),
|
|
3033
|
+
createdBy: z15.string().nullable(),
|
|
3034
|
+
createdAt: z15.string()
|
|
3035
|
+
});
|
|
3036
|
+
var CreateBucketKeyRequest = z15.object({ name: z15.string().optional(), readOnly: z15.boolean().optional() });
|
|
3037
|
+
var CreatedBucketKeySchema = BucketKeySchema.extend({ secret: z15.string(), endpoint: z15.string().nullable(), region: z15.string() });
|
|
3038
|
+
var GrowStorageRequest = z15.object({ sizeGib: z15.number().int() });
|
|
3039
|
+
var StorageBackupSchema = z15.object({
|
|
3040
|
+
id: z15.string(),
|
|
3041
|
+
owner: z15.string(),
|
|
3042
|
+
status: z15.enum(BACKUP_STATUSES),
|
|
2823
3043
|
/** Why it failed; null otherwise. */
|
|
2824
|
-
error:
|
|
3044
|
+
error: z15.string().nullable(),
|
|
2825
3045
|
/** The storage's volume when taken. */
|
|
2826
|
-
diskBytes:
|
|
3046
|
+
diskBytes: z15.number().int().nullable(),
|
|
2827
3047
|
/** What it holds: the slots that are not all zeros. */
|
|
2828
|
-
dataBytes:
|
|
3048
|
+
dataBytes: z15.number().int().nullable(),
|
|
2829
3049
|
/** What this backup added to the backup store (encrypted, compressed). */
|
|
2830
|
-
uploadedBytes:
|
|
3050
|
+
uploadedBytes: z15.number().int().nullable(),
|
|
2831
3051
|
/** The buckets it holds, and how many access keys they had, as kvbox knew them when it was taken. */
|
|
2832
|
-
buckets:
|
|
2833
|
-
keys:
|
|
2834
|
-
createdBy:
|
|
3052
|
+
buckets: z15.array(z15.string()),
|
|
3053
|
+
keys: z15.number().int(),
|
|
3054
|
+
createdBy: z15.string().nullable(),
|
|
2835
3055
|
/** Taken by the storage's nightly schedule rather than by a person: free, and outside the daily limit. */
|
|
2836
|
-
scheduled:
|
|
2837
|
-
createdAt:
|
|
2838
|
-
finishedAt:
|
|
3056
|
+
scheduled: z15.boolean().default(false),
|
|
3057
|
+
createdAt: z15.string(),
|
|
3058
|
+
finishedAt: z15.string().nullable()
|
|
2839
3059
|
});
|
|
2840
|
-
var RestoredKeySchema =
|
|
2841
|
-
var StorageRestoreSchema =
|
|
2842
|
-
backup:
|
|
3060
|
+
var RestoredKeySchema = z15.object({ bucket: z15.string(), id: z15.string(), name: z15.string() });
|
|
3061
|
+
var StorageRestoreSchema = z15.object({
|
|
3062
|
+
backup: z15.string(),
|
|
2843
3063
|
storage: ObjectStorageSchema,
|
|
2844
|
-
buckets:
|
|
2845
|
-
keys:
|
|
2846
|
-
checked:
|
|
2847
|
-
warnings:
|
|
3064
|
+
buckets: z15.object({ kept: z15.array(z15.string()), returned: z15.array(z15.string()), removed: z15.array(z15.string()) }),
|
|
3065
|
+
keys: z15.object({ dropped: z15.array(RestoredKeySchema), revoked: z15.array(RestoredKeySchema) }),
|
|
3066
|
+
checked: z15.boolean(),
|
|
3067
|
+
warnings: z15.array(z15.string())
|
|
2848
3068
|
});
|
|
2849
3069
|
var OBJECT_LIST_MAX = 1e3;
|
|
2850
3070
|
var SHARE_LINK_MAX_SEC = 7 * 24 * 3600;
|
|
@@ -2854,56 +3074,56 @@ var MULTIPART_PART_BYTES = 16 * 1024 * 1024;
|
|
|
2854
3074
|
var UPLOAD_MAX_BYTES = 50 * 1024 * 1024 * 1024;
|
|
2855
3075
|
var MOVE_MAX_BYTES = 5 * 1024 * 1024 * 1024;
|
|
2856
3076
|
var DELETE_PREFIXES_MAX = 100;
|
|
2857
|
-
var StoredObjectSchema =
|
|
2858
|
-
key:
|
|
2859
|
-
size:
|
|
2860
|
-
etag:
|
|
3077
|
+
var StoredObjectSchema = z15.object({
|
|
3078
|
+
key: z15.string(),
|
|
3079
|
+
size: z15.number(),
|
|
3080
|
+
etag: z15.string(),
|
|
2861
3081
|
/** ISO 8601. */
|
|
2862
|
-
modified:
|
|
2863
|
-
});
|
|
2864
|
-
var ObjectListingSchema =
|
|
2865
|
-
prefix:
|
|
2866
|
-
folders:
|
|
2867
|
-
objects:
|
|
2868
|
-
next:
|
|
2869
|
-
canWrite:
|
|
2870
|
-
});
|
|
2871
|
-
var ObjectInfoSchema = StoredObjectSchema.extend({ contentType:
|
|
2872
|
-
var ObjectCountSchema =
|
|
2873
|
-
var ObjectLinkRequest =
|
|
2874
|
-
key:
|
|
2875
|
-
expiresSec:
|
|
3082
|
+
modified: z15.string()
|
|
3083
|
+
});
|
|
3084
|
+
var ObjectListingSchema = z15.object({
|
|
3085
|
+
prefix: z15.string(),
|
|
3086
|
+
folders: z15.array(z15.string()),
|
|
3087
|
+
objects: z15.array(StoredObjectSchema),
|
|
3088
|
+
next: z15.string().optional(),
|
|
3089
|
+
canWrite: z15.boolean()
|
|
3090
|
+
});
|
|
3091
|
+
var ObjectInfoSchema = StoredObjectSchema.extend({ contentType: z15.string() });
|
|
3092
|
+
var ObjectCountSchema = z15.object({ objects: z15.number(), bytes: z15.number(), more: z15.boolean() });
|
|
3093
|
+
var ObjectLinkRequest = z15.object({
|
|
3094
|
+
key: z15.string(),
|
|
3095
|
+
expiresSec: z15.number().int().positive(),
|
|
2876
3096
|
/** Answer as a download (`Content-Disposition: attachment`) instead of showing it. */
|
|
2877
|
-
download:
|
|
3097
|
+
download: z15.boolean().optional(),
|
|
2878
3098
|
/**
|
|
2879
3099
|
* Let the browser keep what the link answers until the link expires (`Cache-Control: private`, `Expires`),
|
|
2880
3100
|
* so the same link shown twice is fetched once. Asked again within the hour, for the same file as it
|
|
2881
3101
|
* is, it is the same URL, and it lasts up to an hour longer than `expiresSec`. For the app's own previews.
|
|
2882
3102
|
* Only a fetch of the whole file is kept so: the storage answers a part of one (`Range`) without the two headers.
|
|
2883
3103
|
*/
|
|
2884
|
-
cached:
|
|
3104
|
+
cached: z15.boolean().optional()
|
|
2885
3105
|
});
|
|
2886
|
-
var ObjectLinkSchema =
|
|
3106
|
+
var ObjectLinkSchema = z15.object({ url: z15.string(), expiresAt: z15.string() });
|
|
2887
3107
|
var MEDIA_TYPE_RE = /^[\w.+-]+\/[\w.+-]+(?:\s*;[\x20-\x7e]*)?$/;
|
|
2888
|
-
var StartUploadRequest =
|
|
2889
|
-
var UploadPlanSchema =
|
|
2890
|
-
|
|
2891
|
-
|
|
3108
|
+
var StartUploadRequest = z15.object({ key: z15.string(), size: z15.number().int().nonnegative(), contentType: z15.string().max(200).regex(MEDIA_TYPE_RE, "not a media type like image/png").optional(), overwrite: z15.boolean().optional() });
|
|
3109
|
+
var UploadPlanSchema = z15.discriminatedUnion("kind", [
|
|
3110
|
+
z15.object({ kind: z15.literal("single"), url: z15.string() }),
|
|
3111
|
+
z15.object({ kind: z15.literal("multipart"), uploadId: z15.string(), partSize: z15.number(), urls: z15.array(z15.string()) })
|
|
2892
3112
|
]);
|
|
2893
|
-
var CompleteUploadRequest =
|
|
2894
|
-
key:
|
|
2895
|
-
uploadId:
|
|
2896
|
-
parts:
|
|
3113
|
+
var CompleteUploadRequest = z15.object({
|
|
3114
|
+
key: z15.string(),
|
|
3115
|
+
uploadId: z15.string(),
|
|
3116
|
+
parts: z15.array(z15.object({ part: z15.number().int().positive(), etag: z15.string() })).min(1)
|
|
2897
3117
|
});
|
|
2898
|
-
var AbortUploadRequest =
|
|
2899
|
-
var DeleteObjectsRequest =
|
|
2900
|
-
var DeletedObjectsSchema =
|
|
2901
|
-
deleted:
|
|
2902
|
-
more:
|
|
2903
|
-
errors:
|
|
3118
|
+
var AbortUploadRequest = z15.object({ key: z15.string(), uploadId: z15.string() });
|
|
3119
|
+
var DeleteObjectsRequest = z15.object({ keys: z15.array(z15.string()).max(OBJECT_LIST_MAX).optional(), prefixes: z15.array(z15.string()).max(DELETE_PREFIXES_MAX).optional() });
|
|
3120
|
+
var DeletedObjectsSchema = z15.object({
|
|
3121
|
+
deleted: z15.number(),
|
|
3122
|
+
more: z15.boolean(),
|
|
3123
|
+
errors: z15.array(z15.object({ key: z15.string(), message: z15.string() }))
|
|
2904
3124
|
});
|
|
2905
|
-
var MoveObjectRequest =
|
|
2906
|
-
var CreateFolderRequest =
|
|
3125
|
+
var MoveObjectRequest = z15.object({ from: z15.string(), to: z15.string(), overwrite: z15.boolean().optional() });
|
|
3126
|
+
var CreateFolderRequest = z15.object({ prefix: z15.string() });
|
|
2907
3127
|
|
|
2908
3128
|
// src/kvm.ts
|
|
2909
3129
|
import { accessSync, constants, readFileSync, statSync } from "fs";
|
|
@@ -3073,7 +3293,7 @@ var ServerClient = class {
|
|
|
3073
3293
|
* `all`: every box on the platform (platform admins only, #78).
|
|
3074
3294
|
*/
|
|
3075
3295
|
listMachines(opts = {}) {
|
|
3076
|
-
return this.call("GET", `/machines${allQuery(opts)}`,
|
|
3296
|
+
return this.call("GET", `/machines${allQuery(opts)}`, z16.array(MachineSchema), void 0, opts.org);
|
|
3077
3297
|
}
|
|
3078
3298
|
createMachine(req) {
|
|
3079
3299
|
return this.call("POST", "/machines", MachineSchema, req, void 0, req.fromBackup !== void 0 ? 2 * 36e5 : void 0);
|
|
@@ -3131,10 +3351,10 @@ var ServerClient = class {
|
|
|
3131
3351
|
}
|
|
3132
3352
|
/** Backups, the control plane's only: a box's disk in object storage. Newest first. */
|
|
3133
3353
|
listBackups() {
|
|
3134
|
-
return this.call("GET", "/backups",
|
|
3354
|
+
return this.call("GET", "/backups", z16.array(BackupSchema));
|
|
3135
3355
|
}
|
|
3136
3356
|
boxBackups(name) {
|
|
3137
|
-
return this.call("GET", `/machines/${encodeURIComponent(name)}/backups`,
|
|
3357
|
+
return this.call("GET", `/machines/${encodeURIComponent(name)}/backups`, z16.array(BackupSchema));
|
|
3138
3358
|
}
|
|
3139
3359
|
boxBackup(name, id) {
|
|
3140
3360
|
return this.call("GET", `/machines/${encodeURIComponent(name)}/backups/${encodeURIComponent(id)}`, BackupSchema);
|
|
@@ -3156,14 +3376,14 @@ var ServerClient = class {
|
|
|
3156
3376
|
* later. Works for a backup whose box, volume or database is gone too.
|
|
3157
3377
|
*/
|
|
3158
3378
|
removeBackup(id) {
|
|
3159
|
-
return this.call("DELETE", `/backups/${encodeURIComponent(id)}`,
|
|
3379
|
+
return this.call("DELETE", `/backups/${encodeURIComponent(id)}`, z16.undefined());
|
|
3160
3380
|
}
|
|
3161
3381
|
/** A volume's backups (#168): the same as a box's, of the volume's disk. Newest first. */
|
|
3162
3382
|
listVolumeBackups() {
|
|
3163
|
-
return this.call("GET", "/backups?kind=volume",
|
|
3383
|
+
return this.call("GET", "/backups?kind=volume", z16.array(VolumeBackupSchema));
|
|
3164
3384
|
}
|
|
3165
3385
|
volumeBackups(name) {
|
|
3166
|
-
return this.call("GET", `/volumes/${encodeURIComponent(name)}/backups`,
|
|
3386
|
+
return this.call("GET", `/volumes/${encodeURIComponent(name)}/backups`, z16.array(VolumeBackupSchema));
|
|
3167
3387
|
}
|
|
3168
3388
|
volumeBackup(name, id) {
|
|
3169
3389
|
return this.call("GET", `/volumes/${encodeURIComponent(name)}/backups/${encodeURIComponent(id)}`, VolumeBackupSchema);
|
|
@@ -3189,7 +3409,7 @@ var ServerClient = class {
|
|
|
3189
3409
|
}
|
|
3190
3410
|
/** Wake hooks (#101), the control plane's only: a URL and a secret that wake the box. */
|
|
3191
3411
|
boxHooks(name) {
|
|
3192
|
-
return this.call("GET", `/machines/${encodeURIComponent(name)}/hooks`,
|
|
3412
|
+
return this.call("GET", `/machines/${encodeURIComponent(name)}/hooks`, z16.array(WakeHookSchema));
|
|
3193
3413
|
}
|
|
3194
3414
|
createBoxHook(name) {
|
|
3195
3415
|
return this.call("POST", `/machines/${encodeURIComponent(name)}/hooks`, CreatedWakeHookSchema);
|
|
@@ -3217,7 +3437,7 @@ var ServerClient = class {
|
|
|
3217
3437
|
}
|
|
3218
3438
|
/** Every readable box's subdomains, one entry each. */
|
|
3219
3439
|
listSubdomains() {
|
|
3220
|
-
return this.call("GET", "/subdomains",
|
|
3440
|
+
return this.call("GET", "/subdomains", z16.array(SubdomainSchema));
|
|
3221
3441
|
}
|
|
3222
3442
|
/** Custom domains (#89), the control plane's only: serve the box at the user's own name. */
|
|
3223
3443
|
addDomain(name, req) {
|
|
@@ -3228,7 +3448,7 @@ var ServerClient = class {
|
|
|
3228
3448
|
}
|
|
3229
3449
|
/** Every readable box's custom domains. */
|
|
3230
3450
|
listDomains() {
|
|
3231
|
-
return this.call("GET", "/domains",
|
|
3451
|
+
return this.call("GET", "/domains", z16.array(DomainSchema));
|
|
3232
3452
|
}
|
|
3233
3453
|
/** A running box's own load, memory and disk, asked of its guest (#67). */
|
|
3234
3454
|
machineStats(name) {
|
|
@@ -3269,22 +3489,22 @@ var ServerClient = class {
|
|
|
3269
3489
|
return this.call("POST", "/billing/redeem", RedeemResponseSchema, { code });
|
|
3270
3490
|
}
|
|
3271
3491
|
deleteMachine(name) {
|
|
3272
|
-
return this.call("DELETE", `/machines/${encodeURIComponent(name)}`,
|
|
3492
|
+
return this.call("DELETE", `/machines/${encodeURIComponent(name)}`, z16.undefined());
|
|
3273
3493
|
}
|
|
3274
3494
|
/** Like `listMachines`, for snapshots. */
|
|
3275
3495
|
listSnapshots(opts = {}) {
|
|
3276
|
-
return this.call("GET", `/snapshots${allQuery(opts)}`,
|
|
3496
|
+
return this.call("GET", `/snapshots${allQuery(opts)}`, z16.array(SnapshotSchema), void 0, opts.org);
|
|
3277
3497
|
}
|
|
3278
3498
|
createSnapshot(req) {
|
|
3279
3499
|
return this.call("POST", "/snapshots", SnapshotSchema, req);
|
|
3280
3500
|
}
|
|
3281
3501
|
deleteSnapshot(name) {
|
|
3282
|
-
return this.call("DELETE", `/snapshots/${encodeURIComponent(name)}`,
|
|
3502
|
+
return this.call("DELETE", `/snapshots/${encodeURIComponent(name)}`, z16.undefined());
|
|
3283
3503
|
}
|
|
3284
3504
|
// ---- environment variables (#88), a control plane only: the caller's slug, or `--org`'s ----
|
|
3285
3505
|
/** `org`: that org's list instead of `--org`'s (or the caller's own). */
|
|
3286
3506
|
listEnv(org) {
|
|
3287
|
-
return this.call("GET", "/vars",
|
|
3507
|
+
return this.call("GET", "/vars", z16.array(EnvVarSchema), void 0, org);
|
|
3288
3508
|
}
|
|
3289
3509
|
setEnv(name, req) {
|
|
3290
3510
|
return this.call("PUT", `/vars/${encodeURIComponent(name)}`, EnvChangeSchema, req);
|
|
@@ -3304,13 +3524,13 @@ var ServerClient = class {
|
|
|
3304
3524
|
}
|
|
3305
3525
|
// ---- volumes (#52) ----
|
|
3306
3526
|
listVolumes(opts = {}) {
|
|
3307
|
-
return this.call("GET", `/volumes${allQuery(opts)}`,
|
|
3527
|
+
return this.call("GET", `/volumes${allQuery(opts)}`, z16.array(VolumeSchema), void 0, opts.org);
|
|
3308
3528
|
}
|
|
3309
3529
|
createVolume(req) {
|
|
3310
3530
|
return this.call("POST", "/volumes", VolumeSchema, req);
|
|
3311
3531
|
}
|
|
3312
3532
|
deleteVolume(name) {
|
|
3313
|
-
return this.call("DELETE", `/volumes/${encodeURIComponent(name)}`,
|
|
3533
|
+
return this.call("DELETE", `/volumes/${encodeURIComponent(name)}`, z16.undefined());
|
|
3314
3534
|
}
|
|
3315
3535
|
/** Both answer with the box as it is afterwards (restarted when it was running). */
|
|
3316
3536
|
attachVolume(name, req) {
|
|
@@ -3325,7 +3545,7 @@ var ServerClient = class {
|
|
|
3325
3545
|
}
|
|
3326
3546
|
// ---- cron service (#190): the control plane's alone ----
|
|
3327
3547
|
listCronServices(opts = {}) {
|
|
3328
|
-
return this.call("GET", `/cron${allQuery(opts)}`,
|
|
3548
|
+
return this.call("GET", `/cron${allQuery(opts)}`, z16.array(CronServiceSchema), void 0, opts.org);
|
|
3329
3549
|
}
|
|
3330
3550
|
createCronService(name) {
|
|
3331
3551
|
return this.call("POST", "/cron", CronServiceSchema, { name });
|
|
@@ -3334,10 +3554,10 @@ var ServerClient = class {
|
|
|
3334
3554
|
return this.call("GET", `/cron/${encodeURIComponent(name)}`, CronServiceSchema);
|
|
3335
3555
|
}
|
|
3336
3556
|
deleteCronService(name) {
|
|
3337
|
-
return this.call("DELETE", `/cron/${encodeURIComponent(name)}`,
|
|
3557
|
+
return this.call("DELETE", `/cron/${encodeURIComponent(name)}`, z16.undefined());
|
|
3338
3558
|
}
|
|
3339
3559
|
listCronTriggers(service) {
|
|
3340
|
-
return this.call("GET", `/cron/${encodeURIComponent(service)}/triggers`,
|
|
3560
|
+
return this.call("GET", `/cron/${encodeURIComponent(service)}/triggers`, z16.array(CronTriggerSchema));
|
|
3341
3561
|
}
|
|
3342
3562
|
addCronTrigger(service, req) {
|
|
3343
3563
|
return this.call("POST", `/cron/${encodeURIComponent(service)}/triggers`, CronTriggerSchema, req);
|
|
@@ -3347,18 +3567,111 @@ var ServerClient = class {
|
|
|
3347
3567
|
return this.call("PATCH", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}`, CronTriggerSchema, { enabled: enabled2 });
|
|
3348
3568
|
}
|
|
3349
3569
|
deleteCronTrigger(service, id) {
|
|
3350
|
-
return this.call("DELETE", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}`,
|
|
3570
|
+
return this.call("DELETE", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}`, z16.undefined());
|
|
3351
3571
|
}
|
|
3352
3572
|
/** Marks it due: kvbox-cron fires it within a few seconds. */
|
|
3353
3573
|
runCronTrigger(service, id) {
|
|
3354
3574
|
return this.call("POST", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}/run`, CronTriggerSchema);
|
|
3355
3575
|
}
|
|
3356
3576
|
listCronRuns(service, id, limit) {
|
|
3357
|
-
return this.call("GET", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}/runs${limit === void 0 ? "" : `?limit=${limit}`}`,
|
|
3577
|
+
return this.call("GET", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}/runs${limit === void 0 ? "" : `?limit=${limit}`}`, z16.array(CronRunSchema));
|
|
3578
|
+
}
|
|
3579
|
+
// ---- Kubernetes clusters (#216): the control plane's alone ----
|
|
3580
|
+
listClusters(opts = {}) {
|
|
3581
|
+
return this.call("GET", `/k8s${allQuery(opts)}`, z16.array(ClusterSchema), void 0, opts.org);
|
|
3582
|
+
}
|
|
3583
|
+
/** The master boots twice (its volume is attached after it is made), so this may take a minute. */
|
|
3584
|
+
createCluster(req) {
|
|
3585
|
+
return this.call("POST", "/k8s", ClusterSchema, req);
|
|
3586
|
+
}
|
|
3587
|
+
getCluster(name) {
|
|
3588
|
+
return this.call("GET", `/k8s/${encodeURIComponent(name)}`, ClusterSchema);
|
|
3589
|
+
}
|
|
3590
|
+
getKubeconfig(name) {
|
|
3591
|
+
return this.call("GET", `/k8s/${encodeURIComponent(name)}/kubeconfig`, KubeconfigSchema);
|
|
3592
|
+
}
|
|
3593
|
+
/** Wakes, resumes or starts the master, whichever its host says it needs. */
|
|
3594
|
+
startCluster(name) {
|
|
3595
|
+
return this.call("POST", `/k8s/${encodeURIComponent(name)}/start`, ClusterSchema);
|
|
3596
|
+
}
|
|
3597
|
+
/** One more pool with its nodes (#217): each node is a box the host makes, so a few seconds a node. */
|
|
3598
|
+
addPool(cluster, req) {
|
|
3599
|
+
return this.call("POST", `/k8s/${encodeURIComponent(cluster)}/pools`, ClusterSchema, req);
|
|
3600
|
+
}
|
|
3601
|
+
/**
|
|
3602
|
+
* How many nodes a pool is meant to have; the missing ones are made. Fewer is only begun when this
|
|
3603
|
+
* answers (`operation`): the nodes are drained one by one; `force` removes them undrained.
|
|
3604
|
+
*/
|
|
3605
|
+
resizePool(cluster, pool, nodes, force = false) {
|
|
3606
|
+
return this.call("PUT", `/k8s/${encodeURIComponent(cluster)}/pools/${encodeURIComponent(pool)}`, ClusterSchema, { nodes, ...force ? { force } : {} });
|
|
3607
|
+
}
|
|
3608
|
+
/** A pool with its nodes, drained first like a shrink: begun when this answers, over when `operation` is gone. */
|
|
3609
|
+
removePool(cluster, pool, force = false) {
|
|
3610
|
+
return this.call("DELETE", `/k8s/${encodeURIComponent(cluster)}/pools/${encodeURIComponent(pool)}${force ? "?force=1" : ""}`, ClusterSchema);
|
|
3611
|
+
}
|
|
3612
|
+
/** A cluster's HTTPS addresses (#219): `kvbox.app` names and custom domains, all to its Traefik. */
|
|
3613
|
+
listClusterSubdomains(cluster) {
|
|
3614
|
+
return this.call("GET", `/k8s/${encodeURIComponent(cluster)}/subdomains`, z16.array(SubdomainSchema));
|
|
3615
|
+
}
|
|
3616
|
+
claimClusterSubdomain(cluster, name) {
|
|
3617
|
+
return this.call("POST", `/k8s/${encodeURIComponent(cluster)}/subdomains`, SubdomainSchema, { name });
|
|
3618
|
+
}
|
|
3619
|
+
releaseClusterSubdomain(cluster, name) {
|
|
3620
|
+
return this.call("DELETE", `/k8s/${encodeURIComponent(cluster)}/subdomains/${encodeURIComponent(name)}`, SubdomainSchema);
|
|
3621
|
+
}
|
|
3622
|
+
listClusterDomains(cluster) {
|
|
3623
|
+
return this.call("GET", `/k8s/${encodeURIComponent(cluster)}/domains`, z16.array(DomainSchema));
|
|
3624
|
+
}
|
|
3625
|
+
addClusterDomain(cluster, domain) {
|
|
3626
|
+
return this.call("POST", `/k8s/${encodeURIComponent(cluster)}/domains`, DomainSchema, { domain });
|
|
3627
|
+
}
|
|
3628
|
+
removeClusterDomain(cluster, domain) {
|
|
3629
|
+
return this.call("DELETE", `/k8s/${encodeURIComponent(cluster)}/domains/${encodeURIComponent(domain)}`, DomainSchema);
|
|
3630
|
+
}
|
|
3631
|
+
/** What a cluster reaches (#220): a database or a box, from every one of its boxes. */
|
|
3632
|
+
listClusterLinks(cluster) {
|
|
3633
|
+
return this.call("GET", `/k8s/${encodeURIComponent(cluster)}/links`, z16.array(ClusterLinkSchema));
|
|
3634
|
+
}
|
|
3635
|
+
linkCluster(cluster, req) {
|
|
3636
|
+
return this.call("POST", `/k8s/${encodeURIComponent(cluster)}/links`, ClusterLinkSchema, req);
|
|
3637
|
+
}
|
|
3638
|
+
unlinkCluster(cluster, req) {
|
|
3639
|
+
return this.call("DELETE", `/k8s/${encodeURIComponent(cluster)}/links`, ClusterLinkSchema, req);
|
|
3640
|
+
}
|
|
3641
|
+
/** A cluster's backups (#221): its master's state, by the engine a database's uses. Every cluster's, removed ones' too. */
|
|
3642
|
+
listClusterBackups() {
|
|
3643
|
+
return this.call("GET", "/backups?managed=k8s", z16.array(ManagedBackupSchema));
|
|
3644
|
+
}
|
|
3645
|
+
clusterBackups(cluster) {
|
|
3646
|
+
return this.call("GET", `/k8s/${encodeURIComponent(cluster)}/backups`, z16.array(ManagedBackupSchema));
|
|
3647
|
+
}
|
|
3648
|
+
clusterBackup(cluster, id) {
|
|
3649
|
+
return this.call("GET", `/k8s/${encodeURIComponent(cluster)}/backups/${encodeURIComponent(id)}`, ManagedBackupSchema);
|
|
3650
|
+
}
|
|
3651
|
+
/** Starts one; it runs in the background (`running`), `clusterBackup` says how it ended. */
|
|
3652
|
+
createClusterBackup(cluster) {
|
|
3653
|
+
return this.call("POST", `/k8s/${encodeURIComponent(cluster)}/backups`, ManagedBackupSchema);
|
|
3654
|
+
}
|
|
3655
|
+
/**
|
|
3656
|
+
* The cluster's state becomes the backup's; its master restarts. Waits for the whole download (the
|
|
3657
|
+
* control plane gives its host 2 h) and for the master to answer again (5 min more), so 2 h 10 min.
|
|
3658
|
+
*/
|
|
3659
|
+
restoreClusterBackup(cluster, id) {
|
|
3660
|
+
return this.call("POST", `/k8s/${encodeURIComponent(cluster)}/backups/${encodeURIComponent(id)}/restore`, ClusterRestoreSchema, {}, void 0, 2 * 36e5 + 10 * 6e4);
|
|
3661
|
+
}
|
|
3662
|
+
/** When the cluster's state is backed up on its own: nightly from its creation. */
|
|
3663
|
+
clusterBackupSchedule(cluster) {
|
|
3664
|
+
return this.call("GET", `/k8s/${encodeURIComponent(cluster)}/backup-schedule`, BackupScheduleSchema);
|
|
3665
|
+
}
|
|
3666
|
+
setClusterBackupSchedule(cluster, change) {
|
|
3667
|
+
return this.call("PUT", `/k8s/${encodeURIComponent(cluster)}/backup-schedule`, BackupScheduleSchema, change);
|
|
3668
|
+
}
|
|
3669
|
+
deleteCluster(name) {
|
|
3670
|
+
return this.call("DELETE", `/k8s/${encodeURIComponent(name)}`, z16.undefined());
|
|
3358
3671
|
}
|
|
3359
3672
|
// ---- object storage (#182): the control plane's alone ----
|
|
3360
3673
|
listBuckets(opts = {}) {
|
|
3361
|
-
return this.call("GET", `/buckets${allQuery(opts)}`,
|
|
3674
|
+
return this.call("GET", `/buckets${allQuery(opts)}`, z16.array(BucketSchema), void 0, opts.org);
|
|
3362
3675
|
}
|
|
3363
3676
|
/** The first bucket of a slug also makes its storage: a box boots twice, so this may take a couple of minutes. */
|
|
3364
3677
|
createBucket(req) {
|
|
@@ -3372,26 +3685,26 @@ var ServerClient = class {
|
|
|
3372
3685
|
return this.call("PUT", `/buckets/${encodeURIComponent(name)}/public`, BucketSchema, req);
|
|
3373
3686
|
}
|
|
3374
3687
|
deleteBucket(name, force = false) {
|
|
3375
|
-
return this.call("DELETE", `/buckets/${encodeURIComponent(name)}${force ? "?force=1" : ""}`,
|
|
3688
|
+
return this.call("DELETE", `/buckets/${encodeURIComponent(name)}${force ? "?force=1" : ""}`, z16.undefined());
|
|
3376
3689
|
}
|
|
3377
3690
|
listBucketKeys(name) {
|
|
3378
|
-
return this.call("GET", `/buckets/${encodeURIComponent(name)}/keys`,
|
|
3691
|
+
return this.call("GET", `/buckets/${encodeURIComponent(name)}/keys`, z16.array(BucketKeySchema));
|
|
3379
3692
|
}
|
|
3380
3693
|
createBucketKey(name, req) {
|
|
3381
3694
|
return this.call("POST", `/buckets/${encodeURIComponent(name)}/keys`, CreatedBucketKeySchema, req);
|
|
3382
3695
|
}
|
|
3383
3696
|
deleteBucketKey(name, id) {
|
|
3384
|
-
return this.call("DELETE", `/buckets/${encodeURIComponent(name)}/keys/${encodeURIComponent(id)}`,
|
|
3697
|
+
return this.call("DELETE", `/buckets/${encodeURIComponent(name)}/keys/${encodeURIComponent(id)}`, z16.undefined());
|
|
3385
3698
|
}
|
|
3386
3699
|
listStorage(opts = {}) {
|
|
3387
|
-
return this.call("GET", `/storage${allQuery(opts)}`,
|
|
3700
|
+
return this.call("GET", `/storage${allQuery(opts)}`, z16.array(ObjectStorageSchema), void 0, opts.org);
|
|
3388
3701
|
}
|
|
3389
3702
|
growStorage(sizeGib) {
|
|
3390
3703
|
return this.call("POST", "/storage/grow", ObjectStorageSchema, { sizeGib });
|
|
3391
3704
|
}
|
|
3392
3705
|
/** Backups of the slug's whole object storage (#186 slice 3), newest first. */
|
|
3393
3706
|
storageBackups() {
|
|
3394
|
-
return this.call("GET", "/storage/backups",
|
|
3707
|
+
return this.call("GET", "/storage/backups", z16.array(StorageBackupSchema));
|
|
3395
3708
|
}
|
|
3396
3709
|
storageBackup(id) {
|
|
3397
3710
|
return this.call("GET", `/storage/backups/${encodeURIComponent(id)}`, StorageBackupSchema);
|
|
@@ -3419,11 +3732,11 @@ var ServerClient = class {
|
|
|
3419
3732
|
return `/managed/${encodeURIComponent(kind)}${name === void 0 ? "" : `/${encodeURIComponent(name)}`}${rest}`;
|
|
3420
3733
|
}
|
|
3421
3734
|
managedCatalog() {
|
|
3422
|
-
return this.call("GET", "/managed/catalog",
|
|
3735
|
+
return this.call("GET", "/managed/catalog", z16.array(ManagedCatalogEntrySchema));
|
|
3423
3736
|
}
|
|
3424
3737
|
/** One kind's services, or every kind's when `kind` is left out. */
|
|
3425
3738
|
listManaged(kind, opts = {}) {
|
|
3426
|
-
return this.call("GET", `${kind === void 0 ? "/managed" : this.managedPath(kind)}${allQuery(opts)}`,
|
|
3739
|
+
return this.call("GET", `${kind === void 0 ? "/managed" : this.managedPath(kind)}${allQuery(opts)}`, z16.array(ManagedSchema), void 0, opts.org);
|
|
3427
3740
|
}
|
|
3428
3741
|
/** From a backup (`fromBackup`) it waits for the restore too: the control plane gives its host 2 h for the download. */
|
|
3429
3742
|
createManaged(kind, req) {
|
|
@@ -3434,7 +3747,7 @@ var ServerClient = class {
|
|
|
3434
3747
|
return this.call("GET", this.managedPath(kind, name), ManagedSchema);
|
|
3435
3748
|
}
|
|
3436
3749
|
deleteManaged(kind, name) {
|
|
3437
|
-
return this.call("DELETE", this.managedPath(kind, name),
|
|
3750
|
+
return this.call("DELETE", this.managedPath(kind, name), z16.undefined());
|
|
3438
3751
|
}
|
|
3439
3752
|
managedPassword(kind, name) {
|
|
3440
3753
|
return this.call("GET", this.managedPath(kind, name, "/password"), ManagedSecretSchema);
|
|
@@ -3456,10 +3769,10 @@ var ServerClient = class {
|
|
|
3456
3769
|
}
|
|
3457
3770
|
/** A managed service's backups (#186): its storage's, by the volume backup engine. Every one of a kind, those of removed services too. */
|
|
3458
3771
|
listManagedBackups(kind) {
|
|
3459
|
-
return this.call("GET", `/backups?managed=${encodeURIComponent(kind)}`,
|
|
3772
|
+
return this.call("GET", `/backups?managed=${encodeURIComponent(kind)}`, z16.array(ManagedBackupSchema));
|
|
3460
3773
|
}
|
|
3461
3774
|
managedBackups(kind, name) {
|
|
3462
|
-
return this.call("GET", this.managedPath(kind, name, "/backups"),
|
|
3775
|
+
return this.call("GET", this.managedPath(kind, name, "/backups"), z16.array(ManagedBackupSchema));
|
|
3463
3776
|
}
|
|
3464
3777
|
managedBackup(kind, name, id) {
|
|
3465
3778
|
return this.call("GET", this.managedPath(kind, name, `/backups/${encodeURIComponent(id)}`), ManagedBackupSchema);
|
|
@@ -3501,7 +3814,7 @@ var ServerClient = class {
|
|
|
3501
3814
|
return this.call("POST", "/login/device/token", DeviceLoginPollSchema, { deviceCode });
|
|
3502
3815
|
}
|
|
3503
3816
|
logout() {
|
|
3504
|
-
return this.call("POST", "/logout",
|
|
3817
|
+
return this.call("POST", "/logout", z16.unknown()).then(() => void 0);
|
|
3505
3818
|
}
|
|
3506
3819
|
me() {
|
|
3507
3820
|
return this.call("GET", "/me", MeResponseSchema);
|
|
@@ -3512,25 +3825,25 @@ var ServerClient = class {
|
|
|
3512
3825
|
* credential. Null: each readable slug whatever `--org` says, which is how the caller's own slug is read.
|
|
3513
3826
|
*/
|
|
3514
3827
|
listIntegrations(org) {
|
|
3515
|
-
return this.call("GET", "/integrations",
|
|
3828
|
+
return this.call("GET", "/integrations", z16.array(IntegrationSchema), void 0, org);
|
|
3516
3829
|
}
|
|
3517
3830
|
/** What can be connected on this control plane, and by which kind of slug. */
|
|
3518
3831
|
integrationCatalog() {
|
|
3519
|
-
return this.call("GET", "/integrations/catalog",
|
|
3832
|
+
return this.call("GET", "/integrations/catalog", z16.array(IntegrationCatalogEntrySchema), void 0, null);
|
|
3520
3833
|
}
|
|
3521
3834
|
// ---- API keys (`kvbox key …`, #189) ----
|
|
3522
3835
|
listApiKeys() {
|
|
3523
|
-
return this.call("GET", "/keys",
|
|
3836
|
+
return this.call("GET", "/keys", z16.array(ApiKeySchema));
|
|
3524
3837
|
}
|
|
3525
3838
|
createApiKey(req) {
|
|
3526
3839
|
return this.call("POST", "/keys", CreatedApiKeySchema, req);
|
|
3527
3840
|
}
|
|
3528
3841
|
deleteApiKey(name) {
|
|
3529
|
-
return this.call("DELETE", `/keys/${encodeURIComponent(name)}`,
|
|
3842
|
+
return this.call("DELETE", `/keys/${encodeURIComponent(name)}`, z16.unknown()).then(() => void 0);
|
|
3530
3843
|
}
|
|
3531
3844
|
// ---- orgs (`kvbox org …`) ----
|
|
3532
3845
|
listOrgs() {
|
|
3533
|
-
return this.call("GET", "/orgs",
|
|
3846
|
+
return this.call("GET", "/orgs", z16.array(OrgMembershipSchema));
|
|
3534
3847
|
}
|
|
3535
3848
|
createOrg(req) {
|
|
3536
3849
|
return this.call("POST", "/orgs", CloudOrgSchema, req);
|
|
@@ -3539,16 +3852,16 @@ var ServerClient = class {
|
|
|
3539
3852
|
return this.call("GET", `/orgs/${encodeURIComponent(slug)}`, OrgDetailSchema);
|
|
3540
3853
|
}
|
|
3541
3854
|
deleteOrg(slug) {
|
|
3542
|
-
return this.call("DELETE", `/orgs/${encodeURIComponent(slug)}`,
|
|
3855
|
+
return this.call("DELETE", `/orgs/${encodeURIComponent(slug)}`, z16.undefined());
|
|
3543
3856
|
}
|
|
3544
3857
|
addMember(slug, req) {
|
|
3545
|
-
return this.call("POST", `/orgs/${encodeURIComponent(slug)}/members`,
|
|
3858
|
+
return this.call("POST", `/orgs/${encodeURIComponent(slug)}/members`, z16.undefined(), req);
|
|
3546
3859
|
}
|
|
3547
3860
|
setRole(slug, username, role) {
|
|
3548
|
-
return this.call("PATCH", `/orgs/${encodeURIComponent(slug)}/members/${encodeURIComponent(username)}`,
|
|
3861
|
+
return this.call("PATCH", `/orgs/${encodeURIComponent(slug)}/members/${encodeURIComponent(username)}`, z16.unknown(), { role }).then(() => void 0);
|
|
3549
3862
|
}
|
|
3550
3863
|
removeMember(slug, username) {
|
|
3551
|
-
return this.call("DELETE", `/orgs/${encodeURIComponent(slug)}/members/${encodeURIComponent(username)}`,
|
|
3864
|
+
return this.call("DELETE", `/orgs/${encodeURIComponent(slug)}/members/${encodeURIComponent(username)}`, z16.undefined());
|
|
3552
3865
|
}
|
|
3553
3866
|
/** Sign this machine's key again (#51); the key must be one the user logged in with. */
|
|
3554
3867
|
sshCert(req) {
|
|
@@ -4313,16 +4626,16 @@ function scpArgs(ep, from, to, recursive) {
|
|
|
4313
4626
|
}
|
|
4314
4627
|
async function runScp(args) {
|
|
4315
4628
|
const child = spawn3("scp", args, { stdio: ["inherit", "inherit", "pipe"] });
|
|
4316
|
-
let
|
|
4629
|
+
let refused2 = false;
|
|
4317
4630
|
child.stderr?.on("data", (c2) => {
|
|
4318
4631
|
process.stderr.write(c2);
|
|
4319
|
-
if (c2.toString("utf8").includes("Permission denied"))
|
|
4632
|
+
if (c2.toString("utf8").includes("Permission denied")) refused2 = true;
|
|
4320
4633
|
});
|
|
4321
4634
|
const status2 = await new Promise((resolve4, reject) => {
|
|
4322
4635
|
child.once("error", (err) => reject(new KvboxError(`could not run scp: ${err.message}`)));
|
|
4323
4636
|
child.once("close", (code, signal) => resolve4(code ?? (signal === "SIGINT" ? 130 : 1)));
|
|
4324
4637
|
});
|
|
4325
|
-
return { status: status2, refused };
|
|
4638
|
+
return { status: status2, refused: refused2 };
|
|
4326
4639
|
}
|
|
4327
4640
|
var cpCommand = new Command4("cp").description("copy files between this machine and a box (kvbox cp ./f <box>:f, kvbox cp <box>:f .)").argument("<src>", "a local path, or <box>:<path>").argument("<dest>", "a local path, or <box>:<path>").option("-r, --recursive", "copy directories").option("--direct", "on the box's host: ssh to the box's private ip, not through the public address or relay").action(async (src, dest, opts, cmd) => {
|
|
4328
4641
|
const { box: box2, from, to } = parseCopy(src, dest);
|
|
@@ -4400,7 +4713,7 @@ var lsCommand = new Command6("ls").description("list boxes with status and addre
|
|
|
4400
4713
|
}
|
|
4401
4714
|
if (org !== void 0) info(`boxes of ${org}`);
|
|
4402
4715
|
table(lsRows(boxes, cloud ? { me: me(client), showHost: admin } : void 0));
|
|
4403
|
-
const behind = boxes.filter((b) => b.latestBase !== void 0 && b.managed === void 0);
|
|
4716
|
+
const behind = boxes.filter((b) => b.latestBase !== void 0 && b.managed === void 0 && b.cluster === void 0);
|
|
4404
4717
|
const asleep = behind.some((b) => b.status === "hibernated");
|
|
4405
4718
|
if (behind.length > 0) info(color.dim(`${behind.length === 1 ? "1 box runs" : `${behind.length} boxes run`} an older image (\u2192 in BASE): kvbox vm update <box> moves it onto the newer one, its files stay${asleep ? " (a hibernated box first: kvbox wake <box>)" : ""}`));
|
|
4406
4719
|
} finally {
|
|
@@ -4411,16 +4724,17 @@ var hostCell = (b) => b.host === void 0 ? "-" : b.country === void 0 ? b.host :
|
|
|
4411
4724
|
function lsRows(boxes, cloud) {
|
|
4412
4725
|
return boxes.map((b) => ({
|
|
4413
4726
|
...cloud ? { owner: ownerCell(b, cloud.me) } : {},
|
|
4414
|
-
// a managed service's or storage's box, which only a platform admin's --all lists: `s3-1a2b3c (storage)
|
|
4415
|
-
|
|
4727
|
+
// a managed service's or storage's box, which only a platform admin's --all lists: `s3-1a2b3c (storage)`;
|
|
4728
|
+
// a cluster's node (#218): `prod-a3f (node of prod)`
|
|
4729
|
+
name: `${boxName(b.name)}${b.managed !== void 0 ? ` ${color.dim(`(${b.managed})`)}` : b.cluster !== void 0 ? ` ${color.dim(`(node of ${b.cluster.name})`)}` : ""}`,
|
|
4416
4730
|
status: status(b.status),
|
|
4417
4731
|
...cloud?.showHost ? { host: hostCell(b) } : {},
|
|
4418
4732
|
address: addressOf(b),
|
|
4419
4733
|
size: b.status === "unknown" ? "-" : `${shape(b.vcpu, b.memMib, b.diskBytes)} ${color.dim(`(${gbShort(b.diskUsedBytes)} used)`)}`,
|
|
4420
4734
|
created: age(b.createdAt),
|
|
4421
4735
|
// An image other than the base one (#87) is named: `postgres v0.1.0`; a newer one on the host follows in yellow: `v0.12.0 → v0.16.0`
|
|
4422
|
-
// (not on a managed service's box, which `vm update` cannot reach).
|
|
4423
|
-
base: b.status === "unknown" || b.base === "" ? "-" : `${b.image !== void 0 ? `${b.image} ${b.base}` : b.base}${b.latestBase === void 0 || b.managed !== void 0 ? "" : color.yellow(` \u2192 ${b.latestBase}`)}`
|
|
4736
|
+
// (not on a managed service's box or a cluster's node, which `vm update` cannot reach).
|
|
4737
|
+
base: b.status === "unknown" || b.base === "" ? "-" : `${b.image !== void 0 ? `${b.image} ${b.base}` : b.base}${b.latestBase === void 0 || b.managed !== void 0 || b.cluster !== void 0 ? "" : color.yellow(` \u2192 ${b.latestBase}`)}`
|
|
4424
4738
|
}));
|
|
4425
4739
|
}
|
|
4426
4740
|
|
|
@@ -4489,6 +4803,7 @@ function getRows(box2, subs, user) {
|
|
|
4489
4803
|
["status", status(box2.status)]
|
|
4490
4804
|
];
|
|
4491
4805
|
if (user !== void 0) rows2.push(["owner", ownerCell(box2, user)]);
|
|
4806
|
+
if (box2.cluster !== void 0) rows2.push(["cluster", `node of ${box2.cluster.name}, pool ${box2.cluster.pool} ${color.dim(`(more or fewer nodes, the newest going first: kvbox k8s pool resize ${box2.cluster.name} ${box2.cluster.pool} --nodes <n>)`)}`]);
|
|
4492
4807
|
if (box2.status !== "unknown") {
|
|
4493
4808
|
rows2.push(["size", `${shape(box2.vcpu, box2.memMib, box2.diskBytes)} ${color.dim(`(${gb(box2.diskUsedBytes)} used)`)}`]);
|
|
4494
4809
|
rows2.push(["address", box2.ssh?.host ?? (box2.ip === "" ? "-" : box2.ip)]);
|
|
@@ -4505,7 +4820,7 @@ function getRows(box2, subs, user) {
|
|
|
4505
4820
|
if (!box2.autoHibernateSec && box2.idleCheck !== void 0) rows2.push(["idle check", `${box2.idleCheck} ${color.dim("(used once auto-hibernate is on)")}`]);
|
|
4506
4821
|
rows2.push(["integrations", box2.integrations?.length ? box2.integrations.join(", ") : "-"]);
|
|
4507
4822
|
rows2.push(["source", box2.source]);
|
|
4508
|
-
const update = box2.latestBase === void 0 ? "" : ` ${color.yellow(`(${box2.latestBase} available: ${box2.status === "hibernated" ? `kvbox wake ${displayName(box2, user)}, then ` : ""}kvbox vm update ${displayName(box2, user)})`)}`;
|
|
4823
|
+
const update = box2.latestBase === void 0 || box2.cluster !== void 0 ? "" : ` ${color.yellow(`(${box2.latestBase} available: ${box2.status === "hibernated" ? `kvbox wake ${displayName(box2, user)}, then ` : ""}kvbox vm update ${displayName(box2, user)})`)}`;
|
|
4509
4824
|
rows2.push(["base", `${box2.image === void 0 ? box2.base : `${box2.image} ${box2.base}`}${update}`]);
|
|
4510
4825
|
rows2.push(["created", `${age(box2.createdAt)} ${color.dim(`(${box2.createdAt})`)}`]);
|
|
4511
4826
|
if (box2.bootedAt !== void 0) rows2.push(["booted", `${age(box2.bootedAt)} ${color.dim(`(${box2.bootedAt})`)}`]);
|
|
@@ -6341,8 +6656,9 @@ var usageCommand2 = new Command64("usage").description("what your boxes and volu
|
|
|
6341
6656
|
const volumes = report.volumes ?? [];
|
|
6342
6657
|
const storage = report.storage ?? [];
|
|
6343
6658
|
const cron = report.cron ?? [];
|
|
6659
|
+
const clusters = report.clusters ?? [];
|
|
6344
6660
|
const backups = report.backups ?? [];
|
|
6345
|
-
if (report.boxes.length === 0 && volumes.length === 0 && storage.length === 0 && cron.length === 0 && backups.length === 0) info("no usage in this window");
|
|
6661
|
+
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");
|
|
6346
6662
|
else if (report.boxes.length > 0) table(perUser ? userRows(perUser) : usageRows(report, cloud));
|
|
6347
6663
|
if (volumes.length > 0) {
|
|
6348
6664
|
info(volumes.length === 1 ? "1 volume" : `${volumes.length} volumes`);
|
|
@@ -6356,13 +6672,17 @@ var usageCommand2 = new Command64("usage").description("what your boxes and volu
|
|
|
6356
6672
|
info(cron.length === 1 ? "1 cron service" : `${cron.length} cron services`);
|
|
6357
6673
|
table(cronRows(report, cloud));
|
|
6358
6674
|
}
|
|
6675
|
+
if (clusters.length > 0) {
|
|
6676
|
+
info(clusters.length === 1 ? "1 Kubernetes cluster" : `${clusters.length} Kubernetes clusters`);
|
|
6677
|
+
table(clusterRows(report, cloud));
|
|
6678
|
+
}
|
|
6359
6679
|
if (backups.length > 0) {
|
|
6360
6680
|
const taken = backups.reduce((n2, b) => n2 + b.count, 0);
|
|
6361
6681
|
info(taken === 1 ? "1 paid backup" : `${taken} paid backups`);
|
|
6362
6682
|
table(backupRows(report, cloud));
|
|
6363
6683
|
}
|
|
6364
|
-
if ((volumes.length > 0 || storage.length > 0 || cron.length > 0 || backups.length > 0) && report.totals.cost !== void 0) {
|
|
6365
|
-
const what = ["boxes", ...volumes.length > 0 ? ["volumes"] : [], ...storage.length > 0 ? ["object storage"] : [], ...cron.length > 0 ? ["cron services"] : [], ...backups.length > 0 ? ["backups"] : []];
|
|
6684
|
+
if ((volumes.length > 0 || storage.length > 0 || cron.length > 0 || clusters.length > 0 || backups.length > 0) && report.totals.cost !== void 0) {
|
|
6685
|
+
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"] : []];
|
|
6366
6686
|
info(`total: ${money(report.totals.cost.amount, report.totals.cost.currency)} ${color.dim(`(${what.slice(0, -1).join(", ")} and ${what.at(-1)}, estimated)`)}`);
|
|
6367
6687
|
}
|
|
6368
6688
|
if (cloud) {
|
|
@@ -6465,6 +6785,38 @@ function cronRows(report, cloud) {
|
|
|
6465
6785
|
...priced ? { cost: money(s.cost?.amount ?? 0, currency) } : {}
|
|
6466
6786
|
}));
|
|
6467
6787
|
}
|
|
6788
|
+
function clusterRows(report, cloud) {
|
|
6789
|
+
const priced = report.totals.cost !== void 0;
|
|
6790
|
+
const currency = report.totals.cost?.currency ?? "";
|
|
6791
|
+
const cells = (t) => ({
|
|
6792
|
+
running: duration(t.seconds.running),
|
|
6793
|
+
"vcpu-h": hours(t.vcpuHours),
|
|
6794
|
+
"ram GiB-h": hours(t.ramGibHours),
|
|
6795
|
+
"disk GiB-h": hours(t.diskGibHours)
|
|
6796
|
+
});
|
|
6797
|
+
const blank = { running: "", "vcpu-h": "", "ram GiB-h": "", "disk GiB-h": "" };
|
|
6798
|
+
const gone = (removed, live) => removed ? color.dim("removed") : live;
|
|
6799
|
+
return (report.clusters ?? []).flatMap((c2) => [
|
|
6800
|
+
{
|
|
6801
|
+
...cloud ? { owner: ownerCell2(c2, cloud.me) } : {},
|
|
6802
|
+
cluster: boxName(c2.name),
|
|
6803
|
+
part: "master",
|
|
6804
|
+
status: gone(c2.status === "removed", "present"),
|
|
6805
|
+
...cells(c2.master),
|
|
6806
|
+
...priced ? { cost: money(c2.master.cost?.amount ?? 0, currency) } : {}
|
|
6807
|
+
},
|
|
6808
|
+
...c2.nodes.map((n2) => ({
|
|
6809
|
+
...cloud ? { owner: "" } : {},
|
|
6810
|
+
cluster: "",
|
|
6811
|
+
part: `${n2.name}${n2.pool === void 0 ? "" : color.dim(` (${n2.pool})`)}`,
|
|
6812
|
+
status: gone(n2.status === "removed", status(n2.status)),
|
|
6813
|
+
...cells(n2),
|
|
6814
|
+
...priced ? { cost: money(n2.cost?.amount ?? 0, currency) } : {}
|
|
6815
|
+
})),
|
|
6816
|
+
...c2.fee === void 0 ? [] : [{ ...cloud ? { owner: "" } : {}, cluster: "", part: "cluster price", status: "", ...blank, ...priced ? { cost: money(c2.fee.amount, currency) } : {} }],
|
|
6817
|
+
{ ...cloud ? { owner: "" } : {}, cluster: "", part: color.bold("total"), status: "", ...blank, ...priced ? { cost: money(c2.cost?.amount ?? 0, currency) } : {} }
|
|
6818
|
+
]);
|
|
6819
|
+
}
|
|
6468
6820
|
function backupRows(report, cloud) {
|
|
6469
6821
|
return (report.backups ?? []).map((b) => ({
|
|
6470
6822
|
name: b.kind === "storage" ? "object storage" : b.name,
|
|
@@ -6490,7 +6842,7 @@ function byUser(report) {
|
|
|
6490
6842
|
return u;
|
|
6491
6843
|
});
|
|
6492
6844
|
users.sort((a, b) => a.user === null ? 1 : b.user === null ? -1 : a.user.localeCompare(b.user));
|
|
6493
|
-
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.backups === void 0 ? {} : { backups: report.backups }, totals: report.totals };
|
|
6845
|
+
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 };
|
|
6494
6846
|
}
|
|
6495
6847
|
function userRows(r) {
|
|
6496
6848
|
const priced = r.totals.cost !== void 0;
|
|
@@ -6581,7 +6933,7 @@ import { Command as Command67, InvalidArgumentError as InvalidArgumentError2, Op
|
|
|
6581
6933
|
// src/commands/deploy/config.ts
|
|
6582
6934
|
import { readFile as readFile5, writeFile as writeFile3 } from "fs/promises";
|
|
6583
6935
|
import { isAbsolute, join as join6, normalize, relative as relative2 } from "path";
|
|
6584
|
-
import { z as
|
|
6936
|
+
import { z as z17 } from "zod";
|
|
6585
6937
|
|
|
6586
6938
|
// src/commands/deploy/templates/docker.ts
|
|
6587
6939
|
import { readFile as readFile4 } from "fs/promises";
|
|
@@ -7005,21 +7357,21 @@ function detectTemplates(pkg, dir = NO_FACTS) {
|
|
|
7005
7357
|
var DEPLOY_AUTO_HIBERNATE_SEC = 3600;
|
|
7006
7358
|
var CONFIG_FILE = "kvbox.json";
|
|
7007
7359
|
var BOX_NAME_RE = /^[a-z0-9][a-z0-9-]{0,11}$/;
|
|
7008
|
-
var DeployConfigSchema =
|
|
7009
|
-
template:
|
|
7010
|
-
name:
|
|
7360
|
+
var DeployConfigSchema = z17.object({
|
|
7361
|
+
template: z17.enum(TEMPLATE_IDS),
|
|
7362
|
+
name: z17.string().regex(BOX_NAME_RE, "1-12 chars, lowercase letters, digits and '-', starting with a letter or digit"),
|
|
7011
7363
|
/** The org whose box it is; absent for the user's own. */
|
|
7012
|
-
org:
|
|
7364
|
+
org: z17.string().regex(ORG_SLUG_RE, "not an org slug").optional(),
|
|
7013
7365
|
/** The HTTPS name (`<subdomain>.kvbox.app`); absent when deploying to this machine's own host. */
|
|
7014
|
-
subdomain:
|
|
7366
|
+
subdomain: z17.string().check((ctx) => {
|
|
7015
7367
|
const problem = subdomainProblem(ctx.value);
|
|
7016
7368
|
if (problem) ctx.issues.push({ code: "custom", message: problem, input: ctx.value });
|
|
7017
7369
|
}).optional(),
|
|
7018
|
-
size:
|
|
7370
|
+
size: z17.enum(SIZE_NAMES).optional(),
|
|
7019
7371
|
/** The build output directory, relative to the app; the template's default when absent. */
|
|
7020
|
-
dist:
|
|
7372
|
+
dist: z17.string().optional(),
|
|
7021
7373
|
/** The port a Next.js app or Node server serves; the template's (3000) when absent. */
|
|
7022
|
-
port:
|
|
7374
|
+
port: z17.number().int().min(1).max(65535).optional()
|
|
7023
7375
|
});
|
|
7024
7376
|
var SERVICE_KEY_RE = /^[a-z][a-z0-9-]{0,19}$/;
|
|
7025
7377
|
var RESERVED_SERVICE_KEYS = ["app", "agent", "init", "volumes"];
|
|
@@ -7031,38 +7383,38 @@ var POSTGRES_PORT = 5432;
|
|
|
7031
7383
|
var POSTGRES_IMAGE = "postgres:17";
|
|
7032
7384
|
var POSTGRES_ENV = "DATABASE_URL";
|
|
7033
7385
|
var IMAGE_RE = /^[a-z0-9][a-z0-9._/:@-]*$/;
|
|
7034
|
-
var ServiceSchema =
|
|
7035
|
-
template:
|
|
7386
|
+
var ServiceSchema = z17.strictObject({
|
|
7387
|
+
template: z17.enum([...TEMPLATE_IDS, POSTGRES]),
|
|
7036
7388
|
/** The service's directory, relative to the one holding kvbox.json; every template but postgres has one. */
|
|
7037
|
-
dir:
|
|
7389
|
+
dir: z17.string().min(1).optional(),
|
|
7038
7390
|
/** A postgres service's image, `postgres:17` when absent (`pgvector/pgvector:pg17` for vectors). */
|
|
7039
|
-
image:
|
|
7391
|
+
image: z17.string().regex(IMAGE_RE, "an image name like postgres:17").optional(),
|
|
7040
7392
|
/** The volume (a key of `volumes`) a postgres service keeps its data on. */
|
|
7041
|
-
volume:
|
|
7393
|
+
volume: z17.string().optional(),
|
|
7042
7394
|
/** The box variable a postgres service's URL is written to, `DATABASE_URL` when absent. */
|
|
7043
|
-
env:
|
|
7395
|
+
env: z17.string().optional(),
|
|
7044
7396
|
/** 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`. */
|
|
7045
|
-
context:
|
|
7046
|
-
dist:
|
|
7397
|
+
context: z17.string().min(1).optional(),
|
|
7398
|
+
dist: z17.string().optional(),
|
|
7047
7399
|
/**
|
|
7048
7400
|
* A command run once per deploy in the service's new version (a docker service: in a container of
|
|
7049
7401
|
* the new image; node, nextjs: in the new source, installed and built), with the box's variables,
|
|
7050
7402
|
* before it replaces the running one. Migrations, mostly. A failing one stops that service's deploy.
|
|
7051
7403
|
*/
|
|
7052
|
-
release:
|
|
7404
|
+
release: z17.string().optional(),
|
|
7053
7405
|
/** The box port of a service with its own server; the template's (3000) when absent. */
|
|
7054
|
-
port:
|
|
7406
|
+
port: z17.number().int().min(1).max(65535).optional(),
|
|
7055
7407
|
/** The URL paths that go to this service, each with everything under it; the prefix is kept. */
|
|
7056
|
-
paths:
|
|
7408
|
+
paths: z17.array(z17.string().regex(ROUTE_RE, "a path like / or /api, no trailing slash")).min(1).optional()
|
|
7057
7409
|
});
|
|
7058
|
-
var StackConfigSchema =
|
|
7410
|
+
var StackConfigSchema = z17.strictObject({
|
|
7059
7411
|
name: DeployConfigSchema.shape.name.optional(),
|
|
7060
7412
|
org: DeployConfigSchema.shape.org,
|
|
7061
7413
|
subdomain: DeployConfigSchema.shape.subdomain,
|
|
7062
7414
|
size: DeployConfigSchema.shape.size,
|
|
7063
7415
|
/** The stack's volumes, name to size ("10GB"): made for its box and attached to it on the first deploy that needs one. */
|
|
7064
|
-
volumes:
|
|
7065
|
-
services:
|
|
7416
|
+
volumes: z17.record(z17.string(), z17.string()).optional(),
|
|
7417
|
+
services: z17.record(z17.string(), ServiceSchema)
|
|
7066
7418
|
});
|
|
7067
7419
|
function volumeGib(text2) {
|
|
7068
7420
|
const mib2 = parseMib(text2);
|
|
@@ -8676,158 +9028,872 @@ for (const cmd of bucketCommand.commands) {
|
|
|
8676
9028
|
else withOrg2(cmd);
|
|
8677
9029
|
}
|
|
8678
9030
|
|
|
8679
|
-
// src/commands/
|
|
8680
|
-
import { Command as
|
|
9031
|
+
// src/commands/k8s/index.ts
|
|
9032
|
+
import { Command as Command126 } from "commander";
|
|
8681
9033
|
|
|
8682
|
-
// src/commands/
|
|
9034
|
+
// src/commands/k8s/backup/index.ts
|
|
9035
|
+
import { Command as Command103 } from "commander";
|
|
9036
|
+
|
|
9037
|
+
// src/commands/k8s/backup/create.ts
|
|
8683
9038
|
import { Command as Command98 } from "commander";
|
|
8684
9039
|
|
|
8685
|
-
// src/commands/
|
|
8686
|
-
async function
|
|
9040
|
+
// src/commands/k8s/shared.ts
|
|
9041
|
+
async function k8sClient(cmd) {
|
|
8687
9042
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
8688
9043
|
if (client.target.kind !== "cloud") {
|
|
8689
9044
|
await client.close();
|
|
8690
|
-
throw new KvboxError("
|
|
9045
|
+
throw new KvboxError("Kubernetes clusters run on the kvbox cloud: kvbox login first (this host's own socket has none)");
|
|
8691
9046
|
}
|
|
8692
9047
|
return client;
|
|
8693
9048
|
}
|
|
8694
|
-
function shownName2(
|
|
9049
|
+
function shownName2(c2, client) {
|
|
8695
9050
|
const context = client.target.kind === "cloud" ? client.target.org ?? client.target.user : void 0;
|
|
8696
|
-
return
|
|
8697
|
-
}
|
|
8698
|
-
function refFor(name, client) {
|
|
8699
|
-
if (client.target.kind !== "cloud" || name.includes("/")) return name;
|
|
8700
|
-
const { org, user } = client.target;
|
|
8701
|
-
return org && org !== user ? `${org}/${name}` : name;
|
|
8702
|
-
}
|
|
8703
|
-
var scheduleText = (t) => t.timezone === "UTC" ? t.expr : `${t.expr} (${t.timezone})`;
|
|
8704
|
-
function until(iso2, now = Date.now()) {
|
|
8705
|
-
const sec = Math.round((Date.parse(iso2) - now) / 1e3);
|
|
8706
|
-
return sec <= 0 ? "now" : `in ${duration(sec)}`;
|
|
8707
|
-
}
|
|
8708
|
-
function outcomeText(outcome) {
|
|
8709
|
-
const words = {
|
|
8710
|
-
running: "running",
|
|
8711
|
-
ok: "ok",
|
|
8712
|
-
failed: "failed",
|
|
8713
|
-
timeout: "timed out",
|
|
8714
|
-
"no-credit": "skipped: no credit",
|
|
8715
|
-
"box-stopped": "skipped: box stopped",
|
|
8716
|
-
"host-down": "host unreachable",
|
|
8717
|
-
"host-outdated": "host needs an update",
|
|
8718
|
-
lost: "lost",
|
|
8719
|
-
"still-running": "skipped: still running",
|
|
8720
|
-
"box-outdated": "box image too old"
|
|
8721
|
-
};
|
|
8722
|
-
const text2 = words[outcome];
|
|
8723
|
-
return outcome === "ok" ? color.green(text2) : outcome === "running" ? color.dim(text2) : color.red(text2);
|
|
9051
|
+
return c2.owner === context ? c2.name : `${c2.owner}/${c2.name}`;
|
|
8724
9052
|
}
|
|
8725
|
-
|
|
8726
|
-
|
|
8727
|
-
|
|
8728
|
-
|
|
8729
|
-
|
|
8730
|
-
|
|
8731
|
-
next: t.enabled ? t.nextRunAt ? until(t.nextRunAt) : "never" : color.yellow("paused"),
|
|
8732
|
-
"last run": t.lastRunAt && t.lastOutcome ? `${outcomeText(t.lastOutcome)} ${color.dim(age(t.lastRunAt))}` : "-"
|
|
8733
|
-
}))
|
|
8734
|
-
);
|
|
9053
|
+
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}`;
|
|
9054
|
+
function priceText2(c2) {
|
|
9055
|
+
const { perMonth, nodesPerMonth, totalPerMonth, currency } = c2.price;
|
|
9056
|
+
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`;
|
|
9057
|
+
const nodes = c2.pools.reduce((n2, p) => n2 + p.boxes.length, 0);
|
|
9058
|
+
return `${money(totalPerMonth, currency)} a month ${color.dim(`(estimated: ${money(perMonth, currency)} the cluster itself, ${money(nodesPerMonth, currency)} its ${nodes === 1 ? "node" : `${nodes} nodes`})`)}`;
|
|
8735
9059
|
}
|
|
9060
|
+
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(", ");
|
|
8736
9061
|
function printRows2(rows2) {
|
|
8737
9062
|
const width2 = Math.max(...rows2.map(([label]) => label.length));
|
|
8738
9063
|
for (const [label, value] of rows2) process.stdout.write(`${color.dim(label.padEnd(width2))} ${value}
|
|
8739
9064
|
`);
|
|
8740
9065
|
}
|
|
8741
|
-
var
|
|
9066
|
+
var READY_WAIT_MS = 5 * 6e4;
|
|
9067
|
+
var READY_EVERY_MS = 3e3;
|
|
9068
|
+
var readyWait = () => Number(process.env["KVBOX_K8S_WAIT_MS"] ?? READY_WAIT_MS);
|
|
9069
|
+
function allReady(c2) {
|
|
9070
|
+
if (c2.health?.ready !== true) return false;
|
|
9071
|
+
const joined = new Set(c2.health.nodes.filter((n2) => n2.ready).map((n2) => n2.name));
|
|
9072
|
+
return c2.pools.every((p) => p.boxes.length >= p.nodes && p.boxes.every((name) => joined.has(name)));
|
|
9073
|
+
}
|
|
9074
|
+
async function untilReady(client, name, made, waitMs, everyMs = Math.min(READY_EVERY_MS, waitMs), done = allReady, fatal = () => false) {
|
|
9075
|
+
const deadline = Date.now() + waitMs;
|
|
9076
|
+
let last = made;
|
|
9077
|
+
for (; ; ) {
|
|
9078
|
+
const now = await client.getCluster(name).catch((err) => {
|
|
9079
|
+
if (fatal(err)) throw err;
|
|
9080
|
+
return void 0;
|
|
9081
|
+
});
|
|
9082
|
+
if (now !== void 0) last = now;
|
|
9083
|
+
if (done(last) || Date.now() + everyMs > deadline) return last;
|
|
9084
|
+
await new Promise((done2) => setTimeout(done2, everyMs));
|
|
9085
|
+
}
|
|
9086
|
+
}
|
|
9087
|
+
function nodeCount(text2) {
|
|
9088
|
+
const nodes = Number(text2);
|
|
9089
|
+
if (!Number.isInteger(nodes) || nodes < 1 || nodes > MAX_POOL_NODES) throw new KvboxError(`--nodes ${text2}: a whole number from 1 to ${MAX_POOL_NODES}`);
|
|
9090
|
+
return nodes;
|
|
9091
|
+
}
|
|
9092
|
+
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)")}`;
|
|
8742
9093
|
|
|
8743
|
-
// src/commands/
|
|
8744
|
-
var createCommand9 = new Command98("create").description("
|
|
8745
|
-
const client = await
|
|
9094
|
+
// src/commands/k8s/backup/create.ts
|
|
9095
|
+
var createCommand9 = new Command98("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) => {
|
|
9096
|
+
const client = await k8sClient(cmd);
|
|
9097
|
+
const ls = `kvbox k8s backup ls ${name}`;
|
|
8746
9098
|
try {
|
|
8747
|
-
const
|
|
8748
|
-
if (opts.
|
|
8749
|
-
json(
|
|
9099
|
+
const started = await client.createClusterBackup(name);
|
|
9100
|
+
if (!opts.wait) {
|
|
9101
|
+
if (opts.json) json(started);
|
|
9102
|
+
else {
|
|
9103
|
+
info(`${color.green("\u2713")} backup ${started.id} of cluster ${color.bold(name)} started; it runs in the background`);
|
|
9104
|
+
info(color.dim(` status: ${ls}`));
|
|
9105
|
+
await printCost(client, false, true);
|
|
9106
|
+
}
|
|
8750
9107
|
return;
|
|
8751
9108
|
}
|
|
8752
|
-
const
|
|
8753
|
-
|
|
8754
|
-
|
|
9109
|
+
const done = await spin(`backing up cluster ${name}\u2026`, untilSettled(() => client.clusterBackup(name, started.id), `cluster ${name}`, started.id, ls));
|
|
9110
|
+
if (opts.json) json(done);
|
|
9111
|
+
if (done.status === "failed") throw new KvboxError(`backup ${done.id} of cluster ${name} failed: ${done.error ?? "no reason given"}`);
|
|
9112
|
+
if (opts.json) return;
|
|
9113
|
+
info(`${color.green("\u2713")} backup ${done.id} of cluster ${color.bold(name)}: ${sizeLine(done)}`);
|
|
9114
|
+
info(color.dim(` restore with: kvbox k8s backup restore ${name} ${done.id}`));
|
|
9115
|
+
await printCost(client, true, true);
|
|
8755
9116
|
} finally {
|
|
8756
9117
|
await client.close();
|
|
8757
9118
|
}
|
|
8758
9119
|
});
|
|
8759
9120
|
|
|
8760
|
-
// src/commands/
|
|
9121
|
+
// src/commands/k8s/backup/ls.ts
|
|
8761
9122
|
import { Command as Command99 } from "commander";
|
|
8762
|
-
var
|
|
8763
|
-
const client = await
|
|
9123
|
+
var lsCommand15 = new Command99("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) => {
|
|
9124
|
+
const client = await k8sClient(cmd);
|
|
9125
|
+
const removedOnes = async (err, name2) => {
|
|
9126
|
+
if (!(err instanceof CallError && err.status === 404)) throw err;
|
|
9127
|
+
const gone = (await client.listClusterBackups()).filter((b) => b.name === name2 || `${b.owner}/${b.name}` === name2);
|
|
9128
|
+
if (gone.length === 0) throw err;
|
|
9129
|
+
const own = name2.includes("/") ? [] : gone.filter((b) => b.owner === me(client));
|
|
9130
|
+
return own.length > 0 ? own : gone;
|
|
9131
|
+
};
|
|
8764
9132
|
try {
|
|
8765
|
-
const
|
|
8766
|
-
const triggers = await client.listCronTriggers(name);
|
|
9133
|
+
const list = name === void 0 ? await client.listClusterBackups() : await client.clusterBackups(name).catch((err) => removedOnes(err, name));
|
|
8767
9134
|
if (opts.json) {
|
|
8768
|
-
json(
|
|
9135
|
+
json(list);
|
|
8769
9136
|
return;
|
|
8770
9137
|
}
|
|
8771
|
-
|
|
8772
|
-
|
|
8773
|
-
|
|
8774
|
-
|
|
8775
|
-
|
|
8776
|
-
|
|
8777
|
-
|
|
8778
|
-
|
|
8779
|
-
|
|
9138
|
+
const schedule = name === void 0 ? null : await client.clusterBackupSchedule(name).catch(() => null);
|
|
9139
|
+
const footer = () => {
|
|
9140
|
+
if (schedule !== null) info(`${color.dim("on its own:")} ${scheduleLine(`kvbox k8s backup schedule ${name}`, schedule)}`);
|
|
9141
|
+
};
|
|
9142
|
+
if (list.length === 0) {
|
|
9143
|
+
info(name === void 0 ? "no backups yet; make one with: kvbox k8s backup create <cluster>" : `cluster ${name} has no backups; make one with: kvbox k8s backup create ${name}`);
|
|
9144
|
+
footer();
|
|
9145
|
+
return;
|
|
9146
|
+
}
|
|
9147
|
+
const anyError = list.some((b) => b.error !== null);
|
|
9148
|
+
const others = list.some((b) => b.owner !== me(client));
|
|
9149
|
+
table(
|
|
9150
|
+
list.map((b) => ({
|
|
9151
|
+
id: b.id,
|
|
9152
|
+
...name === void 0 || others ? { cluster: b.owner === me(client) ? b.name : `${b.owner}/${b.name}` } : {},
|
|
9153
|
+
status: b.status === "ready" ? color.green(b.status) : b.status === "failed" ? color.red(b.status) : color.yellow(b.status),
|
|
9154
|
+
version: b.version,
|
|
9155
|
+
data: b.dataBytes === null ? "-" : gbShort(b.dataBytes),
|
|
9156
|
+
uploaded: b.uploadedBytes === null ? "-" : gbShort(b.uploadedBytes),
|
|
9157
|
+
by: b.scheduled ? color.dim("schedule") : b.createdBy ?? "-",
|
|
9158
|
+
taken: age(b.createdAt),
|
|
9159
|
+
...anyError ? { error: b.error ?? "" } : {}
|
|
9160
|
+
}))
|
|
9161
|
+
);
|
|
9162
|
+
footer();
|
|
8780
9163
|
} finally {
|
|
8781
9164
|
await client.close();
|
|
8782
9165
|
}
|
|
8783
9166
|
});
|
|
8784
9167
|
|
|
8785
|
-
// src/commands/
|
|
9168
|
+
// src/commands/k8s/backup/restore.ts
|
|
8786
9169
|
import { Command as Command100 } from "commander";
|
|
8787
|
-
var
|
|
8788
|
-
const client = await
|
|
9170
|
+
var restoreCommand4 = new Command100("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) => {
|
|
9171
|
+
const client = await k8sClient(cmd);
|
|
8789
9172
|
try {
|
|
8790
|
-
const
|
|
8791
|
-
|
|
8792
|
-
|
|
9173
|
+
const backup = await client.clusterBackup(name, id);
|
|
9174
|
+
const question = `Restore cluster ${name} from backup ${backup.id} (${age(backup.createdAt)} ago, ${sizeLine(backup)})? Everything applied to it since is lost, and its master restarts.`;
|
|
9175
|
+
if (!await confirm(question, opts.yes ?? false)) {
|
|
9176
|
+
info("cancelled");
|
|
9177
|
+
process.exitCode = 1;
|
|
8793
9178
|
return;
|
|
8794
9179
|
}
|
|
8795
|
-
|
|
8796
|
-
|
|
9180
|
+
const done = await spin(`restoring cluster ${name} from ${backup.id}\u2026`, client.restoreClusterBackup(name, id));
|
|
9181
|
+
if (opts.json) {
|
|
9182
|
+
const cluster = opts.wait ? await spin("waiting for its nodes to be Ready again\u2026", untilReady(client, name, done.cluster, readyWait())) : done.cluster;
|
|
9183
|
+
json({ ...done, cluster });
|
|
8797
9184
|
return;
|
|
8798
9185
|
}
|
|
8799
|
-
|
|
8800
|
-
|
|
9186
|
+
info(`${color.green("\u2713")} cluster ${color.bold(name)} restored from backup ${backup.id}`);
|
|
9187
|
+
const list = (names2) => names2.join(", ");
|
|
9188
|
+
if (done.nodes.forgotten.length > 0) info(` nodes removed since the backup, taken out of its list again: ${list(done.nodes.forgotten)}`);
|
|
9189
|
+
if (done.nodes.restarted.length > 0) info(` nodes added since the backup, restarted to join again: ${list(done.nodes.restarted)}`);
|
|
9190
|
+
for (const w of done.warnings) warn(` ${w}`);
|
|
9191
|
+
if (!opts.wait) return;
|
|
9192
|
+
const now = await spin("waiting for its nodes to be Ready again\u2026", untilReady(client, name, done.cluster, readyWait()));
|
|
9193
|
+
if (allReady(now)) info(`${color.green("\u2713")} every node is Ready`);
|
|
9194
|
+
else warn(`it is restored, but not every node is Ready yet; look again with: kvbox k8s info ${name}`);
|
|
8801
9195
|
} finally {
|
|
8802
9196
|
await client.close();
|
|
8803
9197
|
}
|
|
8804
9198
|
});
|
|
8805
9199
|
|
|
8806
|
-
// src/commands/
|
|
9200
|
+
// src/commands/k8s/backup/rm.ts
|
|
8807
9201
|
import { Command as Command101 } from "commander";
|
|
8808
|
-
var rmCommand14 = new Command101("rm").alias("remove").description("
|
|
8809
|
-
const client = await
|
|
9202
|
+
var rmCommand14 = new Command101("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) => {
|
|
9203
|
+
const client = await k8sClient(cmd);
|
|
8810
9204
|
try {
|
|
8811
|
-
|
|
8812
|
-
info("cancelled");
|
|
8813
|
-
process.exitCode = 1;
|
|
8814
|
-
return;
|
|
8815
|
-
}
|
|
8816
|
-
await client.deleteCronService(name);
|
|
8817
|
-
info(`${color.green("\u2713")} cron service ${name} deleted`);
|
|
9205
|
+
await removeListed(client, await client.listClusterBackups(), (b) => b.name, name, id, `cluster ${name}`, opts.yes ?? false);
|
|
8818
9206
|
} finally {
|
|
8819
9207
|
await client.close();
|
|
8820
9208
|
}
|
|
8821
9209
|
});
|
|
8822
9210
|
|
|
8823
|
-
// src/commands/
|
|
8824
|
-
import { Command as Command109 } from "commander";
|
|
8825
|
-
|
|
8826
|
-
// src/commands/cron/trigger/add.ts
|
|
9211
|
+
// src/commands/k8s/backup/schedule.ts
|
|
8827
9212
|
import { Command as Command102 } from "commander";
|
|
8828
|
-
|
|
8829
|
-
|
|
8830
|
-
|
|
9213
|
+
var scheduleCommand4 = scheduleFlags(new Command102("schedule").description("show or change when a cluster is backed up on its own (daily, UTC)").argument("<cluster>", "cluster name")).action(
|
|
9214
|
+
async (name, flags, cmd) => {
|
|
9215
|
+
const change = changeOf(flags);
|
|
9216
|
+
const client = await k8sClient(cmd);
|
|
9217
|
+
try {
|
|
9218
|
+
const changed = Object.keys(change).length > 0;
|
|
9219
|
+
const schedule = changed ? await client.setClusterBackupSchedule(name, change) : await client.clusterBackupSchedule(name);
|
|
9220
|
+
printSchedule(`cluster ${name}`, `kvbox k8s backup schedule ${name}`, schedule, flags, changed);
|
|
9221
|
+
} finally {
|
|
9222
|
+
await client.close();
|
|
9223
|
+
}
|
|
9224
|
+
}
|
|
9225
|
+
);
|
|
9226
|
+
|
|
9227
|
+
// src/commands/k8s/backup/index.ts
|
|
9228
|
+
var backupCommand4 = new Command103("backup").description("back up what a cluster knows, list backups, restore or remove one, or change its nightly schedule").addCommand(createCommand9).addCommand(lsCommand15).addCommand(restoreCommand4).addCommand(rmCommand14).addCommand(scheduleCommand4);
|
|
9229
|
+
|
|
9230
|
+
// src/commands/k8s/create.ts
|
|
9231
|
+
import { Command as Command104 } from "commander";
|
|
9232
|
+
var createCommand10 = new Command104("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) => {
|
|
9233
|
+
if (!NODE_SIZES.includes(opts.size)) throw new KvboxError(`--size ${opts.size}: a node is one of ${NODE_SIZES.join(", ")}`);
|
|
9234
|
+
const nodes = nodeCount(opts.nodes);
|
|
9235
|
+
const client = await k8sClient(cmd);
|
|
9236
|
+
try {
|
|
9237
|
+
const made = await spin(`making cluster ${name} and its ${nodes} node${nodes === 1 ? "" : "s"}\u2026`, client.createCluster({ name, size: opts.size, nodes, ...opts.near !== void 0 ? { near: opts.near } : {} }));
|
|
9238
|
+
const cluster = opts.wait ? await spin("waiting for its API and its nodes\u2026", untilReady(client, name, made, readyWait())) : made;
|
|
9239
|
+
if (opts.json) {
|
|
9240
|
+
json(cluster);
|
|
9241
|
+
return;
|
|
9242
|
+
}
|
|
9243
|
+
const shown = shownName2(cluster, client);
|
|
9244
|
+
info(`${color.green("\u2713")} cluster ${color.bold(shown)} made on ${cluster.host}: Kubernetes ${cluster.version}, ${priceText2(cluster)}`);
|
|
9245
|
+
info(` API: ${apiText(cluster)}`);
|
|
9246
|
+
info(` nodes: ${poolsText(cluster)}`);
|
|
9247
|
+
if (opts.wait && !allReady(cluster)) warn(`it is not all ready yet; look again with: kvbox k8s info ${shown}`);
|
|
9248
|
+
info(color.dim(` next: kvbox k8s kubeconfig ${shown} > ${cluster.name}.yaml (then: kubectl --kubeconfig ${cluster.name}.yaml get nodes)`));
|
|
9249
|
+
} finally {
|
|
9250
|
+
await client.close();
|
|
9251
|
+
}
|
|
9252
|
+
});
|
|
9253
|
+
|
|
9254
|
+
// src/commands/k8s/domain/index.ts
|
|
9255
|
+
import { Command as Command108 } from "commander";
|
|
9256
|
+
|
|
9257
|
+
// src/commands/k8s/domain/add.ts
|
|
9258
|
+
import { Command as Command105 } from "commander";
|
|
9259
|
+
|
|
9260
|
+
// src/commands/domain/shared.ts
|
|
9261
|
+
function requireCloud4(client) {
|
|
9262
|
+
if (client.target.kind !== "cloud") throw new KvboxError("custom domains need the kvbox cloud: kvbox login (this host's own socket has none)");
|
|
9263
|
+
}
|
|
9264
|
+
var boxOf2 = (d, user) => user !== void 0 && d.owner !== user ? `${d.owner}/${d.box}` : d.box;
|
|
9265
|
+
function domainJson(d, user) {
|
|
9266
|
+
return { domain: d.domain, box: boxOf2(d, user), port: d.port, status: d.status, www: d.www, url: d.url, error: d.error, records: d.records, createdAt: d.createdAt };
|
|
9267
|
+
}
|
|
9268
|
+
function zoneOf(domain) {
|
|
9269
|
+
const labels = domain.split(".");
|
|
9270
|
+
const n2 = labels.length > 2 && labels.at(-1).length === 2 && labels.at(-2).length <= 3 ? 3 : 2;
|
|
9271
|
+
return labels.slice(-n2).join(".");
|
|
9272
|
+
}
|
|
9273
|
+
function hostIn(name, zone) {
|
|
9274
|
+
return name === zone ? "@" : name.endsWith(`.${zone}`) ? name.slice(0, -(zone.length + 1)) : name;
|
|
9275
|
+
}
|
|
9276
|
+
|
|
9277
|
+
// src/commands/k8s/domain/add.ts
|
|
9278
|
+
var clusterDomainJson = (d, cluster) => ({ domain: d.domain, cluster, status: d.status, www: d.www, url: d.url, error: d.error, records: d.records, createdAt: d.createdAt });
|
|
9279
|
+
var addCommand3 = new Command105("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 (cluster, domainArg, opts, cmd) => {
|
|
9280
|
+
const domain = assertDomain(domainArg.trim().toLowerCase());
|
|
9281
|
+
const client = await k8sClient(cmd);
|
|
9282
|
+
try {
|
|
9283
|
+
const d = await spin(`adding ${domain}\u2026`, client.addClusterDomain(cluster, domain));
|
|
9284
|
+
if (opts.json) {
|
|
9285
|
+
json(clusterDomainJson(d, cluster));
|
|
9286
|
+
return;
|
|
9287
|
+
}
|
|
9288
|
+
const apex = d.records.some((r) => r.type === "CNAME");
|
|
9289
|
+
const hosts = apex ? `the hosts ${domain} and www.${domain}` : `the host ${domain}`;
|
|
9290
|
+
const ingress = `it answers once an Ingress in the cluster has ${hosts} (ingress class traefik, plain HTTP inside: kvbox ends TLS)`;
|
|
9291
|
+
if (d.status === "live") {
|
|
9292
|
+
info(`${color.green("\u2713")} ${color.bold(d.url)} \u2192 cluster ${color.bold(cluster)}`);
|
|
9293
|
+
info(" the certificate is made on the first visit, which can take a few seconds");
|
|
9294
|
+
info(` ${ingress}`);
|
|
9295
|
+
return;
|
|
9296
|
+
}
|
|
9297
|
+
info(`${color.green("\u2713")} ${domain} added for cluster ${color.bold(cluster)}, waiting for its DNS`);
|
|
9298
|
+
const zone = zoneOf(domain);
|
|
9299
|
+
info(`
|
|
9300
|
+
At the company that runs the DNS of ${zone}, add:
|
|
9301
|
+
`);
|
|
9302
|
+
table(d.records.map((r) => ({ type: r.type, host: hostIn(r.name, zone), value: r.value })));
|
|
9303
|
+
info(`
|
|
9304
|
+
(the TXT record shows ${domain} is yours; keep it, it is checked again if the domain ever goes back to pending)`);
|
|
9305
|
+
if (apex) info(` (the www record is optional: with it, www.${domain} reaches the cluster too, and an Ingress must name that host as well)`);
|
|
9306
|
+
info(`
|
|
9307
|
+
kvbox checks every minute; ${domain} is served at ${d.url} once its records are set (kvbox k8s domain ls ${cluster}).`);
|
|
9308
|
+
info(` ${ingress}`);
|
|
9309
|
+
if (d.error) info(color.dim(` now: ${d.error}`));
|
|
9310
|
+
} finally {
|
|
9311
|
+
await client.close();
|
|
9312
|
+
}
|
|
9313
|
+
});
|
|
9314
|
+
|
|
9315
|
+
// src/commands/k8s/domain/ls.ts
|
|
9316
|
+
import { Command as Command106 } from "commander";
|
|
9317
|
+
var lsCommand16 = new Command106("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 (cluster, opts, cmd) => {
|
|
9318
|
+
const client = await k8sClient(cmd);
|
|
9319
|
+
try {
|
|
9320
|
+
const domains = await client.listClusterDomains(cluster);
|
|
9321
|
+
if (opts.json) {
|
|
9322
|
+
json(domains.map((d) => clusterDomainJson(d, cluster)));
|
|
9323
|
+
return;
|
|
9324
|
+
}
|
|
9325
|
+
if (domains.length === 0) {
|
|
9326
|
+
info(`cluster ${cluster} has no custom domain (kvbox k8s domain add ${cluster} <domain>)`);
|
|
9327
|
+
return;
|
|
9328
|
+
}
|
|
9329
|
+
table(domains.map((d) => ({ domain: d.www ? `${d.domain} (+www)` : d.domain, status: d.status === "live" ? "live" : "pending dns", note: d.status === "live" ? d.url : d.error ?? "" })));
|
|
9330
|
+
} finally {
|
|
9331
|
+
await client.close();
|
|
9332
|
+
}
|
|
9333
|
+
});
|
|
9334
|
+
|
|
9335
|
+
// src/commands/k8s/domain/rm.ts
|
|
9336
|
+
import { Command as Command107 } from "commander";
|
|
9337
|
+
var rmCommand15 = new Command107("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 (cluster, domainArg, opts, cmd) => {
|
|
9338
|
+
const domain = domainArg.trim().toLowerCase();
|
|
9339
|
+
const client = await k8sClient(cmd);
|
|
9340
|
+
try {
|
|
9341
|
+
if (!await confirm(`Stop serving cluster ${cluster} at ${domain}?`, opts.yes ?? false)) {
|
|
9342
|
+
info("cancelled");
|
|
9343
|
+
process.exitCode = 1;
|
|
9344
|
+
return;
|
|
9345
|
+
}
|
|
9346
|
+
await spin(`removing ${domain}\u2026`, client.removeClusterDomain(cluster, domain));
|
|
9347
|
+
info(`${color.green("\u2713")} ${domain} no longer reaches cluster ${cluster} (you can remove its DNS record)`);
|
|
9348
|
+
} finally {
|
|
9349
|
+
await client.close();
|
|
9350
|
+
}
|
|
9351
|
+
});
|
|
9352
|
+
|
|
9353
|
+
// src/commands/k8s/domain/index.ts
|
|
9354
|
+
var domainCommand = new Command108("domain").description("serve a cluster at domains of your own: add one, list them, remove one").addCommand(addCommand3).addCommand(lsCommand16).addCommand(rmCommand15);
|
|
9355
|
+
|
|
9356
|
+
// src/commands/k8s/info.ts
|
|
9357
|
+
import { Command as Command109 } from "commander";
|
|
9358
|
+
var infoCommand2 = new Command109("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) => {
|
|
9359
|
+
const client = await k8sClient(cmd);
|
|
9360
|
+
try {
|
|
9361
|
+
const c2 = await client.getCluster(name);
|
|
9362
|
+
if (opts.json) {
|
|
9363
|
+
json(c2);
|
|
9364
|
+
return;
|
|
9365
|
+
}
|
|
9366
|
+
const shown = shownName2(c2, client);
|
|
9367
|
+
const h = c2.health ?? null;
|
|
9368
|
+
const said = new Map((h?.nodes ?? []).map((n2) => [n2.name, n2]));
|
|
9369
|
+
const node = (name2) => {
|
|
9370
|
+
const n2 = said.get(name2);
|
|
9371
|
+
if (h === null) return name2;
|
|
9372
|
+
return `${name2}${n2 === void 0 ? color.yellow(" (not joined)") : `${n2.ready ? "" : color.yellow(" (not ready)")}${n2.schedulable ? "" : color.dim(" (cordoned)")}`}`;
|
|
9373
|
+
};
|
|
9374
|
+
const rows2 = [
|
|
9375
|
+
["name", color.bold(shown)],
|
|
9376
|
+
["status", h === null ? `${status(c2.status)}${c2.status === "running" ? color.dim(" (not answering yet)") : ""}` : h.ready ? color.green("ready") : color.yellow("starting")],
|
|
9377
|
+
["version", h?.version ?? c2.version],
|
|
9378
|
+
["API", apiText(c2)],
|
|
9379
|
+
["ingress", h === null ? color.dim("unknown") : h.ingress ? "Traefik, ports 80 and 443" : color.dim("not up yet")],
|
|
9380
|
+
["addresses", (c2.addresses ?? []).length === 0 ? color.dim(`none (kvbox k8s proxy claim ${shown} <name>, kvbox k8s domain add ${shown} <domain>)`) : c2.addresses.join(", ")],
|
|
9381
|
+
...c2.pools.length === 0 ? [["nodes", color.dim("none")]] : c2.pools.map((p) => [`pool ${p.name}`, `${p.nodes === 0 ? "being removed" : `${p.nodes} \xD7 ${p.size}`}: ${p.boxes.length === 0 ? color.dim("no node") : p.boxes.map(node).join(", ")}`]),
|
|
9382
|
+
...c2.operation ? [["changing", color.yellow(c2.operation.what)]] : c2.operationError ? [["last change", color.yellow(`did not finish: ${c2.operationError}`)]] : [],
|
|
9383
|
+
...c2.backupSchedule ? [["backups", scheduleLine(`kvbox k8s backup schedule ${shown}`, c2.backupSchedule)]] : [],
|
|
9384
|
+
["host", `${c2.host}${c2.country ? ` (${c2.country})` : ""}`],
|
|
9385
|
+
...c2.room ? [["room", roomText(c2.room)]] : [],
|
|
9386
|
+
["cost", priceText2(c2)],
|
|
9387
|
+
["created", `${age(c2.createdAt)}${c2.createdBy ? ` by ${c2.createdBy}` : ""}`]
|
|
9388
|
+
];
|
|
9389
|
+
printRows2(rows2);
|
|
9390
|
+
} finally {
|
|
9391
|
+
await client.close();
|
|
9392
|
+
}
|
|
9393
|
+
});
|
|
9394
|
+
|
|
9395
|
+
// src/commands/k8s/kubeconfig.ts
|
|
9396
|
+
import { Command as Command110 } from "commander";
|
|
9397
|
+
var kubeconfigCommand = new Command110("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) => {
|
|
9398
|
+
const client = await k8sClient(cmd);
|
|
9399
|
+
try {
|
|
9400
|
+
const made = await client.getKubeconfig(name);
|
|
9401
|
+
if (opts.json) json(made);
|
|
9402
|
+
else process.stdout.write(made.kubeconfig.endsWith("\n") ? made.kubeconfig : `${made.kubeconfig}
|
|
9403
|
+
`);
|
|
9404
|
+
} finally {
|
|
9405
|
+
await client.close();
|
|
9406
|
+
}
|
|
9407
|
+
});
|
|
9408
|
+
|
|
9409
|
+
// src/commands/k8s/link.ts
|
|
9410
|
+
import { Command as Command111 } from "commander";
|
|
9411
|
+
var reachedText = (l) => `${l.kind} ${l.to}`;
|
|
9412
|
+
var linkJson = (l, cluster) => ({ cluster, to: l.to, owner: l.owner, kind: l.kind, port: l.port, host: l.host, ...l.boxes ? { boxes: l.boxes } : {} });
|
|
9413
|
+
var linkCommand2 = new Command111("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 (cluster, target, opts, cmd) => {
|
|
9414
|
+
const port = opts.port === void 0 ? void 0 : parseLinkPort(opts.port);
|
|
9415
|
+
const client = await k8sClient(cmd);
|
|
9416
|
+
try {
|
|
9417
|
+
const link2 = await spin(`linking ${cluster} to ${target}\u2026`, client.linkCluster(cluster, { to: target, ...port !== void 0 ? { port } : {} }));
|
|
9418
|
+
if (opts.json) {
|
|
9419
|
+
json(linkJson(link2, cluster));
|
|
9420
|
+
return;
|
|
9421
|
+
}
|
|
9422
|
+
info(`${color.green("\u2713")} cluster ${color.bold(cluster)} reaches ${reachedText(link2)} at ${color.bold(`${link2.host}:${link2.port}`)}`);
|
|
9423
|
+
info(` from its ${link2.boxes?.length ?? 0} boxes (the master and every node); a node added later gets it too`);
|
|
9424
|
+
info(" in a pod, connect to that name: it resolves inside the cluster");
|
|
9425
|
+
} finally {
|
|
9426
|
+
await client.close();
|
|
9427
|
+
}
|
|
9428
|
+
});
|
|
9429
|
+
|
|
9430
|
+
// src/commands/k8s/links.ts
|
|
9431
|
+
import { Command as Command112 } from "commander";
|
|
9432
|
+
var linksCommand2 = new Command112("links").description("list what a cluster reaches (kvbox k8s link)").argument("<cluster>", "cluster name").option("--json", "print as JSON").action(async (cluster, opts, cmd) => {
|
|
9433
|
+
const client = await k8sClient(cmd);
|
|
9434
|
+
try {
|
|
9435
|
+
const links = await client.listClusterLinks(cluster);
|
|
9436
|
+
if (opts.json) {
|
|
9437
|
+
json(links.map((l) => linkJson(l, cluster)));
|
|
9438
|
+
return;
|
|
9439
|
+
}
|
|
9440
|
+
if (links.length === 0) info(`cluster ${cluster} reaches nothing (kvbox k8s link ${cluster} <database or box>)`);
|
|
9441
|
+
else table(links.map((l) => ({ reaches: reachedText(l), address: `${l.host}:${l.port}` })));
|
|
9442
|
+
} finally {
|
|
9443
|
+
await client.close();
|
|
9444
|
+
}
|
|
9445
|
+
});
|
|
9446
|
+
|
|
9447
|
+
// src/commands/k8s/ls.ts
|
|
9448
|
+
import { Command as Command113 } from "commander";
|
|
9449
|
+
var lsCommand17 = new Command113("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) => {
|
|
9450
|
+
const client = await k8sClient(cmd);
|
|
9451
|
+
try {
|
|
9452
|
+
const clusters = await client.listClusters({ all: opts.all });
|
|
9453
|
+
if (opts.json) {
|
|
9454
|
+
json(clusters);
|
|
9455
|
+
return;
|
|
9456
|
+
}
|
|
9457
|
+
if (clusters.length === 0) {
|
|
9458
|
+
info("no clusters yet; make one with: kvbox k8s create <name> --size m");
|
|
9459
|
+
return;
|
|
9460
|
+
}
|
|
9461
|
+
const me2 = client.target.kind === "cloud" ? client.target.user : void 0;
|
|
9462
|
+
table(
|
|
9463
|
+
clusters.map((c2) => ({
|
|
9464
|
+
owner: c2.owner === me2 ? "private" : c2.owner,
|
|
9465
|
+
name: c2.name,
|
|
9466
|
+
status: status(c2.status),
|
|
9467
|
+
version: c2.version,
|
|
9468
|
+
nodes: c2.pools.length === 0 ? "-" : c2.pools.map((p) => `${p.boxes.length} \xD7 ${p.size}`).join(", "),
|
|
9469
|
+
host: c2.host,
|
|
9470
|
+
api: c2.api === null ? "-" : apiText(c2),
|
|
9471
|
+
created: age(c2.createdAt)
|
|
9472
|
+
}))
|
|
9473
|
+
);
|
|
9474
|
+
} finally {
|
|
9475
|
+
await client.close();
|
|
9476
|
+
}
|
|
9477
|
+
});
|
|
9478
|
+
|
|
9479
|
+
// src/commands/k8s/pool/index.ts
|
|
9480
|
+
import { Command as Command118 } from "commander";
|
|
9481
|
+
|
|
9482
|
+
// src/commands/k8s/pool/add.ts
|
|
9483
|
+
import { Command as Command114 } from "commander";
|
|
9484
|
+
|
|
9485
|
+
// src/commands/k8s/pool/shared.ts
|
|
9486
|
+
function poolReady(c2, pool) {
|
|
9487
|
+
const p = c2.pools.find((x) => x.name === pool);
|
|
9488
|
+
if (c2.health?.ready !== true || p === void 0) return false;
|
|
9489
|
+
const joined = new Set(c2.health.nodes.filter((n2) => n2.ready).map((n2) => n2.name));
|
|
9490
|
+
return p.boxes.length >= p.nodes && p.boxes.every((name) => joined.has(name));
|
|
9491
|
+
}
|
|
9492
|
+
function untilJoined(client, named, changed, pool) {
|
|
9493
|
+
const watched = changed.operation !== void 0;
|
|
9494
|
+
return spin("waiting for the new nodes to join\u2026", untilReady(client, named, changed, readyWait() + (watched ? SLACK_MS : 0), void 0, (c2) => poolReady(c2, pool) || watched && c2.operation === void 0));
|
|
9495
|
+
}
|
|
9496
|
+
var SLACK_MS = 9e4;
|
|
9497
|
+
var DRAIN_WAIT_MS = 13 * 6e4;
|
|
9498
|
+
var leaving = (c2, pool) => {
|
|
9499
|
+
const p = c2.pools.find((x) => x.name === pool);
|
|
9500
|
+
return p === void 0 ? 0 : Math.max(0, p.boxes.length - p.nodes);
|
|
9501
|
+
};
|
|
9502
|
+
function untilDrained(client, named, changed, pool) {
|
|
9503
|
+
if (changed.operation === void 0) return Promise.resolve(changed);
|
|
9504
|
+
const count2 = Math.max(1, leaving(changed, pool));
|
|
9505
|
+
const waitMs = process.env["KVBOX_K8S_WAIT_MS"] !== void 0 ? readyWait() : count2 * DRAIN_WAIT_MS;
|
|
9506
|
+
const ours = changed.operation.since;
|
|
9507
|
+
return spin(
|
|
9508
|
+
`moving pods off ${count2 === 1 ? "the node" : `${count2} nodes`} and removing ${count2 === 1 ? "it" : "them"}\u2026`,
|
|
9509
|
+
untilReady(client, named, changed, waitMs, void 0, (c2) => c2.operation === void 0 || c2.operation.since !== ours, refused)
|
|
9510
|
+
);
|
|
9511
|
+
}
|
|
9512
|
+
var refused = (err) => !(err instanceof CallError) || err.status >= 400 && err.status < 500;
|
|
9513
|
+
function failIfNot(c2, again, ours) {
|
|
9514
|
+
if (c2.operation !== void 0) {
|
|
9515
|
+
if (ours !== void 0 && c2.operation.since !== ours.since) {
|
|
9516
|
+
throw new KvboxError(`another change (${c2.operation.what}) began before this one was seen to end, so how it ended is not known; look again with: kvbox k8s info ${c2.name}`);
|
|
9517
|
+
}
|
|
9518
|
+
return;
|
|
9519
|
+
}
|
|
9520
|
+
if (c2.operationError !== void 0) throw new KvboxError(c2.operationError);
|
|
9521
|
+
if (again !== void 0) throw new KvboxError(`the change stopped before it was done (the control plane was restarted meanwhile); ${again} goes on with it`);
|
|
9522
|
+
}
|
|
9523
|
+
var fails = (c2, again, ours) => c2.operation === void 0 ? c2.operationError !== void 0 || again !== void 0 : ours !== void 0 && c2.operation.since !== ours.since;
|
|
9524
|
+
var poolText = (p) => `${p.nodes} \xD7 ${p.size}${p.boxes.length > 0 ? color.dim(` (${p.boxes.join(", ")})`) : ""}`;
|
|
9525
|
+
var nodesText = (p) => p.nodes === 0 ? color.yellow(`being removed (${p.boxes.length} left)`) : p.boxes.length === p.nodes ? String(p.nodes) : color.yellow(`${p.boxes.length} of ${p.nodes}`);
|
|
9526
|
+
function printPool(client, c2, pool, done, waited) {
|
|
9527
|
+
const p = c2.pools.find((x) => x.name === pool);
|
|
9528
|
+
const shown = shownName2(c2, client);
|
|
9529
|
+
info(`${color.green("\u2713")} ${done}${p ? `: ${poolText(p)}` : ""}`);
|
|
9530
|
+
if (c2.operation !== void 0 && leaving(c2, pool) > 0) info(`${leaving(c2, pool) === 1 ? "a node is" : `${leaving(c2, pool)} nodes are`} still being drained and removed; look again with: kvbox k8s info ${shown}`);
|
|
9531
|
+
else if (waited && !poolReady(c2, pool)) warn(`its nodes have not all joined yet; look again with: kvbox k8s info ${shown}`);
|
|
9532
|
+
}
|
|
9533
|
+
|
|
9534
|
+
// src/commands/k8s/pool/add.ts
|
|
9535
|
+
var addCommand4 = new Command114("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 (cluster, opts, cmd) => {
|
|
9536
|
+
if (!NODE_SIZES.includes(opts.size)) throw new KvboxError(`--size ${opts.size}: a node is one of ${NODE_SIZES.join(", ")}`);
|
|
9537
|
+
const nodes = nodeCount(opts.nodes);
|
|
9538
|
+
const pool = opts.name ?? opts.size;
|
|
9539
|
+
const client = await k8sClient(cmd);
|
|
9540
|
+
try {
|
|
9541
|
+
const made = await spin(`adding pool ${pool} to ${cluster}: ${nodes} ${opts.size} node${nodes === 1 ? "" : "s"}\u2026`, client.addPool(cluster, { size: opts.size, nodes, ...opts.name !== void 0 ? { name: opts.name } : {} }));
|
|
9542
|
+
const now = opts.wait ? await untilJoined(client, cluster, made, pool) : made;
|
|
9543
|
+
if (opts.json) json(now);
|
|
9544
|
+
else printPool(client, now, pool, `pool ${pool} added to cluster ${shownName2(now, client)}`, opts.wait);
|
|
9545
|
+
failIfNot(now);
|
|
9546
|
+
} finally {
|
|
9547
|
+
await client.close();
|
|
9548
|
+
}
|
|
9549
|
+
});
|
|
9550
|
+
|
|
9551
|
+
// src/commands/k8s/pool/ls.ts
|
|
9552
|
+
import { Command as Command115 } from "commander";
|
|
9553
|
+
var lsCommand18 = new Command115("ls").alias("list").description("list a cluster's pools").argument("<cluster>", "cluster name").option("--json", "print as JSON").action(async (cluster, opts, cmd) => {
|
|
9554
|
+
const client = await k8sClient(cmd);
|
|
9555
|
+
try {
|
|
9556
|
+
const c2 = await client.getCluster(cluster);
|
|
9557
|
+
if (opts.json) {
|
|
9558
|
+
json(c2.pools);
|
|
9559
|
+
return;
|
|
9560
|
+
}
|
|
9561
|
+
if (c2.pools.length === 0) info(`no pools yet; add one with: kvbox k8s pool add ${cluster} --size m`);
|
|
9562
|
+
else table(c2.pools.map((p) => ({ pool: p.name, size: p.size, nodes: nodesText(p), boxes: p.boxes.join(", ") || "-" })));
|
|
9563
|
+
if (c2.operation) info(color.yellow(`${c2.operation.what}, since ${age(c2.operation.since)}`));
|
|
9564
|
+
else if (c2.operationError) warn(`the last change did not finish: ${c2.operationError}`);
|
|
9565
|
+
if (c2.room) info(`room for ${roomText(c2.room)}`);
|
|
9566
|
+
} finally {
|
|
9567
|
+
await client.close();
|
|
9568
|
+
}
|
|
9569
|
+
});
|
|
9570
|
+
|
|
9571
|
+
// src/commands/k8s/pool/resize.ts
|
|
9572
|
+
import { Command as Command116 } from "commander";
|
|
9573
|
+
var resizeCommand = new Command116("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 (cluster, pool, opts, cmd) => {
|
|
9574
|
+
const nodes = nodeCount(opts.nodes);
|
|
9575
|
+
const client = await k8sClient(cmd);
|
|
9576
|
+
try {
|
|
9577
|
+
const before = opts.yes ? void 0 : (await client.getCluster(cluster)).pools.find((p) => p.name === pool);
|
|
9578
|
+
const going = before === void 0 ? [] : before.boxes.slice(nodes).reverse();
|
|
9579
|
+
const shrinks = opts.force || going.length > 0;
|
|
9580
|
+
const what = going.length > 0 ? `${going.length === 1 ? "node" : "nodes"} ${going.join(", ")} of pool ${pool}` : `the nodes pool ${pool} of ${cluster} has beyond ${nodes}`;
|
|
9581
|
+
const question = opts.force ? `Remove ${what} without draining, with whatever they keep on their disks?` : `Drain and remove ${what} (cluster ${cluster})?`;
|
|
9582
|
+
if (shrinks && !await confirm(question, opts.yes ?? false)) {
|
|
9583
|
+
info("cancelled");
|
|
9584
|
+
process.exitCode = 1;
|
|
9585
|
+
return;
|
|
9586
|
+
}
|
|
9587
|
+
const changed = await spin(`resizing pool ${pool} of ${cluster} to ${nodes} node${nodes === 1 ? "" : "s"}\u2026`, client.resizePool(cluster, pool, nodes, opts.force ?? false));
|
|
9588
|
+
const now = !opts.wait ? changed : leaving(changed, pool) > 0 ? await untilDrained(client, cluster, changed, pool) : await untilJoined(client, cluster, changed, pool);
|
|
9589
|
+
const again = opts.wait && leaving(now, pool) > 0 ? `kvbox k8s pool resize ${cluster} ${pool} --nodes ${nodes}${opts.force ? " --force -y" : ""}` : void 0;
|
|
9590
|
+
const ours = opts.wait && leaving(changed, pool) > 0 ? changed.operation : void 0;
|
|
9591
|
+
if (opts.json) json(now);
|
|
9592
|
+
else if (!fails(now, again, ours)) printPool(client, now, pool, `pool ${pool} of cluster ${shownName2(now, client)}`, opts.wait);
|
|
9593
|
+
failIfNot(now, again, ours);
|
|
9594
|
+
} finally {
|
|
9595
|
+
await client.close();
|
|
9596
|
+
}
|
|
9597
|
+
});
|
|
9598
|
+
|
|
9599
|
+
// src/commands/k8s/pool/rm.ts
|
|
9600
|
+
import { Command as Command117 } from "commander";
|
|
9601
|
+
var rmCommand16 = new Command117("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 (cluster, pool, opts, cmd) => {
|
|
9602
|
+
const client = await k8sClient(cmd);
|
|
9603
|
+
try {
|
|
9604
|
+
if (!await confirm(`Remove pool ${pool} of cluster ${cluster} and its nodes${opts.force ? " without draining them, with whatever they keep on their disks" : ""}?`, opts.yes ?? false)) {
|
|
9605
|
+
info("cancelled");
|
|
9606
|
+
process.exitCode = 1;
|
|
9607
|
+
return;
|
|
9608
|
+
}
|
|
9609
|
+
const changed = await spin(`removing pool ${pool} of ${cluster}\u2026`, client.removePool(cluster, pool, opts.force ?? false));
|
|
9610
|
+
const now = opts.wait ? await untilDrained(client, cluster, changed, pool) : changed;
|
|
9611
|
+
const again = opts.wait && now.pools.some((p) => p.name === pool) ? `kvbox k8s pool rm ${cluster} ${pool}${opts.force ? " --force" : ""} -y` : void 0;
|
|
9612
|
+
if (opts.json) json(now);
|
|
9613
|
+
failIfNot(now, again, opts.wait ? changed.operation : void 0);
|
|
9614
|
+
if (opts.json) return;
|
|
9615
|
+
const shown = shownName2(now, client);
|
|
9616
|
+
if (now.pools.some((p) => p.name === pool)) info(`pool ${pool} is being removed: its nodes are drained first; look again with: kvbox k8s pool ls ${shown}`);
|
|
9617
|
+
else info(`${color.green("\u2713")} pool ${pool} removed from cluster ${shown}`);
|
|
9618
|
+
} finally {
|
|
9619
|
+
await client.close();
|
|
9620
|
+
}
|
|
9621
|
+
});
|
|
9622
|
+
|
|
9623
|
+
// src/commands/k8s/pool/index.ts
|
|
9624
|
+
var poolCommand = new Command118("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(rmCommand16);
|
|
9625
|
+
|
|
9626
|
+
// src/commands/k8s/proxy/index.ts
|
|
9627
|
+
import { Command as Command122 } from "commander";
|
|
9628
|
+
|
|
9629
|
+
// src/commands/k8s/proxy/claim.ts
|
|
9630
|
+
import { Command as Command119 } from "commander";
|
|
9631
|
+
var claimCommand2 = new Command119("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 (cluster, subArg, opts, cmd) => {
|
|
9632
|
+
const subdomain = assertSubdomain(subArg);
|
|
9633
|
+
const client = await k8sClient(cmd);
|
|
9634
|
+
try {
|
|
9635
|
+
const sub = await spin(`claiming ${subdomain}\u2026`, client.claimClusterSubdomain(cluster, subdomain));
|
|
9636
|
+
if (opts.json) {
|
|
9637
|
+
json({ cluster, subdomain: sub.subdomain, url: sub.url });
|
|
9638
|
+
return;
|
|
9639
|
+
}
|
|
9640
|
+
const host = sub.url.replace(/^https:\/\//, "");
|
|
9641
|
+
info(`${color.green("\u2713")} ${color.bold(sub.url)} \u2192 cluster ${color.bold(cluster)}`);
|
|
9642
|
+
info(` it answers once an Ingress in the cluster has the host ${host} (ingress class traefik, plain HTTP inside: kvbox ends TLS)`);
|
|
9643
|
+
} finally {
|
|
9644
|
+
await client.close();
|
|
9645
|
+
}
|
|
9646
|
+
});
|
|
9647
|
+
|
|
9648
|
+
// src/commands/k8s/proxy/ls.ts
|
|
9649
|
+
import { Command as Command120 } from "commander";
|
|
9650
|
+
var lsCommand19 = new Command120("ls").alias("list").description("list a cluster's kvbox.app addresses").argument("<cluster>", "cluster name").option("--json", "print as JSON").action(async (cluster, opts, cmd) => {
|
|
9651
|
+
const client = await k8sClient(cmd);
|
|
9652
|
+
try {
|
|
9653
|
+
const subs = await client.listClusterSubdomains(cluster);
|
|
9654
|
+
if (opts.json) {
|
|
9655
|
+
json(subs.map((s) => ({ cluster, subdomain: s.subdomain, url: s.url })));
|
|
9656
|
+
return;
|
|
9657
|
+
}
|
|
9658
|
+
if (subs.length === 0) info(`cluster ${cluster} has no kvbox.app address (kvbox k8s proxy claim ${cluster} <subdomain>)`);
|
|
9659
|
+
else table(subs.map((s) => ({ subdomain: s.subdomain, url: s.url })));
|
|
9660
|
+
} finally {
|
|
9661
|
+
await client.close();
|
|
9662
|
+
}
|
|
9663
|
+
});
|
|
9664
|
+
|
|
9665
|
+
// src/commands/k8s/proxy/release.ts
|
|
9666
|
+
import { Command as Command121 } from "commander";
|
|
9667
|
+
var releaseCommand2 = new Command121("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 (cluster, subdomain, opts, cmd) => {
|
|
9668
|
+
const client = await k8sClient(cmd);
|
|
9669
|
+
try {
|
|
9670
|
+
if (!await confirm(`Give up ${subdomain}, one of cluster ${cluster}'s HTTPS addresses? Anyone may claim it after.`, opts.yes ?? false)) {
|
|
9671
|
+
info("cancelled");
|
|
9672
|
+
process.exitCode = 1;
|
|
9673
|
+
return;
|
|
9674
|
+
}
|
|
9675
|
+
const sub = await spin(`releasing ${subdomain}\u2026`, client.releaseClusterSubdomain(cluster, subdomain));
|
|
9676
|
+
info(`${color.green("\u2713")} ${sub.url.replace(/^https:\/\//, "")} no longer reaches cluster ${color.bold(cluster)}`);
|
|
9677
|
+
} finally {
|
|
9678
|
+
await client.close();
|
|
9679
|
+
}
|
|
9680
|
+
});
|
|
9681
|
+
|
|
9682
|
+
// src/commands/k8s/proxy/index.ts
|
|
9683
|
+
var proxyCommand2 = new Command122("proxy").description("a cluster's HTTPS addresses, https://<name>.kvbox.app: claim one, list them, give one up").addCommand(claimCommand2).addCommand(lsCommand19).addCommand(releaseCommand2);
|
|
9684
|
+
|
|
9685
|
+
// src/commands/k8s/rm.ts
|
|
9686
|
+
import { Command as Command123 } from "commander";
|
|
9687
|
+
var rmCommand17 = new Command123("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) => {
|
|
9688
|
+
const client = await k8sClient(cmd);
|
|
9689
|
+
try {
|
|
9690
|
+
if (!await confirm(`Delete cluster ${name} with everything running in it?`, opts.yes ?? false)) {
|
|
9691
|
+
info("cancelled");
|
|
9692
|
+
process.exitCode = 1;
|
|
9693
|
+
return;
|
|
9694
|
+
}
|
|
9695
|
+
await spin(`deleting cluster ${name}\u2026`, client.deleteCluster(name));
|
|
9696
|
+
info(`${color.green("\u2713")} cluster ${name} deleted`);
|
|
9697
|
+
} finally {
|
|
9698
|
+
await client.close();
|
|
9699
|
+
}
|
|
9700
|
+
});
|
|
9701
|
+
|
|
9702
|
+
// src/commands/k8s/start.ts
|
|
9703
|
+
import { Command as Command124 } from "commander";
|
|
9704
|
+
var startCommand2 = new Command124("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) => {
|
|
9705
|
+
const client = await k8sClient(cmd);
|
|
9706
|
+
try {
|
|
9707
|
+
const c2 = await spin(`starting cluster ${name}\u2026`, client.startCluster(name));
|
|
9708
|
+
if (opts.json) json(c2);
|
|
9709
|
+
else info(`${color.green("\u2713")} cluster ${shownName2(c2, client)} is ${c2.status}`);
|
|
9710
|
+
} finally {
|
|
9711
|
+
await client.close();
|
|
9712
|
+
}
|
|
9713
|
+
});
|
|
9714
|
+
|
|
9715
|
+
// src/commands/k8s/unlink.ts
|
|
9716
|
+
import { Command as Command125 } from "commander";
|
|
9717
|
+
var unlinkCommand2 = new Command125("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 (cluster, target, opts, cmd) => {
|
|
9718
|
+
const port = opts.port === void 0 ? void 0 : parseLinkPort(opts.port);
|
|
9719
|
+
if (!await confirm(`Cut cluster ${cluster} off from ${target}${port !== void 0 ? ` port ${port}` : ""}? Its pods' open connections close too.`, opts.yes ?? false)) {
|
|
9720
|
+
info("cancelled");
|
|
9721
|
+
process.exitCode = 1;
|
|
9722
|
+
return;
|
|
9723
|
+
}
|
|
9724
|
+
const client = await k8sClient(cmd);
|
|
9725
|
+
try {
|
|
9726
|
+
const link2 = await spin(`unlinking ${cluster} from ${target}\u2026`, client.unlinkCluster(cluster, { to: target, ...port !== void 0 ? { port } : {} }));
|
|
9727
|
+
if (opts.json) {
|
|
9728
|
+
json(linkJson(link2, cluster));
|
|
9729
|
+
return;
|
|
9730
|
+
}
|
|
9731
|
+
info(`${color.green("\u2713")} cluster ${color.bold(cluster)} no longer reaches ${reachedText(link2)} port ${link2.port}`);
|
|
9732
|
+
} finally {
|
|
9733
|
+
await client.close();
|
|
9734
|
+
}
|
|
9735
|
+
});
|
|
9736
|
+
|
|
9737
|
+
// src/commands/k8s/index.ts
|
|
9738
|
+
var k8sCommand = new Command126("k8s").description("Kubernetes clusters kvbox runs for you").addCommand(createCommand10).addCommand(lsCommand17).addCommand(infoCommand2).addCommand(kubeconfigCommand).addCommand(poolCommand).addCommand(proxyCommand2).addCommand(domainCommand).addCommand(linkCommand2).addCommand(unlinkCommand2).addCommand(linksCommand2).addCommand(backupCommand4).addCommand(startCommand2).addCommand(rmCommand17);
|
|
9739
|
+
var withOrg3 = (cmd) => cmd.option("--org <slug>", "act in this org (- for your personal clusters)");
|
|
9740
|
+
for (const cmd of k8sCommand.commands) {
|
|
9741
|
+
if (cmd.commands.length > 0) cmd.commands.forEach(withOrg3);
|
|
9742
|
+
else withOrg3(cmd);
|
|
9743
|
+
}
|
|
9744
|
+
|
|
9745
|
+
// src/commands/cron/index.ts
|
|
9746
|
+
import { Command as Command139 } from "commander";
|
|
9747
|
+
|
|
9748
|
+
// src/commands/cron/create.ts
|
|
9749
|
+
import { Command as Command127 } from "commander";
|
|
9750
|
+
|
|
9751
|
+
// src/commands/cron/shared.ts
|
|
9752
|
+
async function cronClient(cmd) {
|
|
9753
|
+
const client = await clientFor(cmd.optsWithGlobals());
|
|
9754
|
+
if (client.target.kind !== "cloud") {
|
|
9755
|
+
await client.close();
|
|
9756
|
+
throw new KvboxError("the cron service runs on the kvbox cloud: kvbox login first (on this host's own socket, use the box's own crontab)");
|
|
9757
|
+
}
|
|
9758
|
+
return client;
|
|
9759
|
+
}
|
|
9760
|
+
function shownName3(s, client) {
|
|
9761
|
+
const context = client.target.kind === "cloud" ? client.target.org ?? client.target.user : void 0;
|
|
9762
|
+
return s.owner === context ? s.name : `${s.owner}/${s.name}`;
|
|
9763
|
+
}
|
|
9764
|
+
function refFor(name, client) {
|
|
9765
|
+
if (client.target.kind !== "cloud" || name.includes("/")) return name;
|
|
9766
|
+
const { org, user } = client.target;
|
|
9767
|
+
return org && org !== user ? `${org}/${name}` : name;
|
|
9768
|
+
}
|
|
9769
|
+
var scheduleText = (t) => t.timezone === "UTC" ? t.expr : `${t.expr} (${t.timezone})`;
|
|
9770
|
+
function until(iso2, now = Date.now()) {
|
|
9771
|
+
const sec = Math.round((Date.parse(iso2) - now) / 1e3);
|
|
9772
|
+
return sec <= 0 ? "now" : `in ${duration(sec)}`;
|
|
9773
|
+
}
|
|
9774
|
+
function outcomeText(outcome) {
|
|
9775
|
+
const words = {
|
|
9776
|
+
running: "running",
|
|
9777
|
+
ok: "ok",
|
|
9778
|
+
failed: "failed",
|
|
9779
|
+
timeout: "timed out",
|
|
9780
|
+
"no-credit": "skipped: no credit",
|
|
9781
|
+
"box-stopped": "skipped: box stopped",
|
|
9782
|
+
"host-down": "host unreachable",
|
|
9783
|
+
"host-outdated": "host needs an update",
|
|
9784
|
+
lost: "lost",
|
|
9785
|
+
"still-running": "skipped: still running",
|
|
9786
|
+
"box-outdated": "box image too old"
|
|
9787
|
+
};
|
|
9788
|
+
const text2 = words[outcome];
|
|
9789
|
+
return outcome === "ok" ? color.green(text2) : outcome === "running" ? color.dim(text2) : color.red(text2);
|
|
9790
|
+
}
|
|
9791
|
+
function printTriggers(triggers) {
|
|
9792
|
+
table(
|
|
9793
|
+
triggers.map((t) => ({
|
|
9794
|
+
id: t.id,
|
|
9795
|
+
schedule: scheduleText(t),
|
|
9796
|
+
action: cronTarget(t),
|
|
9797
|
+
next: t.enabled ? t.nextRunAt ? until(t.nextRunAt) : "never" : color.yellow("paused"),
|
|
9798
|
+
"last run": t.lastRunAt && t.lastOutcome ? `${outcomeText(t.lastOutcome)} ${color.dim(age(t.lastRunAt))}` : "-"
|
|
9799
|
+
}))
|
|
9800
|
+
);
|
|
9801
|
+
}
|
|
9802
|
+
function printRows3(rows2) {
|
|
9803
|
+
const width2 = Math.max(...rows2.map(([label]) => label.length));
|
|
9804
|
+
for (const [label, value] of rows2) process.stdout.write(`${color.dim(label.padEnd(width2))} ${value}
|
|
9805
|
+
`);
|
|
9806
|
+
}
|
|
9807
|
+
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>")`);
|
|
9808
|
+
|
|
9809
|
+
// src/commands/cron/create.ts
|
|
9810
|
+
var createCommand11 = new Command127("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) => {
|
|
9811
|
+
const client = await cronClient(cmd);
|
|
9812
|
+
try {
|
|
9813
|
+
const service = await client.createCronService(name);
|
|
9814
|
+
if (opts.json) {
|
|
9815
|
+
json(service);
|
|
9816
|
+
return;
|
|
9817
|
+
}
|
|
9818
|
+
const shown = shownName3(service, client);
|
|
9819
|
+
info(`${color.green("\u2713")} cron service ${color.bold(shown)} made; it keeps the last ${service.keepRuns} runs of each trigger${service.price && service.price.perMonth > 0 ? `, ${money(service.price.perMonth, service.price.currency)} a month` : ""}`);
|
|
9820
|
+
info(color.dim(`Add a trigger: kvbox cron trigger add ${refFor(shown, client)} <box> "0 6 * * *" --port 3000 --path /tasks/daily`));
|
|
9821
|
+
} finally {
|
|
9822
|
+
await client.close();
|
|
9823
|
+
}
|
|
9824
|
+
});
|
|
9825
|
+
|
|
9826
|
+
// src/commands/cron/info.ts
|
|
9827
|
+
import { Command as Command128 } from "commander";
|
|
9828
|
+
var infoCommand3 = new Command128("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) => {
|
|
9829
|
+
const client = await cronClient(cmd);
|
|
9830
|
+
try {
|
|
9831
|
+
const service = await client.getCronService(name);
|
|
9832
|
+
const triggers = await client.listCronTriggers(name);
|
|
9833
|
+
if (opts.json) {
|
|
9834
|
+
json({ ...service, triggerList: triggers });
|
|
9835
|
+
return;
|
|
9836
|
+
}
|
|
9837
|
+
printRows3([
|
|
9838
|
+
["name", shownName3(service, client)],
|
|
9839
|
+
["triggers", String(service.triggers)],
|
|
9840
|
+
["runs kept", `the last ${service.keepRuns} of each trigger`],
|
|
9841
|
+
["made", `${age(service.createdAt)}${service.createdBy ? ` by ${service.createdBy}` : ""}`]
|
|
9842
|
+
]);
|
|
9843
|
+
process.stdout.write("\n");
|
|
9844
|
+
if (triggers.length === 0) noTriggers(refFor(name, client));
|
|
9845
|
+
else printTriggers(triggers);
|
|
9846
|
+
} finally {
|
|
9847
|
+
await client.close();
|
|
9848
|
+
}
|
|
9849
|
+
});
|
|
9850
|
+
|
|
9851
|
+
// src/commands/cron/ls.ts
|
|
9852
|
+
import { Command as Command129 } from "commander";
|
|
9853
|
+
var lsCommand20 = new Command129("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) => {
|
|
9854
|
+
const client = await cronClient(cmd);
|
|
9855
|
+
try {
|
|
9856
|
+
const services = await client.listCronServices({ all: opts.all });
|
|
9857
|
+
if (opts.json) {
|
|
9858
|
+
json(services);
|
|
9859
|
+
return;
|
|
9860
|
+
}
|
|
9861
|
+
if (services.length === 0) {
|
|
9862
|
+
info("no cron services yet; make one with: kvbox cron create <name>");
|
|
9863
|
+
return;
|
|
9864
|
+
}
|
|
9865
|
+
const me2 = client.target.kind === "cloud" ? client.target.user : void 0;
|
|
9866
|
+
table(services.map((s) => ({ owner: s.owner === me2 ? "private" : s.owner, name: s.name, triggers: s.triggers, "runs kept": s.keepRuns, created: age(s.createdAt) })));
|
|
9867
|
+
} finally {
|
|
9868
|
+
await client.close();
|
|
9869
|
+
}
|
|
9870
|
+
});
|
|
9871
|
+
|
|
9872
|
+
// src/commands/cron/rm.ts
|
|
9873
|
+
import { Command as Command130 } from "commander";
|
|
9874
|
+
var rmCommand18 = new Command130("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) => {
|
|
9875
|
+
const client = await cronClient(cmd);
|
|
9876
|
+
try {
|
|
9877
|
+
if (!await confirm(`Delete cron service ${name}? Its triggers stop firing and their run history is deleted.`, opts.yes ?? false)) {
|
|
9878
|
+
info("cancelled");
|
|
9879
|
+
process.exitCode = 1;
|
|
9880
|
+
return;
|
|
9881
|
+
}
|
|
9882
|
+
await client.deleteCronService(name);
|
|
9883
|
+
info(`${color.green("\u2713")} cron service ${name} deleted`);
|
|
9884
|
+
} finally {
|
|
9885
|
+
await client.close();
|
|
9886
|
+
}
|
|
9887
|
+
});
|
|
9888
|
+
|
|
9889
|
+
// src/commands/cron/trigger/index.ts
|
|
9890
|
+
import { Command as Command138 } from "commander";
|
|
9891
|
+
|
|
9892
|
+
// src/commands/cron/trigger/add.ts
|
|
9893
|
+
import { Command as Command131 } from "commander";
|
|
9894
|
+
function portOf(value) {
|
|
9895
|
+
const n2 = Number(value);
|
|
9896
|
+
if (!Number.isInteger(n2) || n2 < 1 || n2 > 65535) throw new KvboxError(`--port ${value}: a port is a number from 1 to 65535`);
|
|
8831
9897
|
return n2;
|
|
8832
9898
|
}
|
|
8833
9899
|
function methodOf(value) {
|
|
@@ -8844,7 +9910,7 @@ function timeoutOf(value) {
|
|
|
8844
9910
|
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`);
|
|
8845
9911
|
return sec;
|
|
8846
9912
|
}
|
|
8847
|
-
var
|
|
9913
|
+
var addCommand5 = new Command131("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) => {
|
|
8848
9914
|
let action;
|
|
8849
9915
|
if (opts.run !== void 0) {
|
|
8850
9916
|
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");
|
|
@@ -8871,8 +9937,8 @@ var addCommand3 = new Command102("add").description("add a trigger: on a schedul
|
|
|
8871
9937
|
});
|
|
8872
9938
|
|
|
8873
9939
|
// src/commands/cron/trigger/ls.ts
|
|
8874
|
-
import { Command as
|
|
8875
|
-
var
|
|
9940
|
+
import { Command as Command132 } from "commander";
|
|
9941
|
+
var lsCommand21 = new Command132("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) => {
|
|
8876
9942
|
const client = await cronClient(cmd);
|
|
8877
9943
|
try {
|
|
8878
9944
|
const triggers = await client.listCronTriggers(service);
|
|
@@ -8888,8 +9954,8 @@ var lsCommand16 = new Command103("ls").alias("list").description("list a cron se
|
|
|
8888
9954
|
});
|
|
8889
9955
|
|
|
8890
9956
|
// src/commands/cron/trigger/pause.ts
|
|
8891
|
-
import { Command as
|
|
8892
|
-
var pauseCommand2 = new
|
|
9957
|
+
import { Command as Command133 } from "commander";
|
|
9958
|
+
var pauseCommand2 = new Command133("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) => {
|
|
8893
9959
|
const client = await cronClient(cmd);
|
|
8894
9960
|
try {
|
|
8895
9961
|
const trigger = await client.setCronTriggerEnabled(service, id, false);
|
|
@@ -8904,8 +9970,8 @@ var pauseCommand2 = new Command104("pause").description("stop a trigger from fir
|
|
|
8904
9970
|
});
|
|
8905
9971
|
|
|
8906
9972
|
// src/commands/cron/trigger/resume.ts
|
|
8907
|
-
import { Command as
|
|
8908
|
-
var resumeCommand2 = new
|
|
9973
|
+
import { Command as Command134 } from "commander";
|
|
9974
|
+
var resumeCommand2 = new Command134("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) => {
|
|
8909
9975
|
const client = await cronClient(cmd);
|
|
8910
9976
|
try {
|
|
8911
9977
|
const trigger = await client.setCronTriggerEnabled(service, id, true);
|
|
@@ -8920,8 +9986,8 @@ var resumeCommand2 = new Command105("resume").description("let a paused trigger
|
|
|
8920
9986
|
});
|
|
8921
9987
|
|
|
8922
9988
|
// src/commands/cron/trigger/rm.ts
|
|
8923
|
-
import { Command as
|
|
8924
|
-
var
|
|
9989
|
+
import { Command as Command135 } from "commander";
|
|
9990
|
+
var rmCommand19 = new Command135("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) => {
|
|
8925
9991
|
const client = await cronClient(cmd);
|
|
8926
9992
|
try {
|
|
8927
9993
|
if (!await confirm(`Delete trigger ${id} of cron service ${service}? Its run history is deleted too.`, opts.yes ?? false)) {
|
|
@@ -8937,8 +10003,8 @@ var rmCommand15 = new Command106("rm").alias("remove").description("delete a tri
|
|
|
8937
10003
|
});
|
|
8938
10004
|
|
|
8939
10005
|
// src/commands/cron/trigger/run.ts
|
|
8940
|
-
import { Command as
|
|
8941
|
-
var runCommand = new
|
|
10006
|
+
import { Command as Command136 } from "commander";
|
|
10007
|
+
var runCommand = new Command136("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) => {
|
|
8942
10008
|
const client = await cronClient(cmd);
|
|
8943
10009
|
try {
|
|
8944
10010
|
const trigger = await client.runCronTrigger(service, id);
|
|
@@ -8954,13 +10020,13 @@ var runCommand = new Command107("run").description("fire a trigger now, once, be
|
|
|
8954
10020
|
});
|
|
8955
10021
|
|
|
8956
10022
|
// src/commands/cron/trigger/runs.ts
|
|
8957
|
-
import { Command as
|
|
10023
|
+
import { Command as Command137 } from "commander";
|
|
8958
10024
|
function limitOf(value) {
|
|
8959
10025
|
const n2 = Number(value);
|
|
8960
10026
|
if (!Number.isInteger(n2) || n2 < 1) throw new KvboxError(`-n ${value}: a number of runs, 1 or more`);
|
|
8961
10027
|
return n2;
|
|
8962
10028
|
}
|
|
8963
|
-
var runsCommand = new
|
|
10029
|
+
var runsCommand = new Command137("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) => {
|
|
8964
10030
|
const limit = limitOf(opts.limit);
|
|
8965
10031
|
const client = await cronClient(cmd);
|
|
8966
10032
|
try {
|
|
@@ -8990,24 +10056,24 @@ var runsCommand = new Command108("runs").aliases(["logs"]).description("show how
|
|
|
8990
10056
|
});
|
|
8991
10057
|
|
|
8992
10058
|
// src/commands/cron/trigger/index.ts
|
|
8993
|
-
var triggerCommand = new
|
|
10059
|
+
var triggerCommand = new Command138("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(rmCommand19);
|
|
8994
10060
|
|
|
8995
10061
|
// src/commands/cron/index.ts
|
|
8996
|
-
var cronCommand = new
|
|
8997
|
-
var
|
|
10062
|
+
var cronCommand = new Command139("cron").description("cron: call a box on a schedule, waking it first if it sleeps").addCommand(createCommand11).addCommand(lsCommand20).addCommand(infoCommand3).addCommand(rmCommand18).addCommand(triggerCommand);
|
|
10063
|
+
var withOrg4 = (cmd) => cmd.option("--org <slug>", "act in this org (- for your personal cron services)");
|
|
8998
10064
|
for (const cmd of cronCommand.commands) {
|
|
8999
|
-
if (cmd === triggerCommand) cmd.commands.forEach(
|
|
9000
|
-
else
|
|
10065
|
+
if (cmd === triggerCommand) cmd.commands.forEach(withOrg4);
|
|
10066
|
+
else withOrg4(cmd);
|
|
9001
10067
|
}
|
|
9002
10068
|
|
|
9003
10069
|
// src/commands/managed/kind.ts
|
|
9004
|
-
import { Command as
|
|
10070
|
+
import { Command as Command158 } from "commander";
|
|
9005
10071
|
|
|
9006
10072
|
// src/commands/managed/backup/index.ts
|
|
9007
|
-
import { Command as
|
|
10073
|
+
import { Command as Command146 } from "commander";
|
|
9008
10074
|
|
|
9009
10075
|
// src/commands/managed/backup/create.ts
|
|
9010
|
-
import { Command as
|
|
10076
|
+
import { Command as Command141 } from "commander";
|
|
9011
10077
|
|
|
9012
10078
|
// src/commands/managed/shared.ts
|
|
9013
10079
|
import "commander";
|
|
@@ -9039,7 +10105,7 @@ async function managedClient(cmd) {
|
|
|
9039
10105
|
}
|
|
9040
10106
|
return client;
|
|
9041
10107
|
}
|
|
9042
|
-
var
|
|
10108
|
+
var shownName4 = (m, user) => m.owner === user ? m.name : `${m.owner}/${m.name}`;
|
|
9043
10109
|
var storageText = (m) => m.health?.storageUsedBytes !== void 0 ? `${gb(m.health.storageUsedBytes)} of ${m.storageGib} GB used` : `${m.storageGib} GB`;
|
|
9044
10110
|
var nearlyFull2 = (m) => m.health?.storageUsedBytes !== void 0 && m.health.storageTotalBytes !== void 0 && m.health.storageTotalBytes > 0 && m.health.storageUsedBytes / m.health.storageTotalBytes >= 0.9;
|
|
9045
10111
|
function stateText(m) {
|
|
@@ -9050,7 +10116,7 @@ function stateText(m) {
|
|
|
9050
10116
|
return `${status(m.status)}, ${m.health.accepting ? "accepting connections" : color.yellow("not accepting connections")}`;
|
|
9051
10117
|
}
|
|
9052
10118
|
function infoRows(spec, m, user) {
|
|
9053
|
-
const name =
|
|
10119
|
+
const name = shownName4(m, user);
|
|
9054
10120
|
const rows2 = [
|
|
9055
10121
|
["name", color.bold(name)],
|
|
9056
10122
|
["status", stateText(m)],
|
|
@@ -9070,7 +10136,7 @@ function infoRows(spec, m, user) {
|
|
|
9070
10136
|
function scheduleText2(spec, name, s, now = Date.now()) {
|
|
9071
10137
|
return scheduleLine(`kvbox ${spec.command} backup schedule ${name}`, s, now);
|
|
9072
10138
|
}
|
|
9073
|
-
function
|
|
10139
|
+
function printRows4(rows2) {
|
|
9074
10140
|
const width2 = Math.max(...rows2.map(([label]) => label.length));
|
|
9075
10141
|
for (const [label, value] of rows2) process.stdout.write(`${color.dim(label.padEnd(width2))} ${value}
|
|
9076
10142
|
`);
|
|
@@ -9094,7 +10160,7 @@ function parseStorage(text2, flag) {
|
|
|
9094
10160
|
}
|
|
9095
10161
|
|
|
9096
10162
|
// src/commands/managed/backup/create.ts
|
|
9097
|
-
var
|
|
10163
|
+
var createCommand12 = (spec) => new Command141("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) => {
|
|
9098
10164
|
const client = await managedClient(cmd);
|
|
9099
10165
|
const ls = `kvbox ${spec.command} backup ls ${name}`;
|
|
9100
10166
|
try {
|
|
@@ -9121,8 +10187,8 @@ var createCommand10 = (spec) => new Command112("create").description("back up a
|
|
|
9121
10187
|
});
|
|
9122
10188
|
|
|
9123
10189
|
// src/commands/managed/backup/ls.ts
|
|
9124
|
-
import { Command as
|
|
9125
|
-
var
|
|
10190
|
+
import { Command as Command142 } from "commander";
|
|
10191
|
+
var lsCommand22 = (spec) => {
|
|
9126
10192
|
const removedOnes = async (err, name, client) => {
|
|
9127
10193
|
if (!(err instanceof CallError && err.status === 404)) throw err;
|
|
9128
10194
|
const gone = (await client.listManagedBackups(spec.kind)).filter((b) => b.name === name || `${b.owner}/${b.name}` === name);
|
|
@@ -9130,7 +10196,7 @@ var lsCommand17 = (spec) => {
|
|
|
9130
10196
|
const own = name.includes("/") ? [] : gone.filter((b) => b.owner === me(client));
|
|
9131
10197
|
return own.length > 0 ? own : gone;
|
|
9132
10198
|
};
|
|
9133
|
-
return new
|
|
10199
|
+
return new Command142("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) => {
|
|
9134
10200
|
const client = await managedClient(cmd);
|
|
9135
10201
|
try {
|
|
9136
10202
|
const list = name === void 0 ? await client.listManagedBackups(spec.kind) : await client.managedBackups(spec.kind, name).catch((err) => removedOnes(err, name, client));
|
|
@@ -9173,8 +10239,8 @@ var lsCommand17 = (spec) => {
|
|
|
9173
10239
|
};
|
|
9174
10240
|
|
|
9175
10241
|
// src/commands/managed/backup/restore.ts
|
|
9176
|
-
import { Command as
|
|
9177
|
-
var
|
|
10242
|
+
import { Command as Command143 } from "commander";
|
|
10243
|
+
var restoreCommand5 = (spec) => new Command143("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) => {
|
|
9178
10244
|
const client = await managedClient(cmd);
|
|
9179
10245
|
try {
|
|
9180
10246
|
const backup = await client.managedBackup(spec.kind, name, id);
|
|
@@ -9196,8 +10262,8 @@ var restoreCommand4 = (spec) => new Command114("restore").description("put a bac
|
|
|
9196
10262
|
});
|
|
9197
10263
|
|
|
9198
10264
|
// src/commands/managed/backup/rm.ts
|
|
9199
|
-
import { Command as
|
|
9200
|
-
var
|
|
10265
|
+
import { Command as Command144 } from "commander";
|
|
10266
|
+
var rmCommand20 = (spec) => new Command144("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) => {
|
|
9201
10267
|
const client = await managedClient(cmd);
|
|
9202
10268
|
try {
|
|
9203
10269
|
await removeListed(client, await client.listManagedBackups(spec.kind), (b) => b.name, name, id, `database ${name}`, opts.yes ?? false);
|
|
@@ -9207,8 +10273,8 @@ var rmCommand16 = (spec) => new Command115("rm").alias("remove").description("re
|
|
|
9207
10273
|
});
|
|
9208
10274
|
|
|
9209
10275
|
// src/commands/managed/backup/schedule.ts
|
|
9210
|
-
import { Command as
|
|
9211
|
-
var
|
|
10276
|
+
import { Command as Command145 } from "commander";
|
|
10277
|
+
var scheduleCommand5 = (spec) => scheduleFlags(new Command145("schedule").description("show or change when a database is backed up on its own (daily, UTC)").argument("<db>", "its name")).action(
|
|
9212
10278
|
async (name, flags, cmd) => {
|
|
9213
10279
|
const change = changeOf(flags);
|
|
9214
10280
|
const client = await managedClient(cmd);
|
|
@@ -9223,19 +10289,19 @@ var scheduleCommand4 = (spec) => scheduleFlags(new Command116("schedule").descri
|
|
|
9223
10289
|
);
|
|
9224
10290
|
|
|
9225
10291
|
// src/commands/managed/backup/index.ts
|
|
9226
|
-
var
|
|
9227
|
-
const command = new
|
|
9228
|
-
for (const make of [
|
|
10292
|
+
var backupCommand5 = (spec) => {
|
|
10293
|
+
const command = new Command146("backup").description("back up a database to the kvbox cloud, list backups, restore or remove one, or change its nightly schedule");
|
|
10294
|
+
for (const make of [createCommand12, lsCommand22, restoreCommand5, rmCommand20, scheduleCommand5]) command.addCommand(make(spec).option("--org <slug>", "act in this org (- for your personal databases)"));
|
|
9229
10295
|
return command;
|
|
9230
10296
|
};
|
|
9231
10297
|
|
|
9232
10298
|
// src/commands/managed/create.ts
|
|
9233
|
-
import { Command as
|
|
10299
|
+
import { Command as Command147 } from "commander";
|
|
9234
10300
|
import { setTimeout as sleep5 } from "timers/promises";
|
|
9235
|
-
var
|
|
10301
|
+
var READY_WAIT_MS2 = 9e4;
|
|
9236
10302
|
var READY_STEP_MS = 2e3;
|
|
9237
|
-
var
|
|
9238
|
-
const command = new
|
|
10303
|
+
var createCommand13 = (spec) => {
|
|
10304
|
+
const command = new Command147("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");
|
|
9239
10305
|
for (const o of spec.options) command.option(`--${o.name} <${o.arg}>`, o.help);
|
|
9240
10306
|
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) => {
|
|
9241
10307
|
const options = Object.fromEntries(spec.options.flatMap((o) => typeof opts[o.name] === "string" ? [[o.name, opts[o.name]]] : []));
|
|
@@ -9251,14 +10317,14 @@ var createCommand11 = (spec) => {
|
|
|
9251
10317
|
try {
|
|
9252
10318
|
const doing = opts.fromBackup === void 0 ? `creating ${spec.title} database ${name}\u2026` : `creating ${spec.title} database ${name} from backup ${opts.fromBackup}\u2026`;
|
|
9253
10319
|
const made = await spin(doing, client.createManaged(spec.kind, req));
|
|
9254
|
-
const shown =
|
|
10320
|
+
const shown = shownName4(made, me(client));
|
|
9255
10321
|
if (opts.fromBackup !== void 0 && made.fromBackup === void 0) {
|
|
9256
10322
|
throw new KvboxError(
|
|
9257
10323
|
`this control plane does not know --from-backup yet: database ${shown} was made empty, not from backup ${opts.fromBackup}; remove it with: kvbox ${spec.command} rm ${shown}`
|
|
9258
10324
|
);
|
|
9259
10325
|
}
|
|
9260
10326
|
const ready = await spin(`starting ${spec.title}\u2026`, async () => {
|
|
9261
|
-
for (const until2 = Date.now() +
|
|
10327
|
+
for (const until2 = Date.now() + READY_WAIT_MS2; Date.now() < until2; await sleep5(READY_STEP_MS)) {
|
|
9262
10328
|
const now = await client.getManaged(spec.kind, shown).catch(() => void 0);
|
|
9263
10329
|
if (now?.health?.ready && now.health.accepting) return true;
|
|
9264
10330
|
}
|
|
@@ -9270,13 +10336,13 @@ var createCommand11 = (spec) => {
|
|
|
9270
10336
|
}
|
|
9271
10337
|
const restored = made.fromBackup === void 0 ? "" : `, the data of backup ${made.fromBackup}`;
|
|
9272
10338
|
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})`)}`);
|
|
9273
|
-
|
|
10339
|
+
printRows4([...settingRows(spec, made.settings), ...secretRows(made.secret)].map(([label, value]) => [` ${label}`, value]));
|
|
9274
10340
|
info("");
|
|
9275
10341
|
info("Nobody can reach it yet. To let something in:");
|
|
9276
10342
|
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})`)}`);
|
|
9277
10343
|
info(` the internet kvbox ${spec.command} public ${shown} on`);
|
|
9278
10344
|
info(color.dim(`It costs about ${money(made.price.perMonth, made.price.currency)} a month while it runs, ${money(made.price.storagePerMonth, made.price.currency)} stopped. The password again: kvbox ${spec.command} password ${shown}`));
|
|
9279
|
-
if (!ready) info(color.dim(`It was not answering after ${
|
|
10345
|
+
if (!ready) info(color.dim(`It was not answering after ${READY_WAIT_MS2 / 1e3} s; see how it is with: kvbox ${spec.command} info ${shown}`));
|
|
9280
10346
|
} finally {
|
|
9281
10347
|
await client.close();
|
|
9282
10348
|
}
|
|
@@ -9284,8 +10350,8 @@ var createCommand11 = (spec) => {
|
|
|
9284
10350
|
};
|
|
9285
10351
|
|
|
9286
10352
|
// src/commands/managed/grow.ts
|
|
9287
|
-
import { Command as
|
|
9288
|
-
var growCommand3 = (spec) => new
|
|
10353
|
+
import { Command as Command148 } from "commander";
|
|
10354
|
+
var growCommand3 = (spec) => new Command148("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) => {
|
|
9289
10355
|
const storageGib = parseStorage(size, "size");
|
|
9290
10356
|
const client = await managedClient(cmd);
|
|
9291
10357
|
try {
|
|
@@ -9298,21 +10364,21 @@ var growCommand3 = (spec) => new Command119("grow").description("give a database
|
|
|
9298
10364
|
});
|
|
9299
10365
|
|
|
9300
10366
|
// src/commands/managed/info.ts
|
|
9301
|
-
import { Command as
|
|
9302
|
-
var
|
|
10367
|
+
import { Command as Command149 } from "commander";
|
|
10368
|
+
var infoCommand4 = (spec) => new Command149("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) => {
|
|
9303
10369
|
const client = await managedClient(cmd);
|
|
9304
10370
|
try {
|
|
9305
10371
|
const m = await client.getManaged(spec.kind, name);
|
|
9306
10372
|
if (opts.json) json(m);
|
|
9307
|
-
else
|
|
10373
|
+
else printRows4(infoRows(spec, m, me(client)));
|
|
9308
10374
|
} finally {
|
|
9309
10375
|
await client.close();
|
|
9310
10376
|
}
|
|
9311
10377
|
});
|
|
9312
10378
|
|
|
9313
10379
|
// src/commands/managed/link.ts
|
|
9314
|
-
import { Command as
|
|
9315
|
-
var
|
|
10380
|
+
import { Command as Command150 } from "commander";
|
|
10381
|
+
var linkCommand3 = (spec) => new Command150("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) => {
|
|
9316
10382
|
const client = await managedClient(cmd);
|
|
9317
10383
|
try {
|
|
9318
10384
|
const m = await spin(`linking ${box2} to ${name}\u2026`, client.linkManaged(spec.kind, name, box2));
|
|
@@ -9328,7 +10394,7 @@ var linkCommand2 = (spec) => new Command121("link").description("let a box reach
|
|
|
9328
10394
|
});
|
|
9329
10395
|
|
|
9330
10396
|
// src/commands/managed/ls.ts
|
|
9331
|
-
import { Command as
|
|
10397
|
+
import { Command as Command151 } from "commander";
|
|
9332
10398
|
function listRows(items, user, kindColumn) {
|
|
9333
10399
|
return items.map((m) => ({
|
|
9334
10400
|
owner: m.owner === user ? "private" : m.owner,
|
|
@@ -9342,7 +10408,7 @@ function listRows(items, user, kindColumn) {
|
|
|
9342
10408
|
created: age(m.createdAt)
|
|
9343
10409
|
}));
|
|
9344
10410
|
}
|
|
9345
|
-
var
|
|
10411
|
+
var lsCommand23 = (spec) => new Command151("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) => {
|
|
9346
10412
|
const client = await managedClient(cmd);
|
|
9347
10413
|
try {
|
|
9348
10414
|
const items = await client.listManaged(spec?.kind, { all: opts.all });
|
|
@@ -9362,8 +10428,8 @@ var lsCommand18 = (spec) => new Command122("ls").alias("list").description(spec
|
|
|
9362
10428
|
});
|
|
9363
10429
|
|
|
9364
10430
|
// src/commands/managed/password.ts
|
|
9365
|
-
import { Command as
|
|
9366
|
-
var passwordCommand = (spec) => new
|
|
10431
|
+
import { Command as Command152 } from "commander";
|
|
10432
|
+
var passwordCommand = (spec) => new Command152("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) => {
|
|
9367
10433
|
const client = await managedClient(cmd);
|
|
9368
10434
|
try {
|
|
9369
10435
|
const secret = opts.reset ? await spin(`setting a new password on ${name}\u2026`, client.resetManagedPassword(spec.kind, name)) : await client.managedPassword(spec.kind, name);
|
|
@@ -9372,15 +10438,15 @@ var passwordCommand = (spec) => new Command123("password").description("show a d
|
|
|
9372
10438
|
return;
|
|
9373
10439
|
}
|
|
9374
10440
|
if (opts.reset) info(`${color.green("\u2713")} database ${name} has a new password; the old one no longer works`);
|
|
9375
|
-
|
|
10441
|
+
printRows4(secretRows(secret));
|
|
9376
10442
|
} finally {
|
|
9377
10443
|
await client.close();
|
|
9378
10444
|
}
|
|
9379
10445
|
});
|
|
9380
10446
|
|
|
9381
10447
|
// src/commands/managed/public.ts
|
|
9382
|
-
import { Command as
|
|
9383
|
-
var publicCommand2 = (spec) => new
|
|
10448
|
+
import { Command as Command153 } from "commander";
|
|
10449
|
+
var publicCommand2 = (spec) => new Command153("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) => {
|
|
9384
10450
|
if (state !== "on" && state !== "off") throw new KvboxError(`write on or off: kvbox ${spec.command} public ${name} on`);
|
|
9385
10451
|
const client = await managedClient(cmd);
|
|
9386
10452
|
try {
|
|
@@ -9401,8 +10467,8 @@ var publicCommand2 = (spec) => new Command124("public").description("open a data
|
|
|
9401
10467
|
});
|
|
9402
10468
|
|
|
9403
10469
|
// src/commands/managed/rm.ts
|
|
9404
|
-
import { Command as
|
|
9405
|
-
var
|
|
10470
|
+
import { Command as Command154 } from "commander";
|
|
10471
|
+
var rmCommand21 = (spec) => new Command154("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) => {
|
|
9406
10472
|
const client = await managedClient(cmd);
|
|
9407
10473
|
try {
|
|
9408
10474
|
if (!await confirm(`Delete database ${name} and all its data? There is no backup.`, opts.yes ?? false)) {
|
|
@@ -9418,8 +10484,8 @@ var rmCommand17 = (spec) => new Command125("rm").alias("remove").description("de
|
|
|
9418
10484
|
});
|
|
9419
10485
|
|
|
9420
10486
|
// src/commands/managed/start.ts
|
|
9421
|
-
import { Command as
|
|
9422
|
-
var
|
|
10487
|
+
import { Command as Command155 } from "commander";
|
|
10488
|
+
var startCommand3 = (spec) => new Command155("start").description("run a stopped database again").argument("<db>", "its name").option("--json", "print as JSON").action(async (name, opts, cmd) => {
|
|
9423
10489
|
const client = await managedClient(cmd);
|
|
9424
10490
|
try {
|
|
9425
10491
|
const m = await spin(`starting ${name}\u2026`, client.startManaged(spec.kind, name));
|
|
@@ -9431,8 +10497,8 @@ var startCommand2 = (spec) => new Command126("start").description("run a stopped
|
|
|
9431
10497
|
});
|
|
9432
10498
|
|
|
9433
10499
|
// src/commands/managed/stop.ts
|
|
9434
|
-
import { Command as
|
|
9435
|
-
var stopCommand2 = (spec) => new
|
|
10500
|
+
import { Command as Command156 } from "commander";
|
|
10501
|
+
var stopCommand2 = (spec) => new Command156("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) => {
|
|
9436
10502
|
const client = await managedClient(cmd);
|
|
9437
10503
|
try {
|
|
9438
10504
|
const m = await spin(`stopping ${name}\u2026`, client.stopManaged(spec.kind, name));
|
|
@@ -9444,8 +10510,8 @@ var stopCommand2 = (spec) => new Command127("stop").description("shut a database
|
|
|
9444
10510
|
});
|
|
9445
10511
|
|
|
9446
10512
|
// src/commands/managed/unlink.ts
|
|
9447
|
-
import { Command as
|
|
9448
|
-
var
|
|
10513
|
+
import { Command as Command157 } from "commander";
|
|
10514
|
+
var unlinkCommand3 = (spec) => new Command157("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) => {
|
|
9449
10515
|
const client = await managedClient(cmd);
|
|
9450
10516
|
try {
|
|
9451
10517
|
const m = await spin(`unlinking ${box2} from ${name}\u2026`, client.unlinkManaged(spec.kind, name, box2));
|
|
@@ -9458,11 +10524,11 @@ var unlinkCommand2 = (spec) => new Command128("unlink").description("stop a box
|
|
|
9458
10524
|
|
|
9459
10525
|
// src/commands/managed/kind.ts
|
|
9460
10526
|
function kindCommand(spec, description) {
|
|
9461
|
-
const command = new
|
|
9462
|
-
for (const make of [
|
|
10527
|
+
const command = new Command158(spec.command).aliases(spec.aliases).description(description);
|
|
10528
|
+
for (const make of [createCommand13, lsCommand23, infoCommand4, passwordCommand, publicCommand2, linkCommand3, unlinkCommand3, growCommand3, stopCommand2, startCommand3, rmCommand21]) {
|
|
9463
10529
|
command.addCommand(make(spec).option("--org <slug>", "act in this org (- for your personal databases)"));
|
|
9464
10530
|
}
|
|
9465
|
-
command.addCommand(
|
|
10531
|
+
command.addCommand(backupCommand5(spec));
|
|
9466
10532
|
return command;
|
|
9467
10533
|
}
|
|
9468
10534
|
|
|
@@ -9473,17 +10539,17 @@ var pgCommand = kindCommand(POSTGRES2, "managed PostgreSQL: a database kvbox run
|
|
|
9473
10539
|
var redisCommand = kindCommand(REDIS, "managed Redis (Valkey): a Redis kvbox runs for you, private until you link a box or make it public");
|
|
9474
10540
|
|
|
9475
10541
|
// src/commands/managed/index.ts
|
|
9476
|
-
import { Command as
|
|
9477
|
-
var managedCommand = new
|
|
10542
|
+
import { Command as Command159 } from "commander";
|
|
10543
|
+
var managedCommand = new Command159("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)"));
|
|
9478
10544
|
|
|
9479
10545
|
// src/commands/env/index.ts
|
|
9480
|
-
import { Command as
|
|
10546
|
+
import { Command as Command163 } from "commander";
|
|
9481
10547
|
|
|
9482
10548
|
// src/commands/env/ls.ts
|
|
9483
|
-
import { Command as
|
|
10549
|
+
import { Command as Command160 } from "commander";
|
|
9484
10550
|
|
|
9485
10551
|
// src/commands/env/shared.ts
|
|
9486
|
-
function
|
|
10552
|
+
function requireCloud5(client) {
|
|
9487
10553
|
if (client.target.kind === "local") throw new KvboxError("kvbox env needs kvbox.sh: kvbox login first");
|
|
9488
10554
|
return client.target.org ?? client.target.user ?? "you";
|
|
9489
10555
|
}
|
|
@@ -9507,7 +10573,7 @@ function firstBootHint(box2, name) {
|
|
|
9507
10573
|
}
|
|
9508
10574
|
|
|
9509
10575
|
// src/commands/env/ls.ts
|
|
9510
|
-
var
|
|
10576
|
+
var lsCommand24 = new Command160("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) => {
|
|
9511
10577
|
const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
|
|
9512
10578
|
try {
|
|
9513
10579
|
if (opts.box !== void 0) {
|
|
@@ -9529,7 +10595,7 @@ var lsCommand19 = new Command131("ls").alias("list").description("list the varia
|
|
|
9529
10595
|
table([...own.vars.map((v) => row(v, "box")), ...inherited.map((v) => row(v, color.dim(slug)))]);
|
|
9530
10596
|
return;
|
|
9531
10597
|
}
|
|
9532
|
-
const owner =
|
|
10598
|
+
const owner = requireCloud5(client);
|
|
9533
10599
|
const vars = await client.listEnv();
|
|
9534
10600
|
if (opts.json) {
|
|
9535
10601
|
json(vars);
|
|
@@ -9546,12 +10612,12 @@ var lsCommand19 = new Command131("ls").alias("list").description("list the varia
|
|
|
9546
10612
|
});
|
|
9547
10613
|
|
|
9548
10614
|
// src/commands/env/rm.ts
|
|
9549
|
-
import { Command as
|
|
9550
|
-
var
|
|
10615
|
+
import { Command as Command161 } from "commander";
|
|
10616
|
+
var rmCommand22 = new Command161("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) => {
|
|
9551
10617
|
const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
|
|
9552
10618
|
try {
|
|
9553
10619
|
const target = opts.box === void 0 ? void 0 : await findBox2(client, opts.box);
|
|
9554
|
-
const owner = target === void 0 ?
|
|
10620
|
+
const owner = target === void 0 ? requireCloud5(client) : `box ${target.ref}`;
|
|
9555
10621
|
if (!await confirm(`Remove ${names2.join(", ")} from ${owner}'s variables?`, opts.yes ?? false)) {
|
|
9556
10622
|
info("cancelled");
|
|
9557
10623
|
process.exitCode = 1;
|
|
@@ -9584,11 +10650,11 @@ var rmCommand18 = new Command132("rm").alias("remove").description("remove varia
|
|
|
9584
10650
|
});
|
|
9585
10651
|
|
|
9586
10652
|
// src/commands/env/set.ts
|
|
9587
|
-
import { Command as
|
|
9588
|
-
var setCommand2 = new
|
|
10653
|
+
import { Command as Command162 } from "commander";
|
|
10654
|
+
var setCommand2 = new Command162("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) => {
|
|
9589
10655
|
const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
|
|
9590
10656
|
try {
|
|
9591
|
-
const owner = opts.box === void 0 ?
|
|
10657
|
+
const owner = opts.box === void 0 ? requireCloud5(client) : void 0;
|
|
9592
10658
|
const target = opts.box === void 0 ? void 0 : await findBox2(client, opts.box);
|
|
9593
10659
|
const ask = interactive();
|
|
9594
10660
|
if ((nameArg === void 0 || valueArg === void 0) && !ask) throw new KvboxError("give the name and the value: kvbox env set NAME VALUE (or run it in a terminal to be asked)");
|
|
@@ -9622,39 +10688,20 @@ var setCommand2 = new Command133("set").description("add or change a variable; b
|
|
|
9622
10688
|
});
|
|
9623
10689
|
|
|
9624
10690
|
// src/commands/env/index.ts
|
|
9625
|
-
var envCommand = new
|
|
10691
|
+
var envCommand = new Command163("env").description("environment variables every box of yours gets when it starts (secrets too)").addCommand(lsCommand24, { isDefault: true }).addCommand(setCommand2).addCommand(rmCommand22);
|
|
9626
10692
|
for (const cmd of envCommand.commands) cmd.option("--org <slug>", "the org's variables instead of yours");
|
|
9627
10693
|
|
|
9628
10694
|
// src/commands/domain/index.ts
|
|
9629
|
-
import { Command as
|
|
10695
|
+
import { Command as Command167 } from "commander";
|
|
9630
10696
|
|
|
9631
10697
|
// src/commands/domain/add.ts
|
|
9632
|
-
import { Command as
|
|
9633
|
-
|
|
9634
|
-
// src/commands/domain/shared.ts
|
|
9635
|
-
function requireCloud5(client) {
|
|
9636
|
-
if (client.target.kind !== "cloud") throw new KvboxError("custom domains need the kvbox cloud: kvbox login (this host's own socket has none)");
|
|
9637
|
-
}
|
|
9638
|
-
var boxOf2 = (d, user) => user !== void 0 && d.owner !== user ? `${d.owner}/${d.box}` : d.box;
|
|
9639
|
-
function domainJson(d, user) {
|
|
9640
|
-
return { domain: d.domain, box: boxOf2(d, user), port: d.port, status: d.status, www: d.www, url: d.url, error: d.error, records: d.records, createdAt: d.createdAt };
|
|
9641
|
-
}
|
|
9642
|
-
function zoneOf(domain) {
|
|
9643
|
-
const labels = domain.split(".");
|
|
9644
|
-
const n2 = labels.length > 2 && labels.at(-1).length === 2 && labels.at(-2).length <= 3 ? 3 : 2;
|
|
9645
|
-
return labels.slice(-n2).join(".");
|
|
9646
|
-
}
|
|
9647
|
-
function hostIn(name, zone) {
|
|
9648
|
-
return name === zone ? "@" : name.endsWith(`.${zone}`) ? name.slice(0, -(zone.length + 1)) : name;
|
|
9649
|
-
}
|
|
9650
|
-
|
|
9651
|
-
// src/commands/domain/add.ts
|
|
9652
|
-
var addCommand4 = new Command135("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) => {
|
|
10698
|
+
import { Command as Command164 } from "commander";
|
|
10699
|
+
var addCommand6 = new Command164("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) => {
|
|
9653
10700
|
const domain = assertDomain(domainArg.trim().toLowerCase());
|
|
9654
10701
|
const port = opts.port === void 0 ? void 0 : parsePorts([opts.port])[0];
|
|
9655
10702
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
9656
10703
|
try {
|
|
9657
|
-
|
|
10704
|
+
requireCloud4(client);
|
|
9658
10705
|
const user = me(client);
|
|
9659
10706
|
const box2 = displayName(await findBox(client, name), user);
|
|
9660
10707
|
const d = await spin(`adding ${domain}\u2026`, client.addDomain(box2, { domain, ...port !== void 0 ? { port } : {} }));
|
|
@@ -9685,11 +10732,11 @@ kvbox checks every minute; ${domain} is served at ${d.url} once its records are
|
|
|
9685
10732
|
});
|
|
9686
10733
|
|
|
9687
10734
|
// src/commands/domain/ls.ts
|
|
9688
|
-
import { Command as
|
|
9689
|
-
var
|
|
10735
|
+
import { Command as Command165 } from "commander";
|
|
10736
|
+
var lsCommand25 = new Command165("ls").alias("list").description("list your custom domains and whether they are live").option("--json", "print as JSON").action(async (opts, cmd) => {
|
|
9690
10737
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
9691
10738
|
try {
|
|
9692
|
-
|
|
10739
|
+
requireCloud4(client);
|
|
9693
10740
|
const user = me(client);
|
|
9694
10741
|
const domains = await client.listDomains();
|
|
9695
10742
|
if (opts.json) {
|
|
@@ -9715,14 +10762,14 @@ var lsCommand20 = new Command136("ls").alias("list").description("list your cust
|
|
|
9715
10762
|
});
|
|
9716
10763
|
|
|
9717
10764
|
// src/commands/domain/rm.ts
|
|
9718
|
-
import { Command as
|
|
9719
|
-
var
|
|
10765
|
+
import { Command as Command166 } from "commander";
|
|
10766
|
+
var rmCommand23 = new Command166("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) => {
|
|
9720
10767
|
const domain = domainArg.trim().toLowerCase();
|
|
9721
10768
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
9722
10769
|
try {
|
|
9723
|
-
|
|
10770
|
+
requireCloud4(client);
|
|
9724
10771
|
const found = (await client.listDomains()).find((d) => d.domain === domain);
|
|
9725
|
-
if (!found) throw new KvboxError(`domain ${domain}: not found (kvbox domain ls)`);
|
|
10772
|
+
if (!found) throw new KvboxError(`domain ${domain}: not found (kvbox domain ls; a cluster's is removed with kvbox k8s domain rm <cluster> ${domain})`);
|
|
9726
10773
|
const box2 = boxOf2(found, me(client));
|
|
9727
10774
|
if (!await confirm(`Stop serving box ${box2} at ${domain}?`, opts.yes ?? false)) {
|
|
9728
10775
|
info("cancelled");
|
|
@@ -9737,15 +10784,15 @@ var rmCommand19 = new Command137("rm").alias("remove").description("stop serving
|
|
|
9737
10784
|
});
|
|
9738
10785
|
|
|
9739
10786
|
// src/commands/domain/index.ts
|
|
9740
|
-
var
|
|
9741
|
-
for (const cmd of
|
|
10787
|
+
var domainCommand2 = new Command167("domain").alias("domains").description("serve a box at a domain of your own").addCommand(addCommand6).addCommand(lsCommand25).addCommand(rmCommand23);
|
|
10788
|
+
for (const cmd of domainCommand2.commands) cmd.option("--org <slug>", "act in this org (- for your personal boxes)");
|
|
9742
10789
|
|
|
9743
10790
|
// src/commands/update.ts
|
|
9744
10791
|
import { spawn as spawn8 } from "child_process";
|
|
9745
10792
|
import { mkdtempSync, rmSync, writeFileSync as writeFileSync2 } from "fs";
|
|
9746
10793
|
import { tmpdir } from "os";
|
|
9747
10794
|
import { join as join9 } from "path";
|
|
9748
|
-
import { Command as
|
|
10795
|
+
import { Command as Command168 } from "commander";
|
|
9749
10796
|
|
|
9750
10797
|
// src/update.ts
|
|
9751
10798
|
import { mkdirSync, readFileSync as readFileSync3, writeFileSync } from "fs";
|
|
@@ -9864,7 +10911,7 @@ function run2(cmd, args) {
|
|
|
9864
10911
|
child.on("exit", (code, signal) => resolve4(code ?? (signal ? 1 : 0)));
|
|
9865
10912
|
});
|
|
9866
10913
|
}
|
|
9867
|
-
var selfUpdateCommand = new
|
|
10914
|
+
var selfUpdateCommand = new Command168("update").description("update kvbox to the latest version (reruns the installer from kvbox.sh, agent skill included)").action(async () => {
|
|
9868
10915
|
suppressUpdateNotice();
|
|
9869
10916
|
const inst = installerFor(process.platform, process.env["KVBOX_INSTALL_URL"] || INSTALL_BASE);
|
|
9870
10917
|
let code;
|
|
@@ -9888,7 +10935,7 @@ var selfUpdateCommand = new Command139("update").description("update kvbox to th
|
|
|
9888
10935
|
import { chmod as chmod2, mkdir as mkdir4, readFile as readFile9, writeFile as writeFile5 } from "fs/promises";
|
|
9889
10936
|
import { homedir as homedir2 } from "os";
|
|
9890
10937
|
import { dirname as dirname2, join as join11 } from "path";
|
|
9891
|
-
import { Command as
|
|
10938
|
+
import { Command as Command169 } from "commander";
|
|
9892
10939
|
|
|
9893
10940
|
// src/sshConfig.ts
|
|
9894
10941
|
import { spawnSync as spawnSync4 } from "child_process";
|
|
@@ -10010,7 +11057,7 @@ async function forgetReplacedBox(alias, id, p) {
|
|
|
10010
11057
|
}
|
|
10011
11058
|
|
|
10012
11059
|
// src/commands/sshConfig.ts
|
|
10013
|
-
var sshConfigCommand = new
|
|
11060
|
+
var sshConfigCommand = new Command169("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) => {
|
|
10014
11061
|
const file = opts.file ?? join11(homedir2(), ".ssh", "config");
|
|
10015
11062
|
const before = await readFile9(file, "utf8").catch((err) => {
|
|
10016
11063
|
if (err.code === "ENOENT") return "";
|
|
@@ -10076,8 +11123,8 @@ async function aliasesOf(client, boxes, gone) {
|
|
|
10076
11123
|
|
|
10077
11124
|
// src/commands/sshProxy.ts
|
|
10078
11125
|
import { connect } from "net";
|
|
10079
|
-
import { Command as
|
|
10080
|
-
var sshProxyCommand = new
|
|
11126
|
+
import { Command as Command170 } from "commander";
|
|
11127
|
+
var sshProxyCommand = new Command170("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) => {
|
|
10081
11128
|
const ref = parseAlias(host);
|
|
10082
11129
|
if (ref === void 0) throw new KvboxError(`${host}: not a kvbox name (<box>.kvbox or <box>.<org>.kvbox)`);
|
|
10083
11130
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
@@ -10177,6 +11224,7 @@ var HELP_GROUPS = [
|
|
|
10177
11224
|
["bucket", "object storage: S3 buckets for your files"],
|
|
10178
11225
|
["pg", "managed PostgreSQL: a database kvbox runs for you"],
|
|
10179
11226
|
["redis", "managed Redis (Valkey): a Redis kvbox runs for you"],
|
|
11227
|
+
["k8s", "managed Kubernetes: a cluster kvbox runs for you, its nodes your boxes"],
|
|
10180
11228
|
["managed", "every managed database, whatever its kind"],
|
|
10181
11229
|
["cron", "call a box on a schedule, waking it first if it sleeps"],
|
|
10182
11230
|
["env", "environment variables and secrets every box of yours gets"],
|
|
@@ -10239,7 +11287,7 @@ function installRootHelp(program) {
|
|
|
10239
11287
|
|
|
10240
11288
|
// src/program.ts
|
|
10241
11289
|
function buildProgram() {
|
|
10242
|
-
const program = new
|
|
11290
|
+
const program = new Command171("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();
|
|
10243
11291
|
program.addCommand(vmCommand);
|
|
10244
11292
|
program.addCommand(snapshotsCommand);
|
|
10245
11293
|
program.addCommand(volumeCommand);
|
|
@@ -10248,8 +11296,9 @@ function buildProgram() {
|
|
|
10248
11296
|
program.addCommand(redisCommand);
|
|
10249
11297
|
program.addCommand(managedCommand);
|
|
10250
11298
|
program.addCommand(cronCommand);
|
|
11299
|
+
program.addCommand(k8sCommand);
|
|
10251
11300
|
program.addCommand(envCommand);
|
|
10252
|
-
program.addCommand(
|
|
11301
|
+
program.addCommand(domainCommand2);
|
|
10253
11302
|
program.addCommand(loginCommand);
|
|
10254
11303
|
program.addCommand(logoutCommand);
|
|
10255
11304
|
program.addCommand(whoamiCommand);
|