Skip to content

Conversation

@brittanycho
Copy link
Contributor

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

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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 functions:list command to leverage the Cloud Run API for listing functions. This change enables the command to accurately retrieve and display Cloud Run-based functions, providing more detailed trigger information and improving the overall user experience for managing serverless deployments.

Highlights

  • Cloud Run API Integration: The functions:list command has been upgraded to utilize the Cloud Run API for retrieving and displaying functions, moving away from the previous Cloud Functions backend.
  • New listServices Function: A new asynchronous function, listServices, has been added to src/gcp/runv2.ts to fetch all Cloud Run services for a given project, including robust pagination handling.
  • Enhanced Trigger Detection: The endpointFromService function in src/gcp/runv2.ts has been updated to accurately determine and define trigger types (HTTP or event-based) for functions based on service annotations.
  • Permission Update: The functions:list command now requires the run.services.list permission, reflecting its reliance on the Cloud Run API.
  • Output Table Refinement: The functions:list command's output table has been modified to replace the 'Version' column with 'Platform', providing more relevant information for Cloud Run services.
  • Comprehensive Testing for listServices: New unit tests have been added in src/gcp/runv2.spec.ts to ensure the listServices function correctly fetches services, handles pagination, and manages API errors.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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.

@brittanycho brittanycho changed the title Fr/cloud run fns list Upgrades functions::list command to utilize Cloud Run API Oct 31, 2025
brittanycho and others added 3 commits October 31, 2025 22:39
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>
@brittanycho brittanycho requested a review from taeold November 3, 2025 22:17
@brittanycho
Copy link
Contributor Author

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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.

brittanycho and others added 5 commits November 5, 2025 23:06
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Comment on lines +31 to +38
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.`,
Copy link
Contributor

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",
Copy link
Contributor

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", () => {
Copy link
Contributor

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);
Copy link
Contributor

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.

@github-project-automation github-project-automation bot moved this to Changes Requested [PR] in [Cloud] Extensions + Functions Nov 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants