vault
vault copied to clipboard
api: provide new merge option: `upsert`
Is your feature request related to a problem? Please describe.
There should be a new MergeMethod that should put the secret if does not exist, otherwise, it should merge the secret by using patch method like as is.
foo, err := client.KVv2("foo").Patch(context.Background(), "bar", data)
if err != nil {
// in case an error fallback to the patch way - key does not exist!
foo, err = client.KVv2("foo").Put(context.Background(), "bar", data)
if err != nil {
log.Printf("could not write to Vault: %s: %v\n", variable.Key, err)
}
}
I've tried to pass KVMergeMethodPatch
and cas=0
but doesn't solve the problem:
client.KVv2("foo").Patch(context.Background(), "bar", data, vault.WithMergeMethod(vault.KVMergeMethodPatch), vault.WithCheckAndSet(0))
Describe the solution you'd like
Provide a new MergeMethod:
KVMergeMethodUpsert = "upsert"
Eventually, I would write the following instead:
client.KVv2("foo").Patch(context.Background(), "bar", data, vault.WithMergeMethod(vault.KVMergeMethodUpsert)
Describe alternatives you've considered
-
Explain any additional use-cases
-
Additional context
-