cmd/helm/search_repo: print info to stderr

Signed-off-by: Zhou Hao <zhouhao@cn.fujitsu.com>
pull/7609/head
Zhou Hao 5 years ago
parent 5ecf3fc099
commit e085bfcb46

@ -22,6 +22,7 @@ import (
"fmt" "fmt"
"io" "io"
"io/ioutil" "io/ioutil"
"os"
"path/filepath" "path/filepath"
"strings" "strings"
@ -102,7 +103,7 @@ func newSearchRepoCmd(out io.Writer) *cobra.Command {
func (o *searchRepoOptions) run(out io.Writer, args []string) error { func (o *searchRepoOptions) run(out io.Writer, args []string) error {
o.setupSearchedVersion() o.setupSearchedVersion()
index, err := o.buildIndex(out) index, err := o.buildIndex()
if err != nil { if err != nil {
return err return err
} }
@ -171,7 +172,7 @@ func (o *searchRepoOptions) applyConstraint(res []*search.Result) ([]*search.Res
return data, nil return data, nil
} }
func (o *searchRepoOptions) buildIndex(out io.Writer) (*search.Index, error) { func (o *searchRepoOptions) buildIndex() (*search.Index, error) {
// Load the repositories.yaml // Load the repositories.yaml
rf, err := repo.LoadFile(o.repoFile) rf, err := repo.LoadFile(o.repoFile)
if isNotExist(err) || len(rf.Repositories) == 0 { if isNotExist(err) || len(rf.Repositories) == 0 {
@ -184,8 +185,7 @@ func (o *searchRepoOptions) buildIndex(out io.Writer) (*search.Index, error) {
f := filepath.Join(o.repoCacheDir, helmpath.CacheIndexFile(n)) f := filepath.Join(o.repoCacheDir, helmpath.CacheIndexFile(n))
ind, err := repo.LoadIndexFile(f) ind, err := repo.LoadIndexFile(f)
if err != nil { if err != nil {
// TODO should print to stderr fmt.Fprintf(os.Stderr, "WARNING: Repo %q is corrupt or missing. Try 'helm repo update'.", n)
fmt.Fprintf(out, "WARNING: Repo %q is corrupt or missing. Try 'helm repo update'.", n)
continue continue
} }

Loading…
Cancel
Save