From 56405e7445b1ec2dbbffd34485ffa7437a31ea1b Mon Sep 17 00:00:00 2001 From: Quan TRAN Date: Thu, 4 Mar 2021 01:32:50 +0100 Subject: [PATCH] panic with a clear message (#1693) --- pkg/state/state.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/state/state.go b/pkg/state/state.go index 40c9607a..0153ed4b 100644 --- a/pkg/state/state.go +++ b/pkg/state/state.go @@ -1988,8 +1988,12 @@ func markExcludedReleases(releases []ReleaseSpec, selectors []string, commonLabe if len(conditionSplit) != 2 { return nil, fmt.Errorf("Condition value must be in the form 'foo.enabled' where 'foo' can be modified as necessary") } - if values[conditionSplit[0]].(map[string]interface{})["enabled"] == true { - conditionMatch = true + if v, ok := values[conditionSplit[0]]; ok { + if v.(map[string]interface{})["enabled"] == true { + conditionMatch = true + } + } else { + panic(fmt.Sprintf("environment values does not contain field %s", conditionSplit[0])) } } res := Release{