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

replace single usage of enable with ensure #3941

Merged
merged 4 commits into from Dec 10, 2021
Merged

replace single usage of enable with ensure #3941

merged 4 commits into from Dec 10, 2021

Conversation

bkendall
Copy link
Contributor

@bkendall bkendall commented Dec 9, 2021

Description

Permissions for checking if an API is enabled and actually enabling the API are separate. Some users may have the former, not the latter. So, let's stick to using only ensure so that those users can succeed.

I went ahead and un-exported enable to make it harder to use it outside its file (and added a comment in code).

Fixes #2574.

Scenarios Tested

init'd functions. also did it turning off the API to make sure it was re-enabled.

@@ -22,8 +22,8 @@ module.exports = async function (setup: any, config: any, options: Options) {
if (projectId) {
await requirePermissions({ ...options, project: projectId });
await Promise.all([
ensureApiEnabled.enable(projectId, "cloudfunctions.googleapis.com"),
ensureApiEnabled.enable(projectId, "runtimeconfig.googleapis.com"),
ensure(projectId, "cloudfunctions.googleapis.com", "unused", true),
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you add these last 2 args? Doesn't seem like they should be here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

At least the 3rd is required. It's "label" (for printing messages) and "silent" (again, printing messages). Setting them to have the same behavior as it does today.

@bkendall bkendall requested a review from joehan December 9, 2021 23:13
Copy link
Contributor

@joehan joehan left a comment

Choose a reason for hiding this comment

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

My bad - I was looking at the signature for enable in the file above and wondering where those args were coming from 🤦

@bkendall bkendall merged commit 0bf69df into master Dec 10, 2021
@bkendall bkendall deleted the bk-2574 branch December 10, 2021 17:02
devpeerapong pushed a commit to devpeerapong/firebase-tools that referenced this pull request Dec 14, 2021
* replace single usage of enable with ensure

* add comment to enable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants