Merge pull request #30579 from smarterclayton/strip_extra_newlines

Automatic merge from submit-queue

Describing a single item should not have extra newlines

@fabianofranz
This commit is contained in:
Kubernetes Submit Queue
2016-08-19 14:33:39 -07:00
committed by GitHub
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())
}
}