-
Notifications
You must be signed in to change notification settings - Fork 16
feat: Expose getIamPolicy support for project #302
feat: Expose getIamPolicy support for project #302
Conversation
| }); | ||
| }); | ||
|
|
||
| it('should not require a callback', () => { |
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.
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.
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.
Making callback require user will not able to use await here What do you think?
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.
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.
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.
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!!
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.
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.
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.
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?
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.
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.
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.
removed callback = callback || util.noop statement and test that was checking the callback.
|
@laljikanjareeya thank you for the changes! |
🤖 I have created a release \*beep\* \*boop\* --- ## [1.2.0](https://www.github.com/googleapis/nodejs-resource/compare/v1.1.5...v1.2.0) (2020-05-20) ### Features * Expose getIamPolicy support for project ([#302](https://www.github.com/googleapis/nodejs-resource/issues/302)) ([85f136d](https://www.github.com/googleapis/nodejs-resource/commit/85f136dfe133e42976864082cfe444a3f0cea37c)) ### Bug Fixes * apache license URL ([#468](https://www.github.com/googleapis/nodejs-resource/issues/468)) ([#308](https://www.github.com/googleapis/nodejs-resource/issues/308)) ([3fdebd3](https://www.github.com/googleapis/nodejs-resource/commit/3fdebd3b5f57d11dc77b8a6755d25d9be3da4794)) * **deps:** update dependency @google-cloud/common to v3 ([#301](https://www.github.com/googleapis/nodejs-resource/issues/301)) ([0ee3bf1](https://www.github.com/googleapis/nodejs-resource/commit/0ee3bf19810f38c4aa2a4e1b389022bc32bc70bc)) * **deps:** update dependency @google-cloud/paginator to v3 ([#299](https://www.github.com/googleapis/nodejs-resource/issues/299)) ([3cffb9f](https://www.github.com/googleapis/nodejs-resource/commit/3cffb9ffbdeaabd77522f17af9b5f25eb11a9009)) * **deps:** update dependency @google-cloud/promisify to v2 ([#298](https://www.github.com/googleapis/nodejs-resource/issues/298)) ([1e8965f](https://www.github.com/googleapis/nodejs-resource/commit/1e8965f204195d7d0014691dad6eb7d2efb632b9)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please).
Expose getIamPolicy for project.
Fixes #281