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

feat(secret-manager): add optional ttl field to createSecret function #3950

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

hivanalejandro
Copy link
Contributor

@hivanalejandro hivanalejandro commented Jan 14, 2025

Description

  • Introduced the 'ttl' parameter in the Node.js sample for creating secrets.
  • Ensured backward compatibility by handling cases where 'ttl' is undefined.

Fixes b-384052815

Note: Before submitting a pull request, please open an issue for discussion if you are not associated with Google.

Checklist

  • I have followed guidelines from CONTRIBUTING.MD and Samples Style Guide
  • Tests pass: npm test (see Testing)
  • Lint pass: npm run lint (see Style)
  • These samples need a new API enabled in testing projects to pass (let us know which ones)
  • These samples need a new/updated env vars in testing projects set to pass (let us know which ones)
  • This pull request is from a branch created directly off of GoogleCloudPlatform/nodejs-docs-samples. Not a fork.
  • This sample adds a new sample directory, and I updated the CODEOWNERS file with the codeowners for this sample
  • This sample adds a new sample directory, and I created GitHub Actions workflow for this sample
  • This sample adds a new Product API, and I updated the Blunderbuss issue/PR auto-assigner with the codeowners for this sample
  • Please merge this PR for me once it is approved

@hivanalejandro hivanalejandro requested review from a team as code owners January 14, 2025 18:39
@product-auto-label product-auto-label bot added the api: secretmanager Issues related to the Secret Manager API. label Jan 14, 2025
Copy link
Contributor

@code-review-assist code-review-assist bot left a 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 the main 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 the ttl in the secret configuration if provided.

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.

@product-auto-label product-auto-label bot added the samples Issues that are directly related to samples. label Jan 14, 2025
Copy link
Contributor

@code-review-assist code-review-assist bot left a 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 Show resolved Hide resolved
secret-manager/createSecret.js Outdated Show resolved Hide resolved
Comment on lines 44 to 45
if (ttl) {
secretConfig.ttl = ttl;

This comment was marked as resolved.

@briandorsey briandorsey self-assigned this Jan 31, 2025
Copy link
Member

@briandorsey briandorsey left a 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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: secretmanager Issues related to the Secret Manager API. samples Issues that are directly related to samples.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants