mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-01 19:17:58 +00:00
Add list support for mysql roles
This commit is contained in:
@@ -29,6 +29,7 @@ func Backend() *framework.Backend {
|
|||||||
Paths: []*framework.Path{
|
Paths: []*framework.Path{
|
||||||
pathConfigConnection(&b),
|
pathConfigConnection(&b),
|
||||||
pathConfigLease(&b),
|
pathConfigLease(&b),
|
||||||
|
pathListRoles(&b),
|
||||||
pathRoles(&b),
|
pathRoles(&b),
|
||||||
pathRoleCreate(&b),
|
pathRoleCreate(&b),
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestBackend_basic(t *testing.T) {
|
func TestBackend_basic(t *testing.T) {
|
||||||
b := Backend()
|
b, _ := Factory(logical.TestBackendConfig())
|
||||||
|
|
||||||
logicaltest.Test(t, logicaltest.TestCase{
|
logicaltest.Test(t, logicaltest.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
|
|||||||
@@ -8,6 +8,19 @@ import (
|
|||||||
"github.com/hashicorp/vault/logical/framework"
|
"github.com/hashicorp/vault/logical/framework"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func pathListRoles(b *backend) *framework.Path {
|
||||||
|
return &framework.Path{
|
||||||
|
Pattern: "roles/?$",
|
||||||
|
|
||||||
|
Callbacks: map[logical.Operation]framework.OperationFunc{
|
||||||
|
logical.ListOperation: b.pathRoleList,
|
||||||
|
},
|
||||||
|
|
||||||
|
HelpSynopsis: pathRoleHelpSyn,
|
||||||
|
HelpDescription: pathRoleHelpDesc,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func pathRoles(b *backend) *framework.Path {
|
func pathRoles(b *backend) *framework.Path {
|
||||||
return &framework.Path{
|
return &framework.Path{
|
||||||
Pattern: "roles/" + framework.GenericNameRegex("name"),
|
Pattern: "roles/" + framework.GenericNameRegex("name"),
|
||||||
@@ -25,7 +38,7 @@ func pathRoles(b *backend) *framework.Path {
|
|||||||
|
|
||||||
Callbacks: map[logical.Operation]framework.OperationFunc{
|
Callbacks: map[logical.Operation]framework.OperationFunc{
|
||||||
logical.ReadOperation: b.pathRoleRead,
|
logical.ReadOperation: b.pathRoleRead,
|
||||||
logical.UpdateOperation: b.pathRoleCreate,
|
logical.UpdateOperation: b.pathRoleCreate,
|
||||||
logical.DeleteOperation: b.pathRoleDelete,
|
logical.DeleteOperation: b.pathRoleDelete,
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -78,6 +91,16 @@ func (b *backend) pathRoleRead(
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (b *backend) pathRoleList(
|
||||||
|
req *logical.Request, d *framework.FieldData) (*logical.Response, error) {
|
||||||
|
entries, err := req.Storage.List("role/")
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return logical.ListResponse(entries), nil
|
||||||
|
}
|
||||||
|
|
||||||
func (b *backend) pathRoleCreate(
|
func (b *backend) pathRoleCreate(
|
||||||
req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
|
req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
|
||||||
name := data.Get("name").(string)
|
name := data.Get("name").(string)
|
||||||
|
|||||||
Reference in New Issue
Block a user