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

Fix bug where environment variables for v2 functions weren't being updated #4209

Merged
merged 5 commits into from
Feb 23, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
- Updates reserved environment variables for CF3 to include 'EVENTARC_CLOUD_EVENT_SOURCE' (#4196).
- Fixes arg order for `firebase emulators:start --only storage` (#4195).
- Fixes bug where environment variable for gen 2 functions weren't updated on deploy (#4209).
13 changes: 10 additions & 3 deletions src/gcp/cloudfunctionsv2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ export async function getFunction(
*/
export async function listFunctions(projectId: string, region: string): Promise<CloudFunction[]> {
const res = await listFunctionsInternal(projectId, region);
if (res.unreachable!.includes(region)) {
if (res.unreachable.includes(region)) {
throw new FirebaseError(`Cloud Functions region ${region} is unavailable`);
}
return res.functions;
Expand Down Expand Up @@ -333,9 +333,16 @@ async function listFunctionsInternal(
export async function updateFunction(
cloudFunction: Omit<CloudFunction, OutputOnlyFields>
): Promise<Operation> {
// Keys in labels and environmentVariables are user defined, so we don't recurse
// for field masks.
const fieldMasks = proto.fieldMasks(
cloudFunction,
/* doNotRecurseIn...=*/ "labels",
"serviceConfig.environmentVariables"
);
try {
const queryParams = {
updateMask: proto.fieldMasks(cloudFunction).join(","),
updateMask: fieldMasks.join(","),
};
const res = await client.patch<typeof cloudFunction, Operation>(
cloudFunction.name,
Expand Down Expand Up @@ -480,7 +487,7 @@ export function endpointFromFunction(gcfFunction: CloudFunction): backend.Endpoi
} else if (gcfFunction.eventTrigger) {
trigger = {
eventTrigger: {
eventType: gcfFunction.eventTrigger!.eventType,
eventType: gcfFunction.eventTrigger.eventType,
eventFilters: {},
retry: false,
},
Expand Down