Describing a single item should not have extra newlines

This commit is contained in:
Clayton Coleman 2016-08-13 19:07:28 -04:00
parent 817256a716
commit 6caf4d5a3f
No known key found for this signature in database
GPG Key ID: 3D16906B4F1C5CB3
2 changed files with 10 additions and 4 deletions

View File

@ -142,6 +142,7 @@ func RunDescribe(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []s
allErrs = append(allErrs, err)
}
first := true
for _, info := range infos {
mapping := info.ResourceMapping()
describer, err := f.Describer(mapping)
@ -154,7 +155,12 @@ func RunDescribe(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []s
allErrs = append(allErrs, err)
continue
}
fmt.Fprintf(out, "%s\n\n", s)
if first {
first = false
fmt.Fprint(out, s)
} else {
fmt.Fprintf(out, "\n\n%s", s)
}
}
return utilerrors.NewAggregate(allErrs)

View File

@ -44,7 +44,7 @@ func TestDescribeUnknownSchemaObject(t *testing.T) {
t.Errorf("unexpected describer: %#v", d)
}
if buf.String() != fmt.Sprintf("%s\n\n", d.Output) {
if buf.String() != fmt.Sprintf("%s", d.Output) {
t.Errorf("unexpected output: %s", buf.String())
}
}
@ -77,7 +77,7 @@ func TestDescribeObject(t *testing.T) {
t.Errorf("unexpected describer: %#v", d)
}
if buf.String() != fmt.Sprintf("%s\n\n", d.Output) {
if buf.String() != fmt.Sprintf("%s", d.Output) {
t.Errorf("unexpected output: %s", buf.String())
}
}
@ -96,7 +96,7 @@ func TestDescribeListObjects(t *testing.T) {
buf := bytes.NewBuffer([]byte{})
cmd := NewCmdDescribe(f, buf)
cmd.Run(cmd, []string{"pods"})
if buf.String() != fmt.Sprintf("%s\n\n%s\n\n", d.Output, d.Output) {
if buf.String() != fmt.Sprintf("%s\n\n%s", d.Output, d.Output) {
t.Errorf("unexpected output: %s", buf.String())
}
}