mirror of
https://github.com/Luzifer/yaml-vault.git
synced 2024-10-18 06:44:25 +00:00
fix read tries when path has no current children
This commit is contained in:
parent
0563f3b2d9
commit
fe4d5ddc86
1 changed files with 18 additions and 17 deletions
29
main.go
29
main.go
|
@ -139,7 +139,21 @@ func exportFromVault(client *api.Client) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func readRecurse(client *api.Client, path string, out *importFile) error {
|
func readRecurse(client *api.Client, path string, out *importFile) error {
|
||||||
if strings.HasSuffix(path, "/") {
|
if !strings.HasSuffix(path, "/") {
|
||||||
|
secret, err := client.Logical().Read(path)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if secret == nil {
|
||||||
|
return fmt.Errorf("Unable to read %s: %#v", path, secret)
|
||||||
|
}
|
||||||
|
|
||||||
|
out.Keys[path] = secret.Data
|
||||||
|
debug("Successfully read data from key '%s'", path)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
secret, err := client.Logical().List(path)
|
secret, err := client.Logical().List(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error reading %s: %s", path, err)
|
return fmt.Errorf("Error reading %s: %s", path, err)
|
||||||
|
@ -153,19 +167,6 @@ func readRecurse(client *api.Client, path string, out *importFile) error {
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
secret, err := client.Logical().Read(path)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if secret == nil {
|
|
||||||
return fmt.Errorf("Unable to read %s: %#v", path, secret)
|
|
||||||
}
|
|
||||||
|
|
||||||
out.Keys[path] = secret.Data
|
|
||||||
debug("Successfully read data from key '%s'", path)
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue