-
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 10 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
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 |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| - Upgraded functions::list command to use cloud run api (#9425) | ||
| - Adds 2nd gen Firebase Data Connect triggers to firebase deploy (#9394). |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -200,6 +200,37 @@ export async function updateService(service: Omit<Service, ServiceOutputFields>) | |
| return svc; | ||
| } | ||
|
|
||
| export async function listServices(projectId: string, filter?: string): Promise<Service[]> { | ||
| let allServices: Service[] = []; | ||
| let pageToken: string | undefined = undefined; | ||
|
|
||
| do { | ||
| const queryParams: Record<string, string> = {}; | ||
| if (pageToken) { | ||
| queryParams["pageToken"] = pageToken; | ||
| } | ||
| if (filter) { | ||
| queryParams["labelSelector"] = filter; | ||
| } | ||
|
|
||
| const res = await client.get<{ services?: Service[]; nextPageToken?: string }>( | ||
| `/projects/${projectId}/locations/-/services`, | ||
| { queryParams }, | ||
| ); | ||
|
|
||
| if (res.status !== 200) { | ||
| throw new FirebaseError(`Failed to list services: ${res.status} ${JSON.stringify(res.body)}`); | ||
brittanycho marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
brittanycho marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| if (res.body.services) { | ||
| allServices = allServices.concat(res.body.services); | ||
brittanycho marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| pageToken = res.body.nextPageToken; | ||
| } while (pageToken); | ||
|
|
||
| return allServices; | ||
| } | ||
|
|
||
| // TODO: Replace with real version: | ||
| function functionNameToServiceName(id: string): string { | ||
| return id.toLowerCase().replace(/_/g, "-"); | ||
|
|
@@ -487,9 +518,14 @@ export function endpointFromService(service: Omit<Service, ServiceOutputFields>) | |
| service.annotations?.[FUNCTION_TARGET_ANNOTATION] || | ||
| service.annotations?.[FUNCTION_ID_ANNOTATION] || | ||
| id, | ||
|
|
||
| // TODO: trigger types. | ||
| httpsTrigger: {}, | ||
| ...(service.annotations?.[TRIGGER_TYPE_ANNOTATION] === "HTTP_TRIGGER" | ||
| ? { httpsTrigger: {} } | ||
| : { | ||
| eventTrigger: { | ||
| eventType: service.annotations?.[TRIGGER_TYPE_ANNOTATION] || "unknown", | ||
| retry: false, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is retry always false here?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. iiuc, I don't think the Cloud Run Service object stores info on retry policies so I don't think we'd be able to know the actual retry setting for a trigger? I didn't see any related fields in https://cloud.google.com/run/docs/reference/rest/v2/projects.locations.services#resource:-service |
||
| }, | ||
| }), | ||
| }; | ||
| proto.renameIfPresent(endpoint, service.template, "concurrency", "containerConcurrency"); | ||
| proto.renameIfPresent(endpoint, service.labels || {}, "codebase", CODEBASE_LABEL); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.