Skip to content

Commit ff16365

Browse files
authored
Add in requireAuth to AppHosting CLI commands to reliably fetch and use ADC when invoking commands through the CLI (#8435)
1 parent a98f7bf commit ff16365

8 files changed

+16
-0
lines changed

src/commands/apphosting-backends-create.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Command } from "../command";
22
import { Options } from "../options";
33
import { needProjectId } from "../projectUtils";
4+
import { requireAuth } from "../requireAuth";
45
import requireInteractive from "../requireInteractive";
56
import { doSetup } from "../apphosting/backend";
67
import { ensureApiEnabled } from "../gcp/apphosting";
@@ -18,6 +19,7 @@ export const command = new Command("apphosting:backends:create")
1819
"specify the service account used to run the server",
1920
"",
2021
)
22+
.before(requireAuth)
2123
.before(ensureApiEnabled)
2224
.before(requireInteractive)
2325
.before(requireTosAcceptance(APPHOSTING_TOS_ID))

src/commands/apphosting-backends-delete.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Command } from "../command";
22
import { Options } from "../options";
33
import { needProjectId } from "../projectUtils";
4+
import { requireAuth } from "../requireAuth";
45
import { FirebaseError, getError } from "../error";
56
import { promptOnce } from "../prompt";
67
import * as utils from "../utils";
@@ -12,6 +13,7 @@ import * as ora from "ora";
1213
export const command = new Command("apphosting:backends:delete <backend>")
1314
.description("delete a Firebase App Hosting backend")
1415
.withForce()
16+
.before(requireAuth)
1517
.before(apphosting.ensureApiEnabled)
1618
.action(async (backendId: string, options: Options) => {
1719
const projectId = needProjectId(options);

src/commands/apphosting-backends-get.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import { Command } from "../command";
22
import { Options } from "../options";
33
import { needProjectId } from "../projectUtils";
4+
import { requireAuth } from "../requireAuth";
45
import { FirebaseError, getError } from "../error";
56
import { logWarning } from "../utils";
67
import * as apphosting from "../gcp/apphosting";
78
import { printBackendsTable } from "./apphosting-backends-list";
89

910
export const command = new Command("apphosting:backends:get <backend>")
1011
.description("print info about a Firebase App Hosting backend")
12+
.before(requireAuth)
1113
.before(apphosting.ensureApiEnabled)
1214
.action(async (backend: string, options: Options) => {
1315
const projectId = needProjectId(options);

src/commands/apphosting-backends-list.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { datetimeString } from "../utils";
33
import { FirebaseError } from "../error";
44
import { logger } from "../logger";
55
import { needProjectId } from "../projectUtils";
6+
import { requireAuth } from "../requireAuth";
67
import { Options } from "../options";
78
import * as apphosting from "../gcp/apphosting";
89
import * as Table from "cli-table3";
@@ -11,6 +12,7 @@ const TABLE_HEAD = ["Backend", "Repository", "URL", "Primary Region", "Updated D
1112

1213
export const command = new Command("apphosting:backends:list")
1314
.description("list Firebase App Hosting backends")
15+
.before(requireAuth)
1416
.before(apphosting.ensureApiEnabled)
1517
.action(async (options: Options) => {
1618
const projectId = needProjectId(options);

src/commands/apphosting-builds-create.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ import { logger } from "../logger";
33
import { Command } from "../command";
44
import { Options } from "../options";
55
import { needProjectId } from "../projectUtils";
6+
import { requireAuth } from "../requireAuth";
67
import { logWarning } from "../utils";
78

89
export const command = new Command("apphosting:builds:create <backendId>")
910
.description("create a build for an App Hosting backend")
1011
.option("-l, --location <location>", "specify the region of the backend")
1112
.option("-i, --id <buildId>", "id of the build (defaults to autogenerating a random id)", "")
1213
.option("-b, --branch <branch>", "repository branch to deploy (defaults to 'main')", "main")
14+
.before(requireAuth)
1315
.before(apphosting.ensureApiEnabled)
1416
.action(async (backendId: string, options: Options) => {
1517
const projectId = needProjectId(options);

src/commands/apphosting-builds-get.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ import { logger } from "../logger";
33
import { Command } from "../command";
44
import { Options } from "../options";
55
import { needProjectId } from "../projectUtils";
6+
import { requireAuth } from "../requireAuth";
67
import { logWarning } from "../utils";
78

89
export const command = new Command("apphosting:builds:get <backendId> <buildId>")
910
.description("get a build for an App Hosting backend")
1011
.option("-l, --location <location>", "specify the region of the backend")
12+
.before(requireAuth)
1113
.before(apphosting.ensureApiEnabled)
1214
.action(async (backendId: string, buildId: string, options: Options) => {
1315
if (options.location !== undefined) {

src/commands/apphosting-rollouts-create.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as apphosting from "../gcp/apphosting";
22
import { Command } from "../command";
33
import { Options } from "../options";
44
import { needProjectId } from "../projectUtils";
5+
import { requireAuth } from "../requireAuth";
56
import { FirebaseError } from "../error";
67
import { createRollout } from "../apphosting/rollout";
78

@@ -13,6 +14,7 @@ export const command = new Command("apphosting:rollouts:create <backendId>")
1314
)
1415
.option("-g, --git-commit <gitCommit>", "git commit to deploy (mutually exclusive with -b)")
1516
.withForce("Skip confirmation before creating rollout")
17+
.before(requireAuth)
1618
.before(apphosting.ensureApiEnabled)
1719
.action(async (backendId: string, options: Options) => {
1820
const projectId = needProjectId(options);

src/commands/apphosting-rollouts-list.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { logger } from "../logger";
33
import { Command } from "../command";
44
import { Options } from "../options";
55
import { needProjectId } from "../projectUtils";
6+
import { requireAuth } from "../requireAuth";
67
import { logWarning } from "../utils";
78

89
export const command = new Command("apphosting:rollouts:list <backendId>")
@@ -11,6 +12,7 @@ export const command = new Command("apphosting:rollouts:list <backendId>")
1112
"-l, --location <location>",
1213
"region of the rollouts (defaults to listing rollouts from all regions)",
1314
)
15+
.before(requireAuth)
1416
.before(apphosting.ensureApiEnabled)
1517
.action(async (backendId: string, options: Options) => {
1618
if (options.location !== undefined) {

0 commit comments

Comments
 (0)