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

pass map representation of proto duration for patch of delete_version_after #62

Merged
merged 1 commit into from
Jun 3, 2022

Conversation

ccapurso
Copy link
Contributor

@ccapurso ccapurso commented Jun 2, 2022

Overview

Attempting to PATCH KVv2 metadata delete_version_after field with a value of 0s for an entry whose value is non-zero does not work. This ultimately is due to the fact that durationpb.Duration struct contains omitempty json tags (the json-patch library requires marshaled JSON byte arrays) for its underlying fields. With that provided 0s will marshal into {} rather than {"seconds": 0, "nanos": 0}. An empty map is treated as a NOOP when it comes to JSON merge patches.

Design of Change

A fix has been added to the patch preprocessor for the KVv2 metadata endpoint. Rather than provided the incoming delete_version_after field as a durationpb.Duration, that duration is converted into a map inline to match the resulting structure of marshaling as JSON minus the omission of empty values.

Attempting to treat both the delete_version_after value of both the input data and existing resource as integers (as provided by framework.TypeDurationSecond) resulted in more complex logic as it required both pre and post processing of the existing resource data. Due to the added complexity, the fix provided in this PR seemed more ideal.

A changelog entry will be added to Vault once a new version is of this plugin is cut and thus upgraded in that repo.

@ccapurso ccapurso requested review from briankassouf and a team June 2, 2022 22:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants