Skip to content

feat(parametermanager): Added samples for delete, enable and disable parameter and parameter version #5253

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

Conversation

durgesh-ninave-crest
Copy link
Contributor

@durgesh-ninave-crest durgesh-ninave-crest commented Apr 7, 2025

Description

Added samples for deleting parameter, enabling, disabling and deleting parameter version using Parameter manager SDK

Sample List (global):

  1. delete-parameter
  2. delete-parameter-version
  3. disable-parameter-version
  4. enable-disabled-parameter-version

Added required tests for it.

Checklist

  • I have followed Contributing Guidelines from CONTRIBUTING.MD
  • Tests pass: go test -v ./.. (see Testing)
  • Code formatted: gofmt (see Formatting)
  • Vetting pass: go vet (see Formatting)
  • 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 sample adds a new sample directory, and I updated the CODEOWNERS file with the codeowners 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

@durgesh-ninave-crest durgesh-ninave-crest requested review from a team as code owners April 7, 2025 08:22
Copy link

snippet-bot bot commented Apr 7, 2025

Here is the summary of changes.

You are about to add 4 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 the samples Issues that are directly related to samples. label Apr 7, 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 @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 new samples for the Parameter Manager SDK, specifically focusing on deleting parameters, deleting parameter versions, disabling parameter versions, and enabling disabled parameter versions. The changes include the addition of four new Go files, each implementing one of these functionalities. Additionally, a test file has been added to verify the correct behavior of these new functions. The go.mod and go.sum files have also been updated to reflect the new dependencies and versions.

Highlights

  • New Samples: Added four new samples demonstrating how to delete a parameter, delete a parameter version, disable a parameter version, and enable a disabled parameter version using the Parameter Manager SDK.
  • Test Coverage: Included a new test file, parametermanager_test.go, to ensure the new functions operate as expected, covering the core functionalities of the added samples.
  • Dependency Updates: Updated go.mod and go.sum to include necessary dependencies and reflect the new Go version (1.23.0) and toolchain (go1.23.4).

Changelog

Click here to see the changelog
  • parametermanager/delete_param.go
    • Added a new function deleteParam that deletes a parameter using the Parameter Manager SDK.
    • Includes error handling for client creation and parameter deletion failures.
    • Prints a success message to the provided io.Writer upon successful deletion.
  • parametermanager/delete_param_version.go
    • Added a new function deleteParamVersion that deletes a specific version of a parameter.
    • Includes error handling for client creation and parameter version deletion failures.
    • Prints a success message to the provided io.Writer upon successful deletion.
  • parametermanager/disable_param_vesion.go
    • Added a new function disableParamVersion that disables a specific version of a parameter.
    • Uses UpdateParameterVersion to set the Disabled field to true.
    • Includes error handling for client creation and parameter version update failures.
    • Prints a success message to the provided io.Writer upon successful disabling.
  • parametermanager/enable_param_version.go
    • Added a new function enableParamVersion that enables a disabled parameter version.
    • Uses UpdateParameterVersion to set the Disabled field to false.
    • Includes error handling for client creation and parameter version update failures.
    • Prints a success message to the provided io.Writer upon successful enabling.
  • parametermanager/go.mod
    • Updated the Go version to 1.23.0 and added a toolchain version of go1.23.4.
    • Added github.com/GoogleCloudPlatform/golang-samples and github.com/gofrs/uuid as required modules.
    • Updated versions of google.golang.org/genproto and google.golang.org/grpc.
    • Added several indirect dependencies related to opentelemetry and googleapis.
  • parametermanager/go.sum
    • Added checksums for the new and updated dependencies in go.mod.
  • parametermanager/parametermanager_test.go
    • Added a new test file to verify the functionality of the new sample functions.
    • Includes helper functions for creating and cleaning up parameters and parameter versions for testing purposes.
    • Tests the disableParamVersion, enableParamVersion, deleteParam, and deleteParamVersion functions.
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 life,
A version's rise and fall,
Code's gentle control.

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 new samples for deleting, enabling, and disabling parameters and parameter versions using the Parameter Manager SDK. The code includes the necessary tests, which is great. Here are some suggestions for improvements.

