Add GCF V1's FUNCTION_REGION env var to V2 - #10862
Conversation
There was a problem hiding this comment.
Code Review
This pull request restores the automatic injection of the FUNCTION_REGION environment variable for Cloud Functions v2 to maintain backward compatibility with v1 behavior, updating both the deployment logic and unit tests. The review feedback suggests using the in operator to check for the existence of the FUNCTION_REGION key rather than a falsy check, preventing the accidental overriding of explicitly set falsy values (such as empty strings).
ajperel
left a comment
There was a problem hiding this comment.
I think you may have accidentally mostly duplciated the code?
Also this is good enough but you could write a test for not overriding a user supplied value.
| { exit: 1 }, | ||
| ); | ||
| } | ||
| gcfFunction.serviceConfig.environmentVariables["FUNCTION_REGION"] = endpoint.region; |
There was a problem hiding this comment.
Why is all this logic repeated again, this time without if (!gcfFunction.serviceConfig.environmentVariables["FUNCTION_REGION"]) {
* Add GCF V1's FUNCTION_REGION env var to V2 * Changelog
What it says on the tin