remove parse

This commit is contained in:
seydx
2025-05-20 22:44:07 +02:00
parent a1f0b86ab3
commit 24310e2f7a
-31
View File
@@ -2,8 +2,6 @@ package app
import (
"fmt"
"regexp"
"strings"
"sync"
"github.com/AlexxIT/go2rtc/pkg/yaml"
@@ -12,8 +10,6 @@ import (
var secrets = make(map[string]*Secret)
var secretsMu sync.Mutex
var templateRegex = regexp.MustCompile(`\{\{\s*([^\}]+)\s*\}\}`)
type Secrets interface {
Get(key string) any
Set(key string, value any)
@@ -76,33 +72,6 @@ func (s *Secret) Set(key string, value any) {
secrets[s.Name] = s
}
func (s *Secret) Parse(template string) string {
if !templateRegex.MatchString(template) {
return template
}
secretsMu.Lock()
defer secretsMu.Unlock()
if _, exists := secrets[s.Name]; !exists {
return template
}
result := templateRegex.ReplaceAllStringFunc(template, func(match string) string {
varName := strings.TrimSpace(templateRegex.FindStringSubmatch(match)[1])
pathParts := strings.Split(varName, ".")
value := getNestedValue(s.Values, pathParts)
if value != nil {
return stringify(value)
}
return ""
})
return result
}
func (s *Secret) Marshal(v any) ([]byte, error) {
secretsMu.Lock()
defer secretsMu.Unlock()