import ( "github.com/hashicorp/vault/logical" "github.com/hashicorp/vault/logical/framework" ) func config(ctx context.Context, req *logical.Request, data *framework.FieldData) (*logical.Response, error) { // retrieve the value of the field "username" username := data.Get("username").(string) // retrieve the value of the field "password" password := data.Get("password").(string) // do something with the retrieved values // ... return &logical.Response{ Data: map[string]interface{}{ "message": "Credentials validated successfully", }, }, nil }
import ( "github.com/hashicorp/vault/logical" "github.com/hashicorp/vault/logical/framework" ) func writeSecret(ctx context.Context, req *logical.Request, data *framework.FieldData) (*logical.Response, error) { // build a map of the secret's key/value pairs using FieldData secretData := make(map[string]interface{}) for _, fieldName := range data.Keys() { secretData[fieldName] = data.Get(fieldName) } // write the secret to Vault path := "secret/foo/bar" err := req.Storage.Put(ctx, &logical.StorageEntry{ Key: path, Value: secretData, }) if err != nil { return nil, err } // return success response return &logical.Response{ Data: map[string]interface{}{ "message": "Secret written successfully", }, }, nil }In this example, the writeSecret function uses FieldData to build a map of the secret's key/value pairs dynamically from the fields provided. The resulting map is then written to Vault using the Put method from req.Storage. Based on these examples, it appears that the FieldData type provided by github.com.hashicorp.vault.logical.framework belongs to a library for implementing and interacting with the Vault secrets management system.