Skip to content

Conversation

@khendrikse
Copy link
Contributor

@khendrikse khendrikse commented Jan 24, 2023

🎉 Thanks for submitting a pull request! 🎉

Summary

I'm sending along the functions config that contains any display names to the deploy command :)

Part of https://github.com/netlify/pod-compute/issues/156

@khendrikse khendrikse self-assigned this Jan 24, 2023
@khendrikse khendrikse added the type: feature code contributing to the implementation of a feature and/or user facing functionality label Jan 24, 2023
@github-actions
Copy link

github-actions bot commented Jan 24, 2023

📊 Benchmark results

Comparing with cfcee54

Package size: 265 MB

(no change)

^  267 MB  267 MB  267 MB  267 MB  272 MB  272 MB  272 MB  272 MB                                         
│   ┌──┐    ┌──┐    ┌──┐    ┌──┐    ┌──┐    ┌──┐    ┌──┐    ┌──┐   265 MB  265 MB  265 MB  265 MB  265 MB 
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    ┌──┐    ┌──┐    ┌──┐    ┌──┐    ┌──┐  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
└───┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴──>
    T-12    T-11    T-10    T-9     T-8     T-7     T-6     T-5     T-4     T-3     T-2     T-1      T    
Legend

@khendrikse khendrikse force-pushed the feat-204/send-functions-config-during-deploy branch from eeb0564 to a1fd791 Compare January 25, 2023 12:37
@khendrikse khendrikse marked this pull request as ready for review January 25, 2023 13:26
@khendrikse khendrikse requested a review from a team January 25, 2023 13:27
Skn0tt
Skn0tt previously approved these changes Jan 25, 2023
Copy link
Contributor

@Skn0tt Skn0tt left a comment

Choose a reason for hiding this comment

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

looks generally good to me. left a tiny comment.

do we have tests for this behaviour? if yes, we should probably update one to assert on functions config. If no, we should make an issue to write tests.

Comment on lines 122 to 125
const fnConfig = functionZips.reduce(
(funcs, curr) => (curr.displayName ? { ...funcs, [curr.name]: { display_name: curr.displayName } } : funcs),
{},
)
Copy link
Contributor

@Skn0tt Skn0tt Jan 25, 2023

Choose a reason for hiding this comment

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

this reads somewhat complicated to me. would this have the same effect?

Suggested change
const fnConfig = functionZips.reduce(
(funcs, curr) => (curr.displayName ? { ...funcs, [curr.name]: { display_name: curr.displayName } } : funcs),
{},
)
const fnConfig = Object.fromEntries(
functionZips
.filter(func => !!func.displayName)
.map(func => [func.name, { display_name: func.displayName}])
)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would not be exactly the same effect, as the result of the reduce would be an object, and the map would be an array. But I did add a filter like you did now, in front of the reduce, maybe that already makes it a bit easier to read?

Copy link
Contributor

Choose a reason for hiding this comment

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

and the map would be an array.

that's what the Object.fromEntries would do, wouldn't it?

Copy link
Contributor Author

@khendrikse khendrikse Jan 25, 2023

Choose a reason for hiding this comment

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

Oooh sorry I totally did not see that part 😆 in that case I think I would still prefer it as a reduce, for me that is a bit more readable, as it shows how the object will look. But I do understand that it might be personal preference as well 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

sounds good 👍

@khendrikse
Copy link
Contributor Author

looks generally good to me. left a tiny comment.

do we have tests for this behaviour? if yes, we should probably update one to assert on functions config. If no, we should make an issue to write tests.

@Skn0tt I tried to add a test, but honestly it was... not as easy as I'd like. I'll make an issue to do this so I can spend a bit more time on it 👍

@khendrikse khendrikse merged commit 63d415b into main Jan 25, 2023
@khendrikse khendrikse deleted the feat-204/send-functions-config-during-deploy branch January 25, 2023 14:20

return await zipFunctions(directories, tmpDir, { basePath: rootDir, config: functionsConfig })
return await zipFunctions(directories, tmpDir, {
featureFlags: { project_deploy_configuration_api_use_per_function_configuration_files: true },
Copy link
Member

Choose a reason for hiding this comment

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

Another note for future reference: in the same way we have a single place for all edge functions feature flags, it would be good to do the same for serverless functions. This will ensure the different entry points into zip-it-and-ship-it use the same set of flags, and thus avoiding a situation where two commands have different behaviour leading to a harder time troubleshooting problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: feature code contributing to the implementation of a feature and/or user facing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants