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 Version string
UserAgent string UserAgent string
ConfigPath string ConfigPath string
SecretPath string
Info = make(map[string]any) Info = make(map[string]any)
) )
@@ -78,10 +77,6 @@ func Init() {
if ConfigPath != "" { if ConfigPath != "" {
Logger.Info().Str("path", ConfigPath).Msg("config") Logger.Info().Str("path", ConfigPath).Msg("config")
} }
if SecretPath != "" {
Logger.Info().Str("path", SecretPath).Msg("secrets")
}
} }
func readRevisionTime() (revision, vcsTime string) { func readRevisionTime() (revision, vcsTime string) {
+21 -21
View File
@@ -26,35 +26,35 @@ type Secrets interface {
type Secret struct { type Secret struct {
Secrets Secrets
Name string Name string
Values map[string]any Values map[string]any
} }
func NewSecret(name string, values interface{}) *Secret { func NewSecret(name string, values interface{}) *Secret {
secretsMu.Lock() secretsMu.Lock()
defer secretsMu.Unlock() defer secretsMu.Unlock()
if s, exists := secrets[name]; exists { if s, exists := secrets[name]; exists {
return s return s
} }
s := &Secret{Name: name, Values: make(map[string]any)} s := &Secret{Name: name, Values: make(map[string]any)}
switch v := values.(type) { switch v := values.(type) {
case map[string]any: case map[string]any:
s.Values = v s.Values = v
default: default:
data, err := yaml.Encode(values, 2) data, err := yaml.Encode(values, 2)
if err == nil { if err == nil {
var mapValues map[string]any var mapValues map[string]any
if err := yaml.Unmarshal(data, &mapValues); err == nil { if err := yaml.Unmarshal(data, &mapValues); err == nil {
s.Values = mapValues s.Values = mapValues
} }
} }
} }
secrets[name] = s secrets[name] = s
return s return s
} }
func (s *Secret) Get(key string) any { func (s *Secret) Get(key string) any {