fix(cmd): display warnings on stderr

The warnings introduced when a chart has been deprecated is displayed on standard out. This is a regression for users piping the output of `helm template` from a deprecated chart to `kubectl`. This changes the error message to display on standard error instead.

Signed-off-by: Matthew Fisher <matt.fisher@microsoft.com>
pull/8227/head
Matthew Fisher 5 years ago committed by Vlad Fratila
parent 3e3d63c1fe
commit 8573eadb98

@ -56,6 +56,11 @@ func debug(format string, v ...interface{}) {
} }
} }
func warning(format string, v ...interface{}) {
format = fmt.Sprintf("WARNING: %s\n", format)
fmt.Fprintf(os.Stderr, format, v...)
}
func initKubeLogs() { func initKubeLogs() {
pflag.CommandLine.SetNormalizeFunc(wordSepNormalizeFunc) pflag.CommandLine.SetNormalizeFunc(wordSepNormalizeFunc)
gofs := flag.NewFlagSet("klog", flag.ExitOnError) gofs := flag.NewFlagSet("klog", flag.ExitOnError)

@ -17,7 +17,6 @@ limitations under the License.
package main package main
import ( import (
"fmt"
"io" "io"
<<<<<<< HEAD <<<<<<< HEAD
"io/ioutil" "io/ioutil"
@ -213,7 +212,7 @@ func runInstall(args []string, client *action.Install, valueOpts *values.Options
} }
if chartRequested.Metadata.Deprecated { if chartRequested.Metadata.Deprecated {
fmt.Fprintln(out, "WARNING: This chart is deprecated") warning("This chart is deprecated")
} }
if req := chartRequested.Metadata.Dependencies; req != nil { if req := chartRequested.Metadata.Dependencies; req != nil {

@ -1,4 +1,3 @@
WARNING: This chart is deprecated
NAME: aeneas NAME: aeneas
LAST DEPLOYED: Fri Sep 2 22:04:05 1977 LAST DEPLOYED: Fri Sep 2 22:04:05 1977
NAMESPACE: default NAMESPACE: default

@ -149,7 +149,7 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
} }
if ch.Metadata.Deprecated { if ch.Metadata.Deprecated {
fmt.Fprintln(out, "WARNING: This chart is deprecated") warning("This chart is deprecated")
} }
err = loadExternalFiles(ch, client.ExternalFiles) err = loadExternalFiles(ch, client.ExternalFiles)

Loading…
Cancel
Save