format
This commit is contained in:
@@ -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) {
|
||||||
|
|||||||
+22
-22
@@ -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) {
|
|
||||||
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
|
switch v := values.(type) {
|
||||||
return s
|
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 {
|
func (s *Secret) Get(key string) any {
|
||||||
|
|||||||
@@ -21,4 +21,4 @@ func (l *Listener) Fire(msg any) {
|
|||||||
|
|
||||||
func (l *Listener) NewSecret(name string, defaultValues interface{}) *app.Secret {
|
func (l *Listener) NewSecret(name string, defaultValues interface{}) *app.Secret {
|
||||||
return app.NewSecret(name, defaultValues)
|
return app.NewSecret(name, defaultValues)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user