Output secrets sorted by key
Instead of printing them in random order each time `vault read` is invoked.
This commit is contained in:
parent
9d574dd5d5
commit
607d12174d
|
@ -4,6 +4,7 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/hashicorp/vault/api"
|
"github.com/hashicorp/vault/api"
|
||||||
|
@ -68,8 +69,14 @@ func outputFormatTable(ui cli.Ui, s *api.Secret, whitespace bool) int {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for k, v := range s.Data {
|
keys := make([]string, 0, len(s.Data))
|
||||||
input = append(input, fmt.Sprintf("%s %s %v", k, config.Delim, v))
|
for k := range s.Data {
|
||||||
|
keys = append(keys, k)
|
||||||
|
}
|
||||||
|
sort.Strings(keys)
|
||||||
|
|
||||||
|
for _, k := range keys {
|
||||||
|
input = append(input, fmt.Sprintf("%s %s %v", k, config.Delim, s.Data[k]))
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(s.Warnings) != 0 {
|
if len(s.Warnings) != 0 {
|
||||||
|
|
Loading…
Reference in New Issue