From b6ad96f105ebb837f60426bc5b3091bbbdae433c Mon Sep 17 00:00:00 2001 From: Peoplelike <44111453+Peoplelike@users.noreply.github.com> Date: Sat, 7 Sep 2024 12:43:41 +0800 Subject: [PATCH] optimize code (#1694) * fix something Signed-off-by: lijianxin <1430473452@qq.com> --- pkg/policy/checker.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/policy/checker.go b/pkg/policy/checker.go index 8935d868..eea0a0cd 100644 --- a/pkg/policy/checker.go +++ b/pkg/policy/checker.go @@ -6,6 +6,7 @@ import ( "errors" "fmt" "regexp" + "slices" "strings" "github.com/helmfile/helmfile/pkg/runtime" @@ -34,7 +35,7 @@ func forbidEnvironmentsWithReleases(filePath string, content []byte) (bool, erro result := []string{} resultKeys := map[string]interface{}{} for _, k := range topKeys { - if k == "environments" || k == "releases" || k == "---" { + if slices.Contains([]string{"environments", "releases", "---"}, k) { if _, ok := resultKeys[k]; !ok { result = append(result, k) if k != "---" {