Skip to content

Conversation

@taeold
Copy link
Contributor

@taeold taeold commented Jan 5, 2026

Adds support for deploying Cloud Functions from a remote Git repository, allowing users to deploy third-party solutions without vendoring source code locally.

Key changes:

  • New remoteSource config option with repository, ref, and optional dir fields
  • configDir option for persisting environment variables locally
  • Requires functions.yaml manifest for security (prevents arbitrary code execution during discovery)
  • Downloads source via GitHub archive API

Example config:

  {
    "functions": {
      "remoteSource": {
        "repository": "org/repo",
        "ref": "v1.0.0",
        "dir": "packages/functions"
      },
      "runtime": "nodejs20",
      "configDir": "config"
    }
  }

- Fix writeResolvedParams to only persist for local sources or when configDir is set
- Fix progress bar rendering issue when content-length header is missing
- Remove empty JSDoc blocks and fix typos in error messages
- Add unit tests for remote source with dir, requireFunctionsYaml, and local source path
- Improve error message clarity for missing source configuration
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @taeold, 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 significantly enhances the Cloud Functions deployment process by enabling support for remote Git repositories as function sources. This allows users to deploy third-party solutions or manage monorepos more effectively without needing to vendor source code locally. The changes include new configuration options for specifying remote sources, a mechanism for local environment variable persistence, and a security measure requiring a functions.yaml manifest. The underlying codebase loading and preparation logic has been updated to seamlessly integrate both local and remote function sources.

Highlights

  • Remote Source Support: Introduced a new remoteSource configuration option for Cloud Functions, allowing deployment directly from a Git repository (e.g., GitHub) by specifying repository, ref, and an optional dir.
  • Local Environment Variable Persistence: Added a configDir option to persist environment variables locally, enhancing flexibility for function configurations.
  • Security Requirement: Mandated the presence of a functions.yaml manifest for remote sources to prevent arbitrary code execution during function discovery, improving security.
  • Refactored Codebase Loading: The loadCodebases function has been refactored to accept a DiscoveryContext object and now returns a comprehensive LoadedCodebases object, including discovered builds, resolved source directories, and loaded environment variables for each codebase.
  • Conditional Progress Bar: The download progress bar will now only display if the content-length header is greater than zero, preventing unnecessary display for empty responses.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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 introduces support for deploying Cloud Functions from a remote Git repository. The changes include a new remoteSource configuration option, updates to config validation, and a refactoring of the loadCodebases function to handle both local and remote sources. The implementation correctly uses the GitHub archive API for downloading sources and enforces security by requiring a functions.yaml manifest for remote deployments. My review focuses on the new logic and its integration. I've identified a couple of areas for improvement: one regarding code duplication which affects maintainability, and another a potential bug in handling environment variables for remote sources with a specified configDir.

}
wantBackends[codebase] = wantBackend;
if (functionsEnv.hasUserEnvs(userEnvOpt) || hasEnvsFromParams) {
if (isLocalConfig(config) && (functionsEnv.hasUserEnvs(userEnvOpt) || hasEnvsFromParams)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This condition prevents .env files from being considered authoritative for remote sources, even when a configDir is specified. This means environment variables from previous deployments will be merged instead of overwritten, which is likely unexpected for users who provide a configDir to manage environment variables for a remote source. To ensure consistent behavior for both local and remote sources with user-provided environment files, you should also consider the presence of config.configDir for remote sources.

Suggested change
if (isLocalConfig(config) && (functionsEnv.hasUserEnvs(userEnvOpt) || hasEnvsFromParams)) {
if ((isLocalConfig(config) || config.configDir) && (functionsEnv.hasUserEnvs(userEnvOpt) || hasEnvsFromParams)) {

Comment on lines +560 to +567
const userEnvOpt: functionsEnv.UserEnvsOpts = {
functionsSource: sourceDir,
projectId: projectId,
projectAlias: context.projectAlias,
};
if (codebaseConfig.configDir) {
userEnvOpt.configDir = path.resolve(context.projectDir, codebaseConfig.configDir);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The logic for creating userEnvOpt on these lines is duplicated from lines 171-178 in the prepare function. To improve maintainability and reduce redundancy, consider extracting this logic into a shared helper function. Alternatively, you could construct this object once within loadCodebases and return it as part of the LoadedCodebases result to be used in the prepare function.

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.

1 participant