Config UI: keep mqtt and influx secrets (part 2) (#20340)

This commit is contained in:
Leon 2025-04-04 12:43:11 +02:00 • committed by GitHub
parent 1c1ec03aac
commit 2e5f1808d7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 91 additions and 45 deletions

View file

@ -28,12 +28,33 @@ func ClientID() string {
type Config struct {
Broker string `json:"broker"`
User string `json:"user"`
Password string `json:"password"`
ClientID string `json:"clientID"`
Insecure bool `json:"insecure"`
CaCert string `json:"caCert"`
ClientCert string `json:"clientCert"`
ClientKey string `json:"clientKey"`
Password string `json:"password,omitempty"`
ClientID string `json:"clientID,omitempty"`
Insecure bool `json:"insecure,omitempty"`
CaCert string `json:"caCert,omitempty"`
ClientCert string `json:"clientCert,omitempty"`
ClientKey string `json:"clientKey,omitempty"`
}
func masked(s any) string {
if s != "" {
return "***"
}
return ""
}
// Redacted implements the redactor interface
func (c Config) Redacted() Config {
return Config{
Broker: c.Broker,
User: c.User,
Password: masked(c.Password),
ClientID: c.ClientID,
Insecure: c.Insecure,
CaCert: masked(c.CaCert),
ClientCert: masked(c.ClientCert),
ClientKey: masked(c.ClientKey),
}
}
// Client encapsulates mqtt publish/subscribe functions