Skip to content
This repository was archived by the owner on Jul 20, 2023. It is now read-only.

Conversation

@laljikanjareeya
Copy link
Contributor

Expose getIamPolicy for project.
Fixes #281

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Mar 31, 2020
});
});

it('should not require a callback', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should require a callback, otherwise there's not a point to calling the method. One method that doesn't require a callback, like "restore()", the user could ignore the response, but the actions caused by the API request would still persist.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Making callback require user will not able to use await here What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you explain that further? If it relates, all of our methods require a callback that promisifyAll uses to convert the callback-written function into a promise-based function, that is then compatible with an async workflow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes we are using promisifyAll to convert promise-based function.
I have seen in all repo we are doing same pattern, let me know if you have working example/reference of async workflow will make change accordingly.
Thanks!!

Copy link
Contributor

Choose a reason for hiding this comment

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

The only thing I'm pointing out in this case, is that the callback should not be optional. Here's a comparable function: nodejs-compute/vm#attachDisk() https://github.com/googleapis/nodejs-compute/blob/2484e4b6521fdc9dce0c80b6e8bb4f3da7baf7df/src/vm.js#316

It accepts an optional options argument, and requires a callback.

All of these are compatible with a user who doesn't actually provide a function callback, instead using the promise/async flow.

Copy link

Choose a reason for hiding this comment

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

It seems that nodejs-compute is still js and, once converted and annotate with typescript types, the callback will have to be marked as optional as well. From user's perspective, callback is optional. It will nevertheless always be there where as from user or from primisify.

This existing test it('should not require a callback', () => {...}); doesn't really test the functionality of this library, but rathe functionality of promisify and might not be needed here at all. WDYT?

Copy link
Contributor

@stephenplusplus stephenplusplus Apr 1, 2020

Choose a reason for hiding this comment

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

This is definitely hard to follow between all of our layers 👨💥

The test is making sure that "callback = callback || util.noop" is there, which is what I think should not be there. I don't know if it makes a difference after promisify overwrites the method?, but if not, we could just assume there is always a callback, and remove the "defaulting to noop" line, and remove the test?

The user seeing it in the docs or annotations as optional is good, but the code falling back to a noop seems misleading.

Copy link
Contributor Author

@laljikanjareeya laljikanjareeya Apr 2, 2020

Choose a reason for hiding this comment

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

removed callback = callback || util.noop statement and test that was checking the callback.

@stephenplusplus
Copy link
Contributor

@laljikanjareeya thank you for the changes!

@laljikanjareeya laljikanjareeya merged commit 85f136d into googleapis:master Apr 3, 2020
@laljikanjareeya laljikanjareeya deleted the get-iam-policy branch April 6, 2020 04:44
gcf-merge-on-green bot pushed a commit that referenced this pull request Jun 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add getIamPolicy() support for project

4 participants