From e900f05a162a887e1ebe0a748383b4c59a6ac36f Mon Sep 17 00:00:00 2001 From: hustclf Date: Wed, 4 Nov 2020 10:48:19 +0800 Subject: [PATCH] refactor: delay to get `CRDObjects()` when it is really needed. Signed-off-by: hustclf --- pkg/action/install.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pkg/action/install.go b/pkg/action/install.go index caeefca68..2bb88a906 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -181,14 +181,16 @@ func (i *Install) Run(chrt *chart.Chart, vals map[string]interface{}) (*release. return nil, err } - // Pre-install anything in the crd/ directory. We do this before Helm + // Pre-install anything in the crds/ directory. We do this before Helm // contacts the upstream server and builds the capabilities object. - if crds := chrt.CRDObjects(); !i.ClientOnly && !i.SkipCRDs && len(crds) > 0 { + if !i.ClientOnly && !i.SkipCRDs { // On dry run, bail here if i.DryRun { i.cfg.Log("WARNING: This chart or one of its subcharts contains CRDs. Rendering may fail or contain inaccuracies.") - } else if err := i.installCRDs(crds); err != nil { - return nil, err + } else if crds := chrt.CRDObjects(); len(crds) > 0 { + if err := i.installCRDs(crds); err != nil { + return nil, err + } } }