2020-12-10 01:42:28 +03:00
|
|
|
package vault
|
|
|
|
|
2024-12-12 09:13:30 +03:00
|
|
|
/*
|
2020-12-10 01:42:28 +03:00
|
|
|
func getKVinfo(cli *api.Client, path string) (string, int, error) {
|
|
|
|
info, err := getKVmount(cli, path)
|
|
|
|
if err != nil {
|
|
|
|
return "", 0, err
|
|
|
|
}
|
|
|
|
|
|
|
|
switch info {
|
|
|
|
case "1":
|
|
|
|
return "", 1, nil
|
|
|
|
case "2":
|
|
|
|
return "data", 2, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return "", 0, fmt.Errorf("Vault engine version info not found: %s", path)
|
|
|
|
}
|
|
|
|
|
|
|
|
func getKVmount(cli *api.Client, path string) (string, error) {
|
|
|
|
requestpath := "/v1/sys/mounts/" + path
|
|
|
|
rsp, err := cli.RawRequest(cli.NewRequest("GET", requestpath))
|
|
|
|
if err != nil {
|
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
defer rsp.Body.Close()
|
|
|
|
|
|
|
|
type MountInfo struct {
|
|
|
|
Data struct {
|
|
|
|
Options struct {
|
|
|
|
Version string `json:"version"`
|
|
|
|
} `json:"options"`
|
|
|
|
} `json:"data"`
|
|
|
|
}
|
|
|
|
|
|
|
|
info := &MountInfo{}
|
|
|
|
if err = json.NewDecoder(rsp.Body).Decode(info); err != nil {
|
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
|
|
|
|
if info.Data.Options.Version == "" {
|
|
|
|
return "1", nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return info.Data.Options.Version, nil
|
|
|
|
}
|
2024-12-12 09:13:30 +03:00
|
|
|
*/
|