Commit 68c4190e authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #30579 from smarterclayton/strip_extra_newlines

Automatic merge from submit-queue Describing a single item should not have extra newlines @fabianofranz
parents bcf2d48e 6caf4d5a
......@@ -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)
......
......@@ -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())
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment