This commit is contained in:
seydx
2025-05-20 22:29:27 +02:00
parent 7f87c6e478
commit a1f0b86ab3
3 changed files with 23 additions and 28 deletions
-5
View File
@@ -13,7 +13,6 @@ var (
Version string
UserAgent string
ConfigPath string
SecretPath string
Info = make(map[string]any)
)
@@ -78,10 +77,6 @@ func Init() {
if ConfigPath != "" {
Logger.Info().Str("path", ConfigPath).Msg("config")
}
if SecretPath != "" {
Logger.Info().Str("path", SecretPath).Msg("secrets")
}
}
func readRevisionTime() (revision, vcsTime string) {
+22 -22
View File
@@ -26,35 +26,35 @@ type Secrets interface {
type Secret struct {
Secrets
Name string
Name string
Values map[string]any
}
func NewSecret(name string, values interface{}) *Secret {
secretsMu.Lock()
defer secretsMu.Unlock()
secretsMu.Lock()
defer secretsMu.Unlock()
if s, exists := secrets[name]; exists {
return s
}
if s, exists := secrets[name]; exists {
return s
}
s := &Secret{Name: name, Values: make(map[string]any)}
switch v := values.(type) {
case map[string]any:
s.Values = v
default:
data, err := yaml.Encode(values, 2)
if err == nil {
var mapValues map[string]any
if err := yaml.Unmarshal(data, &mapValues); err == nil {
s.Values = mapValues
}
}
}
s := &Secret{Name: name, Values: make(map[string]any)}
secrets[name] = s
return s
switch v := values.(type) {
case map[string]any:
s.Values = v
default:
data, err := yaml.Encode(values, 2)
if err == nil {
var mapValues map[string]any
if err := yaml.Unmarshal(data, &mapValues); err == nil {
s.Values = mapValues
}
}
}
secrets[name] = s
return s
}
func (s *Secret) Get(key string) any {
+1 -1
View File
@@ -21,4 +21,4 @@ func (l *Listener) Fire(msg any) {
func (l *Listener) NewSecret(name string, defaultValues interface{}) *app.Secret {
return app.NewSecret(name, defaultValues)
}
}