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

Add Patch KV helper #15587

Merged
merged 26 commits into from
Jun 1, 2022
Merged

Add Patch KV helper #15587

merged 26 commits into from
Jun 1, 2022

Conversation

digivava
Copy link
Collaborator

@digivava digivava commented May 24, 2022

This PR is an addition onto the already-merged KV helpers PR (#15305), to add a helper method to the api package that allows the Patch command. The logic is mostly the same as the CLI. It also provides a new WithOption KVOption to allow for providing an arbitrary key-value option (for future-proofing if we don't get around to adding new With* functions when new options are developed).

@digivava digivava added this to the 1.11.0-rc1 milestone May 24, 2022
@digivava digivava requested a review from a team May 24, 2022 22:39
Base automatically changed from VAULT-5973_api-kv-helpers to main May 25, 2022 18:17
@digivava digivava requested a review from ccapurso May 25, 2022 18:20
@digivava
Copy link
Collaborator Author

I'm adding the no-changelog label since I plan to tag and release this along with #15305 which already has a changelog entry that should cover this in the release notes (as well as future PRs I'm about to do for other KV helper functions like PutMetadata, etc.)

@mladlow Let me know if you think otherwise!

@mladlow
Copy link
Collaborator

mladlow commented May 25, 2022

@digivava changelog plan sounds good!

Copy link
Contributor

@ccapurso ccapurso left a comment

Choose a reason for hiding this comment

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

Looks good, just a couple small comments. It might also be interesting to add a test where we perform a JSON merge patch for an entry that does not exist to prevent regressions with our error handling as that will result in a 404.

@digivava digivava requested a review from VinnyHC May 26, 2022 23:07
Copy link
Contributor

@VinnyHC VinnyHC left a comment

Choose a reason for hiding this comment

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

This looks good to me!

@digivava digivava merged commit 2afaaf4 into main Jun 1, 2022
@digivava digivava deleted the digivava/kv-helpers-patch branch June 1, 2022 14:51
Gabrielopesantos pushed a commit to Gabrielopesantos/vault that referenced this pull request Jun 6, 2022
* Add Read methods for KVClient

* KV write helper

* Add changelog

* Add Delete method

* Use extractVersionMetadata inside extractDataAndVersionMetadata

* Return nil, nil for v1 writes

* Add test for extracting version metadata

* Split kv client into v1 and v2-specific clients

* Add ability to set options on Put

* Add test for KV helpers

* Add custom metadata to top level and allow for getting versions as sorted slice

* Update tests

* Separate KV v1 and v2 into different files

* Add test for GetVersionsAsList, rename Metadata key to VersionMetadata for clarity

* Move structs and godoc comments to more appropriate files

* Add more tests for extract methods

* Rework custom metadata helper to be more consistent with other helpers

* Remove KVSecret from custom metadata test now that we don't append to it as part of helper method

* Add Patch KV helper

* Add godoc comment and use WithOption ourselves in other KVOption functions

* Clean up options-handling and resp parsing logic; add more tests

* Add constants and more patch tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants