add ability to log to file, update to v2.28.1 and fix 'first upgrade' issue

This commit is contained in:
2025-09-13 00:49:05 +03:00
parent d51a98efb3
commit 4f38f3a851
35 changed files with 773 additions and 543 deletions

View File

@@ -25,11 +25,11 @@ func funcMap() template.FuncMap {
"fromJson": fromJSON,
"fromJsonArray": fromJSONArray,
"include": func(string, interface{}) string { return "not implemented" },
"tpl": func(string, interface{}) interface{} { return "not implemented" },
"required": func(string, interface{}) (interface{}, error) { return "not implemented", nil },
"lookup": func(string, string, string, string) (map[string]interface{}, error) {
return map[string]interface{}{}, nil
"include": func(string, any) string { return "not implemented" },
"tpl": func(string, any) any { return "not implemented" },
"required": func(string, any) (any, error) { return "not implemented", nil },
"lookup": func(string, string, string, string) (map[string]any, error) {
return map[string]any{}, nil
},
}
@@ -40,7 +40,7 @@ func funcMap() template.FuncMap {
return f
}
func toYAML(v interface{}) string {
func toYAML(v any) string {
data, err := yaml.Marshal(v)
if err != nil {
// Swallow errors inside of a template.
@@ -49,8 +49,8 @@ func toYAML(v interface{}) string {
return strings.TrimSuffix(string(data), "\n")
}
func fromYAML(str string) map[string]interface{} {
m := map[string]interface{}{}
func fromYAML(str string) map[string]any {
m := map[string]any{}
if err := yaml.Unmarshal([]byte(str), &m); err != nil {
m["Error"] = err.Error()
@@ -58,16 +58,16 @@ func fromYAML(str string) map[string]interface{} {
return m
}
func fromYAMLArray(str string) []interface{} {
a := []interface{}{}
func fromYAMLArray(str string) []any {
a := []any{}
if err := yaml.Unmarshal([]byte(str), &a); err != nil {
a = []interface{}{err.Error()}
a = []any{err.Error()}
}
return a
}
func toTOML(v interface{}) string {
func toTOML(v any) string {
b := bytes.NewBuffer(nil)
e := toml.NewEncoder(b)
err := e.Encode(v)
@@ -77,7 +77,7 @@ func toTOML(v interface{}) string {
return b.String()
}
func toJSON(v interface{}) string {
func toJSON(v any) string {
data, err := json.Marshal(v)
if err != nil {
// Swallow errors inside of a template.
@@ -86,8 +86,8 @@ func toJSON(v interface{}) string {
return string(data)
}
func fromJSON(str string) map[string]interface{} {
m := make(map[string]interface{})
func fromJSON(str string) map[string]any {
m := make(map[string]any)
if err := json.Unmarshal([]byte(str), &m); err != nil {
m["Error"] = err.Error()
@@ -95,11 +95,11 @@ func fromJSON(str string) map[string]interface{} {
return m
}
func fromJSONArray(str string) []interface{} {
a := []interface{}{}
func fromJSONArray(str string) []any {
a := []any{}
if err := json.Unmarshal([]byte(str), &a); err != nil {
a = []interface{}{err.Error()}
a = []any{err.Error()}
}
return a
}