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(parametermanager): Added global samples to create list render parameter and version #4012

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

Conversation

vatsal-vora-crestdata
Copy link

@vatsal-vora-crestdata vatsal-vora-crestdata commented Mar 5, 2025

Description

Created samples for creating, listing and rendering parameter and parameter version

Added Sample List:

  1. parameter-structured-data
  2. parameter-unstructured-data
  3. add-parameter-version (structured, unstructured)
  4. create-parameter-secret-reference
  5. list-all-parameters
  6. view-parameter-details
  7. list-all-parameters-versions
  8. view-parameter-version-details
  9. render-secret-parameter-version

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) - This requires Parameter manager API to be enabled
  • These samples need a new/updated env vars in testing projects set to pass (let us know which ones) - This requires GCLOUD_LOCATION to be set otherwise it will use us-central1
  • 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

@vatsal-vora-crestdata vatsal-vora-crestdata requested review from a team as code owners March 5, 2025 08:17
Copy link

snippet-bot bot commented Mar 5, 2025

Here is the summary of changes.

You are about to add 10 region tags.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@product-auto-label product-auto-label bot added samples Issues that are directly related to samples. api: workflows Issues related to the Workflows API. labels Mar 5, 2025
Copy link

@gemini-code-assist gemini-code-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.

Hello @vatsal-vora-crestdata, 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 Google Cloud Parameter Manager. It includes samples for both structured and unstructured data, as well as examples for referencing secrets within parameters. The changes include new JavaScript files for each sample, a new GitHub Actions workflow file, and an update to the workflows JSON file.

Highlights

  • New Samples: Adds nine new samples demonstrating various Parameter Manager functionalities, including creating parameters with structured and unstructured data, adding parameter versions, referencing secrets, listing parameters and versions, and rendering parameter versions.
  • GitHub Actions Workflow: Introduces a new workflow file (parameter-manager.yaml) to automate testing for the Parameter Manager samples.
  • Workflow Configuration: Updates the workflows.json file to include the new 'parameter-manager' workflow.

Changelog

Click here to see the changelog
  • .github/workflows/parameter-manager.yaml
    • Adds a new GitHub Actions workflow for the parameter-manager samples.
    • Configures the workflow to run on push and pull requests to the main branch, as well as on a schedule.
    • Includes jobs for testing and flaky bot analysis.
  • .github/workflows/utils/workflows.json
    • Adds 'parameter-manager' to the list of workflows.
  • parametermanager/createParam.js
    • Creates a global parameter using the Parameter Manager SDK.
    • Takes projectId and parameterId as input.
    • Uses @google-cloud/parametermanager library to instantiate a client and create the parameter.
  • parametermanager/createParamVersion.js
    • Creates a parameter version globally for unstructured data.
    • Takes projectId, parameterId, parameterVersionId, and payload as input.
    • Uses @google-cloud/parametermanager library to create the parameter version with the given payload.
  • parametermanager/createParamVersionWithSecret.js
    • Creates a new version of an existing parameter with secret references.
    • Takes projectId, parameterId, parameterVersionId, and secretId as input.
    • Constructs a JSON payload with a secret reference and creates the parameter version.
  • parametermanager/createStructuredParam.js
    • Creates a parameter with a specified format (JSON, YAML, UNFORMATTED).
    • Takes projectId, parameterId, and formatType as input.
    • Uses @google-cloud/parametermanager library to create the structured parameter.
  • parametermanager/createStructuredParamVersion.js
    • Creates a new version of an existing parameter with a JSON payload.
    • Takes projectId, parameterId, parameterVersionId, and payload as input.
    • Uses @google-cloud/parametermanager library to create the structured parameter version.
  • parametermanager/getParam.js
    • Retrieves a parameter from the global location.
    • Takes projectId and parameterId as input.
    • Uses @google-cloud/parametermanager library to get the parameter and prints its format.
  • parametermanager/getParamVersion.js
    • Retrieves the details of a specific parameter version.
    • Takes projectId, parameterId, and versionId as input.
    • Uses @google-cloud/parametermanager library to get the parameter version and prints its state and payload.
  • parametermanager/listParamVersions.js
    • Lists all versions of an existing parameter.
    • Takes projectId and parameterId as input.
    • Uses @google-cloud/parametermanager library to list the parameter versions and prints their state.
  • parametermanager/listParams.js
    • Lists all parameters in the global location.
    • Takes projectId as input.
    • Uses @google-cloud/parametermanager library to list the parameters and prints their name and format.
  • parametermanager/package.json
    • Adds dependencies for @google-cloud/parametermanager, @google-cloud/secret-manager, c8, chai, mocha, and uuid.
    • Defines scripts for testing.
  • parametermanager/renderParamVersion.js
    • Retrieves and renders the details of a specific parameter version, resolving secret references.
    • Takes projectId, parameterId, and parameterVersionId as input.
    • Uses @google-cloud/parametermanager library to render the parameter version and prints the rendered payload.
  • parametermanager/test/.eslintrc.yml
    • Configures eslint for mocha tests
  • parametermanager/test/parametermanager.test.js
    • Adds tests for all the samples.
    • Uses chai and child_process to execute the samples and assert the output.
    • Creates temporary secrets and parameters for testing purposes.
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.


