Skip to content

Commit

Permalink
chore(kumactl): don't print info warnings when running Helm (#8111)
Browse files Browse the repository at this point in the history
Signed-off-by: Mike Beaumont <[email protected]>
  • Loading branch information
michaelbeaumont authored Oct 24, 2023
1 parent 7659385 commit b5f0fc5
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions app/kumactl/cmd/install/render_helm_files.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package install

import (
"bytes"
"fmt"
"io"
"log"
"reflect"
"regexp"
"sort"
Expand Down Expand Up @@ -38,6 +41,17 @@ metadata:
`, namespace)
}

type onlyWriteWarnings struct {
writer io.Writer
}

func (w onlyWriteWarnings) Write(p []byte) (int, error) {
if bytes.HasPrefix(p, []byte("Warning:")) {
return w.writer.Write(p)
}
return io.Discard.Write(p)
}

func renderHelmFiles(
templates []data.File,
namespace string,
Expand All @@ -50,9 +64,14 @@ func renderHelmFiles(
return nil, errors.Errorf("Failed to load charts: %s", err)
}

// This is necessary because ProcessDependencies can output warnings as well
// as trash
writer := log.Writer()
log.SetOutput(onlyWriteWarnings{writer: writer})
if err := chartutil.ProcessDependencies(kumaChart, overrideValues); err != nil {
return nil, errors.Errorf("Failed to process dependencies: %s", err)
}
log.SetOutput(writer)

options := generateReleaseOptions(kumaChart.Metadata.Name, namespace)

Expand Down

0 comments on commit b5f0fc5

Please sign in to comment.