github.com/hashicorp/vault/sdk@v0.13.0/plugin/mock/path_internal.go (about) 1 // Copyright (c) HashiCorp, Inc. 2 // SPDX-License-Identifier: MPL-2.0 3 4 package mock 5 6 import ( 7 "context" 8 9 "github.com/hashicorp/vault/sdk/framework" 10 "github.com/hashicorp/vault/sdk/logical" 11 ) 12 13 // pathInternal is used to test viewing internal backend values. In this case, 14 // it is used to test the invalidate func. 15 func pathInternal(b *backend) *framework.Path { 16 return &framework.Path{ 17 Pattern: "internal", 18 Fields: map[string]*framework.FieldSchema{ 19 "value": {Type: framework.TypeString}, 20 }, 21 Callbacks: map[logical.Operation]framework.OperationFunc{ 22 logical.UpdateOperation: b.pathInternalUpdate, 23 logical.ReadOperation: b.pathInternalRead, 24 }, 25 } 26 } 27 28 func (b *backend) pathInternalUpdate(ctx context.Context, req *logical.Request, data *framework.FieldData) (*logical.Response, error) { 29 value := data.Get("value").(string) 30 b.internal = value 31 // Return the secret 32 return nil, nil 33 } 34 35 func (b *backend) pathInternalRead(ctx context.Context, req *logical.Request, data *framework.FieldData) (*logical.Response, error) { 36 // Return the secret 37 return &logical.Response{ 38 Data: map[string]interface{}{ 39 "value": b.internal, 40 }, 41 }, nil 42 }