Skip to content

Commit 6da51ec

Browse files
authored
Log/uid and user information for garm for better traceability (#41)
* log: new log * feat: debug mode * log: fixed to warning as unprepared currentUser won't stop the process
1 parent 05fa448 commit 6da51ec

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

service/server.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"context"
1919
"fmt"
2020
"net/http"
21+
"os/user"
2122
"sync"
2223
"time"
2324

@@ -127,6 +128,15 @@ func (s *server) ListenAndServe(ctx context.Context) chan []error {
127128
wg := new(sync.WaitGroup)
128129
wg.Add(2)
129130

131+
currentUser, err := user.Current()
132+
if err != nil {
133+
glg.Warn(err)
134+
} else {
135+
// Log the current user information:
136+
// With security perspective of UID: https://help.switch.ch/aai/support/documents/attributes/uid/#:~:text=uid%20is%20security%20sensitive%20since,anyhow%20not%20unique%20across%20organizations.
137+
glg.Debugf("Running garm as user [%s] with UID [%s] ...", currentUser.Username, currentUser.Uid)
138+
}
139+
130140
// start both webhook server and health check server
131141
go func() {
132142
s.mu.Lock()

0 commit comments

Comments
 (0)