Update kv with existence check

This commit is contained in:
Jeff Mitchell 2018-03-21 22:58:11 -04:00
parent 3324d6dd12
commit 22f3a337f3
3 changed files with 18 additions and 10 deletions

View File

@ -1,7 +0,0 @@
{
"options": {
},
"data": {
"bar": "baz"
}
}

View File

@ -49,11 +49,26 @@ version matches the version specified in the cas parameter.`,
logical.DeleteOperation: b.upgradeCheck(b.pathDataDelete()),
},
ExistenceCheck: b.dataExistenceCheck(),
HelpSynopsis: dataHelpSyn,
HelpDescription: dataHelpDesc,
}
}
func (b *versionedKVBackend) dataExistenceCheck() framework.ExistenceFunc {
return func(ctx context.Context, req *logical.Request, data *framework.FieldData) (bool, error) {
key := strings.TrimPrefix(req.Path, "data/")
meta, err := b.getKeyMetadata(ctx, req.Storage, key)
if err != nil {
return false, err
}
return meta != nil, nil
}
}
// pathDataRead handles read commands to a kv entry
func (b *versionedKVBackend) pathDataRead() framework.OperationFunc {
return func(ctx context.Context, req *logical.Request, data *framework.FieldData) (*logical.Response, error) {

6
vendor/vendor.json vendored
View File

@ -1303,10 +1303,10 @@
"revisionTime": "2018-03-20T18:05:36Z"
},
{
"checksumSHA1": "j3fIbBNDLAjg8pH3FnmbcqGcCVo=",
"checksumSHA1": "ZYuIUFGjAZ2rgy/zwdjfANFZc/U=",
"path": "github.com/hashicorp/vault-plugin-secrets-kv",
"revision": "d56826f0e6c085b99e83d984e7bb69b2f6655a45",
"revisionTime": "2018-03-22T01:57:02Z"
"revision": "76db4647de517c512e7f87b78c1afc84acf97918",
"revisionTime": "2018-03-22T02:53:20Z"
},
{
"checksumSHA1": "vTfeYxi0Z1y176bjQaYh1/FpQ9s=",