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
Add support for secrets in gcfv2 endpoints #4451
Conversation
…nto dl-cf3v2-secrets
src/deploy/functions/validate.ts
Outdated
@@ -140,7 +140,7 @@ export async function secretsAreValid(projectId: string, wantBackend: backend.Ba | |||
* Ensures that all endpoints specifying secret environment variables target platform that supports the feature. | |||
*/ | |||
function validatePlatformTargets(endpoints: backend.Endpoint[]) { | |||
const supportedPlatforms = ["gcfv1"]; | |||
const supportedPlatforms = ["gcfv1", "gcfv2"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit:
const supportedPlatforms = new Set(["gcfv1", "gcfv2"]);
const unsupported = endpoints.filter((e) => !supportedPlatforms.has(e.platform));
Nit x2: I don't know how often this is called, but maybe it makes more sense to have this defined as a const up top?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Team convention is king. :)
That said, my thoughts are its less about efficiency and more about intention/code clarity.
Set
limits the purpose of the variable/code to just checking for existence.
Array
leaves the implementation open ended. Maybe the array going to be used with has
, reduce
, or map
. Someone else won't know unless they read through the code to find how/why the array is being used.
We now read
secretEnvironmentVariables
property from the endpoint manifest and include the property when creating/updating v1 and v2 functions.Side note - if secretEnvVar in the manifest is missing
secret
property (i.e. doesn't specify the secret resource name), we'll assume that resource name matches thekey
property. This will be the case for all CF3 functions.