mirror of
https://github.com/hashicorp/vault.git
synced 2026-05-04 20:06:27 +02:00
Update format to not use colored UI for json/yaml
This commit is contained in:
parent
d38abb665b
commit
9d4e8c3529
@ -28,6 +28,13 @@ func OutputList(ui cli.Ui, format string, secret *api.Secret) int {
|
||||
}
|
||||
|
||||
func outputWithFormat(ui cli.Ui, format string, secret *api.Secret, data interface{}) int {
|
||||
// If we had a colored UI, pull out the nested ui so we don't add escape
|
||||
// sequences for outputting json, etc.
|
||||
colorUI, ok := ui.(*cli.ColoredUi)
|
||||
if ok {
|
||||
ui = colorUI.Ui
|
||||
}
|
||||
|
||||
formatter, ok := Formatters[strings.ToLower(format)]
|
||||
if !ok {
|
||||
ui.Error(fmt.Sprintf("Invalid output format: %s", format))
|
||||
|
||||
@ -24,18 +24,10 @@ func (m mockUi) AskSecret(_ string) (string, error) {
|
||||
m.t.FailNow()
|
||||
return "", nil
|
||||
}
|
||||
func (m mockUi) Output(s string) {
|
||||
output = s
|
||||
}
|
||||
func (m mockUi) Info(s string) {
|
||||
m.t.Log(s)
|
||||
}
|
||||
func (m mockUi) Error(s string) {
|
||||
m.t.Log(s)
|
||||
}
|
||||
func (m mockUi) Warn(s string) {
|
||||
m.t.Log(s)
|
||||
}
|
||||
func (m mockUi) Output(s string) { output = s }
|
||||
func (m mockUi) Info(s string) { m.t.Log(s) }
|
||||
func (m mockUi) Error(s string) { m.t.Log(s) }
|
||||
func (m mockUi) Warn(s string) { m.t.Log(s) }
|
||||
|
||||
func TestJsonFormatter(t *testing.T) {
|
||||
ui := mockUi{t: t, SampleData: "something"}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user