Summary of Findings

  • Error message consistency: The error messages in the new functions are slightly inconsistent. Standardizing the error message format would improve maintainability.
  • Redundant defer calls in tests: The tests include redundant defer calls to cleanup functions. Removing these would simplify the test code.

Merge Readiness

The code changes are well-structured and include tests. However, addressing the error message consistency and redundant defer calls would improve the overall quality. I am unable to directly approve this pull request, and recommend that another reviewer approve this code before merging. I recommend that the pull request not be merged until the high severity issues are addressed.

Comment on lines +55 to +57
if err != nil {
return fmt.Errorf("failed to delete parameter: %w", err)
}

Choose a reason for hiding this comment

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

medium

Consider including the parameter name in the error message for better context.

How about: return fmt.Errorf("failed to delete parameter %s: %w", name, err)

return fmt.Errorf("failed to delete parameter %s: %w", name, err)

Comment on lines +56 to +57
return fmt.Errorf("failed to delete parameter version: %w", err)
}

Choose a reason for hiding this comment

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

medium

Consider including the parameter version name in the error message for better context.

How about: return fmt.Errorf("failed to delete parameter version %s: %w", name, err)

Suggested change
return fmt.Errorf("failed to delete parameter version: %w", err)
}
return fmt.Errorf("failed to delete parameter version %s: %w", name, err)

Comment on lines +60 to +61
if _, err := client.UpdateParameterVersion(ctx, req); err != nil {
return fmt.Errorf("failed to disable parameter version: %w", err)

Choose a reason for hiding this comment

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

medium

Consider including the parameter version name in the error message for better context.

How about: return fmt.Errorf("failed to disable parameter version %s: %w", name, err)

return fmt.Errorf("failed to disable parameter version %s: %w", name, err)

Comment on lines +60 to +61
if _, err := client.UpdateParameterVersion(ctx, req); err != nil {
return fmt.Errorf("failed to enable parameter version: %w", err)

Choose a reason for hiding this comment

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

medium

Consider including the parameter version name in the error message for better context.

How about: return fmt.Errorf("failed to enable parameter version %s: %w", name, err)

return fmt.Errorf("failed to enable parameter version %s: %w", name, err)

@arpangoswami arpangoswami added kokoro:force-run Add this label to force Kokoro to re-run the tests. kokoro:run Add this label to force Kokoro to re-run the tests. labels Apr 7, 2025
@kokoro-team kokoro-team removed kokoro:run Add this label to force Kokoro to re-run the tests. kokoro:force-run Add this label to force Kokoro to re-run the tests. labels Apr 7, 2025
@arpangoswami
Copy link
Contributor

Please run go mod tidy and relevant commands to fix Go/Lint

goimports -w . && find . -name go.mod -execdir go mod tidy \;

@arpangoswami arpangoswami enabled auto-merge (squash) April 9, 2025 05:58
@telpirion telpirion self-assigned this Apr 9, 2025
@telpirion telpirion dismissed gemini-code-assist[bot]’s stale review April 9, 2025 19:38

code-assist input not useful

auto-merge was automatically disabled April 10, 2025 05:11

Head branch was pushed to by a user without write access

@telpirion telpirion enabled auto-merge (squash) April 11, 2025 17:28
auto-merge was automatically disabled April 14, 2025 06:27

Head branch was pushed to by a user without write access

@telpirion telpirion enabled auto-merge (squash) April 14, 2025 17:17
auto-merge was automatically disabled April 15, 2025 05:12

Head branch was pushed to by a user without write access

@telpirion telpirion enabled auto-merge (squash) April 15, 2025 15:57
@telpirion telpirion merged commit 4d997e9 into GoogleCloudPlatform:main Apr 15, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
samples Issues that are directly related to samples.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants