fix issue 1093 (#1094)

This commit is contained in:
yxxhero
2023-10-25 10:42:47 +08:00
committed by GitHub
parent 73c3058d31
commit 34ccbf9056
2 changed files with 13 additions and 3 deletions
+3 -1
View File
@@ -37,7 +37,9 @@ func forbidEnvironmentsWithReleases(filePath string, content []byte) (bool, erro
if k == "environments" || k == "releases" || k == "---" {
if _, ok := resultKeys[k]; !ok {
result = append(result, k)
resultKeys[k] = nil
if k != "---" {
resultKeys[k] = nil
}
}
}
}
+10 -2
View File
@@ -41,6 +41,14 @@ func TestForbidEnvironmentsWithReleases(t *testing.T) {
expectedErr: false,
isStrict: false,
},
{
name: "no error when has --- between releases and environments, and --- on top of helmfile.yaml.gotmpl",
filePath: "helmfile.yaml.gotmpl",
content: []byte("---\nenvironments:\n---\nreleases:\n"),
v1mode: false,
expectedErr: false,
isStrict: false,
},
{
name: "error when both releases and environments",
filePath: "helmfile.yaml.gotmpl",
@@ -50,8 +58,8 @@ func TestForbidEnvironmentsWithReleases(t *testing.T) {
isStrict: false,
},
{
name: "no error when both releases and environments for plain yaml on v1",
filePath: "helmfile.yaml.gotmpl",
name: "error when both releases and environments for plain yaml on v1",
filePath: "helmfile.yaml",
content: []byte("environments:\nreleases:\n"),
v1mode: true,
expectedErr: true,