Merge pull request #4928 from mortent/FixCustomResourcePrinting

fix(helm): Fix line breaks when printing custom resources
pull/5019/head
Taylor Thomas 6 years ago committed by GitHub
commit 88af9659a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -218,18 +218,15 @@ func (c *Client) Get(namespace string, reader io.Reader) (string, error) {
// an object type changes, so we can just rely on that. Problem is it doesn't seem to keep // an object type changes, so we can just rely on that. Problem is it doesn't seem to keep
// track of tab widths. // track of tab widths.
buf := new(bytes.Buffer) buf := new(bytes.Buffer)
p, _ := get.NewHumanPrintFlags().ToPrinter("") printFlags := get.NewHumanPrintFlags()
index := 0
for t, ot := range objs { for t, ot := range objs {
kindHeader := fmt.Sprintf("==> %s", t) kindHeader := fmt.Sprintf("==> %s\n", t)
if index == 0 {
kindHeader = kindHeader + "\n"
}
if _, err = buf.WriteString(kindHeader); err != nil { if _, err = buf.WriteString(kindHeader); err != nil {
return "", err return "", err
} }
typePrinter, _ := printFlags.ToPrinter("")
for _, o := range ot { for _, o := range ot {
if err := p.PrintObj(o, buf); err != nil { if err := typePrinter.PrintObj(o, buf); err != nil {
c.Log("failed to print object type %s, object: %q :\n %v", t, o, err) c.Log("failed to print object type %s, object: %q :\n %v", t, o, err)
return "", err return "", err
} }
@ -237,7 +234,6 @@ func (c *Client) Get(namespace string, reader io.Reader) (string, error) {
if _, err := buf.WriteString("\n"); err != nil { if _, err := buf.WriteString("\n"); err != nil {
return "", err return "", err
} }
index += 1
} }
if len(missing) > 0 { if len(missing) > 0 {
buf.WriteString(MissingGetHeader) buf.WriteString(MissingGetHeader)

Loading…
Cancel
Save