Skip to content

Commit 245e840

Browse files
jortelweb-flow
authored andcommitted
🐛 Ensure settings are redacted. (#924)
fixes #923 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Startup now logs the full application configuration in YAML with sensitive passphrases redacted, improving diagnostics and visibility. * **Style** * Reformatted the startup log into a single multi-line message for clearer, more readable output on launch. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Jeff Ortel <[email protected]> Signed-off-by: Cherry Picker <[email protected]>
1 parent 249ed50 commit 245e840

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

cmd/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func addonManager(db *gorm.DB) (mgr manager.Manager, err error) {
9494

9595
// main.
9696
func main() {
97-
log.Info("Started", "settings", Settings)
97+
log.Info("Started:\n" + Settings.String())
9898
var err error
9999
defer func() {
100100
if err != nil {

settings/all.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package settings
33
import (
44
"os"
55
"strconv"
6+
7+
"gopkg.in/yaml.v2"
68
)
79

810
var Settings TackleSettings
@@ -34,6 +36,22 @@ func (r *TackleSettings) Load() (err error) {
3436
return
3537
}
3638

39+
// String returns a YAML representation.
40+
// Redacted as needed.
41+
func (r TackleSettings) String() (s string) {
42+
redacted := "********"
43+
r.Encryption.Passphrase = redacted
44+
r.Auth.Keycloak.ClientSecret = redacted
45+
r.Auth.Keycloak.Admin.Pass = redacted
46+
r.Auth.Keycloak.Admin.User = redacted
47+
b, err := yaml.Marshal(r)
48+
if err != nil {
49+
panic(err)
50+
}
51+
s = string(b)
52+
return
53+
}
54+
3755
// Get boolean.
3856
func getEnvBool(name string, def bool) bool {
3957
boolean := def

0 commit comments

Comments
 (0)