-
Notifications
You must be signed in to change notification settings - Fork 2k
feat(parametermanager): Added samples for create, get, list and render global parameter & parameter version #4068
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
base: main
Are you sure you want to change the base?
Conversation
…r global parameter & parameter version
Here is the summary of changes. You are about to add 10 region tags.
This comment is generated by snippet-bot.
|
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.
Hello @durgesh-ninave-crest, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
Summary of Changes
This pull request introduces samples for creating, listing, and rendering parameters and parameter versions using the Parameter Manager SDK. These samples cover various scenarios, including structured and unstructured data, referencing secrets, and managing parameter versions. The changes include the addition of new JavaScript files, each demonstrating a specific functionality of the Parameter Manager API, as well as a package.json file to manage dependencies and tests.
Highlights
- New Samples: Added samples for creating parameters with structured and unstructured data.
- Parameter Versions: Introduced samples for creating and managing parameter versions, including referencing secrets.
- Listing and Rendering: Implemented samples for listing parameters and their versions, as well as rendering parameter versions.
- Testing: Added a test suite to verify the functionality of the new samples.
Changelog
Click here to see the changelog
- parametermanager/createParam.js
- Added a sample for creating a global parameter.
- Demonstrates the use of ParameterManagerClient to create a parameter.
- parametermanager/createParamVersion.js
- Added a sample for creating a parameter version with unstructured data.
- Shows how to construct a parameter version with a payload.
- parametermanager/createParamVersionWithSecret.js
- Added a sample for creating a parameter version with secret references.
- Demonstrates how to include references to secrets in the parameter version payload.
- parametermanager/createStructuredParam.js
- Added a sample for creating a structured parameter.
- Shows how to specify the format of the parameter (JSON, YAML, etc.).
- parametermanager/createStructuredParamVersion.js
- Added a sample for creating a structured parameter version.
- Demonstrates how to store JSON data in a parameter version.
- parametermanager/getParam.js
- Added a sample for retrieving a parameter.
- Shows how to use ParameterManagerClient to get parameter details.
- parametermanager/getParamVersion.js
- Added a sample for retrieving a parameter version.
- Demonstrates how to get the details of a specific version of a parameter.
- parametermanager/listParamVersions.js
- Added a sample for listing parameter versions.
- Shows how to iterate through all versions of a parameter.
- parametermanager/listParams.js
- Added a sample for listing parameters.
- Demonstrates how to list all parameters in a project.
- parametermanager/package.json
- Added dependencies for @google-cloud/parametermanager, @google-cloud/secret-manager, c8, chai, mocha, and uuid.
- Configured test script to use c8 and mocha.
- parametermanager/renderParamVersion.js
- Added a sample for rendering a parameter version.
- Shows how to retrieve and resolve secret references in a parameter version.
- parametermanager/test/.eslintrc.yml
- Added eslint config for test directory.
- parametermanager/test/parametermanager.test.js
- Added tests for all the new samples.
- Tests cover creating, listing, getting, and rendering parameters and parameter versions.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
A parameter's tale,
Versions spun, secrets unveiled,
Rendered, clear and bright.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
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.
Code Review
The pull request introduces samples for creating, listing, and rendering parameters and parameter versions using the Google Cloud Parameter Manager SDK. The samples cover various scenarios, including structured and unstructured data, as well as referencing secrets. Overall, the code is well-structured and easy to follow. However, there are a few areas that could be improved for clarity and robustness.
Summary of Findings
- Missing Error Handling: The samples lack explicit error handling for the API calls. While the
.catch(console.error)
at the end of themain
function will catch some errors, it doesn't provide specific feedback to the user about what went wrong or how to fix it. More robust error handling would improve the user experience. - TODO Comments: The
TODO(developer)
comments suggest that users need to uncomment variables before running the samples. It would be better to provide a mechanism for users to pass these values as command-line arguments or environment variables, making the samples more flexible and easier to use. - Inconsistent Parameter Version ID: In
createParamVersionWithSecret.js
, the parameter version ID is hardcoded as 'v1' in the function definition but is passed as a command-line argument. This inconsistency could lead to confusion. It would be better to either use the command-line argument value as the default or remove the default value from the function definition.
Merge Readiness
The pull request introduces valuable samples for interacting with the Parameter Manager API. However, addressing the identified issues related to error handling and user input would significantly enhance the quality and usability of these samples. I am unable to directly approve this pull request, and recommend that others review and approve this code before merging. At a minimum, the high severity issues should be addressed before merging.
|
||
// Parse command line arguments | ||
const args = process.argv.slice(2); | ||
main(...args).catch(console.error); |
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.
While this .catch
will catch errors, it doesn't provide specific feedback to the user about what went wrong. Consider adding more robust error handling within the main
function to provide more informative error messages.
main(...args).catch(console.error); | |
main(...args).catch(err => { | |
console.error('ERROR:', err); | |
process.exitCode = 1; // Exit with a non-zero status code to indicate failure | |
}); |
parametermanager/createParam.js
Outdated
} | ||
|
||
const args = process.argv.slice(2); | ||
main(...args).catch(console.error); |
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.
While this .catch
will catch errors, it doesn't provide specific feedback to the user about what went wrong. Consider adding more robust error handling within the main
function to provide more informative error messages.
main(...args).catch(console.error); | |
main(...args).catch(err => { | |
console.error('ERROR:', err); | |
process.exitCode = 1; // Exit with a non-zero status code to indicate failure | |
}); |
|
||
// Parse command line arguments | ||
const args = process.argv.slice(2); | ||
main(...args).catch(console.error); |
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.
While this .catch
will catch errors, it doesn't provide specific feedback to the user about what went wrong. Consider adding more robust error handling within the main
function to provide more informative error messages.
main(...args).catch(console.error); | |
main(...args).catch(err => { | |
console.error('ERROR:', err); | |
process.exitCode = 1; // Exit with a non-zero status code to indicate failure | |
}); |
|
||
// Parse command line arguments | ||
const args = process.argv.slice(2); | ||
main(...args).catch(console.error); |
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.
While this .catch
will catch errors, it doesn't provide specific feedback to the user about what went wrong. Consider adding more robust error handling within the main
function to provide more informative error messages.
main(...args).catch(console.error); | |
main(...args).catch(err => { | |
console.error('ERROR:', err); | |
process.exitCode = 1; // Exit with a non-zero status code to indicate failure | |
}); |
parametermanager/listParams.js
Outdated
} | ||
|
||
const args = process.argv.slice(2); | ||
main(...args).catch(console.error); |
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.
While this .catch
will catch errors, it doesn't provide specific feedback to the user about what went wrong. Consider adding more robust error handling within the main
function to provide more informative error messages.
main(...args).catch(console.error); | |
main(...args).catch(err => { | |
console.error('ERROR:', err); | |
process.exitCode = 1; // Exit with a non-zero status code to indicate failure | |
}); |
* TODO(developer): Uncomment these variables before running the sample. | ||
*/ | ||
// const projectId = 'YOUR_PROJECT_ID'; | ||
// const parameterId = 'YOUR_PARAMETER_ID'; |
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.
* TODO(developer): Uncomment these variables before running the sample. | ||
*/ | ||
// const projectId = 'my-project'; |
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.
* TODO(developer): Uncomment these variables before running the sample. | ||
*/ | ||
// const projectId = 'YOUR_PROJECT_ID'; | ||
// const parameterId = 'YOUR_PARAMETER_ID'; | ||
// const parameterVersionId = 'YOUR_PARAMETER_VERSION_ID'; | ||
// const secretId = 'YOUR_SECRET_ID'; // For example projects/my-project/secrets/application-secret/version/latest |
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.
* TODO(developer): Uncomment these variables before running the sample. | ||
*/ | ||
// const projectId = 'YOUR_PROJECT_ID'; | ||
// const parameterId = 'YOUR_PARAMETER_ID'; | ||
// const parameterVersionId = 'YOUR_PARAMETER_VERSION_ID'; |
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.
* TODO(developer): Uncomment these variables before running the sample. | ||
*/ | ||
// const projectId = 'YOUR_PROJECT_ID'; | ||
// const parameterId = 'YOUR_PARAMETER_ID'; | ||
// const parameterVersionId = 'YOUR_PARAMETER_VERSION_ID'; | ||
// const payload = 'This is unstructured data'; |
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.
Description
Created samples for creating, listing and rendering parameter and parameter version
Samples List (global):
Checklist
npm test
(see Testing)npm run lint
(see Style)GoogleCloudPlatform/nodejs-docs-samples
. Not a fork.