From 56ae3530fb91a3ac73a8760d7fc644a069c4add5 Mon Sep 17 00:00:00 2001 From: vishalnayak Date: Wed, 15 Jun 2016 17:13:14 -0400 Subject: [PATCH] Fix the output format when warnings are present --- command/format.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/command/format.go b/command/format.go index 3350d70560..4e8e62c78e 100644 --- a/command/format.go +++ b/command/format.go @@ -176,14 +176,21 @@ func (t TableFormatter) OutputSecret(ui cli.Ui, secret, s *api.Secret) error { input = append(input, fmt.Sprintf("%s %s %v", k, config.Delim, s.Data[k])) } + ui.Output(columnize.Format(input, config)) + + // Print the warning separately because the length of first + // column in the output will be increased by the length of + // the longest warning string making the output look bad. + warningsInput := make([]string, 0, 5) if len(s.Warnings) != 0 { - input = append(input, "") - input = append(input, "The following warnings were returned from the Vault server:") + warningsInput = append(warningsInput, "") + warningsInput = append(warningsInput, "The following warnings were returned from the Vault server:") for _, warning := range s.Warnings { - input = append(input, fmt.Sprintf("* %s", warning)) + warningsInput = append(warningsInput, fmt.Sprintf("* %s", warning)) } } - ui.Output(columnize.Format(input, config)) + ui.Output(columnize.Format(warningsInput, config)) + return nil }