-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Upgrades functions::list command to utilize Cloud Run API #9425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 33 commits
12b9257
0a30722
df189ee
66cf473
3af536c
f6ef8c0
d9fd843
84725cf
6a45457
9cedf12
481d02f
0362303
d4ed0f9
2de426f
7cb75d8
4d06024
3712d0c
d1986ac
8f1c06d
1cef2a6
0de7514
66e5d6f
c1f2e7b
bd8ea09
86ef3f6
9287590
896d3a1
a38b669
c253ae9
0779bff
a36e9d9
5acc3cf
812fda9
4ebc27b
369c402
963ff16
1ba7368
536c3d8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| - [Added] support for new google-genai plugin during `init genkit` (#8957) | ||
| - Updated to v2.17.1 of the Data Connect emulator, which fixes an admin SDK bug for operation without argument #9449 (#9454). | ||
| - Upgraded functions::list command to use cloud run api for v2 functions (#9425) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,38 +1,63 @@ | ||
| import { Command } from "../command"; | ||
| import * as args from "../deploy/functions/args"; | ||
| import { needProjectId } from "../projectUtils"; | ||
| import { Options } from "../options"; | ||
| import { requirePermissions } from "../requirePermissions"; | ||
| import * as backend from "../deploy/functions/backend"; | ||
| import { logger } from "../logger"; | ||
| import * as Table from "cli-table3"; | ||
| import { Options } from "../options"; | ||
| import { FunctionsPlatform } from "../deploy/functions/backend"; | ||
|
|
||
| type PLATFORM_DISPLAY_NAME = "v1" | "v2" | "run"; | ||
| const PLATFORM_TO_DISPLAY_NAME: Record<FunctionsPlatform, PLATFORM_DISPLAY_NAME> = { | ||
| gcfv1: "v1", | ||
| gcfv2: "v2", | ||
| run: "run", | ||
| }; | ||
|
|
||
| export const command = new Command("functions:list") | ||
| .description("list all deployed functions in your Firebase project") | ||
| .before(requirePermissions, ["cloudfunctions.functions.list"]) | ||
| .before(requirePermissions, ["cloudfunctions.functions.list", "run.services.list"]) | ||
| .action(async (options: Options) => { | ||
| const projectId = needProjectId(options); | ||
| const context = { | ||
| projectId: needProjectId(options), | ||
| projectId, | ||
| } as args.Context; | ||
| const existing = await backend.existingBackend(context); | ||
| const endpointsList = backend.allEndpoints(existing).sort(backend.compareFunctions); | ||
|
|
||
| let endpoints: backend.Endpoint[] = []; | ||
| try { | ||
| const existing = await backend.existingBackend(context); | ||
| endpoints = backend.allEndpoints(existing); | ||
| } catch (err: any) { | ||
| logger.debug(`Failed to list functions:`, err); | ||
| logger.warn(err.message); | ||
|
Check warning on line 33 in src/commands/functions-list.ts
|
||
brittanycho marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
brittanycho marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| endpoints.sort(backend.compareFunctions); | ||
|
|
||
| if (endpoints.length === 0) { | ||
| logger.info(`No functions found in project ${projectId}.`); | ||
| return []; | ||
| } | ||
|
|
||
| const table = new Table({ | ||
| head: ["Function", "Version", "Trigger", "Location", "Memory", "Runtime"], | ||
| style: { head: ["yellow"] }, | ||
| }); | ||
| for (const endpoint of endpointsList) { | ||
| }) as any; | ||
|
|
||
| for (const endpoint of endpoints) { | ||
| const trigger = backend.endpointTriggerType(endpoint); | ||
| const availableMemoryMb = endpoint.availableMemoryMb || "---"; | ||
| const entry = [ | ||
| endpoint.id, | ||
| endpoint.platform === "gcfv2" ? "v2" : "v1", | ||
| PLATFORM_TO_DISPLAY_NAME[endpoint.platform] || "v1", | ||
brittanycho marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| trigger, | ||
| endpoint.region, | ||
| availableMemoryMb, | ||
| endpoint.runtime, | ||
| ]; | ||
| table.push(entry); | ||
|
Check warning on line 59 in src/commands/functions-list.ts
|
||
| } | ||
| logger.info(table.toString()); | ||
|
Check warning on line 61 in src/commands/functions-list.ts
|
||
| return endpointsList; | ||
| return endpoints; | ||
| }); | ||
Uh oh!
There was an error while loading. Please reload this page.