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 <eb@fabmation.de>
pull/7021/head
Emanuel Bennici 6 years ago
parent c05d789151
commit 8af200d0a5
No known key found for this signature in database
GPG Key ID: 17FA2D56BAD01661

@ -38,6 +38,8 @@ By default, the output is printed in a Table but you can change this behavior
with the '--output' Flag. with the '--output' Flag.
` `
var ignoreNoRepo bool = false
func newOutdatedCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { func newOutdatedCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
client := action.NewList(cfg) client := action.NewList(cfg)
var outfmt output.Format 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.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.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(&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.BoolVar(&client.Pending, "pending", false, "show pending releases")
flags.BoolVarP(&client.AllNamespaces, "all-namespaces", "A", false, "list releases across all namespaces") 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") 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 // search if it exists a newer Chart in the Chart-Repository
repoResult, err := searchChart(results, r.Chart.Name(), r.Chart.Metadata.Version, devel) repoResult, err := searchChart(results, r.Chart.Name(), r.Chart.Metadata.Version, devel)
if err != nil { if err != nil {
if !ignoreNoRepo {
fmt.Fprintf(out, "%s", errors.Wrap(err, "ERROR: Could not initialize search index").Error()) fmt.Fprintf(out, "%s", errors.Wrap(err, "ERROR: Could not initialize search index").Error())
os.Exit(1) 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 // skip if no newer Chart was found

Loading…
Cancel
Save