diff --git a/cmd/configure/configure.go b/cmd/configure/configure.go index 5c6ade40d..e0c4f4049 100644 --- a/cmd/configure/configure.go +++ b/cmd/configure/configure.go @@ -6,7 +6,7 @@ import ( "text/template" "github.com/evcc-io/evcc/util/templates" - "github.com/go-sprout/sprout" + "github.com/go-sprout/sprout/sprigin" ) type device struct { @@ -116,7 +116,7 @@ var configTmpl string // RenderConfiguration creates a yaml configuration func (c *Configure) RenderConfiguration() ([]byte, error) { - tmpl, err := template.New("yaml").Funcs(sprout.FuncMap()).Parse(configTmpl) + tmpl, err := template.New("yaml").Funcs(sprigin.FuncMap()).Parse(configTmpl) if err != nil { panic(err) } diff --git a/cmd/dump.go b/cmd/dump.go index 76934cdf9..665243f1d 100644 --- a/cmd/dump.go +++ b/cmd/dump.go @@ -11,7 +11,7 @@ import ( "github.com/evcc-io/evcc/core" "github.com/evcc-io/evcc/server" "github.com/evcc-io/evcc/util/config" - "github.com/go-sprout/sprout" + "github.com/go-sprout/sprout/sprigin" "github.com/spf13/cobra" ) @@ -70,7 +70,7 @@ func runDump(cmd *cobra.Command, args []string) { tmpl := template.Must( template.New("dump"). - Funcs(sprout.FuncMap()). + Funcs(sprigin.FuncMap()). Parse(dumpTmpl)) out := new(bytes.Buffer) diff --git a/cmd/eebus.go b/cmd/eebus.go index 30b2ddbc6..1d34618e1 100644 --- a/cmd/eebus.go +++ b/cmd/eebus.go @@ -5,7 +5,7 @@ import ( "text/template" "github.com/evcc-io/evcc/server/eebus" - "github.com/go-sprout/sprout" + "github.com/go-sprout/sprout/sprigin" "github.com/spf13/cobra" ) @@ -42,7 +42,7 @@ func generateEEBUSCert() { log.FATAL.Fatal("could not process generated certificate", err) } - t := template.Must(template.New("out").Funcs(sprout.FuncMap()).Parse(tmpl)) + t := template.Must(template.New("out").Funcs(sprigin.FuncMap()).Parse(tmpl)) if err := t.Execute(os.Stdout, map[string]interface{}{ "public": pubKey, "private": privKey, diff --git a/cmd/tools/decorate.go b/cmd/tools/decorate.go index a4d013f06..dc61640c7 100644 --- a/cmd/tools/decorate.go +++ b/cmd/tools/decorate.go @@ -11,7 +11,7 @@ import ( "strings" "text/template" - "github.com/go-sprout/sprout" + "github.com/go-sprout/sprout/sprigin" combinations "github.com/mxschmitt/golang-combinations" "github.com/spf13/pflag" "golang.org/x/tools/imports" @@ -33,7 +33,7 @@ func generate(out io.Writer, packageName, functionName, baseType string, dynamic types := make(map[string]typeStruct, len(dynamicTypes)) combos := make([]string, 0) - tmpl, err := template.New("gen").Funcs(sprout.FuncMap()).Funcs(template.FuncMap{ + tmpl, err := template.New("gen").Funcs(sprigin.FuncMap()).Funcs(template.FuncMap{ // contains checks if slice contains string "contains": slices.Contains[[]string, string], // ordered returns a slice of typeStructs ordered by dynamicType diff --git a/go.mod b/go.mod index cdc83ac4d..aa2eb0ffe 100644 --- a/go.mod +++ b/go.mod @@ -109,6 +109,7 @@ require ( ) require ( + github.com/Masterminds/semver/v3 v3.2.1 // indirect github.com/ahmetb/go-linq/v3 v3.2.0 // indirect github.com/andybalholm/cascadia v1.3.2 // indirect github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect @@ -153,6 +154,8 @@ require ( github.com/mergermarket/go-pkcs7 v0.0.0-20170926155232-153b18ea13c9 // indirect github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect github.com/miekg/dns v1.1.62 // indirect + github.com/mitchellh/copystructure v1.2.0 // indirect + github.com/mitchellh/reflectwalk v1.0.2 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect diff --git a/go.sum b/go.sum index 094b38840..dfd81468b 100644 --- a/go.sum +++ b/go.sum @@ -8,6 +8,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0= github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= +github.com/Masterminds/semver/v3 v3.2.1 h1:RN9w6+7QoMeJVGyfmbcgs28Br8cvmnucEXnY0rYXWg0= +github.com/Masterminds/semver/v3 v3.2.1/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ= github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2 h1:+vx7roKuyA63nhn5WAunQHLTznkw5W8b1Xc0dNjp83s= github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2/go.mod h1:HBCaDeC1lPdgDeDbhX8XFpy1jqjK0IBG8W5K+xYqA0w= github.com/PuerkitoBio/goquery v1.9.2 h1:4/wZksC3KgkQw7SQgkKotmKljk0M6V8TUvA8Wb4yPeE= @@ -423,6 +425,8 @@ github.com/miekg/dns v1.1.43/go.mod h1:+evo5L0630/F6ca/Z9+GAqzhjGyn8/c+TBaOyfEl0 github.com/miekg/dns v1.1.62 h1:cN8OuEF1/x5Rq6Np+h1epln8OiyPWV+lROx9LxcGgIQ= github.com/miekg/dns v1.1.62/go.mod h1:mvDlcItzm+br7MToIKqkglaGhlFMHJ9DTNNWONWXbNQ= github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= +github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= +github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= @@ -431,6 +435,8 @@ github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS4 github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= +github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/mlnoga/rct v0.1.2-0.20240421173556-1c5b75037e2f h1:63hbvjkIpccli0EA60fqvzokvU1fH1ZPiNzlF/vUmvM= github.com/mlnoga/rct v0.1.2-0.20240421173556-1c5b75037e2f/go.mod h1:0lfd2mmBnBzIvuzYtdhG+2371u+cUfIxsYErm4P9KRI= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= diff --git a/push/hub.go b/push/hub.go index 1376a4218..f08ec87c6 100644 --- a/push/hub.go +++ b/push/hub.go @@ -7,7 +7,7 @@ import ( "github.com/evcc-io/evcc/core/vehicle" "github.com/evcc-io/evcc/util" - "github.com/go-sprout/sprout" + "github.com/go-sprout/sprout/sprigin" ) // Event is a notification event @@ -38,10 +38,10 @@ type Hub struct { func NewHub(cc map[string]EventTemplateConfig, vv Vehicles, cache *util.Cache) (*Hub, error) { // instantiate all event templates for k, v := range cc { - if _, err := template.New("out").Funcs(sprout.FuncMap()).Parse(v.Title); err != nil { + if _, err := template.New("out").Funcs(sprigin.FuncMap()).Parse(v.Title); err != nil { return nil, fmt.Errorf("invalid event title: %s (%w)", k, err) } - if _, err := template.New("out").Funcs(sprout.FuncMap()).Parse(v.Msg); err != nil { + if _, err := template.New("out").Funcs(sprigin.FuncMap()).Parse(v.Msg); err != nil { return nil, fmt.Errorf("invalid event message: %s (%w)", k, err) } } diff --git a/util/format.go b/util/format.go index e54e50899..6ff27c62e 100644 --- a/util/format.go +++ b/util/format.go @@ -10,7 +10,7 @@ import ( "strings" "time" - "github.com/go-sprout/sprout" + "github.com/go-sprout/sprout/sprigin" "github.com/samber/lo" ) @@ -55,7 +55,7 @@ func FormatValue(format string, val interface{}) string { func ReplaceFormatted(s string, kv map[string]interface{}) (string, error) { // Enhanced golang template logic tpl, err := template.New("base"). - Funcs(sprout.FuncMap()). + Funcs(sprigin.FuncMap()). Funcs(map[string]any{ "timeRound": timeRound, }).Parse(s) diff --git a/util/templates/documentation.go b/util/templates/documentation.go index c041af521..17d016c55 100644 --- a/util/templates/documentation.go +++ b/util/templates/documentation.go @@ -8,7 +8,7 @@ import ( "strings" "text/template" - "github.com/go-sprout/sprout" + "github.com/go-sprout/sprout/sprigin" ) //go:embed documentation.tpl @@ -45,7 +45,7 @@ func (t *Template) RenderDocumentation(product Product, lang string) ([]byte, er var modbusRender string if modbusChoices := t.ModbusChoices(); len(modbusChoices) > 0 { if i, _ := t.ParamByName(ParamModbus); i > -1 { - modbusTmpl, err := template.New("yaml").Funcs(sprout.FuncMap()).Parse(documentationModbusTmpl) + modbusTmpl, err := template.New("yaml").Funcs(sprigin.FuncMap()).Parse(documentationModbusTmpl) if err != nil { panic(err) } diff --git a/util/templates/template.go b/util/templates/template.go index c2e1d09b9..9077b6b93 100644 --- a/util/templates/template.go +++ b/util/templates/template.go @@ -9,7 +9,7 @@ import ( "strings" "text/template" - "github.com/go-sprout/sprout" + "github.com/go-sprout/sprout/sprigin" ) // Template describes is a proxy device for use with cli and automated testing @@ -207,7 +207,7 @@ var proxyTmpl string // RenderProxyWithValues renders the proxy template func (t *Template) RenderProxyWithValues(values map[string]interface{}, lang string) ([]byte, error) { - tmpl, err := template.New("yaml").Funcs(sprout.FuncMap()).Parse(proxyTmpl) + tmpl, err := template.New("yaml").Funcs(sprigin.FuncMap()).Parse(proxyTmpl) if err != nil { panic(err) } diff --git a/util/templates/utils.go b/util/templates/utils.go index 3058743e7..1a83a6a13 100644 --- a/util/templates/utils.go +++ b/util/templates/utils.go @@ -7,7 +7,7 @@ import ( "strings" "text/template" - "github.com/go-sprout/sprout" + "github.com/go-sprout/sprout/sprigin" "gopkg.in/yaml.v3" ) @@ -59,5 +59,5 @@ func FuncMap(tmpl *template.Template) *template.Template { "urlEncode": url.QueryEscape, } - return tmpl.Funcs(sprout.FuncMap()).Funcs(funcMap) + return tmpl.Funcs(sprigin.FuncMap()).Funcs(funcMap) }