fix issue 1093 (#1094)
This commit is contained in:
parent
73c3058d31
commit
34ccbf9056
|
|
@ -37,10 +37,12 @@ func forbidEnvironmentsWithReleases(filePath string, content []byte) (bool, erro
|
||||||
if k == "environments" || k == "releases" || k == "---" {
|
if k == "environments" || k == "releases" || k == "---" {
|
||||||
if _, ok := resultKeys[k]; !ok {
|
if _, ok := resultKeys[k]; !ok {
|
||||||
result = append(result, k)
|
result = append(result, k)
|
||||||
|
if k != "---" {
|
||||||
resultKeys[k] = nil
|
resultKeys[k] = nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if len(result) < 2 {
|
if len(result) < 2 {
|
||||||
return false, nil
|
return false, nil
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,14 @@ func TestForbidEnvironmentsWithReleases(t *testing.T) {
|
||||||
expectedErr: false,
|
expectedErr: false,
|
||||||
isStrict: 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",
|
name: "error when both releases and environments",
|
||||||
filePath: "helmfile.yaml.gotmpl",
|
filePath: "helmfile.yaml.gotmpl",
|
||||||
|
|
@ -50,8 +58,8 @@ func TestForbidEnvironmentsWithReleases(t *testing.T) {
|
||||||
isStrict: false,
|
isStrict: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "no error when both releases and environments for plain yaml on v1",
|
name: "error when both releases and environments for plain yaml on v1",
|
||||||
filePath: "helmfile.yaml.gotmpl",
|
filePath: "helmfile.yaml",
|
||||||
content: []byte("environments:\nreleases:\n"),
|
content: []byte("environments:\nreleases:\n"),
|
||||||
v1mode: true,
|
v1mode: true,
|
||||||
expectedErr: true,
|
expectedErr: true,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue