diff --git a/pkg/agent/templates/templates.go b/pkg/agent/templates/templates.go index 78260fb895d..aadf6c0112e 100644 --- a/pkg/agent/templates/templates.go +++ b/pkg/agent/templates/templates.go @@ -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 { diff --git a/pkg/agent/templates/templates_linux.go b/pkg/agent/templates/templates_linux.go index 912d12d7023..bf302be6f5e 100644 --- a/pkg/agent/templates/templates_linux.go +++ b/pkg/agent/templates/templates_linux.go @@ -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) }, diff --git a/pkg/agent/templates/templates_windows.go b/pkg/agent/templates/templates_windows.go index 34857968d43..300df300e3e 100644 --- a/pkg/agent/templates/templates_windows.go +++ b/pkg/agent/templates/templates_windows.go @@ -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) }, diff --git a/pkg/bootstrap/bootstrap.go b/pkg/bootstrap/bootstrap.go index 756e0df80d3..40b2a95dc28 100644 --- a/pkg/bootstrap/bootstrap.go +++ b/pkg/bootstrap/bootstrap.go @@ -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 diff --git a/pkg/bootstrap/bootstrap_test.go b/pkg/bootstrap/bootstrap_test.go index 96c66aee017..ca0245ce6c0 100644 --- a/pkg/bootstrap/bootstrap_test.go +++ b/pkg/bootstrap/bootstrap_test.go @@ -8,7 +8,7 @@ import ( func TestObjToMap(t *testing.T) { type args struct { - obj interface{} + obj any } tests := []struct { name string diff --git a/pkg/cloudprovider/servicelb.go b/pkg/cloudprovider/servicelb.go index cd574eacbbb..e31784e7f18 100644 --- a/pkg/cloudprovider/servicelb.go +++ b/pkg/cloudprovider/servicelb.go @@ -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 diff --git a/pkg/configfilearg/parser.go b/pkg/configfilearg/parser.go index 6d86f2c0c71..b54ac30439d 100644 --- a/pkg/configfilearg/parser.go +++ b/pkg/configfilearg/parser.go @@ -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} } } diff --git a/pkg/daemons/executor/executor.go b/pkg/daemons/executor/executor.go index 7d092e744d5..7e32efec3d8 100644 --- a/pkg/daemons/executor/executor.go +++ b/pkg/daemons/executor/executor.go @@ -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 } diff --git a/pkg/nodepassword/nodepassword_test.go b/pkg/nodepassword/nodepassword_test.go index 360990cc7af..4c7a82f5a9f 100644 --- a/pkg/nodepassword/nodepassword_test.go +++ b/pkg/nodepassword/nodepassword_test.go @@ -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) } diff --git a/pkg/util/condition.go b/pkg/util/condition.go index 4aa7c7e7454..2ad9ebc60a3 100644 --- a/pkg/util/condition.go +++ b/pkg/util/condition.go @@ -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}, }, }) diff --git a/pkg/util/reflect.go b/pkg/util/reflect.go index 9530f02e9b4..758707e2666 100644 --- a/pkg/util/reflect.go +++ b/pkg/util/reflect.go @@ -5,6 +5,6 @@ import ( "runtime" ) -func GetFunctionName(i interface{}) string { +func GetFunctionName(i any) string { return runtime.FuncForPC(reflect.ValueOf(i).Pointer()).Name() }