mirror of
https://github.com/fatedier/frp.git
synced 2025-06-16 16:28:23 +00:00
Merge 7664abb6d2505c21723fe91aa7b68c3c70d99eec into ae73ec2fedc13cc2c44039dabba719a318221be5
This commit is contained in:
commit
279f4c8d63
1
go.mod
1
go.mod
@ -6,6 +6,7 @@ require (
|
||||
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5
|
||||
github.com/coreos/go-oidc/v3 v3.10.0
|
||||
github.com/fatedier/golib v0.5.0
|
||||
github.com/go-task/slim-sprig/v3 v3.0.0
|
||||
github.com/google/uuid v1.6.0
|
||||
github.com/gorilla/mux v1.8.1
|
||||
github.com/gorilla/websocket v1.5.0
|
||||
|
2
go.sum
2
go.sum
@ -34,6 +34,8 @@ github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ=
|
||||
github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI=
|
||||
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls=
|
||||
github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI=
|
||||
github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
|
@ -18,10 +18,11 @@ import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"html/template"
|
||||
"maps"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"text/template"
|
||||
|
||||
toml "github.com/pelletier/go-toml/v2"
|
||||
"github.com/samber/lo"
|
||||
@ -34,6 +35,8 @@ import (
|
||||
"github.com/fatedier/frp/pkg/config/v1/validation"
|
||||
"github.com/fatedier/frp/pkg/msg"
|
||||
"github.com/fatedier/frp/pkg/util/util"
|
||||
|
||||
"github.com/go-task/slim-sprig/v3"
|
||||
)
|
||||
|
||||
var glbEnvs map[string]string
|
||||
@ -80,10 +83,14 @@ func DetectLegacyINIFormatFromFile(path string) bool {
|
||||
}
|
||||
|
||||
func RenderWithTemplate(in []byte, values *Values) ([]byte, error) {
|
||||
tmpl, err := template.New("frp").Funcs(template.FuncMap{
|
||||
funcMap := sprig.FuncMap()
|
||||
|
||||
maps.Copy(funcMap, template.FuncMap{
|
||||
"parseNumberRange": parseNumberRange,
|
||||
"parseNumberRangePair": parseNumberRangePair,
|
||||
}).Parse(string(in))
|
||||
})
|
||||
|
||||
tmpl, err := template.New("frp").Funcs(funcMap).Parse(string(in))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -92,6 +99,7 @@ func RenderWithTemplate(in []byte, values *Values) ([]byte, error) {
|
||||
if err := tmpl.Execute(buffer, values); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return buffer.Bytes(), nil
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user