mirror of
https://github.com/helmfile/helmfile.git
synced 2026-10-07 18:56:36 +02:00
Add helmfile state validate policy (#592)
This commit is contained in:
@@ -29,6 +29,7 @@ import (
|
||||
"github.com/helmfile/helmfile/pkg/filesystem"
|
||||
"github.com/helmfile/helmfile/pkg/helmexec"
|
||||
"github.com/helmfile/helmfile/pkg/maputil"
|
||||
"github.com/helmfile/helmfile/pkg/policy"
|
||||
"github.com/helmfile/helmfile/pkg/remote"
|
||||
"github.com/helmfile/helmfile/pkg/tmpl"
|
||||
)
|
||||
@@ -83,6 +84,30 @@ type ReleaseSetSpec struct {
|
||||
LockFile string `yaml:"lockFilePath,omitempty"`
|
||||
}
|
||||
|
||||
// helmStateAlias is helm state alias
|
||||
type helmStateAlias HelmState
|
||||
|
||||
func (hs HelmState) MarshalYAML() (interface{}, error) {
|
||||
return helmStateAlias(hs), nil
|
||||
}
|
||||
|
||||
func (hs *HelmState) UnmarshalYAML(value *yaml.Node) error {
|
||||
helmStateInfo := make(map[string]interface{})
|
||||
if err := value.DecodeWithOptions(&helmStateInfo, yaml.DecodeOptions{KnownFields: true}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
isStrict, err := policy.Checker(helmStateInfo)
|
||||
if err != nil {
|
||||
if isStrict {
|
||||
return err
|
||||
}
|
||||
fmt.Fprintf(os.Stderr, "Warning: %v\n", err)
|
||||
}
|
||||
|
||||
return value.DecodeWithOptions((*helmStateAlias)(hs), yaml.DecodeOptions{KnownFields: true})
|
||||
}
|
||||
|
||||
// HelmState structure for the helmfile
|
||||
type HelmState struct {
|
||||
basePath string
|
||||
|
||||
Reference in New Issue
Block a user