Config dump

This commit is contained in:
Ben Sarmiento
2024-04-26 15:00:22 +02:00
parent 755b50c82f
commit 2dbabd3ead
4 changed files with 80 additions and 40 deletions

View File

@@ -4,7 +4,6 @@ type ConfigInterface interface {
GetConfig() ZurgConfig
GetVersion() string
GetToken() string
GetTokens() []string
GetNumOfWorkers() int
GetRefreshEverySecs() int
GetRepairEveryMins() int
@@ -35,9 +34,8 @@ type ConfigInterface interface {
}
type ZurgConfig struct {
Version string `yaml:"zurg" json:"-"`
Token string `yaml:"token" json:"-"`
Tokens []string `yaml:"tokens" json:"-"`
Version string `yaml:"zurg" json:"-"`
Token string `yaml:"token" json:"-"`
ApiTimeoutSecs int `yaml:"api_timeout_secs" json:"api_timeout_secs"`
CanRepair bool `yaml:"enable_repair" json:"enable_repair"`
@@ -74,10 +72,6 @@ func (z *ZurgConfig) GetToken() string {
return z.Token
}
func (z *ZurgConfig) GetTokens() []string {
return z.Tokens
}
func (z *ZurgConfig) GetHost() string {
if z.Host == "" {
return "[::]"

View File

@@ -23,6 +23,16 @@ func loadV1Config(content []byte, log *logutil.Logger) (*ZurgConfigV1, error) {
if err := yaml.Unmarshal(content, &configV1); err != nil {
return nil, err
}
// don't log token and password
bufToken := configV1.Token
configV1.Token = strings.Repeat("*", len(bufToken)-4) + bufToken[len(bufToken)-4:]
bufPassword := configV1.Password
configV1.Password = strings.Repeat("*", len(bufPassword))
log.Debugf("Config dump: %+v", configV1)
configV1.Token = bufToken
configV1.Password = bufPassword
configV1.log = log
return &configV1, nil
}