fix more issue
Signed-off-by: yxxhero <aiopsclub@163.com>
This commit is contained in:
parent
6e6b479473
commit
d933f95110
|
|
@ -414,7 +414,7 @@ releases:
|
|||
t.Run("fail due to unknown field with goccy/go-yaml", func(t *testing.T) {
|
||||
check(t, testcase{
|
||||
goccyGoYaml: true,
|
||||
error: `in ./helmfile.yaml: failed to read helmfile.yaml: reading document at index 1, you should add .gotmpl extension to your helmfile to enable helmfile to load it as a template since helmfile v1: [4:3] unknown field "foobar"
|
||||
error: `in ./helmfile.yaml: failed to read helmfile.yaml: reading document at index 1. Started seeing this since Helmfile v1? Add the .gotmpl file extension: [4:3] unknown field "foobar"
|
||||
2 | releases:
|
||||
3 | - name: app1
|
||||
> 4 | foobar: FOOBAR
|
||||
|
|
@ -426,7 +426,7 @@ releases:
|
|||
t.Run("fail due to unknown field with gopkg.in/yaml.v2", func(t *testing.T) {
|
||||
check(t, testcase{
|
||||
goccyGoYaml: false,
|
||||
error: `in ./helmfile.yaml: failed to read helmfile.yaml: reading document at index 1, you should add .gotmpl extension to your helmfile to enable helmfile to load it as a template since helmfile v1: yaml: unmarshal errors:
|
||||
error: `in ./helmfile.yaml: failed to read helmfile.yaml: reading document at index 1. Started seeing this since Helmfile v1? Add the .gotmpl file extension: yaml: unmarshal errors:
|
||||
line 4: field foobar not found in type state.ReleaseSpec`,
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
|
|
@ -109,7 +110,10 @@ func (c *StateCreator) Parse(content []byte, baseDir, file string) (*HelmState,
|
|||
if err == io.EOF {
|
||||
break
|
||||
} else if err != nil {
|
||||
return nil, &StateLoadError{fmt.Sprintf("failed to read %s: reading document at index %d, you should add .gotmpl extension to your helmfile to enable helmfile to load it as a template since helmfile v1", file, i), err}
|
||||
if filepath.Ext(file) != ".gotmpl" {
|
||||
return nil, &StateLoadError{fmt.Sprintf("failed to read %s: reading document at index %d. Started seeing this since Helmfile v1? Add the .gotmpl file extension", file, i), err}
|
||||
}
|
||||
return nil, &StateLoadError{fmt.Sprintf("failed to read %s: reading document at index %d", file, i), err}
|
||||
}
|
||||
|
||||
if err := mergo.Merge(&state, &intermediate, mergo.WithAppendSlice); err != nil {
|
||||
|
|
|
|||
Loading…
Reference in New Issue