Replace interface{} by any (#901)
Signed-off-by: yxxhero <aiopsclub@163.com>
This commit is contained in:
parent
94fe519ed5
commit
c55fa0f765
|
|
@ -41,7 +41,7 @@ type App struct {
|
|||
Selectors []string
|
||||
Args string
|
||||
ValuesFiles []string
|
||||
Set map[string]interface{}
|
||||
Set map[string]any
|
||||
|
||||
FileOrDir string
|
||||
|
||||
|
|
@ -1056,7 +1056,7 @@ func (a *App) visitStatesWithSelectorsAndRemoteSupport(fileOrDir string, converg
|
|||
o(&opts)
|
||||
}
|
||||
|
||||
envvals := []interface{}{}
|
||||
envvals := []any{}
|
||||
|
||||
for _, v := range a.ValuesFiles {
|
||||
envvals = append(envvals, v)
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ func injectFs(app *App, fs *testhelper.TestFs) *App {
|
|||
if app.Set == nil {
|
||||
// Consistent behavior with NewGlobalImpl.
|
||||
// Doesn't really belong here, but simplest place for it until some refactoring happens
|
||||
app.Set = make(map[string]interface{})
|
||||
app.Set = make(map[string]any)
|
||||
}
|
||||
|
||||
app.fs = fs.ToFileSystem()
|
||||
|
|
@ -1019,7 +1019,7 @@ bar: "bar1"
|
|||
Selectors: []string{},
|
||||
Env: "default",
|
||||
ValuesFiles: []string{"overrides.yaml"},
|
||||
Set: map[string]interface{}{"bar": "bar2", "baz": "baz1"},
|
||||
Set: map[string]any{"bar": "bar2", "baz": "baz1"},
|
||||
FileOrDir: "helmfile.yaml",
|
||||
}, files)
|
||||
|
||||
|
|
@ -1140,7 +1140,7 @@ x:
|
|||
Selectors: []string{},
|
||||
Env: testcase.env,
|
||||
ValuesFiles: []string{"overrides.yaml"},
|
||||
Set: map[string]interface{}{"x": map[string]interface{}{"hoge": "hoge_set", "fuga": "fuga_set"}},
|
||||
Set: map[string]any{"x": map[string]any{"hoge": "hoge_set", "fuga": "fuga_set"}},
|
||||
FileOrDir: "helmfile.yaml",
|
||||
}, files)
|
||||
|
||||
|
|
@ -1920,15 +1920,15 @@ releases:
|
|||
// See https://github.com/roboll/helmfile/issues/623
|
||||
func TestLoadDesiredStateFromYaml_MultiPartTemplate_MergeMapsVariousKeys(t *testing.T) {
|
||||
type testcase struct {
|
||||
overrideValues interface{}
|
||||
overrideValues any
|
||||
expected string
|
||||
}
|
||||
testcases := []testcase{
|
||||
{map[interface{}]interface{}{"foo": "FOO"}, `FOO`},
|
||||
{map[interface{}]interface{}{"foo": map[interface{}]interface{}{"foo": "FOO"}}, `map[foo:FOO]`},
|
||||
{map[interface{}]interface{}{"foo": map[string]interface{}{"foo": "FOO"}}, `map[foo:FOO]`},
|
||||
{map[interface{}]interface{}{"foo": []interface{}{"foo"}}, `[foo]`},
|
||||
{map[interface{}]interface{}{"foo": "FOO"}, `FOO`},
|
||||
{map[any]any{"foo": "FOO"}, `FOO`},
|
||||
{map[any]any{"foo": map[any]any{"foo": "FOO"}}, `map[foo:FOO]`},
|
||||
{map[any]any{"foo": map[string]any{"foo": "FOO"}}, `map[foo:FOO]`},
|
||||
{map[any]any{"foo": []any{"foo"}}, `[foo]`},
|
||||
{map[any]any{"foo": "FOO"}, `FOO`},
|
||||
}
|
||||
for i := range testcases {
|
||||
tc := testcases[i]
|
||||
|
|
@ -1960,7 +1960,7 @@ releases:
|
|||
opts := LoadOpts{
|
||||
CalleePath: statePath,
|
||||
Environment: state.SubhelmfileEnvironmentSpec{
|
||||
OverrideValues: []interface{}{tc.overrideValues},
|
||||
OverrideValues: []any{tc.overrideValues},
|
||||
},
|
||||
Reverse: true,
|
||||
}
|
||||
|
|
@ -2017,7 +2017,7 @@ releases:
|
|||
{stateInline, `{{ if hasKey .Environment.Values "bar" }}{{ .Environment.Values.bar.baz }}{{ end }}`, `BAZ`},
|
||||
{stateInline, `{{ if (keys .Environment.Values | has "foo") }}{{ .Environment.Values.foo }}{{ end }}`, `FOO`},
|
||||
// See https://github.com/roboll/helmfile/issues/624
|
||||
// This fails when .Environment.Values.bar is not map[string]interface{}. At the time of #624 it was map[interface{}]interface{}, which sprig's dict funcs don't support.
|
||||
// This fails when .Environment.Values.bar is not map[string]any. At the time of #624 it was map[any]any, which sprig's dict funcs don't support.
|
||||
{stateInline, `{{ if (keys .Environment.Values | has "bar") }}{{ if (keys .Environment.Values.bar | has "baz") }}{{ .Environment.Values.bar.baz }}{{ end }}{{ end }}`, `BAZ`},
|
||||
{stateExternal, `{{ getOrNil "foo" .Environment.Values }}`, `FOO`},
|
||||
{stateExternal, `{{ getOrNil "baz" (getOrNil "bar" .Environment.Values) }}`, `BAZ`},
|
||||
|
|
@ -2035,7 +2035,7 @@ releases:
|
|||
{stateInline, `{{ if hasKey .Values "bar" }}{{ .Values.bar.baz }}{{ end }}`, `BAZ`},
|
||||
{stateInline, `{{ if (keys .Values | has "foo") }}{{ .Values.foo }}{{ end }}`, `FOO`},
|
||||
// See https://github.com/roboll/helmfile/issues/624
|
||||
// This fails when .Values.bar is not map[string]interface{}. At the time of #624 it was map[interface{}]interface{}, which sprig's dict funcs don't support.
|
||||
// This fails when .Values.bar is not map[string]any. At the time of #624 it was map[any]any, which sprig's dict funcs don't support.
|
||||
{stateInline, `{{ if (keys .Values | has "bar") }}{{ if (keys .Values.bar | has "baz") }}{{ .Values.bar.baz }}{{ end }}{{ end }}`, `BAZ`},
|
||||
{stateExternal, `{{ getOrNil "foo" .Values }}`, `FOO`},
|
||||
{stateExternal, `{{ getOrNil "baz" (getOrNil "bar" .Values) }}`, `BAZ`},
|
||||
|
|
@ -4204,9 +4204,9 @@ releases:
|
|||
value: val-{{"{{ .Release.Name }}"}}
|
||||
`,
|
||||
}
|
||||
expectedValues := []interface{}{
|
||||
map[string]interface{}{"val1": "zipkin"},
|
||||
map[string]interface{}{"val2": "val2"}}
|
||||
expectedValues := []any{
|
||||
map[string]any{"val1": "zipkin"},
|
||||
map[string]any{"val2": "val2"}}
|
||||
expectedSetValues := []state.SetValue{
|
||||
{Name: "name-zipkin", Value: "val-zipkin"},
|
||||
{Name: "name", Value: "val"}}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ type ConfigProvider interface {
|
|||
Namespace() string
|
||||
Chart() string
|
||||
Selectors() []string
|
||||
StateValuesSet() map[string]interface{}
|
||||
StateValuesSet() map[string]any
|
||||
StateValuesFiles() []string
|
||||
Env() string
|
||||
|
||||
|
|
@ -266,7 +266,7 @@ type ListConfigProvider interface {
|
|||
SkipCharts() bool
|
||||
}
|
||||
|
||||
type CacheConfigProvider interface{}
|
||||
type CacheConfigProvider any
|
||||
|
||||
type InitConfigProvider interface {
|
||||
Force() bool
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ func (r *desiredStateLoader) renderPrestate(firstPassEnv, overrode *environment.
|
|||
if err != nil {
|
||||
return firstPassEnv, nil
|
||||
}
|
||||
tmplData := state.NewEnvironmentTemplateData(*initEnv, r.namespace, map[string]interface{}{})
|
||||
tmplData := state.NewEnvironmentTemplateData(*initEnv, r.namespace, map[string]any{})
|
||||
firstPassRenderer := tmpl.NewFirstPassRenderer(baseDir, tmplData)
|
||||
|
||||
// parse as much as we can, tolerate errors, this is a preparse
|
||||
|
|
@ -72,7 +72,7 @@ type RenderOpts struct {
|
|||
}
|
||||
|
||||
func (r *desiredStateLoader) renderTemplatesToYaml(baseDir, filename string, content []byte) (*bytes.Buffer, error) {
|
||||
env := &environment.Environment{Name: r.env, Values: map[string]interface{}(nil)}
|
||||
env := &environment.Environment{Name: r.env, Values: map[string]any(nil)}
|
||||
|
||||
return r.renderTemplatesToYamlWithEnv(baseDir, filename, content, env, nil)
|
||||
}
|
||||
|
|
@ -97,7 +97,7 @@ func (r *desiredStateLoader) twoPassRenderTemplateToYaml(inherited, overrode *en
|
|||
var (
|
||||
renderingPhase string
|
||||
finalEnv *environment.Environment
|
||||
vals map[string]interface{}
|
||||
vals map[string]any
|
||||
)
|
||||
|
||||
if runtime.V1Mode {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import (
|
|||
func NewCLIConfigImpl(g *GlobalImpl) error {
|
||||
optsSet := g.RawStateValuesSet()
|
||||
if len(optsSet) > 0 {
|
||||
set := map[string]interface{}{}
|
||||
set := map[string]any{}
|
||||
for i := range optsSet {
|
||||
ops := strings.Split(optsSet[i], ",")
|
||||
for j := range ops {
|
||||
|
|
|
|||
|
|
@ -72,19 +72,19 @@ func (g *GlobalOptions) SetLogger(logger *zap.SugaredLogger) {
|
|||
// GlobalImpl is the global configuration for the Helmfile CLI.
|
||||
type GlobalImpl struct {
|
||||
*GlobalOptions
|
||||
set map[string]interface{}
|
||||
set map[string]any
|
||||
}
|
||||
|
||||
// NewGlobalImpl creates a new GlobalImpl.
|
||||
func NewGlobalImpl(opts *GlobalOptions) *GlobalImpl {
|
||||
return &GlobalImpl{
|
||||
GlobalOptions: opts,
|
||||
set: make(map[string]interface{}),
|
||||
set: make(map[string]any),
|
||||
}
|
||||
}
|
||||
|
||||
// Setset sets the set
|
||||
func (g *GlobalImpl) SetSet(set map[string]interface{}) {
|
||||
func (g *GlobalImpl) SetSet(set map[string]any) {
|
||||
g.set = set
|
||||
}
|
||||
|
||||
|
|
@ -119,7 +119,7 @@ func (g *GlobalImpl) Selectors() []string {
|
|||
}
|
||||
|
||||
// StateValuesSet returns the set
|
||||
func (g *GlobalImpl) StateValuesSet() map[string]interface{} {
|
||||
func (g *GlobalImpl) StateValuesSet() map[string]any {
|
||||
return g.set
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ import (
|
|||
type Environment struct {
|
||||
Name string
|
||||
KubeContext string
|
||||
Values map[string]interface{}
|
||||
Defaults map[string]interface{}
|
||||
Values map[string]any
|
||||
Defaults map[string]any
|
||||
}
|
||||
|
||||
var EmptyEnvironment Environment
|
||||
|
|
@ -21,8 +21,8 @@ func New(name string) *Environment {
|
|||
return &Environment{
|
||||
Name: name,
|
||||
KubeContext: "",
|
||||
Values: map[string]interface{}{},
|
||||
Defaults: map[string]interface{}{},
|
||||
Values: map[string]any{},
|
||||
Defaults: map[string]any{},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -31,7 +31,7 @@ func (e Environment) DeepCopy() Environment {
|
|||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
var values map[string]interface{}
|
||||
var values map[string]any
|
||||
if err := yaml.Unmarshal(valuesBytes, &values); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
@ -44,7 +44,7 @@ func (e Environment) DeepCopy() Environment {
|
|||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
var defaults map[string]interface{}
|
||||
var defaults map[string]any
|
||||
if err := yaml.Unmarshal(defaultsBytes, &defaults); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
@ -78,8 +78,8 @@ func (e *Environment) Merge(other *Environment) (*Environment, error) {
|
|||
return ©, nil
|
||||
}
|
||||
|
||||
func (e *Environment) GetMergedValues() (map[string]interface{}, error) {
|
||||
vals := map[string]interface{}{}
|
||||
func (e *Environment) GetMergedValues() (map[string]any, error) {
|
||||
vals := map[string]any{}
|
||||
|
||||
if err := mergo.Merge(&vals, e.Defaults, mergo.WithOverride); err != nil {
|
||||
return nil, err
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ import (
|
|||
func TestMerge_OverwriteNilValue_Issue1150(t *testing.T) {
|
||||
dst := &Environment{
|
||||
Name: "dst",
|
||||
Values: map[string]interface{}{
|
||||
"components": map[string]interface{}{
|
||||
Values: map[string]any{
|
||||
"components": map[string]any{
|
||||
"etcd-operator": nil,
|
||||
},
|
||||
},
|
||||
|
|
@ -21,9 +21,9 @@ func TestMerge_OverwriteNilValue_Issue1150(t *testing.T) {
|
|||
|
||||
src := &Environment{
|
||||
Name: "src",
|
||||
Values: map[string]interface{}{
|
||||
"components": map[string]interface{}{
|
||||
"etcd-operator": map[string]interface{}{
|
||||
Values: map[string]any{
|
||||
"components": map[string]any{
|
||||
"etcd-operator": map[string]any{
|
||||
"version": "0.10.3",
|
||||
},
|
||||
},
|
||||
|
|
@ -38,9 +38,9 @@ func TestMerge_OverwriteNilValue_Issue1150(t *testing.T) {
|
|||
|
||||
actual := merged.Values
|
||||
|
||||
expected := map[string]interface{}{
|
||||
"components": map[string]interface{}{
|
||||
"etcd-operator": map[string]interface{}{
|
||||
expected := map[string]any{
|
||||
"components": map[string]any{
|
||||
"etcd-operator": map[string]any{
|
||||
"version": "0.10.3",
|
||||
},
|
||||
},
|
||||
|
|
@ -55,9 +55,9 @@ func TestMerge_OverwriteNilValue_Issue1150(t *testing.T) {
|
|||
func TestMerge_OverwriteWithNilValue_Issue1154(t *testing.T) {
|
||||
dst := &Environment{
|
||||
Name: "dst",
|
||||
Values: map[string]interface{}{
|
||||
"components": map[string]interface{}{
|
||||
"etcd-operator": map[string]interface{}{
|
||||
Values: map[string]any{
|
||||
"components": map[string]any{
|
||||
"etcd-operator": map[string]any{
|
||||
"version": "0.10.0",
|
||||
},
|
||||
},
|
||||
|
|
@ -67,9 +67,9 @@ func TestMerge_OverwriteWithNilValue_Issue1154(t *testing.T) {
|
|||
|
||||
src := &Environment{
|
||||
Name: "src",
|
||||
Values: map[string]interface{}{
|
||||
"components": map[string]interface{}{
|
||||
"etcd-operator": map[string]interface{}{
|
||||
Values: map[string]any{
|
||||
"components": map[string]any{
|
||||
"etcd-operator": map[string]any{
|
||||
"version": "0.10.3",
|
||||
},
|
||||
"prometheus": nil,
|
||||
|
|
@ -85,9 +85,9 @@ func TestMerge_OverwriteWithNilValue_Issue1154(t *testing.T) {
|
|||
|
||||
actual := merged.Values
|
||||
|
||||
expected := map[string]interface{}{
|
||||
"components": map[string]interface{}{
|
||||
"etcd-operator": map[string]interface{}{
|
||||
expected := map[string]any{
|
||||
"components": map[string]any{
|
||||
"etcd-operator": map[string]any{
|
||||
"version": "0.10.3",
|
||||
},
|
||||
"prometheus": nil,
|
||||
|
|
|
|||
|
|
@ -51,11 +51,11 @@ type ExitCoder interface {
|
|||
// ExitError fulfills both the builtin `error` interface and `ExitCoder`
|
||||
type ExitError struct {
|
||||
exitCode int
|
||||
message interface{}
|
||||
message any
|
||||
}
|
||||
|
||||
// NewExitError makes a new *ExitError
|
||||
func NewExitError(message interface{}, exitCode int) *ExitError {
|
||||
func NewExitError(message any, exitCode int) *ExitError {
|
||||
return &ExitError{
|
||||
exitCode: exitCode,
|
||||
message: message,
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ var (
|
|||
}
|
||||
)
|
||||
|
||||
func expect(t *testing.T, a interface{}, b interface{}) {
|
||||
func expect(t *testing.T, a any, b any) {
|
||||
_, fn, line, _ := runtime.Caller(1)
|
||||
fn = strings.Replace(fn, wd+"/", "", -1)
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ type Bus struct {
|
|||
Logger *zap.SugaredLogger
|
||||
}
|
||||
|
||||
func (bus *Bus) Trigger(evt string, evtErr error, context map[string]interface{}) (bool, error) {
|
||||
func (bus *Bus) Trigger(evt string, evtErr error, context map[string]any) (bool, error) {
|
||||
if bus.Runner == nil {
|
||||
bus.Runner = helmexec.ShellRunner{
|
||||
Dir: bus.BasePath,
|
||||
|
|
@ -94,7 +94,7 @@ func (bus *Bus) Trigger(evt string, evtErr error, context map[string]interface{}
|
|||
|
||||
bus.Logger.Debugf("hook[%s]: stateFilePath=%s, basePath=%s\n", name, bus.StateFilePath, bus.BasePath)
|
||||
|
||||
data := map[string]interface{}{
|
||||
data := map[string]any{
|
||||
"Environment": bus.Env,
|
||||
"Namespace": bus.Namespace,
|
||||
"Event": event{
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ func TestTrigger(t *testing.T) {
|
|||
}
|
||||
|
||||
bus.Runner = &runner{}
|
||||
data := map[string]interface{}{
|
||||
data := map[string]any{
|
||||
"Release": "myrel",
|
||||
"HelmfileCommand": "mycmd",
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@ import (
|
|||
"strings"
|
||||
)
|
||||
|
||||
func CastKeysToStrings(s interface{}) (map[string]interface{}, error) {
|
||||
new := map[string]interface{}{}
|
||||
func CastKeysToStrings(s any) (map[string]any, error) {
|
||||
new := map[string]any{}
|
||||
switch src := s.(type) {
|
||||
case map[interface{}]interface{}:
|
||||
case map[any]any:
|
||||
for k, v := range src {
|
||||
var strK string
|
||||
switch typedK := k.(type) {
|
||||
|
|
@ -25,7 +25,7 @@ func CastKeysToStrings(s interface{}) (map[string]interface{}, error) {
|
|||
|
||||
new[strK] = castedV
|
||||
}
|
||||
case map[string]interface{}:
|
||||
case map[string]any:
|
||||
for k, v := range src {
|
||||
castedV, err := recursivelyStringifyMapKey(v)
|
||||
if err != nil {
|
||||
|
|
@ -38,17 +38,17 @@ func CastKeysToStrings(s interface{}) (map[string]interface{}, error) {
|
|||
return new, nil
|
||||
}
|
||||
|
||||
func recursivelyStringifyMapKey(v interface{}) (interface{}, error) {
|
||||
var castedV interface{}
|
||||
func recursivelyStringifyMapKey(v any) (any, error) {
|
||||
var castedV any
|
||||
switch typedV := v.(type) {
|
||||
case map[interface{}]interface{}, map[string]interface{}:
|
||||
case map[any]any, map[string]any:
|
||||
tmp, err := CastKeysToStrings(typedV)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
castedV = tmp
|
||||
case []interface{}:
|
||||
a := []interface{}{}
|
||||
case []any:
|
||||
a := []any{}
|
||||
for i := range typedV {
|
||||
res, err := recursivelyStringifyMapKey(typedV[i])
|
||||
if err != nil {
|
||||
|
|
@ -64,28 +64,28 @@ func recursivelyStringifyMapKey(v interface{}) (interface{}, error) {
|
|||
}
|
||||
|
||||
type arg interface {
|
||||
getMap(map[string]interface{}) map[string]interface{}
|
||||
set(map[string]interface{}, string)
|
||||
getMap(map[string]any) map[string]any
|
||||
set(map[string]any, string)
|
||||
}
|
||||
|
||||
type keyArg struct {
|
||||
key string
|
||||
}
|
||||
|
||||
func (a keyArg) getMap(m map[string]interface{}) map[string]interface{} {
|
||||
func (a keyArg) getMap(m map[string]any) map[string]any {
|
||||
_, ok := m[a.key]
|
||||
if !ok {
|
||||
m[a.key] = map[string]interface{}{}
|
||||
m[a.key] = map[string]any{}
|
||||
}
|
||||
switch t := m[a.key].(type) {
|
||||
case map[string]interface{}:
|
||||
case map[string]any:
|
||||
return t
|
||||
default:
|
||||
panic(fmt.Errorf("unexpected type: %v(%T)", t, t))
|
||||
}
|
||||
}
|
||||
|
||||
func (a keyArg) set(m map[string]interface{}, value string) {
|
||||
func (a keyArg) set(m map[string]any, value string) {
|
||||
m[a.key] = value
|
||||
}
|
||||
|
||||
|
|
@ -94,15 +94,15 @@ type indexedKeyArg struct {
|
|||
index int
|
||||
}
|
||||
|
||||
func (a indexedKeyArg) getArray(m map[string]interface{}) []interface{} {
|
||||
func (a indexedKeyArg) getArray(m map[string]any) []any {
|
||||
_, ok := m[a.key]
|
||||
if !ok {
|
||||
m[a.key] = make([]interface{}, a.index+1)
|
||||
m[a.key] = make([]any, a.index+1)
|
||||
}
|
||||
switch t := m[a.key].(type) {
|
||||
case []interface{}:
|
||||
case []any:
|
||||
if len(t) <= a.index {
|
||||
t2 := make([]interface{}, a.index+1)
|
||||
t2 := make([]any, a.index+1)
|
||||
copy(t2, t)
|
||||
t = t2
|
||||
}
|
||||
|
|
@ -112,20 +112,20 @@ func (a indexedKeyArg) getArray(m map[string]interface{}) []interface{} {
|
|||
}
|
||||
}
|
||||
|
||||
func (a indexedKeyArg) getMap(m map[string]interface{}) map[string]interface{} {
|
||||
func (a indexedKeyArg) getMap(m map[string]any) map[string]any {
|
||||
t := a.getArray(m)
|
||||
if t[a.index] == nil {
|
||||
t[a.index] = map[string]interface{}{}
|
||||
t[a.index] = map[string]any{}
|
||||
}
|
||||
switch t := t[a.index].(type) {
|
||||
case map[string]interface{}:
|
||||
case map[string]any:
|
||||
return t
|
||||
default:
|
||||
panic(fmt.Errorf("unexpected type: %v(%T)", t, t))
|
||||
}
|
||||
}
|
||||
|
||||
func (a indexedKeyArg) set(m map[string]interface{}, value string) {
|
||||
func (a indexedKeyArg) set(m map[string]any, value string) {
|
||||
t := a.getArray(m)
|
||||
t[a.index] = value
|
||||
m[a.key] = t
|
||||
|
|
@ -178,7 +178,7 @@ func ParseKey(key string) []string {
|
|||
return r
|
||||
}
|
||||
|
||||
func Set(m map[string]interface{}, key []string, value string) {
|
||||
func Set(m map[string]any, key []string, value string) {
|
||||
if len(key) == 0 {
|
||||
panic(fmt.Errorf("bug: unexpected length of key: %d", len(key)))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,11 +7,11 @@ import (
|
|||
)
|
||||
|
||||
func TestMapUtil_StrKeys(t *testing.T) {
|
||||
m := map[string]interface{}{
|
||||
"a": []interface{}{
|
||||
map[string]interface{}{
|
||||
"b": []interface{}{
|
||||
map[string]interface{}{
|
||||
m := map[string]any{
|
||||
"a": []any{
|
||||
map[string]any{
|
||||
"b": []any{
|
||||
map[string]any{
|
||||
"c": "C",
|
||||
},
|
||||
},
|
||||
|
|
@ -24,10 +24,10 @@ func TestMapUtil_StrKeys(t *testing.T) {
|
|||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
|
||||
a := r["a"].([]interface{})
|
||||
a0 := a[0].(map[string]interface{})
|
||||
b := a0["b"].([]interface{})
|
||||
b0 := b[0].(map[string]interface{})
|
||||
a := r["a"].([]any)
|
||||
a0 := a[0].(map[string]any)
|
||||
b := a0["b"].([]any)
|
||||
b0 := b[0].(map[string]any)
|
||||
c := b0["c"]
|
||||
|
||||
if c != "C" {
|
||||
|
|
@ -36,11 +36,11 @@ func TestMapUtil_StrKeys(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestMapUtil_IFKeys(t *testing.T) {
|
||||
m := map[interface{}]interface{}{
|
||||
"a": []interface{}{
|
||||
map[interface{}]interface{}{
|
||||
"b": []interface{}{
|
||||
map[interface{}]interface{}{
|
||||
m := map[any]any{
|
||||
"a": []any{
|
||||
map[any]any{
|
||||
"b": []any{
|
||||
map[any]any{
|
||||
"c": "C",
|
||||
},
|
||||
},
|
||||
|
|
@ -53,10 +53,10 @@ func TestMapUtil_IFKeys(t *testing.T) {
|
|||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
|
||||
a := r["a"].([]interface{})
|
||||
a0 := a[0].(map[string]interface{})
|
||||
b := a0["b"].([]interface{})
|
||||
b0 := b[0].(map[string]interface{})
|
||||
a := r["a"].([]any)
|
||||
a0 := a[0].(map[string]any)
|
||||
b := a0["b"].([]any)
|
||||
b0 := b[0].(map[string]any)
|
||||
c := b0["c"]
|
||||
|
||||
if c != "C" {
|
||||
|
|
@ -65,13 +65,13 @@ func TestMapUtil_IFKeys(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestMapUtil_KeyArg(t *testing.T) {
|
||||
m := map[string]interface{}{}
|
||||
m := map[string]any{}
|
||||
|
||||
key := []string{"a", "b", "c"}
|
||||
|
||||
Set(m, key, "C")
|
||||
|
||||
c := (((m["a"].(map[string]interface{}))["b"]).(map[string]interface{}))["c"]
|
||||
c := (((m["a"].(map[string]any))["b"]).(map[string]any))["c"]
|
||||
|
||||
if c != "C" {
|
||||
t.Errorf("unexpected c: expected=C, got=%s", c)
|
||||
|
|
@ -79,13 +79,13 @@ func TestMapUtil_KeyArg(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestMapUtil_IndexedKeyArg(t *testing.T) {
|
||||
m := map[string]interface{}{}
|
||||
m := map[string]any{}
|
||||
|
||||
key := []string{"a", "b[0]", "c"}
|
||||
|
||||
Set(m, key, "C")
|
||||
|
||||
c := (((m["a"].(map[string]interface{}))["b"].([]interface{}))[0].(map[string]interface{}))["c"]
|
||||
c := (((m["a"].(map[string]any))["b"].([]any))[0].(map[string]any))["c"]
|
||||
|
||||
if c != "C" {
|
||||
t.Errorf("unexpected c: expected=C, got=%s", c)
|
||||
|
|
@ -96,27 +96,27 @@ func TestMapUtil_IndexedKeyArg2(t *testing.T) {
|
|||
cases := []struct {
|
||||
name string
|
||||
stateValuesSet []string
|
||||
want map[string]interface{}
|
||||
want map[string]any
|
||||
}{
|
||||
{
|
||||
name: "IndexedKeyArg",
|
||||
stateValuesSet: []string{"myvalues[0]=HELLO,myvalues[1]=HELMFILE"},
|
||||
want: map[string]interface{}{"myvalues": []interface{}{"HELLO", "HELMFILE"}},
|
||||
want: map[string]any{"myvalues": []any{"HELLO", "HELMFILE"}},
|
||||
},
|
||||
{
|
||||
name: "two state value",
|
||||
stateValuesSet: []string{"myvalues[0]=HELLO,myvalues[1]=HELMFILE", "myvalues[2]=HELLO"},
|
||||
want: map[string]interface{}{"myvalues": []interface{}{"HELLO", "HELMFILE", "HELLO"}},
|
||||
want: map[string]any{"myvalues": []any{"HELLO", "HELMFILE", "HELLO"}},
|
||||
},
|
||||
{
|
||||
name: "different key",
|
||||
stateValuesSet: []string{"myvalues[0]=HELLO,key2[0]=HELMFILE", "myvalues[1]=HELLO2"},
|
||||
want: map[string]interface{}{"myvalues": []interface{}{"HELLO", "HELLO2"}, "key2": []interface{}{"HELMFILE"}},
|
||||
want: map[string]any{"myvalues": []any{"HELLO", "HELLO2"}, "key2": []any{"HELMFILE"}},
|
||||
},
|
||||
}
|
||||
for _, c := range cases {
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
set := map[string]interface{}{}
|
||||
set := map[string]any{}
|
||||
for i := range c.stateValuesSet {
|
||||
ops := strings.Split(c.stateValuesSet[i], ",")
|
||||
for j := range ops {
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@ var (
|
|||
)
|
||||
|
||||
// checkerFunc is a function that checks the helmState.
|
||||
type checkerFunc func(string, map[string]interface{}) (bool, error)
|
||||
type checkerFunc func(string, map[string]any) (bool, error)
|
||||
|
||||
func forbidEnvironmentsWithReleases(filePath string, releaseState map[string]interface{}) (bool, error) {
|
||||
func forbidEnvironmentsWithReleases(filePath string, releaseState map[string]any) (bool, error) {
|
||||
// forbid environments and releases to be defined at the same yaml part
|
||||
_, hasEnvironments := releaseState["environments"]
|
||||
_, hasReleases := releaseState["releases"]
|
||||
|
|
@ -30,7 +30,7 @@ var checkerFuncs = []checkerFunc{
|
|||
}
|
||||
|
||||
// Checker is a policy checker for the helmfile state.
|
||||
func Checker(filePath string, helmState map[string]interface{}) (bool, error) {
|
||||
func Checker(filePath string, helmState map[string]any) (bool, error) {
|
||||
for _, fn := range checkerFuncs {
|
||||
if isStrict, err := fn(filePath, helmState); err != nil {
|
||||
return isStrict, err
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ func TestForbidEnvironmentsWithReleases(t *testing.T) {
|
|||
name string
|
||||
filePath string
|
||||
v1mode bool
|
||||
helmState map[string]interface{}
|
||||
helmState map[string]any
|
||||
expectedErr bool
|
||||
isStrict bool
|
||||
}{
|
||||
|
|
@ -21,8 +21,8 @@ func TestForbidEnvironmentsWithReleases(t *testing.T) {
|
|||
name: "no error when only releases",
|
||||
filePath: "helmfile.yaml",
|
||||
v1mode: false,
|
||||
helmState: map[string]interface{}{
|
||||
"releases": interface{}(nil),
|
||||
helmState: map[string]any{
|
||||
"releases": any(nil),
|
||||
},
|
||||
expectedErr: false,
|
||||
isStrict: false,
|
||||
|
|
@ -31,8 +31,8 @@ func TestForbidEnvironmentsWithReleases(t *testing.T) {
|
|||
name: "no error when only environments",
|
||||
filePath: "helmfile.yaml",
|
||||
v1mode: false,
|
||||
helmState: map[string]interface{}{
|
||||
"environments": map[string]interface{}{},
|
||||
helmState: map[string]any{
|
||||
"environments": map[string]any{},
|
||||
},
|
||||
expectedErr: false,
|
||||
isStrict: false,
|
||||
|
|
@ -41,9 +41,9 @@ func TestForbidEnvironmentsWithReleases(t *testing.T) {
|
|||
name: "error when both releases and environments",
|
||||
filePath: "helmfile.yaml",
|
||||
v1mode: false,
|
||||
helmState: map[string]interface{}{
|
||||
"environments": interface{}(nil),
|
||||
"releases": interface{}(nil),
|
||||
helmState: map[string]any{
|
||||
"environments": any(nil),
|
||||
"releases": any(nil),
|
||||
},
|
||||
expectedErr: true,
|
||||
isStrict: false,
|
||||
|
|
@ -52,9 +52,9 @@ func TestForbidEnvironmentsWithReleases(t *testing.T) {
|
|||
name: "no error when both releases and environments for plain yaml on v1",
|
||||
filePath: "helmfile.yaml",
|
||||
v1mode: true,
|
||||
helmState: map[string]interface{}{
|
||||
"environments": interface{}(nil),
|
||||
"releases": interface{}(nil),
|
||||
helmState: map[string]any{
|
||||
"environments": any(nil),
|
||||
"releases": any(nil),
|
||||
},
|
||||
expectedErr: false,
|
||||
isStrict: false,
|
||||
|
|
|
|||
|
|
@ -222,7 +222,7 @@ func (c *StateCreator) loadBases(envValues, overrodeEnv *environment.Environment
|
|||
|
||||
// nolint: unparam
|
||||
func (c *StateCreator) loadEnvValues(st *HelmState, name string, failOnMissingEnv bool, ctxEnv, overrode *environment.Environment) (*environment.Environment, error) {
|
||||
envVals := map[string]interface{}{}
|
||||
envVals := map[string]any{}
|
||||
envSpec, ok := st.Environments[name]
|
||||
if ok {
|
||||
var err error
|
||||
|
|
@ -277,7 +277,7 @@ func (c *StateCreator) loadEnvValues(st *HelmState, name string, failOnMissingEn
|
|||
return newEnv, nil
|
||||
}
|
||||
|
||||
func (c *StateCreator) scatterGatherEnvSecretFiles(st *HelmState, envSecretFiles []string, envVals map[string]interface{}) error {
|
||||
func (c *StateCreator) scatterGatherEnvSecretFiles(st *HelmState, envSecretFiles []string, envVals map[string]any) error {
|
||||
var errs []error
|
||||
|
||||
helm := c.getHelm(st)
|
||||
|
|
@ -286,7 +286,7 @@ func (c *StateCreator) scatterGatherEnvSecretFiles(st *HelmState, envSecretFiles
|
|||
|
||||
type secretResult struct {
|
||||
id int
|
||||
result map[string]interface{}
|
||||
result map[string]any
|
||||
err error
|
||||
path string
|
||||
}
|
||||
|
|
@ -327,13 +327,13 @@ func (c *StateCreator) scatterGatherEnvSecretFiles(st *HelmState, envSecretFiles
|
|||
results <- secretResult{secret.id, nil, fmt.Errorf("failed to load environment secrets file \"%s\": %v", secret.path, err), secret.path}
|
||||
continue
|
||||
}
|
||||
m := map[string]interface{}{}
|
||||
m := map[string]any{}
|
||||
if err := yaml.Unmarshal(bytes, &m); err != nil {
|
||||
results <- secretResult{secret.id, nil, fmt.Errorf("failed to load environment secrets file \"%s\": %v", secret.path, err), secret.path}
|
||||
continue
|
||||
}
|
||||
// All the nested map key should be string. Otherwise we get strange errors due to that
|
||||
// mergo or reflect is unable to merge map[interface{}]interface{} with map[string]interface{} or vice versa.
|
||||
// mergo or reflect is unable to merge map[any]any with map[string]any or vice versa.
|
||||
// See https://github.com/roboll/helmfile/issues/677
|
||||
vals, err := maputil.CastKeysToStrings(m)
|
||||
if err != nil {
|
||||
|
|
@ -373,10 +373,10 @@ func (c *StateCreator) scatterGatherEnvSecretFiles(st *HelmState, envSecretFiles
|
|||
return nil
|
||||
}
|
||||
|
||||
func (st *HelmState) loadValuesEntries(missingFileHandler *string, entries []interface{}, remote *remote.Remote, ctxEnv *environment.Environment, envName string) (map[string]interface{}, error) {
|
||||
var envVals map[string]interface{}
|
||||
func (st *HelmState) loadValuesEntries(missingFileHandler *string, entries []any, remote *remote.Remote, ctxEnv *environment.Environment, envName string) (map[string]any, error) {
|
||||
var envVals map[string]any
|
||||
|
||||
valuesEntries := append([]interface{}{}, entries...)
|
||||
valuesEntries := append([]any{}, entries...)
|
||||
ld := NewEnvironmentValuesLoader(st.storage(), st.fs, st.logger, remote)
|
||||
var err error
|
||||
envVals, err = ld.LoadEnvironmentValues(missingFileHandler, valuesEntries, ctxEnv, envName)
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ env: {{ .Environment.Name }}
|
|||
barTextFile := "/example/path/to/bar.txt"
|
||||
barTextContent := []byte("BAR")
|
||||
|
||||
expected := map[string]interface{}{
|
||||
expected := map[string]any{
|
||||
"foo": "FOO",
|
||||
"bar": "BAR",
|
||||
// As the file doesn't have an file extension ".gotmpl", this template expression should not be evaluated
|
||||
|
|
@ -212,7 +212,7 @@ bar: {{ readFile "bar.txt" }}
|
|||
barTextFile := "/example/path/to/bar.txt"
|
||||
barTextContent := []byte("BAR")
|
||||
|
||||
expected := map[string]interface{}{
|
||||
expected := map[string]any{
|
||||
"foo": "FOO",
|
||||
"bar": "BAR",
|
||||
// As the file doesn't have an file extension ".gotmpl", this template expression should not be evaluated
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package state
|
||||
|
||||
type EnvironmentSpec struct {
|
||||
Values []interface{} `yaml:"values,omitempty"`
|
||||
Values []any `yaml:"values,omitempty"`
|
||||
Secrets []string `yaml:"secrets,omitempty"`
|
||||
KubeContext string `yaml:"kubeContext,omitempty"`
|
||||
|
||||
|
|
|
|||
|
|
@ -34,11 +34,11 @@ func NewEnvironmentValuesLoader(storage *Storage, fs *filesystem.FileSystem, log
|
|||
}
|
||||
}
|
||||
|
||||
func (ld *EnvironmentValuesLoader) LoadEnvironmentValues(missingFileHandler *string, valuesEntries []interface{}, ctxEnv *environment.Environment, envName string) (map[string]interface{}, error) {
|
||||
result := map[string]interface{}{}
|
||||
func (ld *EnvironmentValuesLoader) LoadEnvironmentValues(missingFileHandler *string, valuesEntries []any, ctxEnv *environment.Environment, envName string) (map[string]any, error) {
|
||||
result := map[string]any{}
|
||||
|
||||
for _, entry := range valuesEntries {
|
||||
maps := []interface{}{}
|
||||
maps := []any{}
|
||||
|
||||
switch strOrMap := entry.(type) {
|
||||
case string:
|
||||
|
|
@ -58,27 +58,27 @@ func (ld *EnvironmentValuesLoader) LoadEnvironmentValues(missingFileHandler *str
|
|||
env = *ctxEnv
|
||||
}
|
||||
|
||||
tmplData := NewEnvironmentTemplateData(env, "", map[string]interface{}{})
|
||||
tmplData := NewEnvironmentTemplateData(env, "", map[string]any{})
|
||||
r := tmpl.NewFileRenderer(ld.fs, filepath.Dir(f), tmplData)
|
||||
bytes, err := r.RenderToBytes(f)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to load environment values file \"%s\": %v", f, err)
|
||||
}
|
||||
m := map[string]interface{}{}
|
||||
m := map[string]any{}
|
||||
if err := yaml.Unmarshal(bytes, &m); err != nil {
|
||||
return nil, fmt.Errorf("failed to load environment values file \"%s\": %v\n\nOffending YAML:\n%s", f, err, bytes)
|
||||
}
|
||||
maps = append(maps, m)
|
||||
ld.logger.Debugf("envvals_loader: loaded %s:%v", strOrMap, m)
|
||||
}
|
||||
case map[interface{}]interface{}, map[string]interface{}:
|
||||
case map[any]any, map[string]any:
|
||||
maps = append(maps, strOrMap)
|
||||
default:
|
||||
return nil, fmt.Errorf("unexpected type of value: value=%v, type=%T", strOrMap, strOrMap)
|
||||
}
|
||||
for _, m := range maps {
|
||||
// All the nested map key should be string. Otherwise we get strange errors due to that
|
||||
// mergo or reflect is unable to merge map[interface{}]interface{} with map[string]interface{} or vice versa.
|
||||
// mergo or reflect is unable to merge map[any]any with map[string]any or vice versa.
|
||||
// See https://github.com/roboll/helmfile/issues/677
|
||||
vals, err := maputil.CastKeysToStrings(m)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -29,13 +29,13 @@ func newLoader() *EnvironmentValuesLoader {
|
|||
func TestEnvValsLoad_SingleValuesFile(t *testing.T) {
|
||||
l := newLoader()
|
||||
|
||||
actual, err := l.LoadEnvironmentValues(nil, []interface{}{"testdata/values.5.yaml"}, nil, "")
|
||||
actual, err := l.LoadEnvironmentValues(nil, []any{"testdata/values.5.yaml"}, nil, "")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
expected := map[string]interface{}{
|
||||
"affinity": map[string]interface{}{},
|
||||
expected := map[string]any{
|
||||
"affinity": map[string]any{},
|
||||
}
|
||||
|
||||
if diff := cmp.Diff(expected, actual); diff != "" {
|
||||
|
|
@ -46,10 +46,10 @@ func TestEnvValsLoad_SingleValuesFile(t *testing.T) {
|
|||
func TestEnvValsLoad_EnvironmentNameFile(t *testing.T) {
|
||||
l := newLoader()
|
||||
|
||||
expected := map[string]interface{}{
|
||||
expected := map[string]any{
|
||||
"envName": "test",
|
||||
}
|
||||
emptyExpected := map[string]interface{}{
|
||||
emptyExpected := map[string]any{
|
||||
"envName": nil,
|
||||
}
|
||||
|
||||
|
|
@ -57,7 +57,7 @@ func TestEnvValsLoad_EnvironmentNameFile(t *testing.T) {
|
|||
name string
|
||||
env *environment.Environment
|
||||
envName string
|
||||
expected map[string]interface{}
|
||||
expected map[string]any
|
||||
}{
|
||||
{
|
||||
name: "env is nil but envName is not",
|
||||
|
|
@ -87,7 +87,7 @@ func TestEnvValsLoad_EnvironmentNameFile(t *testing.T) {
|
|||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
actual, err := l.LoadEnvironmentValues(nil, []interface{}{"testdata/values.6.yaml.gotmpl"}, tt.env, tt.envName)
|
||||
actual, err := l.LoadEnvironmentValues(nil, []any{"testdata/values.6.yaml.gotmpl"}, tt.env, tt.envName)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -103,12 +103,12 @@ func TestEnvValsLoad_EnvironmentNameFile(t *testing.T) {
|
|||
func TestEnvValsLoad_SingleValuesFileRemote(t *testing.T) {
|
||||
l := newLoader()
|
||||
|
||||
actual, err := l.LoadEnvironmentValues(nil, []interface{}{"git::https://github.com/helm/helm.git@cmd/helm/testdata/output/values.yaml?ref=v3.8.1"}, nil, "")
|
||||
actual, err := l.LoadEnvironmentValues(nil, []any{"git::https://github.com/helm/helm.git@cmd/helm/testdata/output/values.yaml?ref=v3.8.1"}, nil, "")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
expected := map[string]interface{}{
|
||||
expected := map[string]any{
|
||||
"name": string("value"),
|
||||
}
|
||||
|
||||
|
|
@ -121,14 +121,14 @@ func TestEnvValsLoad_SingleValuesFileRemote(t *testing.T) {
|
|||
func TestEnvValsLoad_OverwriteNilValue_Issue1150(t *testing.T) {
|
||||
l := newLoader()
|
||||
|
||||
actual, err := l.LoadEnvironmentValues(nil, []interface{}{"testdata/values.1.yaml", "testdata/values.2.yaml"}, nil, "")
|
||||
actual, err := l.LoadEnvironmentValues(nil, []any{"testdata/values.1.yaml", "testdata/values.2.yaml"}, nil, "")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
expected := map[string]interface{}{
|
||||
"components": map[string]interface{}{
|
||||
"etcd-operator": map[string]interface{}{
|
||||
expected := map[string]any{
|
||||
"components": map[string]any{
|
||||
"etcd-operator": map[string]any{
|
||||
"version": "0.10.3",
|
||||
},
|
||||
},
|
||||
|
|
@ -143,14 +143,14 @@ func TestEnvValsLoad_OverwriteNilValue_Issue1150(t *testing.T) {
|
|||
func TestEnvValsLoad_OverwriteWithNilValue_Issue1154(t *testing.T) {
|
||||
l := newLoader()
|
||||
|
||||
actual, err := l.LoadEnvironmentValues(nil, []interface{}{"testdata/values.3.yaml", "testdata/values.4.yaml"}, nil, "")
|
||||
actual, err := l.LoadEnvironmentValues(nil, []any{"testdata/values.3.yaml", "testdata/values.4.yaml"}, nil, "")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
expected := map[string]interface{}{
|
||||
"components": map[string]interface{}{
|
||||
"etcd-operator": map[string]interface{}{
|
||||
expected := map[string]any{
|
||||
"components": map[string]any{
|
||||
"etcd-operator": map[string]any{
|
||||
"version": "0.10.3",
|
||||
},
|
||||
"prometheus": nil,
|
||||
|
|
@ -166,14 +166,14 @@ func TestEnvValsLoad_OverwriteWithNilValue_Issue1154(t *testing.T) {
|
|||
func TestEnvValsLoad_OverwriteEmptyValue_Issue1168(t *testing.T) {
|
||||
l := newLoader()
|
||||
|
||||
actual, err := l.LoadEnvironmentValues(nil, []interface{}{"testdata/issues/1168/addons.yaml", "testdata/issues/1168/addons2.yaml"}, nil, "")
|
||||
actual, err := l.LoadEnvironmentValues(nil, []any{"testdata/issues/1168/addons.yaml", "testdata/issues/1168/addons2.yaml"}, nil, "")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
expected := map[string]interface{}{
|
||||
"addons": map[string]interface{}{
|
||||
"mychart": map[string]interface{}{
|
||||
expected := map[string]any{
|
||||
"addons": map[string]any{
|
||||
"mychart": map[string]any{
|
||||
"skip": false,
|
||||
"name": "mychart",
|
||||
"namespace": "kube-system",
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ func (r ReleaseSpec) ExecuteTemplateExpressions(renderer *tmpl.FileRenderer) (*R
|
|||
if len(result.ValuesTemplate) > 0 {
|
||||
for i, t := range result.ValuesTemplate {
|
||||
switch ts := t.(type) {
|
||||
case map[interface{}]interface{}, map[string]interface{}:
|
||||
case map[any]any, map[string]any:
|
||||
serialized, err := yaml.Marshal(ts)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed executing template expressions in release \"%s\".values[%d] = \"%v\": %v", r.Name, i, ts, err)
|
||||
|
|
@ -99,7 +99,7 @@ func (r ReleaseSpec) ExecuteTemplateExpressions(renderer *tmpl.FileRenderer) (*R
|
|||
return nil, fmt.Errorf("failed executing template expressions in release \"%s\".values[%d] = \"%v\": %v", r.Name, i, string(serialized), err)
|
||||
}
|
||||
|
||||
var deserialized map[string]interface{}
|
||||
var deserialized map[string]any
|
||||
|
||||
if err := yaml.Unmarshal(s.Bytes(), &deserialized); err != nil {
|
||||
return nil, fmt.Errorf("failed executing template expressions in release \"%s\".values[%d] = \"%v\": %v", r.Name, i, ts, err)
|
||||
|
|
@ -114,7 +114,7 @@ func (r ReleaseSpec) ExecuteTemplateExpressions(renderer *tmpl.FileRenderer) (*R
|
|||
}
|
||||
}
|
||||
|
||||
var newvals []interface{}
|
||||
var newvals []any
|
||||
newvals = append(newvals, result.ValuesTemplate...)
|
||||
result.Values = append(newvals, result.Values...)
|
||||
}
|
||||
|
|
@ -127,7 +127,7 @@ func (r ReleaseSpec) ExecuteTemplateExpressions(renderer *tmpl.FileRenderer) (*R
|
|||
return nil, fmt.Errorf("failed executing template expressions in release \"%s\".values[%d] = \"%s\": %v", r.Name, i, ts, err)
|
||||
}
|
||||
result.Values[i] = s.String()
|
||||
case map[interface{}]interface{}:
|
||||
case map[any]any:
|
||||
m, err := maputil.CastKeysToStrings(ts)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed executing template expressions in release \"%s\".values[%d] = \"%s\": %v", r.Name, i, ts, err)
|
||||
|
|
|
|||
|
|
@ -11,13 +11,13 @@ import (
|
|||
)
|
||||
|
||||
func TestExecuteTemplateExpressions(t *testing.T) {
|
||||
render := tmpl.NewFileRenderer(filesystem.DefaultFileSystem(), "", map[string]interface{}{
|
||||
"Values": map[string]interface{}{
|
||||
"foo": map[string]interface{}{
|
||||
render := tmpl.NewFileRenderer(filesystem.DefaultFileSystem(), "", map[string]any{
|
||||
"Values": map[string]any{
|
||||
"foo": map[string]any{
|
||||
"releaseName": "foo",
|
||||
},
|
||||
},
|
||||
"Release": map[string]interface{}{
|
||||
"Release": map[string]any{
|
||||
"Name": "foo",
|
||||
},
|
||||
})
|
||||
|
|
@ -32,8 +32,8 @@ func TestExecuteTemplateExpressions(t *testing.T) {
|
|||
Name: "foo",
|
||||
Chart: "bar",
|
||||
Namespace: "baz",
|
||||
ValuesTemplate: []interface{}{
|
||||
map[string]interface{}{
|
||||
ValuesTemplate: []any{
|
||||
map[string]any{
|
||||
"fullnameOverride": "{{ .Values | get (printf \"%s.releaseName\" .Release.Name) .Release.Name }}",
|
||||
},
|
||||
},
|
||||
|
|
@ -41,5 +41,5 @@ func TestExecuteTemplateExpressions(t *testing.T) {
|
|||
result, err := rs.ExecuteTemplateExpressions(render)
|
||||
|
||||
require.NoErrorf(t, err, "failed to execute template expressions: %v", err)
|
||||
require.Equalf(t, result.ValuesTemplate[0].(map[string]interface{})["fullnameOverride"], "foo", "failed to execute template expressions")
|
||||
require.Equalf(t, result.ValuesTemplate[0].(map[string]any)["fullnameOverride"], "foo", "failed to execute template expressions")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ type ReleaseSetSpec struct {
|
|||
DefaultHelmBinary string `yaml:"helmBinary,omitempty"`
|
||||
|
||||
// DefaultValues is the default values to be overrode by environment values and command-line overrides
|
||||
DefaultValues []interface{} `yaml:"values,omitempty"`
|
||||
DefaultValues []any `yaml:"values,omitempty"`
|
||||
|
||||
Environments map[string]EnvironmentSpec `yaml:"environments,omitempty"`
|
||||
|
||||
|
|
@ -101,8 +101,8 @@ type MissingFileHandlerConfig struct {
|
|||
// helmStateAlias is helm state alias
|
||||
type helmStateAlias HelmState
|
||||
|
||||
func (hs *HelmState) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
helmStateInfo := make(map[string]interface{})
|
||||
func (hs *HelmState) UnmarshalYAML(unmarshal func(any) error) error {
|
||||
helmStateInfo := make(map[string]any)
|
||||
if err := unmarshal(&helmStateInfo); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -134,7 +134,7 @@ type HelmState struct {
|
|||
// RenderedValues is the helmfile-wide values that is `.Values`
|
||||
// which is accessible from within the whole helmfile go template.
|
||||
// Note that this is usually computed by DesiredStateLoader from ReleaseSetSpec.Env
|
||||
RenderedValues map[string]interface{}
|
||||
RenderedValues map[string]any
|
||||
}
|
||||
|
||||
// SubHelmfileSpec defines the subhelmfile path and options
|
||||
|
|
@ -151,7 +151,7 @@ type SubHelmfileSpec struct {
|
|||
|
||||
// SubhelmfileEnvironmentSpec is the environment spec for a subhelmfile
|
||||
type SubhelmfileEnvironmentSpec struct {
|
||||
OverrideValues []interface{} `yaml:"values,omitempty"`
|
||||
OverrideValues []any `yaml:"values,omitempty"`
|
||||
}
|
||||
|
||||
// HelmSpec to defines helmDefault values
|
||||
|
|
@ -293,12 +293,12 @@ type ReleaseSpec struct {
|
|||
Name string `yaml:"name,omitempty"`
|
||||
Namespace string `yaml:"namespace,omitempty"`
|
||||
Labels map[string]string `yaml:"labels,omitempty"`
|
||||
Values []interface{} `yaml:"values,omitempty"`
|
||||
Secrets []interface{} `yaml:"secrets,omitempty"`
|
||||
Values []any `yaml:"values,omitempty"`
|
||||
Secrets []any `yaml:"secrets,omitempty"`
|
||||
SetValues []SetValue `yaml:"set,omitempty"`
|
||||
duration time.Duration
|
||||
|
||||
ValuesTemplate []interface{} `yaml:"valuesTemplate,omitempty"`
|
||||
ValuesTemplate []any `yaml:"valuesTemplate,omitempty"`
|
||||
SetValuesTemplate []SetValue `yaml:"setTemplate,omitempty"`
|
||||
|
||||
// Capabilities.APIVersions
|
||||
|
|
@ -324,15 +324,15 @@ type ReleaseSpec struct {
|
|||
|
||||
// These settings requires helm-x integration to work
|
||||
Dependencies []Dependency `yaml:"dependencies,omitempty"`
|
||||
JSONPatches []interface{} `yaml:"jsonPatches,omitempty"`
|
||||
StrategicMergePatches []interface{} `yaml:"strategicMergePatches,omitempty"`
|
||||
JSONPatches []any `yaml:"jsonPatches,omitempty"`
|
||||
StrategicMergePatches []any `yaml:"strategicMergePatches,omitempty"`
|
||||
|
||||
// Transformers is the list of Kustomize transformers
|
||||
//
|
||||
// Each item can be a path to a YAML or go template file, or an embedded transformer declaration as a YAML hash.
|
||||
// It's often used to add common labels and annotations to your resources.
|
||||
// See https://github.com/kubernetes-sigs/kustomize/blob/master/examples/configureBuiltinPlugin.md#configuring-the-builtin-plugins-instead for more information.
|
||||
Transformers []interface{} `yaml:"transformers,omitempty"`
|
||||
Transformers []any `yaml:"transformers,omitempty"`
|
||||
Adopt []string `yaml:"adopt,omitempty"`
|
||||
|
||||
//version of the chart that has really been installed cause desired version may be fuzzy (~2.0.0)
|
||||
|
|
@ -367,7 +367,7 @@ type ReleaseSpec struct {
|
|||
Inherit Inherits `yaml:"inherit,omitempty"`
|
||||
}
|
||||
|
||||
func (r *Inherits) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
func (r *Inherits) UnmarshalYAML(unmarshal func(any) error) error {
|
||||
var v0151 []Inherit
|
||||
if err := unmarshal(&v0151); err != nil {
|
||||
var v0150 Inherit
|
||||
|
|
@ -1561,10 +1561,10 @@ func (st *HelmState) WriteReleasesValues(helm helmexec.Interface, additionalValu
|
|||
|
||||
st.logger.Infof("Writing values file %s", outputValuesFile)
|
||||
|
||||
merged := map[string]interface{}{}
|
||||
merged := map[string]any{}
|
||||
|
||||
for _, f := range append(generatedFiles, additionalValues...) {
|
||||
src := map[string]interface{}{}
|
||||
src := map[string]any{}
|
||||
|
||||
srcBytes, err := st.fs.ReadFile(f)
|
||||
if err != nil {
|
||||
|
|
@ -2152,7 +2152,7 @@ func (st *HelmState) SelectReleases(includeTransitiveNeeds bool) ([]Release, err
|
|||
return rs, nil
|
||||
}
|
||||
|
||||
func markExcludedReleases(releases []ReleaseSpec, selectors []string, commonLabels map[string]string, values map[string]interface{}, includeTransitiveNeeds bool) ([]Release, error) {
|
||||
func markExcludedReleases(releases []ReleaseSpec, selectors []string, commonLabels map[string]string, values map[string]any, includeTransitiveNeeds bool) ([]Release, error) {
|
||||
var filteredReleases []Release
|
||||
filters := []ReleaseFilter{}
|
||||
for _, label := range selectors {
|
||||
|
|
@ -2203,7 +2203,7 @@ func markExcludedReleases(releases []ReleaseSpec, selectors []string, commonLabe
|
|||
return filteredReleases, nil
|
||||
}
|
||||
|
||||
func ConditionEnabled(r ReleaseSpec, values map[string]interface{}) (bool, error) {
|
||||
func ConditionEnabled(r ReleaseSpec, values map[string]any) (bool, error) {
|
||||
var conditionMatch bool
|
||||
if len(r.Condition) == 0 {
|
||||
return true, nil
|
||||
|
|
@ -2216,7 +2216,7 @@ func ConditionEnabled(r ReleaseSpec, values map[string]interface{}) (bool, error
|
|||
if v == nil {
|
||||
panic(fmt.Sprintf("environment values field '%s' is nil", conditionSplit[0]))
|
||||
}
|
||||
if v.(map[string]interface{})["enabled"] == true {
|
||||
if v.(map[string]any)["enabled"] == true {
|
||||
conditionMatch = true
|
||||
}
|
||||
} else {
|
||||
|
|
@ -2308,7 +2308,7 @@ func (st *HelmState) triggerGlobalReleaseEvent(evt string, evtErr error, helmfil
|
|||
Logger: st.logger,
|
||||
Fs: st.fs,
|
||||
}
|
||||
data := map[string]interface{}{
|
||||
data := map[string]any{
|
||||
"HelmfileCommand": helmfileCmd,
|
||||
}
|
||||
return bus.Trigger(evt, evtErr, data)
|
||||
|
|
@ -2346,7 +2346,7 @@ func (st *HelmState) triggerReleaseEvent(evt string, evtErr error, r *ReleaseSpe
|
|||
Fs: st.fs,
|
||||
}
|
||||
vals := st.Values()
|
||||
data := map[string]interface{}{
|
||||
data := map[string]any{
|
||||
"Values": vals,
|
||||
"Release": r,
|
||||
"HelmfileCommand": helmfileCmd,
|
||||
|
|
@ -2730,7 +2730,7 @@ func (st *HelmState) RenderReleaseValuesFileToBytes(release *ReleaseSpec, path s
|
|||
}
|
||||
|
||||
if match {
|
||||
var rawYaml map[string]interface{}
|
||||
var rawYaml map[string]any
|
||||
|
||||
if err := yaml.Unmarshal(rawBytes, &rawYaml); err != nil {
|
||||
return nil, err
|
||||
|
|
@ -2823,7 +2823,7 @@ func (c MissingFileHandlerConfig) resolveFileOptions() []resolveFileOption {
|
|||
}
|
||||
}
|
||||
|
||||
func (st *HelmState) generateTemporaryReleaseValuesFiles(release *ReleaseSpec, values []interface{}, missingFileHandler *string) ([]string, error) {
|
||||
func (st *HelmState) generateTemporaryReleaseValuesFiles(release *ReleaseSpec, values []any, missingFileHandler *string) ([]string, error) {
|
||||
generatedFiles := []string{}
|
||||
|
||||
for _, value := range values {
|
||||
|
|
@ -2862,7 +2862,7 @@ func (st *HelmState) generateTemporaryReleaseValuesFiles(release *ReleaseSpec, v
|
|||
st.logger.Debugf("Successfully generated the value file at %s. produced:\n%s", path, string(yamlBytes))
|
||||
|
||||
generatedFiles = append(generatedFiles, valfile.Name())
|
||||
case map[interface{}]interface{}, map[string]interface{}:
|
||||
case map[any]any, map[string]any:
|
||||
valfile, err := createTempValuesFile(release, typedValue)
|
||||
if err != nil {
|
||||
return generatedFiles, err
|
||||
|
|
@ -2889,7 +2889,7 @@ func (st *HelmState) generateTemporaryReleaseValuesFiles(release *ReleaseSpec, v
|
|||
}
|
||||
|
||||
func (st *HelmState) generateVanillaValuesFiles(release *ReleaseSpec) ([]string, error) {
|
||||
values := []interface{}{}
|
||||
values := []any{}
|
||||
for _, v := range release.Values {
|
||||
switch typedValue := v.(type) {
|
||||
case string:
|
||||
|
|
@ -2900,12 +2900,12 @@ func (st *HelmState) generateVanillaValuesFiles(release *ReleaseSpec) ([]string,
|
|||
}
|
||||
}
|
||||
|
||||
valuesMapSecretsRendered, err := st.valsRuntime.Eval(map[string]interface{}{"values": values})
|
||||
valuesMapSecretsRendered, err := st.valsRuntime.Eval(map[string]any{"values": values})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
valuesSecretsRendered, ok := valuesMapSecretsRendered["values"].([]interface{})
|
||||
valuesSecretsRendered, ok := valuesMapSecretsRendered["values"].([]any)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("Failed to render values in %s for release %s: type %T isn't supported", st.FilePath, release.Name, valuesMapSecretsRendered["values"])
|
||||
}
|
||||
|
|
@ -2919,7 +2919,7 @@ func (st *HelmState) generateVanillaValuesFiles(release *ReleaseSpec) ([]string,
|
|||
}
|
||||
|
||||
func (st *HelmState) generateSecretValuesFiles(helm helmexec.Interface, release *ReleaseSpec, workerIndex int) ([]string, error) {
|
||||
var generatedDecryptedFiles []interface{}
|
||||
var generatedDecryptedFiles []any
|
||||
|
||||
for _, v := range release.Secrets {
|
||||
var (
|
||||
|
|
@ -3091,12 +3091,12 @@ func (st *HelmState) setFlags(setValues []SetValue) ([]string, error) {
|
|||
func renderValsSecrets(e vals.Evaluator, input ...string) ([]string, error) {
|
||||
output := make([]string, len(input))
|
||||
if len(input) > 0 {
|
||||
mapRendered, err := e.Eval(map[string]interface{}{"values": input})
|
||||
mapRendered, err := e.Eval(map[string]any{"values": input})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rendered, ok := mapRendered["values"].([]interface{})
|
||||
rendered, ok := mapRendered["values"].([]any)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("type %T isn't supported", mapRendered["values"])
|
||||
}
|
||||
|
|
@ -3165,12 +3165,12 @@ func escape(value string) string {
|
|||
|
||||
// MarshalYAML will ensure we correctly marshal SubHelmfileSpec structure correctly so it can be unmarshalled at some
|
||||
// future time
|
||||
func (p SubHelmfileSpec) MarshalYAML() (interface{}, error) {
|
||||
func (p SubHelmfileSpec) MarshalYAML() (any, error) {
|
||||
type SubHelmfileSpecTmp struct {
|
||||
Path string `yaml:"path,omitempty"`
|
||||
Selectors []string `yaml:"selectors,omitempty"`
|
||||
SelectorsInherited bool `yaml:"selectorsInherited,omitempty"`
|
||||
OverrideValues []interface{} `yaml:"values,omitempty"`
|
||||
OverrideValues []any `yaml:"values,omitempty"`
|
||||
}
|
||||
return &SubHelmfileSpecTmp{
|
||||
Path: p.Path,
|
||||
|
|
@ -3182,8 +3182,8 @@ func (p SubHelmfileSpec) MarshalYAML() (interface{}, error) {
|
|||
|
||||
// UnmarshalYAML will unmarshal the helmfile yaml section and fill the SubHelmfileSpec structure
|
||||
// this is required go-yto keep allowing string scalar for defining helmfile
|
||||
func (hf *SubHelmfileSpec) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
var tmp interface{}
|
||||
func (hf *SubHelmfileSpec) UnmarshalYAML(unmarshal func(any) error) error {
|
||||
var tmp any
|
||||
if err := unmarshal(&tmp); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -3191,7 +3191,7 @@ func (hf *SubHelmfileSpec) UnmarshalYAML(unmarshal func(interface{}) error) erro
|
|||
switch i := tmp.(type) {
|
||||
case string: // single path definition without sub items, legacy sub helmfile definition
|
||||
hf.Path = i
|
||||
case map[interface{}]interface{}, map[string]interface{}: // helmfile path with sub section
|
||||
case map[any]any, map[string]any: // helmfile path with sub section
|
||||
var subHelmfileSpecTmp struct {
|
||||
Path string `yaml:"path"`
|
||||
Selectors []string `yaml:"selectors"`
|
||||
|
|
@ -3391,13 +3391,13 @@ func (st *HelmState) ToYaml() (string, error) {
|
|||
}
|
||||
}
|
||||
|
||||
func (st *HelmState) LoadYAMLForEmbedding(release *ReleaseSpec, entries []interface{}, missingFileHandler *string, pathPrefix string) ([]interface{}, error) {
|
||||
var result []interface{}
|
||||
func (st *HelmState) LoadYAMLForEmbedding(release *ReleaseSpec, entries []any, missingFileHandler *string, pathPrefix string) ([]any, error) {
|
||||
var result []any
|
||||
|
||||
for _, v := range entries {
|
||||
switch t := v.(type) {
|
||||
case string:
|
||||
var values map[string]interface{}
|
||||
var values map[string]any
|
||||
|
||||
paths, skip, err := st.storage().resolveFile(missingFileHandler, "values", pathPrefix+t, st.MissingFileHandlerConfig.resolveFileOptions()...)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import (
|
|||
"github.com/helmfile/helmfile/pkg/yaml"
|
||||
)
|
||||
|
||||
func (st *HelmState) Values() map[string]interface{} {
|
||||
func (st *HelmState) Values() map[string]any {
|
||||
if st.RenderedValues == nil {
|
||||
panic("[bug] RenderedValues is nil")
|
||||
}
|
||||
|
|
@ -20,7 +20,7 @@ func (st *HelmState) Values() map[string]interface{} {
|
|||
return st.RenderedValues
|
||||
}
|
||||
|
||||
func (st *HelmState) createReleaseTemplateData(release *ReleaseSpec, vals map[string]interface{}) releaseTemplateData {
|
||||
func (st *HelmState) createReleaseTemplateData(release *ReleaseSpec, vals map[string]any) releaseTemplateData {
|
||||
tmplData := releaseTemplateData{
|
||||
Environment: st.Env,
|
||||
KubeContext: st.OverrideKubeContext,
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@ func TestHelmState_executeTemplates(t *testing.T) {
|
|||
Version: "{{ .Release.Name }}-0.1",
|
||||
Name: "test-app",
|
||||
Namespace: "test-namespace-{{ .Release.Name }}",
|
||||
ValuesTemplate: []interface{}{"config/{{ .Environment.Name }}/{{ .Release.Name }}/values.yaml"},
|
||||
Secrets: []interface{}{"config/{{ .Environment.Name }}/{{ .Release.Name }}/secrets.yaml"},
|
||||
ValuesTemplate: []any{"config/{{ .Environment.Name }}/{{ .Release.Name }}/values.yaml"},
|
||||
Secrets: []any{"config/{{ .Environment.Name }}/{{ .Release.Name }}/secrets.yaml"},
|
||||
Labels: map[string]string{"id": "{{ .Release.Name }}"},
|
||||
},
|
||||
want: ReleaseSpec{
|
||||
|
|
@ -40,8 +40,8 @@ func TestHelmState_executeTemplates(t *testing.T) {
|
|||
Version: "test-app-0.1",
|
||||
Name: "test-app",
|
||||
Namespace: "test-namespace-test-app",
|
||||
Values: []interface{}{"config/test_env/test-app/values.yaml"},
|
||||
Secrets: []interface{}{"config/test_env/test-app/secrets.yaml"},
|
||||
Values: []any{"config/test_env/test-app/values.yaml"},
|
||||
Secrets: []any{"config/test_env/test-app/secrets.yaml"},
|
||||
Labels: map[string]string{"id": "test-app"},
|
||||
},
|
||||
},
|
||||
|
|
@ -112,14 +112,14 @@ func TestHelmState_executeTemplates(t *testing.T) {
|
|||
Verify: nil,
|
||||
Name: "app",
|
||||
Namespace: "dev",
|
||||
ValuesTemplate: []interface{}{map[string]string{"key": "{{ .Release.Name }}-val0"}},
|
||||
ValuesTemplate: []any{map[string]string{"key": "{{ .Release.Name }}-val0"}},
|
||||
},
|
||||
want: ReleaseSpec{
|
||||
Chart: "test-charts/chart",
|
||||
Verify: nil,
|
||||
Name: "app",
|
||||
Namespace: "dev",
|
||||
Values: []interface{}{map[string]interface{}{"key": "app-val0"}},
|
||||
Values: []any{map[string]any{"key": "app-val0"}},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
@ -140,7 +140,7 @@ func TestHelmState_executeTemplates(t *testing.T) {
|
|||
tt.input,
|
||||
},
|
||||
},
|
||||
RenderedValues: map[string]interface{}{},
|
||||
RenderedValues: map[string]any{},
|
||||
}
|
||||
|
||||
r, err := state.ExecuteTemplates()
|
||||
|
|
@ -237,7 +237,7 @@ func TestHelmState_recursiveRefsTemplates(t *testing.T) {
|
|||
tt.input,
|
||||
},
|
||||
},
|
||||
RenderedValues: map[string]interface{}{},
|
||||
RenderedValues: map[string]any{},
|
||||
}
|
||||
|
||||
r, err := state.ExecuteTemplates()
|
||||
|
|
|
|||
|
|
@ -1350,7 +1350,7 @@ func TestHelmState_SyncReleases(t *testing.T) {
|
|||
},
|
||||
logger: logger,
|
||||
valsRuntime: valsRuntime,
|
||||
RenderedValues: map[string]interface{}{},
|
||||
RenderedValues: map[string]any{},
|
||||
}
|
||||
if errs := state.SyncReleases(&AffectedReleases{}, tt.helm, []string{}, 1); len(errs) > 0 {
|
||||
if len(errs) != len(tt.wantErrorMsgs) {
|
||||
|
|
@ -1418,7 +1418,7 @@ func TestHelmState_SyncReleases_MissingValuesFileForUndesiredRelease(t *testing.
|
|||
release: ReleaseSpec{
|
||||
Name: "foo",
|
||||
Chart: "../../foo-bar",
|
||||
Values: []interface{}{"noexistent.values.yaml"},
|
||||
Values: []any{"noexistent.values.yaml"},
|
||||
},
|
||||
listResult: ``,
|
||||
expectedError: `failed processing release foo: values file matching "noexistent.values.yaml" does not exist in "."`,
|
||||
|
|
@ -1428,7 +1428,7 @@ func TestHelmState_SyncReleases_MissingValuesFileForUndesiredRelease(t *testing.
|
|||
release: ReleaseSpec{
|
||||
Name: "foo",
|
||||
Chart: "../../foo-bar",
|
||||
Values: []interface{}{"noexistent.values.yaml"},
|
||||
Values: []any{"noexistent.values.yaml"},
|
||||
},
|
||||
listResult: `NAME REVISION UPDATED STATUS CHART APP VERSION NAMESPACE
|
||||
foo 1 Wed Apr 17 17:39:04 2019 DEPLOYED foo-bar-2.0.4 0.1.0 default`,
|
||||
|
|
@ -1439,7 +1439,7 @@ func TestHelmState_SyncReleases_MissingValuesFileForUndesiredRelease(t *testing.
|
|||
release: ReleaseSpec{
|
||||
Name: "foo",
|
||||
Chart: "../../foo-bar",
|
||||
Values: []interface{}{"noexistent.values.yaml"},
|
||||
Values: []any{"noexistent.values.yaml"},
|
||||
Installed: &no,
|
||||
},
|
||||
listResult: `NAME REVISION UPDATED STATUS CHART APP VERSION NAMESPACE
|
||||
|
|
@ -1457,7 +1457,7 @@ func TestHelmState_SyncReleases_MissingValuesFileForUndesiredRelease(t *testing.
|
|||
},
|
||||
logger: logger,
|
||||
valsRuntime: valsRuntime,
|
||||
RenderedValues: map[string]interface{}{},
|
||||
RenderedValues: map[string]any{},
|
||||
}
|
||||
fs := testhelper.NewTestFs(map[string]string{})
|
||||
state = injectFs(state, fs)
|
||||
|
|
@ -1604,7 +1604,7 @@ func TestHelmState_SyncReleasesAffectedRealeases(t *testing.T) {
|
|||
},
|
||||
logger: logger,
|
||||
valsRuntime: valsRuntime,
|
||||
RenderedValues: map[string]interface{}{},
|
||||
RenderedValues: map[string]any{},
|
||||
}
|
||||
helm := &exectest.Helm{
|
||||
Lists: map[exectest.ListKey]string{},
|
||||
|
|
@ -1717,7 +1717,7 @@ func TestGetDeployedVersion(t *testing.T) {
|
|||
},
|
||||
logger: logger,
|
||||
valsRuntime: valsRuntime,
|
||||
RenderedValues: map[string]interface{}{},
|
||||
RenderedValues: map[string]any{},
|
||||
}
|
||||
|
||||
helm := &exectest.Helm{
|
||||
|
|
@ -1836,7 +1836,7 @@ func TestHelmState_DiffReleases(t *testing.T) {
|
|||
},
|
||||
logger: logger,
|
||||
valsRuntime: valsRuntime,
|
||||
RenderedValues: map[string]interface{}{},
|
||||
RenderedValues: map[string]any{},
|
||||
}
|
||||
_, errs := state.DiffReleases(tt.helm, []string{}, 1, false, false, false, []string{}, false, false, false, false, false)
|
||||
if len(errs) > 0 {
|
||||
|
|
@ -1879,7 +1879,7 @@ func TestHelmState_DiffFlags(t *testing.T) {
|
|||
},
|
||||
logger: logger,
|
||||
valsRuntime: valsRuntime,
|
||||
RenderedValues: map[string]interface{}{},
|
||||
RenderedValues: map[string]any{},
|
||||
}
|
||||
for j := range tt.releases {
|
||||
flags, _, errs := state.flagsForDiff(tt.helm, &tt.releases[j], false, 1, nil)
|
||||
|
|
@ -1918,8 +1918,8 @@ func TestHelmState_SyncReleasesCleanup(t *testing.T) {
|
|||
{
|
||||
Name: "releaseName",
|
||||
Chart: "foo",
|
||||
Values: []interface{}{
|
||||
map[interface{}]interface{}{
|
||||
Values: []any{
|
||||
map[any]any{
|
||||
"someList": "a,b,c",
|
||||
},
|
||||
},
|
||||
|
|
@ -1934,8 +1934,8 @@ func TestHelmState_SyncReleasesCleanup(t *testing.T) {
|
|||
{
|
||||
Name: "releaseName",
|
||||
Chart: "foo",
|
||||
Values: []interface{}{
|
||||
map[interface{}]interface{}{
|
||||
Values: []any{
|
||||
map[any]any{
|
||||
"someList": "a,b,c",
|
||||
},
|
||||
"someFile",
|
||||
|
|
@ -1956,7 +1956,7 @@ func TestHelmState_SyncReleasesCleanup(t *testing.T) {
|
|||
},
|
||||
logger: logger,
|
||||
valsRuntime: valsRuntime,
|
||||
RenderedValues: map[string]interface{}{},
|
||||
RenderedValues: map[string]any{},
|
||||
}
|
||||
testfs := testhelper.NewTestFs(map[string]string{
|
||||
"/path/to/someFile": `foo: FOO`,
|
||||
|
|
@ -2005,8 +2005,8 @@ func TestHelmState_DiffReleasesCleanup(t *testing.T) {
|
|||
{
|
||||
Name: "releaseName",
|
||||
Chart: "foo",
|
||||
Values: []interface{}{
|
||||
map[interface{}]interface{}{
|
||||
Values: []any{
|
||||
map[any]any{
|
||||
"someList": "a,b,c",
|
||||
},
|
||||
},
|
||||
|
|
@ -2021,8 +2021,8 @@ func TestHelmState_DiffReleasesCleanup(t *testing.T) {
|
|||
{
|
||||
Name: "releaseName",
|
||||
Chart: "foo",
|
||||
Values: []interface{}{
|
||||
map[interface{}]interface{}{
|
||||
Values: []any{
|
||||
map[any]any{
|
||||
"someList": "a,b,c",
|
||||
},
|
||||
"someFile",
|
||||
|
|
@ -2043,7 +2043,7 @@ func TestHelmState_DiffReleasesCleanup(t *testing.T) {
|
|||
},
|
||||
logger: logger,
|
||||
valsRuntime: valsRuntime,
|
||||
RenderedValues: map[string]interface{}{},
|
||||
RenderedValues: map[string]any{},
|
||||
}
|
||||
testfs := testhelper.NewTestFs(map[string]string{
|
||||
"/path/to/someFile": `foo: bar
|
||||
|
|
@ -2301,7 +2301,7 @@ func TestHelmState_ReleaseStatuses(t *testing.T) {
|
|||
releases: []ReleaseSpec{
|
||||
{
|
||||
Name: "error",
|
||||
Values: []interface{}{
|
||||
Values: []any{
|
||||
"foo.yaml",
|
||||
},
|
||||
},
|
||||
|
|
@ -2314,7 +2314,7 @@ func TestHelmState_ReleaseStatuses(t *testing.T) {
|
|||
releases: []ReleaseSpec{
|
||||
{
|
||||
Name: "error",
|
||||
Values: []interface{}{
|
||||
Values: []any{
|
||||
"foo.yaml",
|
||||
},
|
||||
Installed: boolValue(false),
|
||||
|
|
@ -2425,7 +2425,7 @@ func TestConditionEnabled(t *testing.T) {
|
|||
tests := []struct {
|
||||
name string
|
||||
condition string
|
||||
values map[string]interface{}
|
||||
values map[string]any
|
||||
want bool
|
||||
wantErr bool
|
||||
wantPanic bool
|
||||
|
|
@ -2433,8 +2433,8 @@ func TestConditionEnabled(t *testing.T) {
|
|||
{
|
||||
name: "enabled",
|
||||
condition: "foo.enabled",
|
||||
values: map[string]interface{}{
|
||||
"foo": map[string]interface{}{
|
||||
values: map[string]any{
|
||||
"foo": map[string]any{
|
||||
"enabled": true,
|
||||
},
|
||||
},
|
||||
|
|
@ -2443,8 +2443,8 @@ func TestConditionEnabled(t *testing.T) {
|
|||
{
|
||||
name: "disabled",
|
||||
condition: "foo.enabled",
|
||||
values: map[string]interface{}{
|
||||
"foo": map[string]interface{}{
|
||||
values: map[string]any{
|
||||
"foo": map[string]any{
|
||||
"enabled": false,
|
||||
},
|
||||
},
|
||||
|
|
@ -2453,8 +2453,8 @@ func TestConditionEnabled(t *testing.T) {
|
|||
{
|
||||
name: "missing enabled",
|
||||
condition: "foo.enabled",
|
||||
values: map[string]interface{}{
|
||||
"foo": map[string]interface{}{
|
||||
values: map[string]any{
|
||||
"foo": map[string]any{
|
||||
"something else": false,
|
||||
},
|
||||
},
|
||||
|
|
@ -2463,7 +2463,7 @@ func TestConditionEnabled(t *testing.T) {
|
|||
{
|
||||
name: "foo nil",
|
||||
condition: "foo.enabled",
|
||||
values: map[string]interface{}{
|
||||
values: map[string]any{
|
||||
"foo": nil,
|
||||
},
|
||||
wantPanic: true,
|
||||
|
|
@ -2471,7 +2471,7 @@ func TestConditionEnabled(t *testing.T) {
|
|||
{
|
||||
name: "foo missing",
|
||||
condition: "foo.enabled",
|
||||
values: map[string]interface{}{},
|
||||
values: map[string]any{},
|
||||
wantPanic: true,
|
||||
},
|
||||
{
|
||||
|
|
@ -2564,7 +2564,7 @@ func TestHelmState_NoReleaseMatched(t *testing.T) {
|
|||
Releases: releases,
|
||||
},
|
||||
logger: logger,
|
||||
RenderedValues: map[string]interface{}{},
|
||||
RenderedValues: map[string]any{},
|
||||
}
|
||||
state.Selectors = []string{tt.labels}
|
||||
errs := state.FilterReleases(false)
|
||||
|
|
@ -2725,7 +2725,7 @@ func TestHelmState_Delete(t *testing.T) {
|
|||
Releases: releases,
|
||||
},
|
||||
logger: logger,
|
||||
RenderedValues: map[string]interface{}{},
|
||||
RenderedValues: map[string]any{},
|
||||
}
|
||||
helm := &exectest.Helm{
|
||||
Lists: map[exectest.ListKey]string{},
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import (
|
|||
"github.com/helmfile/helmfile/pkg/envvar"
|
||||
)
|
||||
|
||||
func createTempValuesFile(release *ReleaseSpec, data interface{}) (*os.File, error) {
|
||||
func createTempValuesFile(release *ReleaseSpec, data any) (*os.File, error) {
|
||||
p, err := tempValuesFilePath(release, data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
@ -28,7 +28,7 @@ func createTempValuesFile(release *ReleaseSpec, data interface{}) (*os.File, err
|
|||
return f, nil
|
||||
}
|
||||
|
||||
func tempValuesFilePath(release *ReleaseSpec, data interface{}) (*string, error) {
|
||||
func tempValuesFilePath(release *ReleaseSpec, data any) (*string, error) {
|
||||
id, err := generateValuesID(release, data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
@ -54,7 +54,7 @@ func tempValuesFilePath(release *ReleaseSpec, data interface{}) (*string, error)
|
|||
return &d, nil
|
||||
}
|
||||
|
||||
func generateValuesID(release *ReleaseSpec, data interface{}) (string, error) {
|
||||
func generateValuesID(release *ReleaseSpec, data any) (string, error) {
|
||||
var id []string
|
||||
|
||||
if release.Namespace != "" {
|
||||
|
|
@ -63,7 +63,7 @@ func generateValuesID(release *ReleaseSpec, data interface{}) (string, error) {
|
|||
|
||||
id = append(id, release.Name, "values")
|
||||
|
||||
hash, err := HashObject([]interface{}{release, data})
|
||||
hash, err := HashObject([]any{release, data})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
@ -73,7 +73,7 @@ func generateValuesID(release *ReleaseSpec, data interface{}) (string, error) {
|
|||
return strings.Join(id, "-"), nil
|
||||
}
|
||||
|
||||
func HashObject(obj interface{}) (string, error) {
|
||||
func HashObject(obj any) (string, error) {
|
||||
hash := fnv.New32a()
|
||||
|
||||
hash.Reset()
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ func TestGenerateID(t *testing.T) {
|
|||
type testcase struct {
|
||||
subject string
|
||||
release ReleaseSpec
|
||||
data interface{}
|
||||
data any
|
||||
want string
|
||||
}
|
||||
|
||||
|
|
@ -51,7 +51,7 @@ func TestGenerateID(t *testing.T) {
|
|||
run(testcase{
|
||||
subject: "different map content",
|
||||
release: ReleaseSpec{Name: "foo", Chart: "incubator/raw"},
|
||||
data: map[string]interface{}{"k": "v"},
|
||||
data: map[string]any{"k": "v"},
|
||||
want: "foo-values-77cdb7dbb6",
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -16,11 +16,11 @@ type EnvironmentTemplateData struct {
|
|||
// Namespace is accessible as `.Namespace` from any non-values template executed by the renderer
|
||||
Namespace string
|
||||
// Values is accessible as `.Values` and it contains default state values overrode by environment values and override values.
|
||||
Values map[string]interface{}
|
||||
StateValues *map[string]interface{}
|
||||
Values map[string]any
|
||||
StateValues *map[string]any
|
||||
}
|
||||
|
||||
func NewEnvironmentTemplateData(environment environment.Environment, namespace string, values map[string]interface{}) *EnvironmentTemplateData {
|
||||
func NewEnvironmentTemplateData(environment environment.Environment, namespace string, values map[string]any) *EnvironmentTemplateData {
|
||||
d := EnvironmentTemplateData{environment, namespace, values, nil}
|
||||
d.StateValues = &d.Values
|
||||
return &d
|
||||
|
|
@ -35,8 +35,8 @@ type releaseTemplateData struct {
|
|||
// It contains a subset of ReleaseSpec that is known to be useful to dynamically render values.
|
||||
Release releaseTemplateDataRelease
|
||||
// Values is accessible as `.Values` and it contains default state values overrode by environment values and override values.
|
||||
Values map[string]interface{}
|
||||
StateValues *map[string]interface{}
|
||||
Values map[string]any
|
||||
StateValues *map[string]any
|
||||
// KubeContext is HelmState.OverrideKubeContext.
|
||||
// You should better use Release.KubeContext as it might work as you'd expect even if HelmState.OverrideKubeContext is not set.
|
||||
// See releaseTemplateDataRelease.KubeContext for more information.
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import (
|
|||
"github.com/helmfile/helmfile/pkg/yaml"
|
||||
)
|
||||
|
||||
type Values = map[string]interface{}
|
||||
type Values = map[string]any
|
||||
|
||||
var DisableInsecureFeaturesErr = DisableInsecureFeaturesError{envvar.DisableInsecureFeatures + " is active, insecure function calls are disabled"}
|
||||
|
||||
|
|
@ -65,10 +65,10 @@ func (c *Context) createFuncMap() template.FuncMap {
|
|||
}
|
||||
if c.preRender || skipInsecureTemplateFunctions {
|
||||
// disable potential side-effect template calls
|
||||
funcMap["exec"] = func(string, []interface{}, ...string) (string, error) {
|
||||
funcMap["exec"] = func(string, []any, ...string) (string, error) {
|
||||
return "", nil
|
||||
}
|
||||
funcMap["envExec"] = func(map[string]interface{}, string, []interface{}, ...string) (string, error) {
|
||||
funcMap["envExec"] = func(map[string]any, string, []any, ...string) (string, error) {
|
||||
return "", nil
|
||||
}
|
||||
funcMap["readFile"] = func(string) (string, error) {
|
||||
|
|
@ -83,7 +83,7 @@ func (c *Context) createFuncMap() template.FuncMap {
|
|||
}
|
||||
if disableInsecureFeatures {
|
||||
// disable insecure functions
|
||||
funcMap["exec"] = func(string, []interface{}, ...string) (string, error) {
|
||||
funcMap["exec"] = func(string, []any, ...string) (string, error) {
|
||||
return "", DisableInsecureFeaturesErr
|
||||
}
|
||||
funcMap["readFile"] = func(string) (string, error) {
|
||||
|
|
@ -101,7 +101,7 @@ func (c *Context) createFuncMap() template.FuncMap {
|
|||
}
|
||||
|
||||
// TODO: in the next major version, remove this function.
|
||||
func (c *Context) EnvExec(envs map[string]interface{}, command string, args []interface{}, inputs ...string) (string, error) {
|
||||
func (c *Context) EnvExec(envs map[string]any, command string, args []any, inputs ...string) (string, error) {
|
||||
var input string
|
||||
if len(inputs) > 0 {
|
||||
input = inputs[0]
|
||||
|
|
@ -192,7 +192,7 @@ func (c *Context) EnvExec(envs map[string]interface{}, command string, args []in
|
|||
return string(bytes), nil
|
||||
}
|
||||
|
||||
func (c *Context) Exec(command string, args []interface{}, inputs ...string) (string, error) {
|
||||
func (c *Context) Exec(command string, args []any, inputs ...string) (string, error) {
|
||||
return c.EnvExec(nil, command, args, inputs...)
|
||||
}
|
||||
|
||||
|
|
@ -271,7 +271,7 @@ func (c *Context) ReadDirEntries(path string) ([]fs.DirEntry, error) {
|
|||
return entries, nil
|
||||
}
|
||||
|
||||
func (c *Context) Tpl(text string, data interface{}) (string, error) {
|
||||
func (c *Context) Tpl(text string, data any) (string, error) {
|
||||
buf, err := c.RenderTemplateToBuffer(text, data)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
|
@ -279,7 +279,7 @@ func (c *Context) Tpl(text string, data interface{}) (string, error) {
|
|||
return buf.String(), nil
|
||||
}
|
||||
|
||||
func ToYaml(v interface{}) (string, error) {
|
||||
func ToYaml(v any) (string, error) {
|
||||
data, err := yaml.Marshal(v)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
|
@ -288,7 +288,7 @@ func ToYaml(v interface{}) (string, error) {
|
|||
}
|
||||
|
||||
func FromYaml(str string) (Values, error) {
|
||||
m := map[string]interface{}{}
|
||||
m := map[string]any{}
|
||||
|
||||
if err := yaml.Unmarshal([]byte(str), &m); err != nil {
|
||||
return nil, fmt.Errorf("%s, offending yaml: %s", err, str)
|
||||
|
|
@ -302,23 +302,23 @@ func FromYaml(str string) (Values, error) {
|
|||
return m, nil
|
||||
}
|
||||
|
||||
func SetValueAtPath(path string, value interface{}, values Values) (Values, error) {
|
||||
var current interface{}
|
||||
func SetValueAtPath(path string, value any, values Values) (Values, error) {
|
||||
var current any
|
||||
current = values
|
||||
components := strings.Split(path, ".")
|
||||
pathToMap := components[:len(components)-1]
|
||||
key := components[len(components)-1]
|
||||
for _, k := range pathToMap {
|
||||
var elem interface{}
|
||||
var elem any
|
||||
|
||||
switch typedCurrent := current.(type) {
|
||||
case map[string]interface{}:
|
||||
case map[string]any:
|
||||
v, exists := typedCurrent[k]
|
||||
if !exists {
|
||||
return nil, fmt.Errorf("failed to set value at path \"%s\": value for key \"%s\" does not exist", path, k)
|
||||
}
|
||||
elem = v
|
||||
case map[interface{}]interface{}:
|
||||
case map[any]any:
|
||||
v, exists := typedCurrent[k]
|
||||
if !exists {
|
||||
return nil, fmt.Errorf("failed to set value at path \"%s\": value for key \"%s\" does not exist", path, k)
|
||||
|
|
@ -329,7 +329,7 @@ func SetValueAtPath(path string, value interface{}, values Values) (Values, erro
|
|||
}
|
||||
|
||||
switch typedElem := elem.(type) {
|
||||
case map[string]interface{}, map[interface{}]interface{}:
|
||||
case map[string]any, map[any]any:
|
||||
current = typedElem
|
||||
default:
|
||||
return nil, fmt.Errorf("failed to set value at path \"%s\": value for key \"%s\" was not a map", path, k)
|
||||
|
|
@ -337,9 +337,9 @@ func SetValueAtPath(path string, value interface{}, values Values) (Values, erro
|
|||
}
|
||||
|
||||
switch typedCurrent := current.(type) {
|
||||
case map[string]interface{}:
|
||||
case map[string]any:
|
||||
typedCurrent[key] = value
|
||||
case map[interface{}]interface{}:
|
||||
case map[any]any:
|
||||
typedCurrent[key] = value
|
||||
default:
|
||||
return nil, fmt.Errorf("failed to set value at path \"%s\": value for key \"%s\" was not a map", path, key)
|
||||
|
|
@ -355,7 +355,7 @@ func RequiredEnv(name string) (string, error) {
|
|||
return "", fmt.Errorf("required env var `%s` is not set", name)
|
||||
}
|
||||
|
||||
func Required(warn string, val interface{}) (interface{}, error) {
|
||||
func Required(warn string, val any) (any, error) {
|
||||
if val == nil {
|
||||
return nil, fmt.Errorf(warn)
|
||||
} else if _, ok := val.(string); ok {
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@ func TestCreateFuncMap(t *testing.T) {
|
|||
disableInsecureFeatures = false
|
||||
ctx := &Context{basePath: "."}
|
||||
funcMaps := ctx.createFuncMap()
|
||||
args := make([]interface{}, 0)
|
||||
outputExec, _ := funcMaps["exec"].(func(command string, args []interface{}, inputs ...string) (string, error))("ls", args)
|
||||
args := make([]any, 0)
|
||||
outputExec, _ := funcMaps["exec"].(func(command string, args []any, inputs ...string) (string, error))("ls", args)
|
||||
require.Contains(t, outputExec, "context.go")
|
||||
}
|
||||
|
||||
|
|
@ -36,8 +36,8 @@ func TestCreateFuncMap_DisabledInsecureFeatures(t *testing.T) {
|
|||
disableInsecureFeatures = true
|
||||
ctx := &Context{basePath: "."}
|
||||
funcMaps := ctx.createFuncMap()
|
||||
args := make([]interface{}, 0)
|
||||
_, err1 := funcMaps["exec"].(func(command string, args []interface{}, inputs ...string) (string, error))("ls", args)
|
||||
args := make([]any, 0)
|
||||
_, err1 := funcMaps["exec"].(func(command string, args []any, inputs ...string) (string, error))("ls", args)
|
||||
require.ErrorIs(t, err1, DisableInsecureFeaturesErr)
|
||||
_, err2 := funcMaps["readFile"].(func(filename string) (string, error))("context_funcs_test.go")
|
||||
require.ErrorIs(t, err2, DisableInsecureFeaturesErr)
|
||||
|
|
@ -53,8 +53,8 @@ func TestCreateFuncMap_SkipInsecureTemplateFunctions(t *testing.T) {
|
|||
skipInsecureTemplateFunctions = true
|
||||
ctx := &Context{basePath: "."}
|
||||
funcMaps := ctx.createFuncMap()
|
||||
args := make([]interface{}, 0)
|
||||
actual1, err1 := funcMaps["exec"].(func(command string, args []interface{}, inputs ...string) (string, error))("ls", args)
|
||||
args := make([]any, 0)
|
||||
actual1, err1 := funcMaps["exec"].(func(command string, args []any, inputs ...string) (string, error))("ls", args)
|
||||
require.Equal(t, "", actual1)
|
||||
require.ErrorIs(t, err1, nil)
|
||||
actual2, err2 := funcMaps["readFile"].(func(filename string) (string, error))("context_funcs_test.go")
|
||||
|
|
@ -185,8 +185,8 @@ func TestToYaml_NestedMapInterfaceKey(t *testing.T) {
|
|||
})
|
||||
|
||||
// nolint: unconvert
|
||||
vals := Values(map[string]interface{}{
|
||||
"foo": map[interface{}]interface{}{
|
||||
vals := Values(map[string]any{
|
||||
"foo": map[any]any{
|
||||
"bar": "BAR",
|
||||
},
|
||||
})
|
||||
|
|
@ -209,8 +209,8 @@ func TestToYaml(t *testing.T) {
|
|||
bar: BAR
|
||||
`
|
||||
// nolint: unconvert
|
||||
vals := Values(map[string]interface{}{
|
||||
"foo": map[string]interface{}{
|
||||
vals := Values(map[string]any{
|
||||
"foo": map[string]any{
|
||||
"bar": "BAR",
|
||||
},
|
||||
})
|
||||
|
|
@ -242,8 +242,8 @@ func TestFromYaml(t *testing.T) {
|
|||
t,
|
||||
true,
|
||||
// nolint: unconvert
|
||||
Values(map[string]interface{}{
|
||||
"foo": map[string]interface{}{
|
||||
Values(map[string]any{
|
||||
"foo": map[string]any{
|
||||
"bar": "BAR",
|
||||
},
|
||||
}),
|
||||
|
|
@ -255,8 +255,8 @@ func TestFromYaml(t *testing.T) {
|
|||
t,
|
||||
false,
|
||||
// nolint: unconvert
|
||||
Values(map[string]interface{}{
|
||||
"foo": map[string]interface{}{
|
||||
Values(map[string]any{
|
||||
"foo": map[string]any{
|
||||
"bar": "BAR",
|
||||
},
|
||||
}),
|
||||
|
|
@ -279,10 +279,10 @@ func TestFromYamlToJson(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestSetValueAtPath_OneComponent(t *testing.T) {
|
||||
input := map[string]interface{}{
|
||||
input := map[string]any{
|
||||
"foo": "",
|
||||
}
|
||||
expected := map[string]interface{}{
|
||||
expected := map[string]any{
|
||||
"foo": "FOO",
|
||||
}
|
||||
actual, err := SetValueAtPath("foo", "FOO", input)
|
||||
|
|
@ -291,13 +291,13 @@ func TestSetValueAtPath_OneComponent(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestSetValueAtPath_TwoComponents(t *testing.T) {
|
||||
input := map[string]interface{}{
|
||||
"foo": map[interface{}]interface{}{
|
||||
input := map[string]any{
|
||||
"foo": map[any]any{
|
||||
"bar": "",
|
||||
},
|
||||
}
|
||||
expected := map[string]interface{}{
|
||||
"foo": map[interface{}]interface{}{
|
||||
expected := map[string]any{
|
||||
"foo": map[any]any{
|
||||
"bar": "FOO_BAR",
|
||||
},
|
||||
}
|
||||
|
|
@ -313,13 +313,13 @@ func TestTpl(t *testing.T) {
|
|||
input string
|
||||
expected string
|
||||
hasErr bool
|
||||
data map[string]interface{}
|
||||
data map[string]any
|
||||
}{
|
||||
{
|
||||
name: "simple",
|
||||
input: `foo: {{ .foo }}`,
|
||||
expected: `foo: Foo`,
|
||||
data: map[string]interface{}{
|
||||
data: map[string]any{
|
||||
"foo": "Foo",
|
||||
},
|
||||
},
|
||||
|
|
@ -328,7 +328,7 @@ func TestTpl(t *testing.T) {
|
|||
input: `{{ .name }}
|
||||
end`,
|
||||
expected: "multiline\nend",
|
||||
data: map[string]interface{}{
|
||||
data: map[string]any{
|
||||
"name": "multiline",
|
||||
},
|
||||
},
|
||||
|
|
@ -350,12 +350,12 @@ end`,
|
|||
func TestRequired(t *testing.T) {
|
||||
type args struct {
|
||||
warn string
|
||||
val interface{}
|
||||
val any
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want interface{}
|
||||
want any
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
|
|
@ -422,12 +422,12 @@ func TestExec(t *testing.T) {
|
|||
|
||||
// test that the command is executed
|
||||
expected := "foo\n"
|
||||
output, err := ctx.Exec("echo", []interface{}{"foo"}, "")
|
||||
output, err := ctx.Exec("echo", []any{"foo"}, "")
|
||||
require.Nilf(t, err, "Expected no error to be returned when executing command")
|
||||
require.Equalf(t, expected, output, "Expected %s to be returned when executing command", expected)
|
||||
|
||||
// test that the command is executed with no-zero exit code
|
||||
_, err = ctx.Exec("bash", []interface{}{"-c", "exit 1"}, "")
|
||||
_, err = ctx.Exec("bash", []any{"-c", "exit 1"}, "")
|
||||
require.Error(t, err, "Expected error to be returned when executing command with non-zero exit code")
|
||||
}
|
||||
|
||||
|
|
@ -441,27 +441,27 @@ func TestEnvExec(t *testing.T) {
|
|||
testKey := "testkey"
|
||||
|
||||
// test that the command is executed with environment variables
|
||||
output, err := ctx.EnvExec(map[string]interface{}{testKey: "foo"}, "bash", []interface{}{"-c", fmt.Sprintf("echo -n $%s", testKey)}, "")
|
||||
output, err := ctx.EnvExec(map[string]any{testKey: "foo"}, "bash", []any{"-c", fmt.Sprintf("echo -n $%s", testKey)}, "")
|
||||
|
||||
require.Nilf(t, err, "Expected no error to be returned when executing command with environment variables")
|
||||
|
||||
require.Equalf(t, expected, output, "Expected %s to be returned when executing command with environment variables", expected)
|
||||
|
||||
// test that the command is executed with invalid environment variables
|
||||
output, err = ctx.EnvExec(map[string]interface{}{testKey: 123}, "bash", []interface{}{"-c", fmt.Sprintf("echo -n $%s", testKey)}, "")
|
||||
output, err = ctx.EnvExec(map[string]any{testKey: 123}, "bash", []any{"-c", fmt.Sprintf("echo -n $%s", testKey)}, "")
|
||||
|
||||
require.Errorf(t, err, "Expected error to be returned when executing command with invalid environment variables")
|
||||
require.Emptyf(t, output, "Expected empty string to be returned when executing command with invalid environment variables")
|
||||
|
||||
// test that the command is executed with no environment variables
|
||||
output, err = ctx.EnvExec(nil, "bash", []interface{}{"-c", fmt.Sprintf("echo -n $%s", testKey)}, "")
|
||||
output, err = ctx.EnvExec(nil, "bash", []any{"-c", fmt.Sprintf("echo -n $%s", testKey)}, "")
|
||||
require.Nilf(t, err, "Expected no error to be returned when executing command with no environment variables")
|
||||
|
||||
require.Emptyf(t, output, "Expected empty string to be returned when executing command with no environment variables")
|
||||
|
||||
// test that the command is executed with os environment variables
|
||||
t.Setenv(testKey, "foo")
|
||||
output, err = ctx.EnvExec(nil, "bash", []interface{}{"-c", fmt.Sprintf("echo -n $%s", testKey)}, "")
|
||||
output, err = ctx.EnvExec(nil, "bash", []any{"-c", fmt.Sprintf("echo -n $%s", testKey)}, "")
|
||||
|
||||
require.Nilf(t, err, "Expected no error to be returned when executing command with environment variables")
|
||||
|
||||
|
|
|
|||
|
|
@ -43,14 +43,14 @@ func (c *Context) newTemplate() *template.Template {
|
|||
return tmpl
|
||||
}
|
||||
|
||||
func (c *Context) RenderTemplateToBuffer(s string, data ...interface{}) (*bytes.Buffer, error) {
|
||||
func (c *Context) RenderTemplateToBuffer(s string, data ...any) (*bytes.Buffer, error) {
|
||||
var t, parseErr = c.newTemplate().Parse(s)
|
||||
if parseErr != nil {
|
||||
return nil, parseErr
|
||||
}
|
||||
|
||||
var tplString bytes.Buffer
|
||||
var d interface{}
|
||||
var d any
|
||||
if len(data) > 0 {
|
||||
d = data[0]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,8 +40,8 @@ func TestRenderTemplate_WithData(t *testing.T) {
|
|||
bar: FOO_BAR
|
||||
`
|
||||
expectedFilename := "values.yaml"
|
||||
data := map[string]interface{}{
|
||||
"foo": map[string]interface{}{
|
||||
data := map[string]any{
|
||||
"foo": map[string]any{
|
||||
"bar": "FOO_BAR",
|
||||
},
|
||||
}
|
||||
|
|
@ -69,7 +69,7 @@ func TestRenderTemplate_AccessingMissingKeyWithGetOrNil(t *testing.T) {
|
|||
bar: <no value>
|
||||
`
|
||||
expectedFilename := "values.yaml"
|
||||
data := map[string]interface{}{}
|
||||
data := map[string]any{}
|
||||
ctx := &Context{fs: &ffs.FileSystem{ReadFile: func(filename string) ([]byte, error) {
|
||||
if filename != expectedFilename {
|
||||
return nil, fmt.Errorf("unexpected filename: expected=%v, actual=%s", expectedFilename, filename)
|
||||
|
|
@ -94,7 +94,7 @@ func TestRenderTemplate_Defaulting(t *testing.T) {
|
|||
bar: DEFAULT
|
||||
`
|
||||
expectedFilename := "values.yaml"
|
||||
data := map[string]interface{}{}
|
||||
data := map[string]any{}
|
||||
ctx := &Context{fs: &ffs.FileSystem{ReadFile: func(filename string) ([]byte, error) {
|
||||
if filename != expectedFilename {
|
||||
return nil, fmt.Errorf("unexpected filename: expected=%v, actual=%s", expectedFilename, filename)
|
||||
|
|
@ -111,7 +111,7 @@ func TestRenderTemplate_Defaulting(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func renderTemplateToString(s string, data ...interface{}) (string, error) {
|
||||
func renderTemplateToString(s string, data ...any) (string, error) {
|
||||
ctx := &Context{fs: &ffs.FileSystem{ReadFile: func(filename string) ([]byte, error) {
|
||||
return nil, fmt.Errorf("unexpected call to readFile: filename=%s", filename)
|
||||
}}}
|
||||
|
|
@ -126,7 +126,7 @@ func Test_renderTemplateToString(t *testing.T) {
|
|||
type args struct {
|
||||
s string
|
||||
envs map[string]string
|
||||
data interface{}
|
||||
data any
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
|
|
@ -184,7 +184,7 @@ func Test_renderTemplateToString(t *testing.T) {
|
|||
args: args{
|
||||
s: `{{ . | get "Foo" }}, {{ . | get "Bar" "2" }}`,
|
||||
envs: map[string]string{},
|
||||
data: map[string]interface{}{
|
||||
data: map[string]any{
|
||||
"Foo": "1",
|
||||
},
|
||||
},
|
||||
|
|
@ -253,14 +253,14 @@ func TestRenderTemplate_Required(t *testing.T) {
|
|||
tests := []struct {
|
||||
name string
|
||||
s string
|
||||
data map[string]interface{}
|
||||
data map[string]any
|
||||
want string
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
name: ".foo is existed",
|
||||
s: `{{ required ".foo.bar is required" .foo }}`,
|
||||
data: map[string]interface{}{
|
||||
data: map[string]any{
|
||||
"foo": "bar",
|
||||
},
|
||||
want: "bar",
|
||||
|
|
@ -269,8 +269,8 @@ func TestRenderTemplate_Required(t *testing.T) {
|
|||
{
|
||||
name: ".foo.bar is existed",
|
||||
s: `{{ required "foo.bar is required" .foo.bar }}`,
|
||||
data: map[string]interface{}{
|
||||
"foo": map[string]interface{}{
|
||||
data: map[string]any{
|
||||
"foo": map[string]any{
|
||||
"bar": "FOO_BAR",
|
||||
},
|
||||
},
|
||||
|
|
@ -280,8 +280,8 @@ func TestRenderTemplate_Required(t *testing.T) {
|
|||
{
|
||||
name: ".foo.bar is existed but value is nil",
|
||||
s: `{{ required "foo.bar is required" .foo.bar }}`,
|
||||
data: map[string]interface{}{
|
||||
"foo": map[string]interface{}{
|
||||
data: map[string]any{
|
||||
"foo": map[string]any{
|
||||
"bar": nil,
|
||||
},
|
||||
},
|
||||
|
|
@ -290,8 +290,8 @@ func TestRenderTemplate_Required(t *testing.T) {
|
|||
{
|
||||
name: ".foo.bar is existed but value is empty string",
|
||||
s: `{{ required "foo.bar is required" .foo.bar }}`,
|
||||
data: map[string]interface{}{
|
||||
"foo": map[string]interface{}{
|
||||
data: map[string]any{
|
||||
"foo": map[string]any{
|
||||
"bar": "",
|
||||
},
|
||||
},
|
||||
|
|
@ -300,7 +300,7 @@ func TestRenderTemplate_Required(t *testing.T) {
|
|||
{
|
||||
name: ".foo is nil",
|
||||
s: `{{ required "foo is required" .foo }}`,
|
||||
data: map[string]interface{}{
|
||||
data: map[string]any{
|
||||
"foo": nil,
|
||||
},
|
||||
wantErr: true,
|
||||
|
|
@ -308,7 +308,7 @@ func TestRenderTemplate_Required(t *testing.T) {
|
|||
{
|
||||
name: ".foo is a empty string",
|
||||
s: `{{ required "foo is required" .foo }}`,
|
||||
data: map[string]interface{}{
|
||||
data: map[string]any{
|
||||
"foo": "",
|
||||
},
|
||||
wantErr: true,
|
||||
|
|
|
|||
|
|
@ -11,14 +11,14 @@ import (
|
|||
|
||||
// to generate mock run mockgen -source=expand_secret_ref.go -destination=expand_secrets_mock.go -package=tmpl
|
||||
type valClient interface {
|
||||
Eval(template map[string]interface{}) (map[string]interface{}, error)
|
||||
Eval(template map[string]any) (map[string]any, error)
|
||||
}
|
||||
|
||||
var once sync.Once
|
||||
var secretsClient valClient
|
||||
|
||||
func fetchSecretValue(path string) (string, error) {
|
||||
tmpMap := make(map[string]interface{})
|
||||
tmpMap := make(map[string]any)
|
||||
tmpMap["key"] = path
|
||||
resultMap, err := fetchSecretValues(tmpMap)
|
||||
if err != nil {
|
||||
|
|
@ -38,7 +38,7 @@ func fetchSecretValue(path string) (string, error) {
|
|||
return result, nil
|
||||
}
|
||||
|
||||
func fetchSecretValues(values map[string]interface{}) (map[string]interface{}, error) {
|
||||
func fetchSecretValues(values map[string]any) (map[string]any, error) {
|
||||
var err error
|
||||
// below lines are for tests
|
||||
once.Do(func() {
|
||||
|
|
|
|||
|
|
@ -15,10 +15,10 @@ func Test_fetchSecretValue(t *testing.T) {
|
|||
secretsClient = c
|
||||
|
||||
secretPath := "ref+vault://key/#path"
|
||||
expectArg := make(map[string]interface{})
|
||||
expectArg := make(map[string]any)
|
||||
expectArg["key"] = secretPath
|
||||
|
||||
valsResult := make(map[string]interface{})
|
||||
valsResult := make(map[string]any)
|
||||
valsResult["key"] = "key_value"
|
||||
c.EXPECT().Eval(expectArg).Return(valsResult, nil)
|
||||
result, err := fetchSecretValue(secretPath)
|
||||
|
|
@ -33,7 +33,7 @@ func Test_fetchSecretValue_error(t *testing.T) {
|
|||
secretsClient = c
|
||||
|
||||
secretPath := "ref+vault://key/#path"
|
||||
expectArg := make(map[string]interface{})
|
||||
expectArg := make(map[string]any)
|
||||
expectArg["key"] = secretPath
|
||||
|
||||
expectedErr := errors.New("some error")
|
||||
|
|
@ -50,10 +50,10 @@ func Test_fetchSecretValue_no_key(t *testing.T) {
|
|||
secretsClient = c
|
||||
|
||||
secretPath := "ref+vault://key/#path"
|
||||
expectArg := make(map[string]interface{})
|
||||
expectArg := make(map[string]any)
|
||||
expectArg["key"] = secretPath
|
||||
|
||||
valsResult := make(map[string]interface{})
|
||||
valsResult := make(map[string]any)
|
||||
c.EXPECT().Eval(expectArg).Return(valsResult, nil)
|
||||
result, err := fetchSecretValue(secretPath)
|
||||
assert.Error(t, err, "unexpected error occurred, map[] doesn't have 'key' key")
|
||||
|
|
@ -67,10 +67,10 @@ func Test_fetchSecretValue_invalid_type(t *testing.T) {
|
|||
secretsClient = c
|
||||
|
||||
secretPath := "ref+vault://key/#path"
|
||||
expectArg := make(map[string]interface{})
|
||||
expectArg := make(map[string]any)
|
||||
expectArg["key"] = secretPath
|
||||
|
||||
valsResult := make(map[string]interface{})
|
||||
valsResult := make(map[string]any)
|
||||
valsResult["key"] = 10
|
||||
c.EXPECT().Eval(expectArg).Return(valsResult, nil)
|
||||
result, err := fetchSecretValue(secretPath)
|
||||
|
|
|
|||
|
|
@ -33,14 +33,14 @@ func (_m *MockvalClient) EXPECT() *MockvalClientMockRecorder {
|
|||
}
|
||||
|
||||
// Eval mocks base method
|
||||
func (_m *MockvalClient) Eval(template map[string]interface{}) (map[string]interface{}, error) {
|
||||
func (_m *MockvalClient) Eval(template map[string]any) (map[string]any, error) {
|
||||
ret := _m.ctrl.Call(_m, "Eval", template)
|
||||
ret0, _ := ret[0].(map[string]interface{})
|
||||
ret0, _ := ret[0].(map[string]any)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// Eval indicates an expected call of Eval
|
||||
func (_mr *MockvalClientMockRecorder) Eval(arg0 interface{}) *gomock.Call {
|
||||
func (_mr *MockvalClientMockRecorder) Eval(arg0 any) *gomock.Call {
|
||||
return _mr.mock.ctrl.RecordCallWithMethodType(_mr.mock, "Eval", reflect.TypeOf((*MockvalClient)(nil).Eval), arg0)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,10 +11,10 @@ import (
|
|||
type FileRenderer struct {
|
||||
fs *filesystem.FileSystem
|
||||
Context *Context
|
||||
Data interface{}
|
||||
Data any
|
||||
}
|
||||
|
||||
func NewFileRenderer(fs *filesystem.FileSystem, basePath string, data interface{}) *FileRenderer {
|
||||
func NewFileRenderer(fs *filesystem.FileSystem, basePath string, data any) *FileRenderer {
|
||||
return &FileRenderer{
|
||||
fs: fs,
|
||||
Context: &Context{
|
||||
|
|
@ -25,7 +25,7 @@ func NewFileRenderer(fs *filesystem.FileSystem, basePath string, data interface{
|
|||
}
|
||||
}
|
||||
|
||||
func NewFirstPassRenderer(basePath string, data interface{}) *FileRenderer {
|
||||
func NewFirstPassRenderer(basePath string, data any) *FileRenderer {
|
||||
fs := filesystem.DefaultFileSystem()
|
||||
return &FileRenderer{
|
||||
fs: fs,
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import (
|
|||
"github.com/helmfile/helmfile/pkg/filesystem"
|
||||
)
|
||||
|
||||
var emptyEnvTmplData = map[string]interface{}{
|
||||
var emptyEnvTmplData = map[string]any{
|
||||
"Environment": environment.EmptyEnvironment,
|
||||
"Namespace": "",
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,10 +14,10 @@ func (e *noValueError) Error() string {
|
|||
return e.msg
|
||||
}
|
||||
|
||||
func get(path string, varArgs ...interface{}) (interface{}, error) {
|
||||
func get(path string, varArgs ...any) (any, error) {
|
||||
var defSet bool
|
||||
var def interface{}
|
||||
var obj interface{}
|
||||
var def any
|
||||
var obj any
|
||||
switch len(varArgs) {
|
||||
case 1:
|
||||
defSet = false
|
||||
|
|
@ -35,14 +35,14 @@ func get(path string, varArgs ...interface{}) (interface{}, error) {
|
|||
return obj, nil
|
||||
}
|
||||
keys := strings.Split(path, ".")
|
||||
var v interface{}
|
||||
var v any
|
||||
var ok bool
|
||||
switch typedObj := obj.(type) {
|
||||
case *map[string]interface{}:
|
||||
case *map[string]any:
|
||||
obj = *typedObj
|
||||
}
|
||||
switch typedObj := obj.(type) {
|
||||
case map[string]interface{}:
|
||||
case map[string]any:
|
||||
v, ok = typedObj[keys[0]]
|
||||
if !ok {
|
||||
if defSet {
|
||||
|
|
@ -59,7 +59,7 @@ func get(path string, varArgs ...interface{}) (interface{}, error) {
|
|||
return nil, &noValueError{fmt.Sprintf("no value exist for key \"%s\" in %v", keys[0], typedObj)}
|
||||
}
|
||||
return v, nil
|
||||
case map[interface{}]interface{}:
|
||||
case map[any]any:
|
||||
v, ok = typedObj[keys[0]]
|
||||
if !ok {
|
||||
if defSet {
|
||||
|
|
@ -70,7 +70,7 @@ func get(path string, varArgs ...interface{}) (interface{}, error) {
|
|||
default:
|
||||
maybeStruct := reflect.ValueOf(typedObj)
|
||||
if maybeStruct.Kind() != reflect.Struct {
|
||||
return nil, &noValueError{fmt.Sprintf("unexpected type(%v) of value for key \"%s\": it must be either map[string]interface{} or any struct", reflect.TypeOf(obj), keys[0])}
|
||||
return nil, &noValueError{fmt.Sprintf("unexpected type(%v) of value for key \"%s\": it must be either map[string]any or any struct", reflect.TypeOf(obj), keys[0])}
|
||||
} else if maybeStruct.NumField() < 1 {
|
||||
return nil, &noValueError{fmt.Sprintf("no accessible struct fields for key \"%s\"", keys[0])}
|
||||
}
|
||||
|
|
@ -90,7 +90,7 @@ func get(path string, varArgs ...interface{}) (interface{}, error) {
|
|||
return get(strings.Join(keys[1:], "."), v)
|
||||
}
|
||||
|
||||
func getOrNil(path string, o interface{}) (interface{}, error) {
|
||||
func getOrNil(path string, o any) (any, error) {
|
||||
v, err := get(path, o)
|
||||
if err != nil {
|
||||
switch err.(type) {
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ func TestGetSimpleStruct(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetMap(t *testing.T) {
|
||||
obj := map[string]interface{}{"Foo": map[string]interface{}{"Bar": "Bar"}}
|
||||
obj := map[string]any{"Foo": map[string]any{"Bar": "Bar"}}
|
||||
|
||||
v1, err := get("Foo.Bar", obj)
|
||||
|
||||
|
|
@ -79,7 +79,7 @@ func TestGetMap(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetMapPtr(t *testing.T) {
|
||||
obj := map[string]interface{}{"Foo": map[string]interface{}{"Bar": "Bar"}}
|
||||
obj := map[string]any{"Foo": map[string]any{"Bar": "Bar"}}
|
||||
objPrt := &obj
|
||||
|
||||
v1, err := get("Foo.Bar", objPrt)
|
||||
|
|
@ -99,7 +99,7 @@ func TestGetMapPtr(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGet_Default(t *testing.T) {
|
||||
obj := map[string]interface{}{"Foo": map[string]interface{}{}, "foo": 1}
|
||||
obj := map[string]any{"Foo": map[string]any{}, "foo": 1}
|
||||
|
||||
v1, err := get("Foo.Bar", "Bar", obj)
|
||||
|
||||
|
|
@ -151,7 +151,7 @@ func TestGetOrNilStruct(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetOrNilMap(t *testing.T) {
|
||||
obj := map[string]interface{}{"Foo": map[string]interface{}{"Bar": "Bar"}}
|
||||
obj := map[string]any{"Foo": map[string]any{"Bar": "Bar"}}
|
||||
|
||||
v1, err := getOrNil("Foo.Bar", obj)
|
||||
|
||||
|
|
|
|||
|
|
@ -7,14 +7,14 @@ import (
|
|||
type templateTextRenderer struct {
|
||||
ReadText func(string) ([]byte, error)
|
||||
Context *Context
|
||||
Data interface{}
|
||||
Data any
|
||||
}
|
||||
|
||||
type TextRenderer interface {
|
||||
RenderTemplateText(text string) (string, error)
|
||||
}
|
||||
|
||||
func NewTextRenderer(fs *filesystem.FileSystem, basePath string, data interface{}) *templateTextRenderer {
|
||||
func NewTextRenderer(fs *filesystem.FileSystem, basePath string, data any) *templateTextRenderer {
|
||||
return &templateTextRenderer{
|
||||
ReadText: fs.ReadFile,
|
||||
Context: &Context{
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import (
|
|||
|
||||
// TestTextRenderer tests the text renderer.
|
||||
func TestNewTextRenderer(t *testing.T) {
|
||||
tData := map[string]interface{}{
|
||||
tData := map[string]any{
|
||||
"foo": "bar",
|
||||
}
|
||||
tr := NewTextRenderer(filesystem.DefaultFileSystem(), ".", tData)
|
||||
|
|
@ -20,7 +20,7 @@ func TestNewTextRenderer(t *testing.T) {
|
|||
|
||||
// TestTextRenderer tests the text renderer.
|
||||
func TestTextRender(t *testing.T) {
|
||||
tData := map[string]interface{}{
|
||||
tData := map[string]any{
|
||||
"foot": "bart",
|
||||
}
|
||||
tr := NewTextRenderer(filesystem.DefaultFileSystem(), ".", tData)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import (
|
|||
)
|
||||
|
||||
type Encoder interface {
|
||||
Encode(interface{}) error
|
||||
Encode(any) error
|
||||
Close() error
|
||||
}
|
||||
|
||||
|
|
@ -24,7 +24,7 @@ func NewEncoder(w io.Writer) Encoder {
|
|||
return v2.NewEncoder(w)
|
||||
}
|
||||
|
||||
func Unmarshal(data []byte, v interface{}) error {
|
||||
func Unmarshal(data []byte, v any) error {
|
||||
if runtime.GoccyGoYaml {
|
||||
return yaml.Unmarshal(data, v)
|
||||
}
|
||||
|
|
@ -36,7 +36,7 @@ func Unmarshal(data []byte, v interface{}) error {
|
|||
// contained within the YAML document stream per each call.
|
||||
// When strict is true, this function ensures that every field found in the YAML document
|
||||
// to have the corresponding field in the decoded Go struct.
|
||||
func NewDecoder(data []byte, strict bool) func(interface{}) error {
|
||||
func NewDecoder(data []byte, strict bool) func(any) error {
|
||||
if runtime.GoccyGoYaml {
|
||||
var opts []yaml.DecodeOption
|
||||
if strict {
|
||||
|
|
@ -48,7 +48,7 @@ func NewDecoder(data []byte, strict bool) func(interface{}) error {
|
|||
opts...,
|
||||
)
|
||||
|
||||
return func(v interface{}) error {
|
||||
return func(v any) error {
|
||||
return decoder.Decode(v)
|
||||
}
|
||||
}
|
||||
|
|
@ -56,12 +56,12 @@ func NewDecoder(data []byte, strict bool) func(interface{}) error {
|
|||
decoder := v2.NewDecoder(bytes.NewReader(data))
|
||||
decoder.SetStrict(strict)
|
||||
|
||||
return func(v interface{}) error {
|
||||
return func(v any) error {
|
||||
return decoder.Decode(v)
|
||||
}
|
||||
}
|
||||
|
||||
func Marshal(v interface{}) ([]byte, error) {
|
||||
func Marshal(v any) ([]byte, error) {
|
||||
if runtime.GoccyGoYaml {
|
||||
var b bytes.Buffer
|
||||
yamlEncoder := yaml.NewEncoder(
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ func globYamlFilenames(dir string) (sets.Set[string], error) {
|
|||
return set, nil
|
||||
}
|
||||
|
||||
type resource map[string]interface{}
|
||||
type resource map[string]any
|
||||
|
||||
type meta struct {
|
||||
apiVersion string
|
||||
|
|
@ -146,7 +146,7 @@ func (res resource) getMeta() meta {
|
|||
m.apiVersion = apiVersion
|
||||
kind, _ := res["kind"].(string)
|
||||
m.kind = kind
|
||||
metadata, _ := res["metadata"].(map[string]interface{})
|
||||
metadata, _ := res["metadata"].(map[string]any)
|
||||
name, _ := metadata["name"].(string)
|
||||
m.name = name
|
||||
namespace, _ := metadata["namespace"].(string)
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ type tmplTestCase struct {
|
|||
// tmplString is the template string to be parsed
|
||||
tmplString string
|
||||
// data is the data to be passed to the template
|
||||
data interface{}
|
||||
data any
|
||||
// wantErr is true if the template should fail to parse
|
||||
wantErr bool
|
||||
// output is the expected output of the template
|
||||
|
|
@ -172,9 +172,9 @@ var fromYamlTestCases = []tmplTestCase{
|
|||
|
||||
var setValueAtPathTestCases = []tmplTestCase{
|
||||
{
|
||||
data: map[string]interface{}{
|
||||
"root": map[string]interface{}{
|
||||
"testKey": map[string]interface{}{
|
||||
data: map[string]any{
|
||||
"root": map[string]any{
|
||||
"testKey": map[string]any{
|
||||
"testKey2": "test",
|
||||
},
|
||||
},
|
||||
|
|
@ -185,7 +185,7 @@ var setValueAtPathTestCases = []tmplTestCase{
|
|||
output: "testNewValue",
|
||||
},
|
||||
{
|
||||
data: map[string]interface{}{
|
||||
data: map[string]any{
|
||||
"root": "test",
|
||||
},
|
||||
wantErr: true,
|
||||
|
|
@ -196,9 +196,9 @@ var setValueAtPathTestCases = []tmplTestCase{
|
|||
|
||||
var getTestCases = []tmplTestCase{
|
||||
{
|
||||
data: map[string]interface{}{
|
||||
"root": map[string]interface{}{
|
||||
"testGetKey": map[string]interface{}{
|
||||
data: map[string]any{
|
||||
"root": map[string]any{
|
||||
"testGetKey": map[string]any{
|
||||
"testGetKey2": "test",
|
||||
},
|
||||
},
|
||||
|
|
@ -208,9 +208,9 @@ var getTestCases = []tmplTestCase{
|
|||
output: "test",
|
||||
},
|
||||
{
|
||||
data: map[string]interface{}{
|
||||
"root": map[string]interface{}{
|
||||
"testGetKey": map[string]interface{}{
|
||||
data: map[string]any{
|
||||
"root": map[string]any{
|
||||
"testGetKey": map[string]any{
|
||||
"testGetKey2": "test",
|
||||
},
|
||||
},
|
||||
|
|
@ -223,7 +223,7 @@ var getTestCases = []tmplTestCase{
|
|||
|
||||
var tplTestCases = []tmplTestCase{
|
||||
{
|
||||
data: map[string]interface{}{
|
||||
data: map[string]any{
|
||||
"root": "tplvalue",
|
||||
},
|
||||
name: "tpl",
|
||||
|
|
@ -231,7 +231,7 @@ var tplTestCases = []tmplTestCase{
|
|||
output: "tplvalue",
|
||||
},
|
||||
{
|
||||
data: map[string]interface{}{},
|
||||
data: map[string]any{},
|
||||
name: "tplInvalidTemplate",
|
||||
wantErr: true,
|
||||
tmplString: `{{ . | tpl "{{ .root }}" }}`,
|
||||
|
|
|
|||
Loading…
Reference in New Issue