logical/framework: better string values for types

This commit is contained in:
Mitchell Hashimoto
2015-04-03 21:15:59 -07:00
parent 105e68387a
commit d9e38470a8
4 changed files with 21 additions and 37 deletions

View File

@@ -1,11 +1,9 @@
package framework
import (
"bytes"
"fmt"
"sort"
"strings"
"text/template"
"github.com/hashicorp/vault/logical"
)
@@ -84,19 +82,12 @@ func (p *Path) helpCallback(
}
}
// Parse the help template
tpl, err := template.New("root").Parse(pathHelpTemplate)
help, err := executeTemplate(pathHelpTemplate, &tplData)
if err != nil {
return nil, fmt.Errorf("error parsing template: %s", err)
}
// Execute the template and store the output
var buf bytes.Buffer
if err := tpl.Execute(&buf, &tplData); err != nil {
return nil, fmt.Errorf("error executing template: %s", err)
}
return logical.HelpResponse(strings.TrimSpace(buf.String()), nil), nil
return logical.HelpResponse(help, nil), nil
}
type pathTemplateData struct {
@@ -120,13 +111,12 @@ Matching Route: {{.RoutePattern}}
{{.Synopsis}}
## Parameters
## PARAMETERS
{{range .Fields}}
### {{.Key}} (type: {{.Type}})
{{.Description}}
{{indent 4 .Key}} ({{.Type}})
{{indent 8 .Description}}
{{end}}
## Description
## DESCRIPTION
{{.Description}}
`