-
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
feat(secret-manager): add optional ttl field to createSecret function #3950
base: main
Are you sure you want to change the base?
feat(secret-manager): add optional ttl field to createSecret function #3950
Conversation
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.
Hi team,
I'm currently reviewing this pull request and will provide my feedback shortly. In the meantime, here's a summary for you and other reviewers to quickly get up to speed:
This pull request, authored by @hivanalejandro, aims to add an optional ttl
(time-to-live) field to the createSecret
function in the secret-manager
Node.js sample. The intent is to allow users to specify a lifespan for their secrets.
Here's a breakdown of the changes:
- File Changed:
secret-manager/createSecret.js
- An optional
ttl
parameter has been added to themain
function, allowing users to specify the secret's time-to-live in seconds (e.g.,'900s'
for 15 minutes). - The code now handles cases where
ttl
is undefined, ensuring backward compatibility. - The
createSecret
function is modified to include thettl
in the secret configuration if provided.
- An optional
The changes are implemented cleanly and efficiently. The code is well-documented and easy to understand. Backward compatibility is maintained by handling the case where ttl
is not provided. The addition of the ttl
parameter enhances the functionality of the createSecret
function, providing users with more control over their secrets.
I'll be providing a more detailed review soon.
And now, a little haiku to lighten the mood:
Secrets short or long,
Time to live, a new option,
Code flows smoothly on.
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 pull request adds an optional TTL field to the createSecret
function, which is a good improvement. The implementation looks correct and maintains backward compatibility. However, there are a few minor suggestions for improvement.
secret-manager/createSecret.js
Outdated
if (ttl) { | ||
secretConfig.ttl = ttl; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
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.
Overall looks good.
Could I ask you to also update the test (I think it's: https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/4f660cdf6874bd4c3d5c2c9c1335caef2d20c8a3/secret-manager/test/secretmanager.test.js#L248C7-L248C23) to pass the new TTL parameter as well?
Description
Fixes b-384052815
Note: Before submitting a pull request, please open an issue for discussion if you are not associated with Google.
Checklist
npm test
(see Testing)npm run lint
(see Style)GoogleCloudPlatform/nodejs-docs-samples
. Not a fork.