@layr-labs/ecloud-cli 0.2.0-dev → 0.2.0-dev.2
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/VERSION +2 -2
- package/dist/commands/auth/generate.js +2 -2
- package/dist/commands/auth/generate.js.map +1 -1
- package/dist/commands/auth/login.js +2 -2
- package/dist/commands/auth/login.js.map +1 -1
- package/dist/commands/auth/logout.js +2 -2
- package/dist/commands/auth/logout.js.map +1 -1
- package/dist/commands/auth/migrate.js +2 -2
- package/dist/commands/auth/migrate.js.map +1 -1
- package/dist/commands/auth/whoami.js +2 -2
- package/dist/commands/auth/whoami.js.map +1 -1
- package/dist/commands/billing/cancel.js +4 -5
- package/dist/commands/billing/cancel.js.map +1 -1
- package/dist/commands/billing/status.js +3 -3
- package/dist/commands/billing/status.js.map +1 -1
- package/dist/commands/billing/subscribe.js +4 -5
- package/dist/commands/billing/subscribe.js.map +1 -1
- package/dist/commands/compute/app/create.js +2 -2
- package/dist/commands/compute/app/create.js.map +1 -1
- package/dist/commands/compute/app/deploy.js +17 -545
- package/dist/commands/compute/app/deploy.js.map +1 -1
- package/dist/commands/compute/app/info.js +3 -5
- package/dist/commands/compute/app/info.js.map +1 -1
- package/dist/commands/compute/app/list.js +4 -6
- package/dist/commands/compute/app/list.js.map +1 -1
- package/dist/commands/compute/app/logs.js +5 -8
- package/dist/commands/compute/app/logs.js.map +1 -1
- package/dist/commands/compute/app/profile/set.js +3 -3
- package/dist/commands/compute/app/profile/set.js.map +1 -1
- package/dist/commands/compute/app/start.js +5 -8
- package/dist/commands/compute/app/start.js.map +1 -1
- package/dist/commands/compute/app/stop.js +5 -8
- package/dist/commands/compute/app/stop.js.map +1 -1
- package/dist/commands/compute/app/terminate.js +5 -8
- package/dist/commands/compute/app/terminate.js.map +1 -1
- package/dist/commands/compute/app/upgrade.js +11 -520
- package/dist/commands/compute/app/upgrade.js.map +1 -1
- package/dist/commands/compute/environment/list.js +2 -2
- package/dist/commands/compute/environment/list.js.map +1 -1
- package/dist/commands/compute/environment/set.js +2 -2
- package/dist/commands/compute/environment/set.js.map +1 -1
- package/dist/commands/compute/environment/show.js +2 -2
- package/dist/commands/compute/environment/show.js.map +1 -1
- package/dist/commands/compute/undelegate.js +5 -8
- package/dist/commands/compute/undelegate.js.map +1 -1
- package/dist/commands/{telemetry.js → telemetry/disable.js} +15 -64
- package/dist/commands/telemetry/disable.js.map +1 -0
- package/dist/commands/telemetry/enable.js +164 -0
- package/dist/commands/telemetry/enable.js.map +1 -0
- package/dist/commands/telemetry/status.js +159 -0
- package/dist/commands/telemetry/status.js.map +1 -0
- package/dist/commands/upgrade.js +2 -2
- package/dist/commands/upgrade.js.map +1 -1
- package/dist/commands/version.js +2 -2
- package/dist/commands/version.js.map +1 -1
- package/package.json +2 -5
- package/dist/commands/compute/app/releases.js +0 -1144
- package/dist/commands/compute/app/releases.js.map +0 -1
- package/dist/commands/compute/build/info.js +0 -501
- package/dist/commands/compute/build/info.js.map +0 -1
- package/dist/commands/compute/build/list.js +0 -575
- package/dist/commands/compute/build/list.js.map +0 -1
- package/dist/commands/compute/build/logs.js +0 -460
- package/dist/commands/compute/build/logs.js.map +0 -1
- package/dist/commands/compute/build/status.js +0 -482
- package/dist/commands/compute/build/status.js.map +0 -1
- package/dist/commands/compute/build/submit.js +0 -619
- package/dist/commands/compute/build/submit.js.map +0 -1
- package/dist/commands/compute/build/verify.js +0 -392
- package/dist/commands/compute/build/verify.js.map +0 -1
- package/dist/commands/telemetry.js.map +0 -1
|
@@ -3,11 +3,10 @@
|
|
|
3
3
|
// src/commands/compute/app/upgrade.ts
|
|
4
4
|
import { Command, Args, Flags as Flags2 } from "@oclif/core";
|
|
5
5
|
import {
|
|
6
|
-
getEnvironmentConfig as
|
|
6
|
+
getEnvironmentConfig as getEnvironmentConfig2,
|
|
7
7
|
UserApiClient as UserApiClient3,
|
|
8
8
|
isMainnet,
|
|
9
9
|
prepareUpgrade,
|
|
10
|
-
prepareUpgradeFromVerifiableBuild,
|
|
11
10
|
executeUpgrade,
|
|
12
11
|
watchUpgrade
|
|
13
12
|
} from "@layr-labs/ecloud-sdk";
|
|
@@ -128,8 +127,8 @@ function createCLITelemetryClient() {
|
|
|
128
127
|
const environment = createAppEnvironment(userUUID);
|
|
129
128
|
const telemetryEnabled = getGlobalTelemetryPreference();
|
|
130
129
|
return createTelemetryClient(environment, "ecloud-cli", {
|
|
131
|
-
telemetryEnabled: telemetryEnabled
|
|
132
|
-
//
|
|
130
|
+
telemetryEnabled: telemetryEnabled !== false
|
|
131
|
+
// Enabled by default, disabled only if explicitly set to false
|
|
133
132
|
});
|
|
134
133
|
}
|
|
135
134
|
async function withTelemetry(command, action) {
|
|
@@ -251,7 +250,7 @@ function listApps(environment) {
|
|
|
251
250
|
|
|
252
251
|
// src/utils/version.ts
|
|
253
252
|
function getCliVersion() {
|
|
254
|
-
return true ? "0.2.0-dev" : "0.0.0";
|
|
253
|
+
return true ? "0.2.0-dev.2" : "0.0.0";
|
|
255
254
|
}
|
|
256
255
|
function getClientId() {
|
|
257
256
|
return `ecloud-cli/v${getCliVersion()}`;
|
|
@@ -307,113 +306,6 @@ Found Dockerfile in ${cwd}`);
|
|
|
307
306
|
throw new Error(`Unexpected choice: ${choice}`);
|
|
308
307
|
}
|
|
309
308
|
}
|
|
310
|
-
async function promptUseVerifiableBuild() {
|
|
311
|
-
return confirmWithDefault("Build from verifiable source?", false);
|
|
312
|
-
}
|
|
313
|
-
async function promptVerifiableSourceType() {
|
|
314
|
-
return select({
|
|
315
|
-
message: "Choose verifiable source type:",
|
|
316
|
-
choices: [
|
|
317
|
-
{ name: "Build from git source (public repo required)", value: "git" },
|
|
318
|
-
{ name: "Use a prebuilt verifiable image (eigencloud-containers)", value: "prebuilt" }
|
|
319
|
-
]
|
|
320
|
-
});
|
|
321
|
-
}
|
|
322
|
-
async function promptVerifiableGitSourceInputs() {
|
|
323
|
-
const repoUrl = (await input({
|
|
324
|
-
message: "Enter public git repository URL:",
|
|
325
|
-
default: "",
|
|
326
|
-
validate: (value) => {
|
|
327
|
-
if (!value.trim()) return "Repository URL is required";
|
|
328
|
-
try {
|
|
329
|
-
const url = new URL(value.trim());
|
|
330
|
-
if (url.protocol !== "https:") return "Repository URL must start with https://";
|
|
331
|
-
if (url.hostname.toLowerCase() !== "github.com")
|
|
332
|
-
return "Repository URL must be a public GitHub HTTPS URL (github.com)";
|
|
333
|
-
const parts = url.pathname.replace(/\/+$/, "").split("/").filter(Boolean);
|
|
334
|
-
if (parts.length < 2) return "Repository URL must be https://github.com/<owner>/<repo>";
|
|
335
|
-
const [owner, repo] = parts;
|
|
336
|
-
if (!owner || !repo) return "Repository URL must be https://github.com/<owner>/<repo>";
|
|
337
|
-
if (repo.toLowerCase() === "settings") return "Repository URL looks invalid";
|
|
338
|
-
if (url.search || url.hash)
|
|
339
|
-
return "Repository URL must not include query params or fragments";
|
|
340
|
-
} catch {
|
|
341
|
-
return "Invalid URL format";
|
|
342
|
-
}
|
|
343
|
-
return true;
|
|
344
|
-
}
|
|
345
|
-
})).trim();
|
|
346
|
-
const gitRef = (await input({
|
|
347
|
-
message: "Enter git commit SHA (40 hex chars):",
|
|
348
|
-
default: "",
|
|
349
|
-
validate: (value) => {
|
|
350
|
-
const trimmed = value.trim();
|
|
351
|
-
if (!trimmed) return "Commit SHA is required";
|
|
352
|
-
if (!/^[0-9a-f]{40}$/i.test(trimmed))
|
|
353
|
-
return "Commit must be a 40-character hexadecimal SHA";
|
|
354
|
-
return true;
|
|
355
|
-
}
|
|
356
|
-
})).trim();
|
|
357
|
-
const buildContextPath = (await input({
|
|
358
|
-
message: "Enter build context path (relative to repo):",
|
|
359
|
-
default: ".",
|
|
360
|
-
validate: (value) => value.trim() ? true : "Build context path cannot be empty"
|
|
361
|
-
})).trim();
|
|
362
|
-
const dockerfilePath = (await input({
|
|
363
|
-
message: "Enter Dockerfile path (relative to build context):",
|
|
364
|
-
default: "Dockerfile",
|
|
365
|
-
validate: (value) => value.trim() ? true : "Dockerfile path cannot be empty"
|
|
366
|
-
})).trim();
|
|
367
|
-
const caddyfileRaw = (await input({
|
|
368
|
-
message: "Enter Caddyfile path (relative to build context, optional):",
|
|
369
|
-
default: "",
|
|
370
|
-
validate: (value) => {
|
|
371
|
-
const trimmed = value.trim();
|
|
372
|
-
if (!trimmed) return true;
|
|
373
|
-
if (trimmed.includes("..")) return "Caddyfile path must not contain '..'";
|
|
374
|
-
return true;
|
|
375
|
-
}
|
|
376
|
-
})).trim();
|
|
377
|
-
const depsRaw = (await input({
|
|
378
|
-
message: "Enter dependency digests (comma-separated sha256:..., optional):",
|
|
379
|
-
default: "",
|
|
380
|
-
validate: (value) => {
|
|
381
|
-
const trimmed = value.trim();
|
|
382
|
-
if (!trimmed) return true;
|
|
383
|
-
const parts = trimmed.split(",").map((p) => p.trim()).filter(Boolean);
|
|
384
|
-
for (const p of parts) {
|
|
385
|
-
if (!/^sha256:[0-9a-f]{64}$/i.test(p)) {
|
|
386
|
-
return `Invalid dependency digest: ${p} (expected sha256:<64 hex>)`;
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
return true;
|
|
390
|
-
}
|
|
391
|
-
})).trim();
|
|
392
|
-
const dependencies = depsRaw === "" ? [] : depsRaw.split(",").map((p) => p.trim()).filter(Boolean);
|
|
393
|
-
return {
|
|
394
|
-
repoUrl,
|
|
395
|
-
gitRef,
|
|
396
|
-
dockerfilePath,
|
|
397
|
-
caddyfilePath: caddyfileRaw === "" ? void 0 : caddyfileRaw,
|
|
398
|
-
buildContextPath,
|
|
399
|
-
dependencies
|
|
400
|
-
};
|
|
401
|
-
}
|
|
402
|
-
async function promptVerifiablePrebuiltImageRef() {
|
|
403
|
-
const ref = await input({
|
|
404
|
-
message: "Enter prebuilt verifiable image ref:",
|
|
405
|
-
default: "docker.io/eigenlayer/eigencloud-containers:",
|
|
406
|
-
validate: (value) => {
|
|
407
|
-
const trimmed = value.trim();
|
|
408
|
-
if (!trimmed) return "Image reference is required";
|
|
409
|
-
if (!/^docker\.io\/eigenlayer\/eigencloud-containers:[^@\s]+$/i.test(trimmed)) {
|
|
410
|
-
return "Image ref must match docker.io/eigenlayer/eigencloud-containers:<tag>";
|
|
411
|
-
}
|
|
412
|
-
return true;
|
|
413
|
-
}
|
|
414
|
-
});
|
|
415
|
-
return ref.trim();
|
|
416
|
-
}
|
|
417
309
|
function extractHostname(registry) {
|
|
418
310
|
let hostname = registry.replace(/^https?:\/\//, "");
|
|
419
311
|
hostname = hostname.split("/")[0];
|
|
@@ -1071,8 +963,8 @@ async function getPrivateKeyInteractive(privateKey) {
|
|
|
1071
963
|
}
|
|
1072
964
|
return privateKey;
|
|
1073
965
|
}
|
|
1074
|
-
const { getPrivateKeyWithSource
|
|
1075
|
-
const result = await
|
|
966
|
+
const { getPrivateKeyWithSource } = await import("@layr-labs/ecloud-sdk");
|
|
967
|
+
const result = await getPrivateKeyWithSource({ privateKey: void 0 });
|
|
1076
968
|
if (result) {
|
|
1077
969
|
return result.key;
|
|
1078
970
|
}
|
|
@@ -1091,50 +983,6 @@ async function getPrivateKeyInteractive(privateKey) {
|
|
|
1091
983
|
});
|
|
1092
984
|
return key.trim();
|
|
1093
985
|
}
|
|
1094
|
-
async function getEnvironmentInteractive(environment) {
|
|
1095
|
-
if (environment) {
|
|
1096
|
-
try {
|
|
1097
|
-
getEnvironmentConfig(environment);
|
|
1098
|
-
if (!isEnvironmentAvailable(environment)) {
|
|
1099
|
-
throw new Error(`Environment ${environment} is not available in this build`);
|
|
1100
|
-
}
|
|
1101
|
-
return environment;
|
|
1102
|
-
} catch {
|
|
1103
|
-
}
|
|
1104
|
-
}
|
|
1105
|
-
const availableEnvs = getAvailableEnvironments();
|
|
1106
|
-
let defaultEnv;
|
|
1107
|
-
const configDefaultEnv = getDefaultEnvironment();
|
|
1108
|
-
if (configDefaultEnv && availableEnvs.includes(configDefaultEnv)) {
|
|
1109
|
-
try {
|
|
1110
|
-
getEnvironmentConfig(configDefaultEnv);
|
|
1111
|
-
defaultEnv = configDefaultEnv;
|
|
1112
|
-
} catch {
|
|
1113
|
-
}
|
|
1114
|
-
}
|
|
1115
|
-
const choices = [];
|
|
1116
|
-
if (availableEnvs.includes("sepolia")) {
|
|
1117
|
-
choices.push({ name: "sepolia - Ethereum Sepolia testnet", value: "sepolia" });
|
|
1118
|
-
}
|
|
1119
|
-
if (availableEnvs.includes("sepolia-dev")) {
|
|
1120
|
-
choices.push({ name: "sepolia-dev - Ethereum Sepolia testnet (dev)", value: "sepolia-dev" });
|
|
1121
|
-
}
|
|
1122
|
-
if (availableEnvs.includes("mainnet-alpha")) {
|
|
1123
|
-
choices.push({
|
|
1124
|
-
name: "mainnet-alpha - Ethereum mainnet (\u26A0\uFE0F uses real funds)",
|
|
1125
|
-
value: "mainnet-alpha"
|
|
1126
|
-
});
|
|
1127
|
-
}
|
|
1128
|
-
if (choices.length === 0) {
|
|
1129
|
-
throw new Error("No environments available in this build");
|
|
1130
|
-
}
|
|
1131
|
-
const env = await select({
|
|
1132
|
-
message: "Select environment:",
|
|
1133
|
-
choices,
|
|
1134
|
-
default: defaultEnv
|
|
1135
|
-
});
|
|
1136
|
-
return env;
|
|
1137
|
-
}
|
|
1138
986
|
var MAX_IMAGE_SIZE = 4 * 1024 * 1024;
|
|
1139
987
|
|
|
1140
988
|
// src/flags.ts
|
|
@@ -1160,209 +1008,9 @@ var commonFlags = {
|
|
|
1160
1008
|
default: false
|
|
1161
1009
|
})
|
|
1162
1010
|
};
|
|
1163
|
-
async function validateCommonFlags(flags, options) {
|
|
1164
|
-
if (!flags["environment"]) {
|
|
1165
|
-
flags["environment"] = getDefaultEnvironment();
|
|
1166
|
-
}
|
|
1167
|
-
flags["environment"] = await getEnvironmentInteractive(flags["environment"]);
|
|
1168
|
-
if (options?.requirePrivateKey !== false) {
|
|
1169
|
-
flags["private-key"] = await getPrivateKeyInteractive(flags["private-key"]);
|
|
1170
|
-
}
|
|
1171
|
-
return flags;
|
|
1172
|
-
}
|
|
1173
|
-
|
|
1174
|
-
// src/client.ts
|
|
1175
|
-
import {
|
|
1176
|
-
createComputeModule,
|
|
1177
|
-
createBillingModule,
|
|
1178
|
-
createBuildModule,
|
|
1179
|
-
getEnvironmentConfig as getEnvironmentConfig2,
|
|
1180
|
-
requirePrivateKey,
|
|
1181
|
-
getPrivateKeyWithSource
|
|
1182
|
-
} from "@layr-labs/ecloud-sdk";
|
|
1183
|
-
async function createBuildClient(flags) {
|
|
1184
|
-
flags = await validateCommonFlags(flags, { requirePrivateKey: false });
|
|
1185
|
-
return createBuildModule({
|
|
1186
|
-
verbose: flags.verbose,
|
|
1187
|
-
privateKey: flags["private-key"],
|
|
1188
|
-
environment: flags.environment,
|
|
1189
|
-
clientId: getClientId(),
|
|
1190
|
-
skipTelemetry: true
|
|
1191
|
-
// CLI already has telemetry, skip SDK telemetry
|
|
1192
|
-
});
|
|
1193
|
-
}
|
|
1194
1011
|
|
|
1195
1012
|
// src/commands/compute/app/upgrade.ts
|
|
1196
1013
|
import chalk from "chalk";
|
|
1197
|
-
|
|
1198
|
-
// src/utils/build.ts
|
|
1199
|
-
function formatSourceLink(repoUrl, gitRef) {
|
|
1200
|
-
const normalizedRepo = repoUrl.replace(/\.git$/, "");
|
|
1201
|
-
try {
|
|
1202
|
-
const url = new URL(normalizedRepo);
|
|
1203
|
-
const host = url.host.toLowerCase();
|
|
1204
|
-
if (host === "github.com") {
|
|
1205
|
-
const path4 = url.pathname.replace(/\/+$/, "");
|
|
1206
|
-
if (path4.split("/").filter(Boolean).length >= 2) {
|
|
1207
|
-
return `https://github.com${path4}/tree/${gitRef}`;
|
|
1208
|
-
}
|
|
1209
|
-
}
|
|
1210
|
-
} catch {
|
|
1211
|
-
}
|
|
1212
|
-
return `${repoUrl}@${gitRef}`;
|
|
1213
|
-
}
|
|
1214
|
-
function extractRepoName(repoUrl) {
|
|
1215
|
-
const normalized = repoUrl.replace(/\.git$/, "");
|
|
1216
|
-
const match = normalized.match(/\/([^/]+?)$/);
|
|
1217
|
-
return match?.[1];
|
|
1218
|
-
}
|
|
1219
|
-
function formatDependencyLines(dependencies) {
|
|
1220
|
-
if (!dependencies || Object.keys(dependencies).length === 0) return [];
|
|
1221
|
-
const lines = [];
|
|
1222
|
-
lines.push("Dependencies (resolved builds):");
|
|
1223
|
-
for (const [digest, dep] of Object.entries(dependencies)) {
|
|
1224
|
-
const name = extractRepoName(dep.repoUrl);
|
|
1225
|
-
const depSource = formatSourceLink(dep.repoUrl, dep.gitRef);
|
|
1226
|
-
lines.push(` - ${digest} \u2713${name ? ` ${name}` : ""}`);
|
|
1227
|
-
lines.push(` ${depSource}`);
|
|
1228
|
-
}
|
|
1229
|
-
return lines;
|
|
1230
|
-
}
|
|
1231
|
-
function formatVerifiableBuildSummary(options) {
|
|
1232
|
-
const lines = [];
|
|
1233
|
-
lines.push("Build completed successfully \u2713");
|
|
1234
|
-
lines.push("");
|
|
1235
|
-
lines.push(`Image: ${options.imageUrl}`);
|
|
1236
|
-
lines.push(`Digest: ${options.imageDigest}`);
|
|
1237
|
-
lines.push(`Source: ${formatSourceLink(options.repoUrl, options.gitRef)}`);
|
|
1238
|
-
const depLines = formatDependencyLines(options.dependencies);
|
|
1239
|
-
if (depLines.length) {
|
|
1240
|
-
lines.push("");
|
|
1241
|
-
lines.push(...depLines);
|
|
1242
|
-
}
|
|
1243
|
-
lines.push("");
|
|
1244
|
-
lines.push("Provenance signature verified \u2713");
|
|
1245
|
-
lines.push(`provenance_signature: ${options.provenanceSignature}`);
|
|
1246
|
-
if (options.buildId) {
|
|
1247
|
-
lines.push("");
|
|
1248
|
-
lines.push(`Build ID: ${options.buildId}`);
|
|
1249
|
-
}
|
|
1250
|
-
return lines;
|
|
1251
|
-
}
|
|
1252
|
-
|
|
1253
|
-
// src/utils/verifiableBuild.ts
|
|
1254
|
-
import { BUILD_STATUS } from "@layr-labs/ecloud-sdk";
|
|
1255
|
-
function assertCommitSha40(commit) {
|
|
1256
|
-
if (!/^[0-9a-f]{40}$/i.test(commit)) {
|
|
1257
|
-
throw new Error("Commit must be a 40-character hexadecimal SHA");
|
|
1258
|
-
}
|
|
1259
|
-
}
|
|
1260
|
-
async function runVerifiableBuildAndVerify(client, request, options = {}) {
|
|
1261
|
-
const { buildId } = await client.submit(request);
|
|
1262
|
-
const completed = await client.waitForBuild(buildId, { onLog: options.onLog });
|
|
1263
|
-
if (completed.status !== BUILD_STATUS.SUCCESS) {
|
|
1264
|
-
throw new Error(`Build did not complete successfully (status: ${completed.status})`);
|
|
1265
|
-
}
|
|
1266
|
-
const [build, verify] = await Promise.all([client.get(buildId), client.verify(buildId)]);
|
|
1267
|
-
if (verify.status !== "verified") {
|
|
1268
|
-
throw new Error(`Provenance verification failed: ${verify.error}`);
|
|
1269
|
-
}
|
|
1270
|
-
return { build, verified: verify };
|
|
1271
|
-
}
|
|
1272
|
-
|
|
1273
|
-
// src/utils/dockerhub.ts
|
|
1274
|
-
var DOCKERHUB_OWNER = "eigenlayer";
|
|
1275
|
-
var DOCKERHUB_REPO = "eigencloud-containers";
|
|
1276
|
-
function parseEigencloudContainersImageRef(imageRef) {
|
|
1277
|
-
const trimmed = imageRef.trim();
|
|
1278
|
-
const match = /^docker\.io\/([^/]+)\/([^:@]+):([^@\s]+)$/i.exec(trimmed);
|
|
1279
|
-
if (!match) {
|
|
1280
|
-
throw new Error("Image ref must match docker.io/eigenlayer/eigencloud-containers:<tag>");
|
|
1281
|
-
}
|
|
1282
|
-
const owner = match[1].toLowerCase();
|
|
1283
|
-
const repo = match[2].toLowerCase();
|
|
1284
|
-
const tag = match[3];
|
|
1285
|
-
if (owner !== DOCKERHUB_OWNER || repo !== DOCKERHUB_REPO) {
|
|
1286
|
-
throw new Error(`Image ref must be from docker.io/${DOCKERHUB_OWNER}/${DOCKERHUB_REPO}:<tag>`);
|
|
1287
|
-
}
|
|
1288
|
-
if (!tag.trim()) {
|
|
1289
|
-
throw new Error("Image tag cannot be empty");
|
|
1290
|
-
}
|
|
1291
|
-
return { owner, repo, tag };
|
|
1292
|
-
}
|
|
1293
|
-
function assertEigencloudContainersImageRef(imageRef) {
|
|
1294
|
-
parseEigencloudContainersImageRef(imageRef);
|
|
1295
|
-
}
|
|
1296
|
-
async function getDockerHubToken(owner, repo) {
|
|
1297
|
-
const url = new URL("https://auth.docker.io/token");
|
|
1298
|
-
url.searchParams.set("service", "registry.docker.io");
|
|
1299
|
-
url.searchParams.set("scope", `repository:${owner}/${repo}:pull`);
|
|
1300
|
-
const res = await fetch(url.toString(), { method: "GET" });
|
|
1301
|
-
if (!res.ok) {
|
|
1302
|
-
const body = await safeReadText(res);
|
|
1303
|
-
throw new Error(`Failed to fetch Docker Hub token (${res.status}): ${body || res.statusText}`);
|
|
1304
|
-
}
|
|
1305
|
-
const data = await res.json();
|
|
1306
|
-
if (!data.token) {
|
|
1307
|
-
throw new Error("Docker Hub token response missing 'token'");
|
|
1308
|
-
}
|
|
1309
|
-
return data.token;
|
|
1310
|
-
}
|
|
1311
|
-
async function safeReadText(res) {
|
|
1312
|
-
try {
|
|
1313
|
-
return (await res.text()).trim();
|
|
1314
|
-
} catch {
|
|
1315
|
-
return "";
|
|
1316
|
-
}
|
|
1317
|
-
}
|
|
1318
|
-
async function resolveDockerHubImageDigest(imageRef) {
|
|
1319
|
-
const { owner, repo, tag } = parseEigencloudContainersImageRef(imageRef);
|
|
1320
|
-
const token = await getDockerHubToken(owner, repo);
|
|
1321
|
-
const manifestUrl = `https://registry-1.docker.io/v2/${owner}/${repo}/manifests/${encodeURIComponent(tag)}`;
|
|
1322
|
-
const headers = {
|
|
1323
|
-
Authorization: `Bearer ${token}`,
|
|
1324
|
-
Accept: "application/vnd.docker.distribution.manifest.v2+json"
|
|
1325
|
-
};
|
|
1326
|
-
let res = await fetch(manifestUrl, { method: "HEAD", headers });
|
|
1327
|
-
if (!res.ok) {
|
|
1328
|
-
res = await fetch(manifestUrl, { method: "GET", headers });
|
|
1329
|
-
}
|
|
1330
|
-
if (!res.ok) {
|
|
1331
|
-
const body = await safeReadText(res);
|
|
1332
|
-
throw new Error(
|
|
1333
|
-
`Failed to resolve digest for ${imageRef} (${res.status}) at ${manifestUrl}: ${body || res.statusText}`
|
|
1334
|
-
);
|
|
1335
|
-
}
|
|
1336
|
-
const digest = res.headers.get("docker-content-digest") || res.headers.get("Docker-Content-Digest");
|
|
1337
|
-
if (!digest) {
|
|
1338
|
-
throw new Error(
|
|
1339
|
-
`Docker registry response missing Docker-Content-Digest header for ${imageRef}`
|
|
1340
|
-
);
|
|
1341
|
-
}
|
|
1342
|
-
if (!/^sha256:[0-9a-f]{64}$/i.test(digest)) {
|
|
1343
|
-
throw new Error(`Unexpected digest format from Docker registry: ${digest}`);
|
|
1344
|
-
}
|
|
1345
|
-
return digest;
|
|
1346
|
-
}
|
|
1347
|
-
|
|
1348
|
-
// src/utils/tls.ts
|
|
1349
|
-
import fs4 from "fs";
|
|
1350
|
-
function isTlsEnabledFromDomain(domain) {
|
|
1351
|
-
const d = (domain ?? "").trim();
|
|
1352
|
-
if (!d) return false;
|
|
1353
|
-
if (d.toLowerCase() === "localhost") return false;
|
|
1354
|
-
return true;
|
|
1355
|
-
}
|
|
1356
|
-
function isTlsEnabledFromEnvFile(envFilePath) {
|
|
1357
|
-
if (!envFilePath) return false;
|
|
1358
|
-
if (!fs4.existsSync(envFilePath)) return false;
|
|
1359
|
-
const envContent = fs4.readFileSync(envFilePath, "utf-8");
|
|
1360
|
-
const match = envContent.match(/^DOMAIN=(.+)$/m);
|
|
1361
|
-
if (!match?.[1]) return false;
|
|
1362
|
-
return isTlsEnabledFromDomain(match[1]);
|
|
1363
|
-
}
|
|
1364
|
-
|
|
1365
|
-
// src/commands/compute/app/upgrade.ts
|
|
1366
1014
|
var AppUpgrade = class _AppUpgrade extends Command {
|
|
1367
1015
|
static description = "Upgrade existing deployment";
|
|
1368
1016
|
static args = {
|
|
@@ -1405,33 +1053,6 @@ var AppUpgrade = class _AppUpgrade extends Command {
|
|
|
1405
1053
|
description: "Resource usage monitoring: enable or disable",
|
|
1406
1054
|
options: ["enable", "disable"],
|
|
1407
1055
|
env: "ECLOUD_RESOURCE_USAGE_MONITORING"
|
|
1408
|
-
}),
|
|
1409
|
-
// Verifiable build flags
|
|
1410
|
-
verifiable: Flags2.boolean({
|
|
1411
|
-
description: "Enable verifiable build mode (either build from git source via --repo/--commit, or upgrade to a prebuilt verifiable image via --image-ref)",
|
|
1412
|
-
default: false
|
|
1413
|
-
}),
|
|
1414
|
-
repo: Flags2.string({
|
|
1415
|
-
description: "Git repository URL (required with --verifiable git source mode)",
|
|
1416
|
-
env: "ECLOUD_BUILD_REPO"
|
|
1417
|
-
}),
|
|
1418
|
-
commit: Flags2.string({
|
|
1419
|
-
description: "Git commit SHA (required with --verifiable git source mode)",
|
|
1420
|
-
env: "ECLOUD_BUILD_COMMIT"
|
|
1421
|
-
}),
|
|
1422
|
-
"build-dockerfile": Flags2.string({
|
|
1423
|
-
description: "Dockerfile path for verifiable build (git source mode)",
|
|
1424
|
-
default: "Dockerfile",
|
|
1425
|
-
env: "ECLOUD_BUILD_DOCKERFILE"
|
|
1426
|
-
}),
|
|
1427
|
-
"build-context": Flags2.string({
|
|
1428
|
-
description: "Build context path for verifiable build (git source mode)",
|
|
1429
|
-
default: ".",
|
|
1430
|
-
env: "ECLOUD_BUILD_CONTEXT"
|
|
1431
|
-
}),
|
|
1432
|
-
"build-dependencies": Flags2.string({
|
|
1433
|
-
description: "Dependency digests for verifiable build (git source mode) (sha256:...)",
|
|
1434
|
-
multiple: true
|
|
1435
1056
|
})
|
|
1436
1057
|
};
|
|
1437
1058
|
async run() {
|
|
@@ -1444,7 +1065,7 @@ var AppUpgrade = class _AppUpgrade extends Command {
|
|
|
1444
1065
|
debug: (msg) => flags.verbose && this.log(msg)
|
|
1445
1066
|
};
|
|
1446
1067
|
const environment = flags.environment || "sepolia";
|
|
1447
|
-
const environmentConfig =
|
|
1068
|
+
const environmentConfig = getEnvironmentConfig2(environment);
|
|
1448
1069
|
const rpcUrl = flags["rpc-url"] || environmentConfig.defaultRPCURL;
|
|
1449
1070
|
const privateKey = await getPrivateKeyInteractive(flags["private-key"]);
|
|
1450
1071
|
const appID = await getOrPromptAppID({
|
|
@@ -1454,125 +1075,10 @@ var AppUpgrade = class _AppUpgrade extends Command {
|
|
|
1454
1075
|
rpcUrl,
|
|
1455
1076
|
action: "upgrade"
|
|
1456
1077
|
});
|
|
1457
|
-
|
|
1458
|
-
const getBuildClient = async () => {
|
|
1459
|
-
if (buildClient) return buildClient;
|
|
1460
|
-
buildClient = await createBuildClient({
|
|
1461
|
-
...flags,
|
|
1462
|
-
"private-key": privateKey
|
|
1463
|
-
});
|
|
1464
|
-
return buildClient;
|
|
1465
|
-
};
|
|
1466
|
-
let verifiableImageUrl;
|
|
1467
|
-
let verifiableImageDigest;
|
|
1468
|
-
let verifiableMode = "none";
|
|
1469
|
-
let envFilePath;
|
|
1470
|
-
if (flags.verifiable) {
|
|
1471
|
-
if (flags.repo || flags.commit) {
|
|
1472
|
-
verifiableMode = "git";
|
|
1473
|
-
if (!flags.repo)
|
|
1474
|
-
this.error("--repo is required when using --verifiable (git source mode)");
|
|
1475
|
-
if (!flags.commit)
|
|
1476
|
-
this.error("--commit is required when using --verifiable (git source mode)");
|
|
1477
|
-
try {
|
|
1478
|
-
assertCommitSha40(flags.commit);
|
|
1479
|
-
} catch (e) {
|
|
1480
|
-
this.error(e?.message || String(e));
|
|
1481
|
-
}
|
|
1482
|
-
} else if (flags["image-ref"]) {
|
|
1483
|
-
verifiableMode = "prebuilt";
|
|
1484
|
-
try {
|
|
1485
|
-
assertEigencloudContainersImageRef(flags["image-ref"]);
|
|
1486
|
-
} catch (e) {
|
|
1487
|
-
this.error(e?.message || String(e));
|
|
1488
|
-
}
|
|
1489
|
-
} else {
|
|
1490
|
-
this.error(
|
|
1491
|
-
"When using --verifiable, you must provide either --repo/--commit or --image-ref"
|
|
1492
|
-
);
|
|
1493
|
-
}
|
|
1494
|
-
} else {
|
|
1495
|
-
if (!flags.dockerfile) {
|
|
1496
|
-
const useVerifiable = await promptUseVerifiableBuild();
|
|
1497
|
-
if (useVerifiable) {
|
|
1498
|
-
const sourceType = await promptVerifiableSourceType();
|
|
1499
|
-
verifiableMode = sourceType;
|
|
1500
|
-
}
|
|
1501
|
-
}
|
|
1502
|
-
}
|
|
1503
|
-
if (verifiableMode === "git") {
|
|
1504
|
-
const inputs = flags.verifiable ? {
|
|
1505
|
-
repoUrl: flags.repo,
|
|
1506
|
-
gitRef: flags.commit,
|
|
1507
|
-
dockerfilePath: flags["build-dockerfile"],
|
|
1508
|
-
caddyfilePath: void 0,
|
|
1509
|
-
buildContextPath: flags["build-context"],
|
|
1510
|
-
dependencies: flags["build-dependencies"]
|
|
1511
|
-
} : await promptVerifiableGitSourceInputs();
|
|
1512
|
-
envFilePath = await getEnvFileInteractive(flags["env-file"]);
|
|
1513
|
-
const includeTlsCaddyfile = isTlsEnabledFromEnvFile(envFilePath);
|
|
1514
|
-
if (includeTlsCaddyfile && !inputs.caddyfilePath) {
|
|
1515
|
-
inputs.caddyfilePath = "Caddyfile";
|
|
1516
|
-
}
|
|
1517
|
-
this.log(chalk.blue("Building from source with verifiable build..."));
|
|
1518
|
-
this.log("");
|
|
1519
|
-
const buildClient2 = await getBuildClient();
|
|
1520
|
-
const { build, verified } = await runVerifiableBuildAndVerify(buildClient2, inputs, {
|
|
1521
|
-
onLog: (chunk) => process.stdout.write(chunk)
|
|
1522
|
-
});
|
|
1523
|
-
if (!build.imageUrl || !build.imageDigest) {
|
|
1524
|
-
this.error(
|
|
1525
|
-
"Build completed but did not return imageUrl/imageDigest; cannot upgrade verifiable build"
|
|
1526
|
-
);
|
|
1527
|
-
}
|
|
1528
|
-
verifiableImageUrl = build.imageUrl;
|
|
1529
|
-
verifiableImageDigest = build.imageDigest;
|
|
1530
|
-
for (const line of formatVerifiableBuildSummary({
|
|
1531
|
-
buildId: build.buildId,
|
|
1532
|
-
imageUrl: build.imageUrl,
|
|
1533
|
-
imageDigest: build.imageDigest,
|
|
1534
|
-
repoUrl: build.repoUrl,
|
|
1535
|
-
gitRef: build.gitRef,
|
|
1536
|
-
dependencies: build.dependencies,
|
|
1537
|
-
provenanceSignature: verified.provenanceSignature
|
|
1538
|
-
})) {
|
|
1539
|
-
this.log(line);
|
|
1540
|
-
}
|
|
1541
|
-
}
|
|
1542
|
-
if (verifiableMode === "prebuilt") {
|
|
1543
|
-
const imageRef2 = flags.verifiable ? flags["image-ref"] : await promptVerifiablePrebuiltImageRef();
|
|
1544
|
-
try {
|
|
1545
|
-
assertEigencloudContainersImageRef(imageRef2);
|
|
1546
|
-
} catch (e) {
|
|
1547
|
-
this.error(e?.message || String(e));
|
|
1548
|
-
}
|
|
1549
|
-
this.log(chalk.blue("Resolving and verifying prebuilt verifiable image..."));
|
|
1550
|
-
this.log("");
|
|
1551
|
-
const digest = await resolveDockerHubImageDigest(imageRef2);
|
|
1552
|
-
const buildClient2 = await getBuildClient();
|
|
1553
|
-
const verify = await buildClient2.verify(digest);
|
|
1554
|
-
if (verify.status !== "verified") {
|
|
1555
|
-
this.error(`Provenance verification failed: ${verify.error}`);
|
|
1556
|
-
}
|
|
1557
|
-
verifiableImageUrl = imageRef2;
|
|
1558
|
-
verifiableImageDigest = digest;
|
|
1559
|
-
for (const line of formatVerifiableBuildSummary({
|
|
1560
|
-
buildId: verify.buildId,
|
|
1561
|
-
imageUrl: imageRef2,
|
|
1562
|
-
imageDigest: digest,
|
|
1563
|
-
repoUrl: verify.repoUrl,
|
|
1564
|
-
gitRef: verify.gitRef,
|
|
1565
|
-
dependencies: void 0,
|
|
1566
|
-
provenanceSignature: verify.provenanceSignature
|
|
1567
|
-
})) {
|
|
1568
|
-
this.log(line);
|
|
1569
|
-
}
|
|
1570
|
-
}
|
|
1571
|
-
const isVerifiable = verifiableMode !== "none";
|
|
1572
|
-
const dockerfilePath = isVerifiable ? "" : await getDockerfileInteractive(flags.dockerfile);
|
|
1078
|
+
const dockerfilePath = await getDockerfileInteractive(flags.dockerfile);
|
|
1573
1079
|
const buildFromDockerfile = dockerfilePath !== "";
|
|
1574
|
-
const imageRef =
|
|
1575
|
-
envFilePath =
|
|
1080
|
+
const imageRef = await getImageReferenceInteractive(flags["image-ref"], buildFromDockerfile);
|
|
1081
|
+
const envFilePath = await getEnvFileInteractive(flags["env-file"]);
|
|
1576
1082
|
let currentInstanceType = "";
|
|
1577
1083
|
try {
|
|
1578
1084
|
const userApiClient = new UserApiClient3(
|
|
@@ -1604,22 +1110,7 @@ var AppUpgrade = class _AppUpgrade extends Command {
|
|
|
1604
1110
|
flags["resource-usage-monitoring"]
|
|
1605
1111
|
);
|
|
1606
1112
|
const logVisibility = logSettings.publicLogs ? "public" : logSettings.logRedirect ? "private" : "off";
|
|
1607
|
-
const { prepared, gasEstimate } =
|
|
1608
|
-
{
|
|
1609
|
-
appId: appID,
|
|
1610
|
-
privateKey,
|
|
1611
|
-
rpcUrl,
|
|
1612
|
-
environment,
|
|
1613
|
-
imageRef,
|
|
1614
|
-
imageDigest: verifiableImageDigest,
|
|
1615
|
-
envFilePath,
|
|
1616
|
-
instanceType,
|
|
1617
|
-
logVisibility,
|
|
1618
|
-
resourceUsageMonitoring,
|
|
1619
|
-
skipTelemetry: true
|
|
1620
|
-
},
|
|
1621
|
-
logger
|
|
1622
|
-
) : await prepareUpgrade(
|
|
1113
|
+
const { prepared, gasEstimate } = await prepareUpgrade(
|
|
1623
1114
|
{
|
|
1624
1115
|
appId: appID,
|
|
1625
1116
|
privateKey,
|