-
Notifications
You must be signed in to change notification settings - Fork 959
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Clean up App Hosting commands used for testing purposes" and …
…gate them behind `internaltesting` flag (#7005) * Revert "Clean up apphosting commands used for testing purposes (#6978)" This reverts commit 8a6e608. * move apphosting builds and rollouts commands behind internaltesting experiment --------- Co-authored-by: Mathusan Selvarajah <mathusan@google.com>
- Loading branch information
Showing
5 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import * as apphosting from "../gcp/apphosting"; | ||
import { logger } from "../logger"; | ||
import { Command } from "../command"; | ||
import { Options } from "../options"; | ||
import { needProjectId } from "../projectUtils"; | ||
|
||
export const command = new Command("apphosting:builds:create <backendId>") | ||
.description("create a build for an App Hosting backend") | ||
.option("-l, --location <location>", "specify the region of the backend", "us-central1") | ||
.option("-i, --id <buildId>", "id of the build (defaults to autogenerating a random id)", "") | ||
.option("-b, --branch <branch>", "repository branch to deploy (defaults to 'main')", "main") | ||
.before(apphosting.ensureApiEnabled) | ||
.action(async (backendId: string, options: Options) => { | ||
const projectId = needProjectId(options); | ||
const location = options.location as string; | ||
const buildId = | ||
(options.buildId as string) || | ||
(await apphosting.getNextRolloutId(projectId, location, backendId)); | ||
const branch = (options.branch as string | undefined) ?? "main"; | ||
|
||
const op = await apphosting.createBuild(projectId, location, backendId, buildId, { | ||
source: { | ||
codebase: { | ||
branch, | ||
}, | ||
}, | ||
}); | ||
|
||
logger.info(`Started a build for backend ${backendId} on branch ${branch}.`); | ||
logger.info("Check status by running:"); | ||
logger.info(`\tfirebase apphosting:builds:get ${backendId} ${buildId} --location ${location}`); | ||
return op; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import * as apphosting from "../gcp/apphosting"; | ||
import { logger } from "../logger"; | ||
import { Command } from "../command"; | ||
import { Options } from "../options"; | ||
import { needProjectId } from "../projectUtils"; | ||
|
||
export const command = new Command("apphosting:builds:get <backendId> <buildId>") | ||
.description("get a build for an App Hosting backend") | ||
.option("-l, --location <location>", "specify the region of the backend", "us-central1") | ||
.before(apphosting.ensureApiEnabled) | ||
.action(async (backendId: string, buildId: string, options: Options) => { | ||
const projectId = needProjectId(options); | ||
const location = options.location as string; | ||
const build = await apphosting.getBuild(projectId, location, backendId, buildId); | ||
logger.info(JSON.stringify(build, null, 2)); | ||
return build; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import * as apphosting from "../gcp/apphosting"; | ||
import { logger } from "../logger"; | ||
import { Command } from "../command"; | ||
import { Options } from "../options"; | ||
import { needProjectId } from "../projectUtils"; | ||
|
||
export const command = new Command("apphosting:rollouts:create <backendId> <buildId>") | ||
.description("create a rollout using a build for an App Hosting backend") | ||
.option("-l, --location <location>", "specify the region of the backend", "us-central1") | ||
.option("-i, --id <rolloutId>", "id of the rollout (defaults to autogenerating a random id)", "") | ||
.before(apphosting.ensureApiEnabled) | ||
.action(async (backendId: string, buildId: string, options: Options) => { | ||
const projectId = needProjectId(options); | ||
const location = options.location as string; | ||
// TODO: Should we just reuse the buildId? | ||
const rolloutId = | ||
(options.buildId as string) || | ||
(await apphosting.getNextRolloutId(projectId, location, backendId)); | ||
const build = `projects/${projectId}/backends/${backendId}/builds/${buildId}`; | ||
const op = await apphosting.createRollout(projectId, location, backendId, rolloutId, { | ||
build, | ||
}); | ||
logger.info(`Started a rollout for backend ${backendId} with build ${buildId}.`); | ||
logger.info("Check status by running:"); | ||
logger.info(`\tfirebase apphosting:rollouts:list --location ${location}`); | ||
return op; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import * as apphosting from "../gcp/apphosting"; | ||
import { logger } from "../logger"; | ||
import { Command } from "../command"; | ||
import { Options } from "../options"; | ||
import { needProjectId } from "../projectUtils"; | ||
|
||
export const command = new Command("apphosting:rollouts:list <backendId>") | ||
.description("list rollouts of an App Hosting backend") | ||
.option( | ||
"-l, --location <location>", | ||
"region of the rollouts (defaults to listing rollouts from all regions)", | ||
"-", | ||
) | ||
.before(apphosting.ensureApiEnabled) | ||
.action(async (backendId: string, options: Options) => { | ||
const projectId = needProjectId(options); | ||
const location = options.location as string; | ||
const rollouts = await apphosting.listRollouts(projectId, location, backendId); | ||
if (rollouts.unreachable) { | ||
logger.error( | ||
`WARNING: the following locations were unreachable: ${rollouts.unreachable.join(", ")}`, | ||
); | ||
} | ||
logger.info(JSON.stringify(rollouts.rollouts, null, 2)); | ||
return rollouts; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters