mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-03 12:07:54 +00:00
Add a deprecated helper to tokenutil and JSON output to path-help (#7006)
This commit is contained in:
@@ -26,4 +26,5 @@ func (c *Client) Help(path string) (*Help, error) {
|
|||||||
type Help struct {
|
type Help struct {
|
||||||
Help string `json:"help"`
|
Help string `json:"help"`
|
||||||
SeeAlso []string `json:"see_also"`
|
SeeAlso []string `json:"see_also"`
|
||||||
|
OpenAPI map[string]interface{} `json:"openapi"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package command
|
package command
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@@ -44,13 +45,15 @@ Usage: vault path-help [options] PATH
|
|||||||
|
|
||||||
Each secret engine produces different help output.
|
Each secret engine produces different help output.
|
||||||
|
|
||||||
|
If -format is specified as JSON, the output will be in OpenAPI format.
|
||||||
|
|
||||||
` + c.Flags().Help()
|
` + c.Flags().Help()
|
||||||
|
|
||||||
return strings.TrimSpace(helpText)
|
return strings.TrimSpace(helpText)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *PathHelpCommand) Flags() *FlagSets {
|
func (c *PathHelpCommand) Flags() *FlagSets {
|
||||||
return c.flagSet(FlagSetHTTP)
|
return c.flagSet(FlagSetHTTP | FlagSetOutputFormat)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *PathHelpCommand) AutocompleteArgs() complete.Predictor {
|
func (c *PathHelpCommand) AutocompleteArgs() complete.Predictor {
|
||||||
@@ -97,6 +100,17 @@ func (c *PathHelpCommand) Run(args []string) int {
|
|||||||
return 2
|
return 2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch c.flagFormat {
|
||||||
|
case "json":
|
||||||
|
b, err := json.Marshal(help.OpenAPI)
|
||||||
|
if err != nil {
|
||||||
|
c.UI.Error(fmt.Sprintf("Error marshaling OpenAPI: %s", err))
|
||||||
|
return 2
|
||||||
|
}
|
||||||
|
c.UI.Output(string(b))
|
||||||
|
default:
|
||||||
c.UI.Output(help.Help)
|
c.UI.Output(help.Help)
|
||||||
|
}
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user