Skip to content

Commit

Permalink
Fix bug where environment variables for v2 functions weren't being up…
Browse files Browse the repository at this point in the history
…dated (#4209)

When calculating update mask for v2, we weren't properly accounting for the fact that the object holding environment variables should not be recursed.

Fixes #4192
  • Loading branch information
taeold committed Feb 23, 2022
1 parent 22c04d4 commit 73eec36
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
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

0 comments on commit 73eec36

Please sign in to comment.