mirror of
https://github.com/hashicorp/vault.git
synced 2025-12-16 15:01:13 +01:00
Output JSON with spaces not tabs
This commit is contained in:
parent
7f6aa892a4
commit
ac63ed573b
@ -1,7 +1,6 @@
|
|||||||
package command
|
package command
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
@ -53,17 +52,15 @@ var Formatters = map[string]Formatter{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// An output formatter for json output of an object
|
// An output formatter for json output of an object
|
||||||
type JsonFormatter struct {
|
type JsonFormatter struct{}
|
||||||
}
|
|
||||||
|
|
||||||
func (j JsonFormatter) Output(ui cli.Ui, secret *api.Secret, data interface{}) error {
|
func (j JsonFormatter) Output(ui cli.Ui, secret *api.Secret, data interface{}) error {
|
||||||
b, err := json.Marshal(data)
|
b, err := json.MarshalIndent(data, "", " ")
|
||||||
if err == nil {
|
if err != nil {
|
||||||
var out bytes.Buffer
|
return err
|
||||||
json.Indent(&out, b, "", "\t")
|
|
||||||
ui.Output(out.String())
|
|
||||||
}
|
}
|
||||||
return err
|
ui.Output(string(b))
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// An output formatter for yaml output format of an object
|
// An output formatter for yaml output format of an object
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user