Trivia time!

What is the purpose of the 'uuid' library used in the tests?

Click here for the answer
The 'uuid' library is used to generate unique identifiers, which are used to create unique parameter and secret names for testing purposes, avoiding naming conflicts.

Footnotes

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

Copy link

@gemini-code-assist gemini-code-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.

Code Review

The pull request introduces samples for creating, listing, and rendering parameters and parameter versions using the Parameter Manager SDK. The samples cover various scenarios, including structured and unstructured data, referencing secrets, and retrieving parameter details. Overall, the code is well-structured and easy to follow. However, there are a few areas that could be improved for clarity and consistency.

Summary of Findings

  • Copyright Year: The copyright year in the files is set to 2025. Please ensure this is the correct and intended year.
  • Missing Tests: While the pull request includes a test file, it would be beneficial to have individual tests for each sample to ensure they function as expected and to prevent regressions.
  • Inconsistent Parameter Version ID: The parameterVersionId is hardcoded as 'v1' in some samples. Consider generating a unique ID for each version to avoid conflicts.

Merge Readiness

The pull request introduces new functionality with sample code. While the code appears functional, the absence of individual tests for each sample raises concerns about long-term maintainability and reliability. Addressing the copyright year and adding more comprehensive tests would significantly improve the readiness of this pull request for merging. I am unable to directly approve the pull request, and recommend that others review and approve this code before merging.

@@ -0,0 +1,53 @@
// Copyright 2025 Google LLC

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The copyright year is set to 2025. Please confirm if this is the correct year, or if it should be updated to the current year.

Suggested change
// Copyright 2025 Google LLC
// Copyright 2023 Google LLC

@@ -0,0 +1,75 @@
// Copyright 2025 Google LLC

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The copyright year is set to 2025. Please confirm if this is the correct year, or if it should be updated to the current year.

Suggested change
// Copyright 2025 Google LLC
// Copyright 2023 Google LLC

@@ -0,0 +1,85 @@
// Copyright 2025 Google LLC

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The copyright year is set to 2025. Please confirm if this is the correct year, or if it should be updated to the current year.

Suggested change
// Copyright 2025 Google LLC
// Copyright 2023 Google LLC

@@ -0,0 +1,69 @@
// Copyright 2025 Google LLC

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The copyright year is set to 2025. Please confirm if this is the correct year, or if it should be updated to the current year.

Suggested change
// Copyright 2025 Google LLC
// Copyright 2023 Google LLC

@@ -0,0 +1,77 @@
// Copyright 2025 Google LLC

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The copyright year is set to 2025. Please confirm if this is the correct year, or if it should be updated to the current year.

Suggested change
// Copyright 2025 Google LLC
// Copyright 2023 Google LLC

@glasnt
Copy link
Contributor

glasnt commented Mar 6, 2025

@vatsal-vora-crestdata The automated code comments here are valid: please update the copyright years since these are new samples

@vatsal-vora-crestdata
Copy link
Author

@vatsal-vora-crestdata The automated code comments here are valid: please update the copyright years since these are new samples

I have added year as 2025 only, the comments are suggesting to change it back to 2023. I will update year in autogenerated workflow file to 2025 but for others it is 2025 only

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

Successfully merging this pull request may close these issues.

2 participants