Skip to content

feat(functions): add GCFv2 generation upgrade API wrapper and types - #11561

Open
wandamora wants to merge 1 commit into
mainfrom
morawand/gcfv1-upgrade-api-wrapper
Open

wandamora wants to merge 1 commit into
mainfrom
morawand/gcfv1-upgrade-api-wrapper

Conversation

@wandamora

@wandamora wandamora commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds GCF v2 generation upgrade API client wrappers, types, and backend endpoint mapping for upgrading GCF 1st Gen functions to 2nd Gen.

Includes:

  • GCFv2 API wrappers for generation upgrade endpoints: setupFunctionUpgradeConfig (supporting optional triggerServiceAccount and buildConfigOverrides), redirectFunctionUpgradeTraffic, rollbackFunctionUpgradeTraffic, commitFunctionUpgradeAsGen2, and abortFunctionUpgrade.
  • UpgradeState and UpgradeInfo type declarations matching GCF v2 API schemas.
  • OutputCloudFunction.upgradeInfo and environment properties, and propagation to backend.Endpoint.upgradeInfo.
  • Comprehensive unit test coverage in src/gcp/cloudfunctionsv2.spec.ts.

Scenarios Tested

  • Unit tests verifying endpoint paths, payloads (including buildConfigOverrides), and operation returns for all 5 upgrade RPC methods.
  • Unit tests verifying endpoint mapping propagates upgradeInfo from GCF v2 output.
  • Unit tests verifying error wrapping in FirebaseError.
  • Full project compilation via npm run test:compile.
  • Lint checks via npx eslint.

Sample Commands

  • npx mocha src/gcp/cloudfunctionsv2.spec.ts src/deploy/functions/backend.spec.ts

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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 migrating Cloud Functions from V1 to V2 by adding upgrade metadata types (UpgradeState, UpgradeInfo) and implementing five new API wrapper functions in cloudfunctionsv2.ts (setupFunctionUpgradeConfig, redirectFunctionUpgradeTraffic, rollbackFunctionUpgradeTraffic, commitFunctionUpgradeAsGen2, and abortFunctionUpgrade), along with corresponding unit tests. The feedback suggests extracting a shared helper, wrapUpgradeError, to unify the error-wrapping logic across these five new API wrappers and preserve the HTTP status code from the underlying API errors, aligning with the repository's style guide on harmonizing utilities.

Comment thread src/gcp/cloudfunctionsv2.ts Resolved
Comment thread src/gcp/cloudfunctionsv2.ts Resolved
Comment thread src/gcp/cloudfunctionsv2.ts Resolved
Comment thread src/gcp/cloudfunctionsv2.ts Resolved
Comment thread src/gcp/cloudfunctionsv2.ts Resolved
@wandamora
wandamora force-pushed the morawand/gcfv1-upgrade-api-wrapper branch 2 times, most recently from cdc4100 to 7ac0928 Compare November 19, 2026 19:59
Adds GCF v2 generation upgrade API client wrappers, types, and backend endpoint mapping for upgrading GCF 1st Gen functions to 2nd Gen.

Includes:
- GCFv2 API wrappers for generation upgrade endpoints: `setupFunctionUpgradeConfig` (accepting `SetupFunctionUpgradeConfigOptions` for optional `triggerServiceAccount` and `buildConfigOverrides`), `redirectFunctionUpgradeTraffic`, `rollbackFunctionUpgradeTraffic`, `commitFunctionUpgradeAsGen2`, and `abortFunctionUpgrade`, preserving HTTP status codes in `FirebaseError`.
- `UpgradeState` and `UpgradeInfo` type declarations matching GCF v2 API schemas.
- `OutputCloudFunction.upgradeInfo` property and propagation to `backend.Endpoint.upgradeInfo`.
- Unit test coverage in `src/gcp/cloudfunctionsv2.spec.ts`.

- Unit tests verifying endpoint paths, payloads (including `SetupFunctionUpgradeConfigOptions`), and operation returns for all 5 upgrade RPC methods.
- Unit tests verifying endpoint mapping propagates `upgradeInfo` from GCF v2 output.
- Unit tests verifying `FirebaseError` wrapping preserves HTTP status, `original`, and `context`.
- Full project compilation via `npm run test:compile`, lint via `npx eslint`, and formatting via `npx prettier --check`.

- `npx mocha src/gcp/cloudfunctionsv2.spec.ts src/deploy/functions/backend.spec.ts`
@wandamora
wandamora force-pushed the morawand/gcfv1-upgrade-api-wrapper branch from 7ac0928 to bbfeb8c Compare November 19, 2026 20:00
@wandamora
wandamora enabled auto-merge (squash) November 19, 2026 23:32

This branch has not been deployed

No deployments
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