-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Move DLP from REST to gRPC + client libraries #413
Conversation
Change-Id: Iaa03400842667a478e9e29e87ba36fcbda257d60
dlp/inspect.js
Outdated
'Authorization': `Bearer ${authToken}`, | ||
'Content-Type': 'application/json' | ||
// Create a GCS File inspection job, and resolve it using promises | ||
// TODO: is the client library going to handle pagination if no user settings are specified? |
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.
TODOs?
Change-Id: I7fdc39e1528dd222c6795c70cce972efc5c60e1c
dlp/inspect.js
Outdated
.then((findingsBody) => { | ||
const findings = findingsBody.result.findings; | ||
console.log(JSON.stringify(findings, null, 2)); | ||
// Create a GCS File inspection job, and resolve it using event handlers |
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 latter part of this comment seems unhelpful. Would it be better to say:
// Create an operation to instance the data in Google Cloud Storage,
// wait for it to complete, then list the findings.
dlp/inspect.js
Outdated
// TODO this doesn't produce meaningful results | ||
}); | ||
|
||
// Handle job errors |
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 comment is obvious.
return resolve(completeJobResponse); | ||
}); | ||
|
||
// Handle changes in job metadata (e.g. progress updates) |
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 comment is also obvious.
dlp/inspect.js
Outdated
|
||
// Handle changes in job metadata (e.g. progress updates) | ||
operation.on('progress', (metadata) => { | ||
// TODO this doesn't produce meaningful results |
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.
If this does nothing, why not just leave it out?
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 provides (and prints out) semi-meaningful results now.
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 looks mostly fine except for the TODOs and the mostly obvious comments.
Comments should say why you're doing something, not what you're doing.
dlp/inspect.js
Outdated
}) | ||
.catch((err) => { | ||
console.log('Error in inspectString:', err); | ||
console.log('Error in inspectString:', err.message || err); |
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.
nit: Why not: Error in inspectString: ${err.message || err}
to be consistent with other logging style.
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.
Same comment throughout, since this catch block is copy-pasted
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.
Done - will address.
dlp/inspect.js
Outdated
dlp.createInspectOperation(request) | ||
.then((createJobResponse) => { | ||
const operation = createJobResponse[0]; | ||
return new Promise((resolve, reject) => { |
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.
What's the difference between this construct and just operation.promise()
which you used above?
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 uses event handlers - and I wanted to avoid "callback hell".
(If you think the nested callback approach would be better idiomatically vs. mixing promises and event handlers, I'm happy to switch to it.)
category: category, | ||
languageCode: languageCode | ||
}) | ||
.then((body) => { |
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.
What is the type of body
? In other then blocks you use more descriptive names like createJobResponse
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.
Perhaps apiResponse
would be a better name here - WDYT?
(Something like listInfoTypesResponse
seems a little long-winded.)
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.
Either one SGTM
}) | ||
.then((body) => { | ||
const infoTypes = body[0].infoTypes; | ||
console.log(`Info types for category ${category}:`); |
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.
Any possibility of infoTypes being empty?
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.
Having a valid category without valid info types is the only way I can see to trigger this. (Invalid categories are detected outside this sample and the resulting errors are handled correctly.)
Codecov Report
@@ Coverage Diff @@
## master #413 +/- ##
=======================================
Coverage 83.88% 83.88%
=======================================
Files 4 4
Lines 422 422
=======================================
Hits 354 354
Misses 68 68 Continue to review full report at Codecov.
|
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> Co-authored-by: sofisl <[email protected]>
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> Co-authored-by: sofisl <[email protected]>
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> Co-authored-by: sofisl <[email protected]>
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> Co-authored-by: sofisl <[email protected]>
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> Co-authored-by: sofisl <[email protected]>
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> Co-authored-by: sofisl <[email protected]>
🤖 I have created a release *beep* *boop* --- ## [4.1.4](https://togithub.com/googleapis/nodejs-secret-manager/compare/v4.1.3...v4.1.4) (2022-11-11) ### Bug Fixes * **deps:** Use google-gax v3.5.2 ([#413](https://togithub.com/googleapis/nodejs-secret-manager/issues/413)) ([1652509](https://togithub.com/googleapis/nodejs-secret-manager/commit/16525099e4a28b466ebfa067a001124d253c8992)) --- This PR was generated with [Release Please](https://togithub.com/googleapis/release-please). See [documentation](https://togithub.com/googleapis/release-please#release-please).
* Move DLP from REST to gRPC + client libraries * Update package.json * Address comments
No description provided.