Pass writer as argument

Signed-off-by: divolgin <dmitriy@replicated.com>
pull/11593/head
divolgin 3 years ago
parent 5140b246ac
commit 5875ce0b83

@ -20,6 +20,7 @@ import (
"fmt"
"io"
"log"
"os"
"github.com/spf13/cobra"
@ -53,7 +54,7 @@ func newGetValuesCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
return compListReleases(toComplete, args, cfg)
},
RunE: func(cmd *cobra.Command, args []string) error {
overrideRegistryWriter(cfg, outfmt)
overrideRegistryWriter(cfg, outfmt, os.Stderr)
vals, err := client.Run(args[0])
if err != nil {

@ -19,6 +19,7 @@ package main
import (
"fmt"
"io"
"os"
"strconv"
"time"
@ -67,7 +68,7 @@ func newHistoryCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
return compListReleases(toComplete, args, cfg)
},
RunE: func(cmd *cobra.Command, args []string) error {
overrideRegistryWriter(cfg, outfmt)
overrideRegistryWriter(cfg, outfmt, os.Stderr)
history, err := getHistory(client, args[0])
if err != nil {

@ -136,7 +136,7 @@ func newInstallCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
return compInstall(args, toComplete, client)
},
RunE: func(_ *cobra.Command, args []string) error {
overrideRegistryWriter(cfg, outfmt)
overrideRegistryWriter(cfg, outfmt, os.Stderr)
rel, err := runInstall(args, client, valueOpts, out)
if err != nil {

@ -70,7 +70,7 @@ func newListCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
Args: require.NoArgs,
ValidArgsFunction: noCompletions,
RunE: func(cmd *cobra.Command, args []string) error {
overrideRegistryWriter(cfg, outfmt)
overrideRegistryWriter(cfg, outfmt, os.Stderr)
if client.AllNamespaces {
if err := cfg.Init(settings.RESTClientGetter(), "", os.Getenv("HELM_DRIVER"), debug); err != nil {

@ -263,9 +263,9 @@ func checkForExpiredRepos(repofile string) {
}
func overrideRegistryWriter(cfg *action.Configuration, outfmt output.Format) {
func overrideRegistryWriter(cfg *action.Configuration, outfmt output.Format, newWriter io.Writer) {
// Ensure registry output doesn't break structured output
if outfmt != output.Table {
registry.ClientOptWriter(os.Stderr)(cfg.RegistryClient)
registry.ClientOptWriter(newWriter)(cfg.RegistryClient)
}
}

@ -21,6 +21,7 @@ import (
"fmt"
"io"
"log"
"os"
"strings"
"time"
@ -65,7 +66,7 @@ func newStatusCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
return compListReleases(toComplete, args, cfg)
},
RunE: func(cmd *cobra.Command, args []string) error {
overrideRegistryWriter(cfg, outfmt)
overrideRegistryWriter(cfg, outfmt, os.Stderr)
// When the output format is a table the resources should be fetched
// and displayed as a table. When YAML or JSON the resources will be

@ -66,7 +66,7 @@ func newTemplateCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
return compInstall(args, toComplete, client)
},
RunE: func(_ *cobra.Command, args []string) error {
overrideRegistryWriter(cfg, output.YAML)
overrideRegistryWriter(cfg, output.YAML, os.Stderr)
if kubeVersion != "" {
parsedKubeVersion, err := chartutil.ParseKubeVersion(kubeVersion)

@ -88,7 +88,7 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
return nil, cobra.ShellCompDirectiveNoFileComp
},
RunE: func(cmd *cobra.Command, args []string) error {
overrideRegistryWriter(cfg, outfmt)
overrideRegistryWriter(cfg, outfmt, os.Stderr)
client.Namespace = settings.Namespace()

Loading…
Cancel
Save