Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed an issue where functions deployment required a new permission. #6425

Merged
merged 3 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
22 changes: 5 additions & 17 deletions src/gcp/storage.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -133,34 +133,22 @@ interface ListBucketsResponse {
];
}

interface GetDefaultBucketResponse {
name: string;
location: string;
bucket: {
name: string;
};
}

/** Response type for obtaining the storage service agent */
interface StorageServiceAccountResponse {
email_address: string;
kind: string;
}

export async function getDefaultBucket(projectId: string): Promise<string> {
await ensure(projectId, "firebasestorage.googleapis.com", "storage", false);
try {
const localAPIClient = new Client({ urlPrefix: firebaseStorageOrigin, apiVersion: "v1alpha" });
const response = await localAPIClient.get<GetDefaultBucketResponse>(
`/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."
Expand Down