@caelo-cms/provisioning 0.10.71 → 0.10.72

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.
@@ -82,6 +82,13 @@ export interface StatePulumiOps {
82
82
  export interface MigrateDeps {
83
83
  readonly pulumi: StatePulumiOps;
84
84
  readonly report: UpgradeReporter;
85
+ /**
86
+ * #1078 — whether this machine's Application Default Credentials (which
87
+ * every Pulumi call here uses) work now. Checked before the first Pulumi
88
+ * call, so missing or expired ones stop the run with the login command
89
+ * instead of a page of per-resource provider errors.
90
+ */
91
+ checkAdc(): Promise<{ readonly ok: true } | { readonly ok: false; readonly error: string }>;
85
92
  /** The install's backend resolved for Pulumi. */
86
93
  resolve(record: StateBackendRecord): ResolvedBackend;
87
94
  /** Ask the operator to accept the ops backend's cost; false = cancel. */
@@ -241,6 +248,10 @@ export async function migrateState(
241
248
  };
242
249
  }
243
250
  }
251
+ const adc = await deps.checkAdc();
252
+ if (!adc.ok) {
253
+ return { ok: false, error: `${adc.error} Nothing was changed.` };
254
+ }
244
255
  const pre = report.step("Preflight: Pulumi CLI, source stack, pending operations, drift");
245
256
  let from: ResolvedBackend;
246
257
  let mode: "stack-migrate" | "export-import";
@@ -51,6 +51,7 @@ import type { DnsRecord } from "../dns/types.js";
51
51
  import {
52
52
  activeAccount,
53
53
  type BillingAccount,
54
+ checkGcloudAuth,
54
55
  createProject,
55
56
  createServiceAccount,
56
57
  enableApis,
@@ -639,19 +640,20 @@ async function resolveImageDigests(): Promise<ImageDigests> {
639
640
  // Per-step helpers
640
641
  // =========================================================================
641
642
 
643
+ /**
644
+ * An active gcloud account that can mint a token now. `activeAccount` alone
645
+ * passes with an expired login (`auth list` reads local config), and the
646
+ * first real gcloud call of the run then failed with a reauth error deep in
647
+ * a later step (#630, #1078).
648
+ */
642
649
  async function stepActiveGcloud(): Promise<void> {
643
- const stepName = "gcloud-active";
644
- const account = await activeAccount();
645
- if (!account) {
646
- log.error(red("No active gcloud account."));
647
- log.warn(
648
- `Run ${bold("gcloud auth login")} in another terminal, then re-run ${bold(selfCommand())}.`,
649
- );
650
- cancel("Aborted — no gcloud auth.");
650
+ const auth = await checkGcloudAuth();
651
+ if (!auth.ok) {
652
+ log.error(red(auth.error));
653
+ cancel("Aborted — nothing was changed.");
651
654
  process.exit(2);
652
655
  }
653
- log.success(`gcloud auth: ${bold(account)}`);
654
- void stepName;
656
+ log.success(`gcloud auth: ${bold(auth.account)}`);
655
657
  }
656
658
 
657
659
  async function stepProjectId(opts: GcpWizardOpts): Promise<string> {
@@ -1385,8 +1387,18 @@ async function stepKeylessProvisioner(
1385
1387
  const sAdc = spinner();
1386
1388
  sAdc.start("Checking that your Application Default Credentials can impersonate it...");
1387
1389
  let adc = await check();
1388
- if (!adc.ok && adc.reason === "no-adc" && !opts.nonInteractive) {
1389
- sAdc.stop(yellow("No Application Default Credentials yet"));
1390
+ if (
1391
+ !adc.ok &&
1392
+ (adc.reason === "no-adc" || adc.reason === "expired-adc") &&
1393
+ !opts.nonInteractive
1394
+ ) {
1395
+ sAdc.stop(
1396
+ yellow(
1397
+ adc.reason === "expired-adc"
1398
+ ? "Your Application Default Credentials have expired"
1399
+ : "No Application Default Credentials yet",
1400
+ ),
1401
+ );
1390
1402
  const login = await confirm({
1391
1403
  message: `Run ${bold("gcloud auth application-default login")} now (opens your browser; sign in as ${account})?`,
1392
1404
  initialValue: true,
@@ -1403,7 +1415,7 @@ async function stepKeylessProvisioner(
1403
1415
  }
1404
1416
  if (!adc.ok) {
1405
1417
  sAdc.stop(red("Infrastructure credentials not ready"));
1406
- log.error(adc.error);
1418
+ log.error(`${adc.error}\nPulumi was not started.`);
1407
1419
  cancel("Aborted.");
1408
1420
  process.exit(1);
1409
1421
  }