lint: use-any

Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
This commit is contained in:
Brad Davidson 2025-12-15 22:13:49 +00:00 committed by Brad Davidson
parent 316464975e
commit eee8234720
11 changed files with 19 additions and 19 deletions

View file

@ -326,7 +326,7 @@ skip_verify = true
{{ end -}}
`
func ParseTemplateFromConfig(userTemplate, baseTemplate string, config interface{}) (string, error) {
func ParseTemplateFromConfig(userTemplate, baseTemplate string, config any) (string, error) {
out := new(bytes.Buffer)
t := template.Must(template.New("compiled_template").Funcs(templateFuncs).Parse(userTemplate))
template.Must(t.New("base").Parse(baseTemplate))
@ -336,7 +336,7 @@ func ParseTemplateFromConfig(userTemplate, baseTemplate string, config interface
return trimEmpty(out)
}
func ParseHostsTemplateFromConfig(userTemplate string, config interface{}) (string, error) {
func ParseHostsTemplateFromConfig(userTemplate string, config any) (string, error) {
out := new(bytes.Buffer)
t := template.Must(template.New("compiled_template").Funcs(templateFuncs).Parse(userTemplate))
if err := t.Execute(out, config); err != nil {

View file

@ -12,7 +12,7 @@ var templateFuncs = template.FuncMap{
"deschemify": func(s string) string {
return s
},
"toJson": func(v interface{}) string {
"toJson": func(v any) string {
output, _ := json.Marshal(v)
return string(output)
},

View file

@ -21,7 +21,7 @@ var templateFuncs = template.FuncMap{
}
return s
},
"toJson": func(v interface{}) string {
"toJson": func(v any) string {
output, _ := json.Marshal(v)
return string(output)
},

View file

@ -84,7 +84,7 @@ func WriteToDiskFromStorage(files PathsDataformat, bootstrap *config.ControlRunt
return nil
}
func ObjToMap(obj interface{}) (map[string]string, error) {
func ObjToMap(obj any) (map[string]string, error) {
bytes, err := json.Marshal(obj)
if err != nil {
return nil, err

View file

@ -8,7 +8,7 @@ import (
func TestObjToMap(t *testing.T) {
type args struct {
obj interface{}
obj any
}
tests := []struct {
name string

View file

@ -201,7 +201,7 @@ func (k *k3s) processNextWorkItem() bool {
// processSingleItem processes a single item from the work queue,
// requeueing it if the handler fails.
func (k *k3s) processSingleItem(obj interface{}) error {
func (k *k3s) processSingleItem(obj any) error {
var (
key string
ok bool

View file

@ -263,7 +263,7 @@ func readConfigFile(file string) (result []string, _ error) {
var (
keySeen = map[string]bool{}
keyOrder []string
values = map[string]interface{}{}
values = map[string]any{}
)
for _, file := range files {
bytes, err := readConfigFileData(file)
@ -302,7 +302,7 @@ func readConfigFile(file string) (result []string, _ error) {
prefix = "-"
}
if slice, ok := v.([]interface{}); ok {
if slice, ok := v.([]any); ok {
for _, v := range slice {
result = append(result, prefix+k+"="+convert.ToString(v))
}
@ -315,18 +315,18 @@ func readConfigFile(file string) (result []string, _ error) {
return
}
func toSlice(v interface{}) []interface{} {
func toSlice(v any) []any {
switch k := v.(type) {
case string:
return []interface{}{k}
case []interface{}:
return []any{k}
case []any:
return k
default:
str := strings.TrimSpace(convert.ToString(v))
if str == "" {
return nil
}
return []interface{}{str}
return []any{str}
}
}

View file

@ -105,7 +105,7 @@ func (e ETCDConfig) ToConfigFile(extraArgs []string) (string, error) {
}
if len(extraArgs) > 0 {
var s map[string]interface{}
var s map[string]any
if err := yaml2.Unmarshal(bytes, &s); err != nil {
return "", err
}

View file

@ -30,13 +30,13 @@ func Test_PasswordError(t *testing.T) {
// --------------------------
// utility functions
func assertEqual(t *testing.T, a interface{}, b interface{}) {
func assertEqual(t *testing.T, a any, b any) {
if a != b {
t.Fatalf("[ %v != %v ]", a, b)
}
}
func assertNotEqual(t *testing.T, a interface{}, b interface{}) {
func assertNotEqual(t *testing.T, a any, b any) {
if a == b {
t.Fatalf("[ %v == %v ]", a, b)
}

View file

@ -30,8 +30,8 @@ func SetNodeCondition(core config.CoreFactory, nodeName string, condition corev1
return ErrCoreNotReady
}
condition.LastHeartbeatTime = metav1.NewTime(time.Now())
patch, err := json.Marshal(map[string]interface{}{
"status": map[string]interface{}{
patch, err := json.Marshal(map[string]any{
"status": map[string]any{
"conditions": []corev1.NodeCondition{condition},
},
})

View file

@ -5,6 +5,6 @@ import (
"runtime"
)
func GetFunctionName(i interface{}) string {
func GetFunctionName(i any) string {
return runtime.FuncForPC(reflect.ValueOf(i).Pointer()).Name()
}