mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-20 01:01:22 +00:00
Describing a single item should not have extra newlines
This commit is contained in:
parent
817256a716
commit
6caf4d5a3f
@ -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())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user