Skip to content

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

Merged
briandorsey merged 13 commits intomainfrom
fix/optional-ttl-field-to-createSecret-function
Mar 13, 2025
Merged

feat(secret-manager): add optional ttl field to createSecret function#3950
briandorsey merged 13 commits intomainfrom
fix/optional-ttl-field-to-createSecret-function

Conversation

@hivanalejandro
Copy link
Copy Markdown
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:

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
Copy Markdown

@ghost ghost 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
Copy Markdown

@ghost ghost 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.

Comment thread secret-manager/createSecret.js Outdated
Comment thread secret-manager/createSecret.js Outdated
Comment thread secret-manager/createSecret.js Outdated
@briandorsey briandorsey self-assigned this Jan 31, 2025
@GoogleCloudPlatform GoogleCloudPlatform deleted a comment Jan 31, 2025
Copy link
Copy Markdown
Contributor

@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?

@hivanalejandro
Copy link
Copy Markdown
Contributor Author

741ca18

Hi @briandorsey. The test has been updated to pass the new TTL parameter (741ca18)

Comment thread secret-manager/test/secretmanager.test.js
@glasnt glasnt added the waiting-for-response Waiting for the author's response. label Mar 5, 2025
@briandorsey briandorsey removed the waiting-for-response Waiting for the author's response. label Mar 13, 2025
Copy link
Copy Markdown
Contributor

@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.

LGTM, thanks for the detailed iteration work!

@briandorsey briandorsey merged commit ac839ba into main Mar 13, 2025
12 checks passed
@briandorsey briandorsey deleted the fix/optional-ttl-field-to-createSecret-function branch March 13, 2025 20:17
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.

5 participants