1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-06 07:57:07 +00:00
kyverno/cmd/cli/kubectl-kyverno/variables/new.go
Charles-Edouard Brétéché d1138764f5
feat: add deprecation warnings in the CLI (#9222)
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
2023-12-20 12:45:26 +00:00

29 lines
844 B
Go

package variables
import (
"fmt"
"io"
"path/filepath"
"github.com/go-git/go-billy/v5"
"github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/apis/v1alpha1"
"github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/deprecations"
"github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/values"
)
func New(out io.Writer, fs billy.Filesystem, resourcePath string, path string, vals *v1alpha1.ValuesSpec, vars ...string) (*Variables, error) {
// if we already have values, skip the file
if vals == nil && path != "" {
v, err := values.Load(fs, filepath.Join(resourcePath, path))
if err != nil {
return nil, fmt.Errorf("unable to load variable file: %s (%w)", path, err)
}
deprecations.CheckValues(out, path, v)
vals = &v.ValuesSpec
}
variables := Variables{
values: vals,
variables: parse(vars...),
}
return &variables, nil
}