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

Add support for secrets in gcfv2 endpoints #4451

Merged
merged 11 commits into from May 3, 2022
Merged

Add support for secrets in gcfv2 endpoints #4451

merged 11 commits into from May 3, 2022

Conversation

taeold
Copy link
Contributor

@taeold taeold commented Apr 16, 2022

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 the key property. This will be the case for all CF3 functions.

@taeold taeold marked this pull request as ready for review April 29, 2022 19:40
@@ -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"];
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You and @inlined should have a talk! @inlined does not like Sets, especially in our code where N is almost always < 50 where using Set (which has every so slightly different API from arrays) doesn't give us much!

Copy link
Contributor

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.

@taeold taeold enabled auto-merge (squash) May 3, 2022 06:13
@taeold taeold merged commit c0f19a3 into master May 3, 2022
@kaibolay kaibolay deleted the dl-cf3v2-secrets branch September 15, 2022 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants