From b4fd4e7d68280f74f643a8c632cbb08d5a086573 Mon Sep 17 00:00:00 2001 From: Finn Date: Mon, 4 Nov 2024 15:08:23 -0800 Subject: [PATCH] freeswitch container: use x-pre-process includes for static configs --- .../freeswitch/dynamic-xmlconfig/main.go | 33 ++----------------- 1 file changed, 2 insertions(+), 31 deletions(-) diff --git a/containers/freeswitch/dynamic-xmlconfig/main.go b/containers/freeswitch/dynamic-xmlconfig/main.go index feab103..214e3c2 100644 --- a/containers/freeswitch/dynamic-xmlconfig/main.go +++ b/containers/freeswitch/dynamic-xmlconfig/main.go @@ -4,11 +4,8 @@ import ( "embed" "errors" "fmt" - "io" - "io/fs" "net/url" "os" - "path/filepath" "text/template" "github.com/kelseyhightower/envconfig" @@ -21,7 +18,6 @@ type Options struct { LogLevel string `envconfig:"LOG_LEVEL" default:"info"` Gateway Gateway `envconfig:"GATEWAY"` Modules []string `envconfig:"MODULES" default:"mod_event_socket,mod_sofia,mod_db,mod_dialplan_xml,mod_g723_1,mod_g729,mod_amr,mod_b64,mod_opus,mod_av,mod_sndfile,mod_native_file,mod_png,mod_local_stream,mod_tone_stream,mod_lua,mod_say_en"` - StaticXMLDir string `envconfig:"STATIC_XML_DIR" default:"/config"` } type Gateway struct { @@ -147,7 +143,7 @@ func main() { fmt.Println("") - staticConfigDirectories, err := os.ReadDir(options.StaticXMLDir) + staticConfigDirectories, err := os.ReadDir("/usr/local/freeswitch/conf") if err != nil { if errors.Is(err, os.ErrNotExist) { return @@ -160,32 +156,7 @@ func main() { continue } fmt.Printf("
\n", entry.Name()) - - filepath.WalkDir(filepath.Join(options.StaticXMLDir, entry.Name()), func(path string, d fs.DirEntry, err error) error { - if d.IsDir() { - return nil - } - - fmt.Printf("\n", path) - if err != nil { - fmt.Printf("", err) - return err - } - - f, err := os.Open(path) - if err != nil { - panic(err) - } - defer f.Close() - - data, err := io.ReadAll(f) - if err != nil { - panic(err) - } - fmt.Println(string(data)) - - return nil - }) + fmt.Printf("\n", entry.Name()) fmt.Println("
") } }