Skip to content
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
Expand Up @@ -2,3 +2,4 @@
- Enhance firebase init apphosting to support local source deploys. (#8479)
- Fixed issue where `firebase init hosting:github` didn't correctly parse the repo input. (#8536)
- Add GCP API client functions to support App Hosting deploy from source feature. (#8545)
- Fix an issue where updating a Cloud Function that retires would add incorrect fields to the updateMask. (#8560)
15 changes: 7 additions & 8 deletions src/gcp/cloudfunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,23 +358,22 @@ export async function updateFunction(
cloudFunction: Omit<CloudFunction, OutputOnlyFields>,
): Promise<Operation> {
const endpoint = `/${cloudFunction.name}`;
cloudFunction.buildEnvironmentVariables = {
...cloudFunction.buildEnvironmentVariables,
// Disable GCF from automatically running npm run build script
// https://cloud.google.com/functions/docs/release-notes
GOOGLE_NODE_RUN_SCRIPTS: "",
};
// Keys in labels and environmentVariables and secretEnvironmentVariables are user defined,
// so we don't recurse for field masks.
const fieldMasks = proto.fieldMasks(
cloudFunction,
/* doNotRecurseIn...=*/ "labels",
"environmentVariables",
"secretEnvironmentVariables",
"buildEnvironmentVariables",
);

cloudFunction.buildEnvironmentVariables = {
...cloudFunction.buildEnvironmentVariables,
// Disable GCF from automatically running npm run build script
// https://cloud.google.com/functions/docs/release-notes
GOOGLE_NODE_RUN_SCRIPTS: "",
};
fieldMasks.push("buildEnvironmentVariables");

// Failure policy is always an explicit policy and is only signified by the presence or absence of
// a protobuf.Empty value, so we have to manually add it in the missing case.
try {
Expand Down
20 changes: 9 additions & 11 deletions src/gcp/cloudfunctionsv2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -421,29 +421,27 @@ async function listFunctionsInternal(
* Customers can force a field to be deleted by setting that field to `undefined`
*/
export async function updateFunction(cloudFunction: InputCloudFunction): Promise<Operation> {
// Keys in labels and environmentVariables and secretEnvironmentVariables are user defined, so we don't recurse
// for field masks.
const fieldMasks = proto.fieldMasks(
cloudFunction,
/* doNotRecurseIn...=*/ "labels",
"serviceConfig.environmentVariables",
"serviceConfig.secretEnvironmentVariables",
);

cloudFunction.buildConfig.environmentVariables = {
...cloudFunction.buildConfig.environmentVariables,
// Disable GCF from automatically running npm run build script
// https://cloud.google.com/functions/docs/release-notes
GOOGLE_NODE_RUN_SCRIPTS: "",
};
fieldMasks.push("buildConfig.buildEnvironmentVariables");

cloudFunction.serviceConfig.environmentVariables = {
...cloudFunction.serviceConfig.environmentVariables,
FUNCTION_TARGET: cloudFunction.buildConfig.entryPoint.replaceAll("-", "."),
// Enable logging execution id by default for better debugging
LOG_EXECUTION_ID: "true",
};
// Keys in labels and environmentVariables and secretEnvironmentVariables are user defined, so we don't recurse
// for field masks.
const fieldMasks = proto.fieldMasks(
cloudFunction,
/* doNotRecurseIn...=*/ "labels",
"serviceConfig.environmentVariables",
"serviceConfig.secretEnvironmentVariables",
"buildConfig.environmentVariables",
);

try {
const queryParams = {
Expand Down