-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Only prompt for failurePolicies if they are new. #3164
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
Conversation
Fixes firebase/firebase-functions#798 We can now conditionally list functions earlier in the deploy pipeline if there are any functions with a failure policy in the current set of functions to deploy. Silence the prompt if all functions with failure policies already had failure policies. Also modifies prepare.ts to avoid redndantly calling listallfunctions later.
joehan
left a comment
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.
Mostly LGTM, but I'd prefer to not repeat API calls unnecessarily
src/deploy/functions/prompts.ts
Outdated
|
|
||
| // N.B. Because context is an any, we need to store it in a temporary. This | ||
| // lets us do a 'for of' loop later with typeinfo. | ||
| const existingFunctions = await gcp.cloudfunctions.listAllFunctions(context.projectId); |
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.
We already make this call once during the deployment process, at the start of 'deploy.ts' - WDYT about reordering things such that we only need to do this once?
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.
Guarded both cases with existing || await listAllFunctions. In reality, Context should have context.allFunctions() which is a caching implementation and easily mocked. ¯_(ツ)_/¯
1. Cache the lookups to listAllFunctions
2. When passing a mock to listAllFunctions stub, use the API location
for failurePolicy: {}
3. Add release notes
* Only prompt for failurePolicies if they are new. Fixes firebase/firebase-functions#798 We can now conditionally list functions earlier in the deploy pipeline if there are any functions with a failure policy in the current set of functions to deploy. Silence the prompt if all functions with failure policies already had failure policies. Also modifies prepare.ts to avoid redundantly calling listallfunctions later.
Description
Fixes firebase/firebase-functions#798
We can now conditionally list functions earlier in the deploy pipeline
if there are any functions with a failure policy in the current
set of functions to deploy. Silence the prompt if all functions with
failure policies already had failure policies.
Also modifies prepare.ts to avoid redundantly calling listAllFunctions
later.
Scenarios Tested
Sample Commands
firebase deploy [--only functions]Notes
Tests previously checked for throwing instead of rejecting, which worked if and only if the throw happened before yielding the thread. This broke all tests that ran into the new check for existing functions.