From 8af200d0a5b5e30e9eb06135e07289572710b7f2 Mon Sep 17 00:00:00 2001 From: Emanuel Bennici Date: Tue, 17 Dec 2019 15:59:12 +0100 Subject: [PATCH] Add flag to ignore charts where no repo was found This new flag ('--ignore-repo') provides the functionality to allow the user to continue using the 'outdated' Command even when no Repo was found which holds the specific Chart. Signed-off-by: Emanuel Bennici --- cmd/helm/outdated.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/cmd/helm/outdated.go b/cmd/helm/outdated.go index d86a18947..7b1a7e702 100644 --- a/cmd/helm/outdated.go +++ b/cmd/helm/outdated.go @@ -38,6 +38,8 @@ By default, the output is printed in a Table but you can change this behavior with the '--output' Flag. ` +var ignoreNoRepo bool = false + func newOutdatedCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { client := action.NewList(cfg) var outfmt output.Format @@ -80,6 +82,7 @@ func newOutdatedCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { flags.BoolVar(&client.Uninstalling, "uninstalling", false, "show releases that are currently being uninstalled") flags.BoolVar(&client.Deployed, "deployed", false, "show deployed releases. If no other is specified, this will be automatically enabled") flags.BoolVar(&client.Failed, "failed", false, "show failed releases") + flags.BoolVar(&ignoreNoRepo, "ignore-repo", false, "ignore error if no repo for a chart is found") flags.BoolVar(&client.Pending, "pending", false, "show pending releases") flags.BoolVarP(&client.AllNamespaces, "all-namespaces", "A", false, "list releases across all namespaces") flags.IntVarP(&client.Limit, "max", "m", 256, "maximum number of releases to fetch") @@ -129,8 +132,13 @@ func newOutdatedListWriter(releases []*release.Release, cfg *action.Configuratio // search if it exists a newer Chart in the Chart-Repository repoResult, err := searchChart(results, r.Chart.Name(), r.Chart.Metadata.Version, devel) if err != nil { - fmt.Fprintf(out, "%s", errors.Wrap(err, "ERROR: Could not initialize search index").Error()) - os.Exit(1) + if !ignoreNoRepo { + fmt.Fprintf(out, "%s", errors.Wrap(err, "ERROR: Could not initialize search index").Error()) + os.Exit(1) + } else { + fmt.Fprintf(out, "WARNING: No Repo was found which containing the Chart '%s' (skipping)\n", r.Chart.Name()) + continue + } } // skip if no newer Chart was found