mirror of
https://github.com/anotherhadi/spilltea.git
synced 2026-07-06 20:42:33 +02:00
fix: add ssl_insecure, expand values, edit keybindings, ...
Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com>
This commit is contained in:
@@ -28,6 +28,7 @@ type Config struct {
|
||||
ProxyAuth string `mapstructure:"proxy_auth"`
|
||||
MaxBodySizeMB int `mapstructure:"max_body_size_mb"`
|
||||
ExternalEditor string `mapstructure:"external_editor"`
|
||||
SslInsecure bool `mapstructure:"ssl_insecure"`
|
||||
} `mapstructure:"app"`
|
||||
|
||||
TUI struct {
|
||||
@@ -82,7 +83,12 @@ func Load(path string) error {
|
||||
}
|
||||
|
||||
Global = &Config{}
|
||||
return viper.Unmarshal(Global)
|
||||
if err := viper.Unmarshal(Global); err != nil {
|
||||
return err
|
||||
}
|
||||
Global.App.ProxyAuth = expandEnvValue(Global.App.ProxyAuth)
|
||||
Global.App.UpstreamProxy = expandEnvValue(Global.App.UpstreamProxy)
|
||||
return nil
|
||||
}
|
||||
|
||||
func WriteDefaultConfig(path string) error {
|
||||
@@ -106,6 +112,17 @@ func ExpandPath(p string) string {
|
||||
return p
|
||||
}
|
||||
|
||||
// expandEnvValue replaces a value starting with "$" with the corresponding
|
||||
// environment variable, enabling secrets to be kept out of config files.
|
||||
func expandEnvValue(s string) string {
|
||||
if len(s) > 1 && s[0] == '$' {
|
||||
if val := os.Getenv(s[1:]); val != "" {
|
||||
return val
|
||||
}
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
func flatten(prefix string, m map[string]any) map[string]any {
|
||||
out := make(map[string]any)
|
||||
for k, v := range m {
|
||||
|
||||
Reference in New Issue
Block a user