openapi: Add display attributes for Consul (#19413)

This commit is contained in:
Anton Averchenkov 2023-04-13 11:31:37 -04:00 committed by GitHub
parent c8803cb571
commit c025747e46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 3 deletions

View File

@ -10,6 +10,8 @@ import (
"github.com/hashicorp/vault/sdk/logical"
)
const operationPrefixConsul = "consul"
// ReportedVersion is used to report a specific version to Vault.
var ReportedVersion = ""

View File

@ -15,6 +15,11 @@ import (
func pathConfigAccess(b *backend) *framework.Path {
return &framework.Path{
Pattern: "config/access",
DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: operationPrefixConsul,
},
Fields: map[string]*framework.FieldSchema{
"address": {
Type: framework.TypeString,
@ -55,9 +60,20 @@ must be x509 PEM encoded and if this is set you need to also set client_cert.`,
},
},
Callbacks: map[logical.Operation]framework.OperationFunc{
logical.ReadOperation: b.pathConfigAccessRead,
logical.UpdateOperation: b.pathConfigAccessWrite,
Operations: map[logical.Operation]framework.OperationHandler{
logical.ReadOperation: &framework.PathOperation{
Callback: b.pathConfigAccessRead,
DisplayAttrs: &framework.DisplayAttributes{
OperationSuffix: "access-configuration",
},
},
logical.UpdateOperation: &framework.PathOperation{
Callback: b.pathConfigAccessWrite,
DisplayAttrs: &framework.DisplayAttributes{
OperationVerb: "configure",
OperationSuffix: "access",
},
},
},
}
}

View File

@ -17,6 +17,11 @@ func pathListRoles(b *backend) *framework.Path {
return &framework.Path{
Pattern: "roles/?$",
DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: operationPrefixConsul,
OperationSuffix: "roles",
},
Callbacks: map[logical.Operation]framework.OperationFunc{
logical.ListOperation: b.pathRoleList,
},
@ -26,6 +31,12 @@ func pathListRoles(b *backend) *framework.Path {
func pathRoles(b *backend) *framework.Path {
return &framework.Path{
Pattern: "roles/" + framework.GenericNameRegex("name"),
DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: operationPrefixConsul,
OperationSuffix: "role",
},
Fields: map[string]*framework.FieldSchema{
"name": {
Type: framework.TypeString,

View File

@ -21,6 +21,13 @@ const (
func pathToken(b *backend) *framework.Path {
return &framework.Path{
Pattern: "creds/" + framework.GenericNameRegex("role"),
DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: operationPrefixConsul,
OperationVerb: "generate",
OperationSuffix: "credentials",
},
Fields: map[string]*framework.FieldSchema{
"role": {
Type: framework.TypeString,