mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-09 17:37:12 +00:00
26 lines
708 B
Go
26 lines
708 B
Go
package variables
|
|
|
|
import (
|
|
"fmt"
|
|
"path/filepath"
|
|
|
|
"github.com/go-git/go-billy/v5"
|
|
valuesapi "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/apis/values"
|
|
"github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/values"
|
|
)
|
|
|
|
func New(fs billy.Filesystem, resourcePath string, path string, vals *valuesapi.Values, 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)
|
|
}
|
|
vals = v
|
|
}
|
|
variables := Variables{
|
|
values: vals,
|
|
variables: parse(vars...),
|
|
}
|
|
return &variables, nil
|
|
}
|