-
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?
Conversation
Summary of ChangesHello @brittanycho, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refactors the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request updates the functions:list command to use the Cloud Run API, which is a significant improvement. The implementation looks solid, with good test coverage for the new listServices function. I have a couple of suggestions to improve type safety and error logging.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
/gemini review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request successfully upgrades the functions::list command to use the Cloud Run API, which is a great improvement for supporting Cloud Run-based functions. I've found a critical issue where GCFv2 functions could be duplicated in the list, and I've provided a fix. I also have a minor suggestion to improve performance in the new listServices function. Overall, the changes are well-structured and the tests for the new functionality are thorough.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
| let v2Endpoints: backend.Endpoint[] = []; | ||
| try { | ||
| const services = await listServices(projectId); | ||
| v2Endpoints = services.map((service) => endpointFromService(service)); | ||
| } catch (err: any) { | ||
| logger.debug(`Failed to list v2 functions:`, err); | ||
| logger.warn( | ||
| `Failed to list v2 functions. Ensure you have the Cloud Run Admin API enabled and the necessary permissions.`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this entire logic should live inside backend.existingBackend(context)
existingBackend is the abstraction we have that calls GCF v1/v2 API and then transform it into a common representation. We should add support for Run functions there directly (which would benefit this command along with other places where we need to list functions (e.g. during deploy)
| const entry = [ | ||
| endpoint.id, | ||
| endpoint.platform === "gcfv2" ? "v2" : "v1", | ||
| endpoint.platform === "gcfv2" ? "v2" : endpoint.platform === "run" ? "run" : "v1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm maybe we can use a small map, like PLATFORM_TO_DISPLAY_NAME or something?
type PLATFORM_DISPLAY_NAME = "v1" | "v2" | "run";
const PLATFORM_TO_DISPLAY_NAME: Record<type endpoint.platform, PLATFORM_DISPLAY_NAME> = {
gcfv1: "v1",
gcfv2: "v2",
run: "run",
};
// Returns 'v2', 'run', or falls back to 'v1'
const version = platformMap[endpoint.platform]
| }); | ||
| }); | ||
|
|
||
| describe("listServices", () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like its missing test on whether filtering by label works correctly
|
|
||
| let v2Endpoints: backend.Endpoint[] = []; | ||
| try { | ||
| const services = await listServices(projectId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it looks like this would list all Run services, which is not what we want.
Upgrades functions::list command to utilize Cloud Run API:
Upgrades by adding new function (listServices) to runV2.ts and defining trigger within endpointFromService function. Then listServices and endpointFromService are newly utilized in functions-list.ts so that this command now uses cloud run api