diff --git a/CHANGELOG.md b/CHANGELOG.md index bde97673fe5..5c7202cb996 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1 +1,2 @@ - Fixed an issue with deploying multilevel grouped functions containing v2 functions. (#6419) +- Fixed an issue where functions deployment required a new permission. diff --git a/src/gcp/storage.ts b/src/gcp/storage.ts index d74235e2ab0..b50bf83eaa5 100644 --- a/src/gcp/storage.ts +++ b/src/gcp/storage.ts @@ -1,11 +1,11 @@ import { Readable } from "stream"; import * as path from "path"; -import { firebaseStorageOrigin, storageOrigin } from "../api"; +import { storageOrigin } from "../api"; import { Client } from "../apiv2"; import { FirebaseError } from "../error"; import { logger } from "../logger"; -import { ensure } from "../ensureApiEnabled"; +import { getFirebaseProject } from "../management/projects"; /** Bucket Interface */ interface BucketResponse { @@ -133,14 +133,6 @@ interface ListBucketsResponse { ]; } -interface GetDefaultBucketResponse { - name: string; - location: string; - bucket: { - name: string; - }; -} - /** Response type for obtaining the storage service agent */ interface StorageServiceAccountResponse { email_address: string; @@ -148,19 +140,15 @@ interface StorageServiceAccountResponse { } export async function getDefaultBucket(projectId: string): Promise { - await ensure(projectId, "firebasestorage.googleapis.com", "storage", false); try { - const localAPIClient = new Client({ urlPrefix: firebaseStorageOrigin, apiVersion: "v1alpha" }); - const response = await localAPIClient.get( - `/projects/${projectId}/defaultBucket` - ); - if (!response.body?.bucket.name) { + const metadata = await getFirebaseProject(projectId); + if (!metadata.resources?.storageBucket) { logger.debug("Default storage bucket is undefined."); throw new FirebaseError( "Your project is being set up. Please wait a minute before deploying again." ); } - return response.body.bucket.name.split("/").pop()!; + return metadata.resources.storageBucket; } catch (err: any) { logger.info( "\n\nThere was an issue deploying your functions. Verify that your project has a Google App Engine instance setup at https://console.cloud.google.com/appengine and try again. If this issue persists, please contact support."