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:
@@ -142,6 +142,7 @@ func RunDescribe(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []s
|
|||||||
allErrs = append(allErrs, err)
|
allErrs = append(allErrs, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
first := true
|
||||||
for _, info := range infos {
|
for _, info := range infos {
|
||||||
mapping := info.ResourceMapping()
|
mapping := info.ResourceMapping()
|
||||||
describer, err := f.Describer(mapping)
|
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)
|
allErrs = append(allErrs, err)
|
||||||
continue
|
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)
|
return utilerrors.NewAggregate(allErrs)
|
||||||
|
@@ -44,7 +44,7 @@ func TestDescribeUnknownSchemaObject(t *testing.T) {
|
|||||||
t.Errorf("unexpected describer: %#v", d)
|
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())
|
t.Errorf("unexpected output: %s", buf.String())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -77,7 +77,7 @@ func TestDescribeObject(t *testing.T) {
|
|||||||
t.Errorf("unexpected describer: %#v", d)
|
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())
|
t.Errorf("unexpected output: %s", buf.String())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -96,7 +96,7 @@ func TestDescribeListObjects(t *testing.T) {
|
|||||||
buf := bytes.NewBuffer([]byte{})
|
buf := bytes.NewBuffer([]byte{})
|
||||||
cmd := NewCmdDescribe(f, buf)
|
cmd := NewCmdDescribe(f, buf)
|
||||||
cmd.Run(cmd, []string{"pods"})
|
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())
|
t.Errorf("unexpected output: %s", buf.String())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user