这是indexloc提供的服务,不要输入任何密码
Skip to content

Add support for GOOGLE_CLOUD_QUOTA_PROJECT across Firebase API client #6801

@jeremydw

Description

@jeremydw

We're running into an issue running firebase-tools deploy in Google Cloud Build, when invoking the command inside a build step owned by one GCP project, deploying to Firebase owned by another GCP project.

Essentially, the Firebase Management API isn't enabled in the project that owns the build runner, but it is enabled in the project that owns the target of the firebase-tools deploy command.

When firebase-tools deploy performs its pre-deploy checks, it uses the quota project of the Google Cloud Build environment, not the project of the target deployment.

Environment info

We are running firebase-tools inside Google Cloud Build (Ubuntu).

Expected behavior

I believe the GOOGLE_CLOUD_QUOTA_PROJECT environment variable needs to be honored by firebase-tools base API client. Under the hood, I believe what this does is it sets the x-goog-user-project on the outgoing requests to various Google APIs, so those requests are associated with the project of my choice (and not necessarily the environment).

Actual behavior

GOOGLE_CLOUD_QUOTA_PROJECT isn't supported, and the project associated with the environment (or its service account) is used for quota/billing to API requests instead of the desired target project.

This results in this error:

npx firebase-tools@latest deploy --debug --project $TARGET_PROJECT
...
[2024-02-21T00:36:31.601Z] <<< [apiv2][body] GET https://firebase.googleapis.com/v1beta1/projects/$TARGET_PROJECT {"error":{"code":403,"message":"Firebase Management API has not been used in project $SOURCE_PROJECT_NUMBER before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/firebase.googleapis.com/overview?project=$SOURCE_PROJECT_NUMBER then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.","status":"PERMISSION_DENIED","details":[{"@type":"type.googleapis.com/google.rpc.Help","links":[{"description":"Google developers console API activation","url":"https://console.developers.google.com/apis/api/firebase.googleapis.com/overview?project=587340091677"}]},{"@type":"type.googleapis.com/google.rpc.ErrorInfo","reason":"SERVICE_DISABLED","domain":"googleapis.com","metadata":{"consumer":"projects/$SOURCE_PROJECT_NUMBER","service":"firebase.googleapis.com"}}]}}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions