From a40debd42b309a44b97b6845e72158f51edf5f10 Mon Sep 17 00:00:00 2001 From: Simon Alling Date: Tue, 1 Oct 2019 18:29:53 +0200 Subject: [PATCH] ref(pkg/chartutil): Simplify processDependencyConditions Before this commit, `r.Enabled` was modified if and only if a boolean was found in the for loop, and in that case, it was assigned the value of said boolean, just in a more complicated way. Signed-off-by: Simon Alling --- pkg/chartutil/dependencies.go | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/pkg/chartutil/dependencies.go b/pkg/chartutil/dependencies.go index 6b644edda..39c6a1f60 100644 --- a/pkg/chartutil/dependencies.go +++ b/pkg/chartutil/dependencies.go @@ -36,7 +36,6 @@ func processDependencyConditions(reqs []*chart.Dependency, cvals Values) { return } for _, r := range reqs { - var hasTrue, hasFalse bool for _, c := range strings.Split(strings.TrimSpace(r.Condition), ",") { if len(c) > 0 { // retrieve value @@ -44,11 +43,8 @@ func processDependencyConditions(reqs []*chart.Dependency, cvals Values) { if err == nil { // if not bool, warn if bv, ok := vv.(bool); ok { - if bv { - hasTrue = true - } else { - hasFalse = true - } + r.Enabled = bv + break } else { log.Printf("Warning: Condition path '%s' for chart %s returned non-bool value", c, r.Name) } @@ -56,18 +52,8 @@ func processDependencyConditions(reqs []*chart.Dependency, cvals Values) { // this is a real error log.Printf("Warning: PathValue returned error %v", err) } - if vv != nil { - // got first value, break loop - break - } } } - if !hasTrue && hasFalse { - r.Enabled = false - } else if hasTrue { - r.Enabled = true - - } } }