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/8277/head
Matthew Fisher 4 years ago
parent 90492c125b
commit 863588ca69
No known key found for this signature in database
GPG Key ID: 92AA783CBAAE8E3B

@ -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"
"log" "log"
"time" "time"
@ -207,7 +206,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

@ -148,7 +148,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")
} }
rel, err := client.Run(args[0], ch, vals) rel, err := client.Run(args[0], ch, vals)

Loading…
Cancel
Save