Skip to content

Commit 02c178a

Browse files
abhis3joehan
andauthored
Fixed an issue where functions deployment required a new permission. (#6425)
* - Fixed an issue where functions deployment required a new permission. * pretty --------- Co-authored-by: joehan <joehanley@google.com>
1 parent 6c467cf commit 02c178a

File tree

2 files changed

+6
-17
lines changed

2 files changed

+6
-17
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
- Fixed an issue with deploying multilevel grouped functions containing v2 functions. (#6419)
2+
- Fixed an issue where functions deployment required a new permission.

src/gcp/storage.ts

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { Readable } from "stream";
22
import * as path from "path";
33

4-
import { firebaseStorageOrigin, storageOrigin } from "../api";
4+
import { storageOrigin } from "../api";
55
import { Client } from "../apiv2";
66
import { FirebaseError } from "../error";
77
import { logger } from "../logger";
8-
import { ensure } from "../ensureApiEnabled";
8+
import { getFirebaseProject } from "../management/projects";
99

1010
/** Bucket Interface */
1111
interface BucketResponse {
@@ -133,34 +133,22 @@ interface ListBucketsResponse {
133133
];
134134
}
135135

136-
interface GetDefaultBucketResponse {
137-
name: string;
138-
location: string;
139-
bucket: {
140-
name: string;
141-
};
142-
}
143-
144136
/** Response type for obtaining the storage service agent */
145137
interface StorageServiceAccountResponse {
146138
email_address: string;
147139
kind: string;
148140
}
149141

150142
export async function getDefaultBucket(projectId: string): Promise<string> {
151-
await ensure(projectId, "firebasestorage.googleapis.com", "storage", false);
152143
try {
153-
const localAPIClient = new Client({ urlPrefix: firebaseStorageOrigin, apiVersion: "v1alpha" });
154-
const response = await localAPIClient.get<GetDefaultBucketResponse>(
155-
`/projects/${projectId}/defaultBucket`
156-
);
157-
if (!response.body?.bucket.name) {
144+
const metadata = await getFirebaseProject(projectId);
145+
if (!metadata.resources?.storageBucket) {
158146
logger.debug("Default storage bucket is undefined.");
159147
throw new FirebaseError(
160148
"Your project is being set up. Please wait a minute before deploying again."
161149
);
162150
}
163-
return response.body.bucket.name.split("/").pop()!;
151+
return metadata.resources.storageBucket;
164152
} catch (err: any) {
165153
logger.info(
166154
"\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."

0 commit comments

Comments
 (0)