optimize code (#1694)

* fix something

Signed-off-by: lijianxin <1430473452@qq.com>
This commit is contained in:
Peoplelike 2024-09-07 12:43:41 +08:00 committed by GitHub
parent 224e0f6c6a
commit b6ad96f105
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 1 deletions

View File

@ -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 != "---" {