Skip to content

Commit 6f164ae

Browse files
ncodemxab
authored andcommittedMar 5, 2025
fix README and update logging to add clientIP and AccessorID
1 parent 734d9aa commit 6f164ae

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed
 

‎README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import future.keywords
3232
3333
patch contains ops if [
3434
35-
input.Name == "greeting_job"
35+
input.job.Name == "greeting_job"
3636
ops:= {
3737
"op": "add",
3838
"path": "/Meta",
@@ -44,13 +44,13 @@ patch contains ops if [
4444
4545
errors contains msg if {
4646
47-
input.Name == "silent_job"
47+
input.job.Name == "silent_job"
4848
msg := "cannot greet"
4949
}
5050
5151
warnings contains msg if {
5252
53-
input.Name == "had_no_coffee_yet_job"
53+
input.job.Name == "had_no_coffee_yet_job"
5454
msg := "you should have coffee first"
5555
}
5656
```
@@ -132,12 +132,12 @@ import future.keywords.if
132132
133133
errors contains msg if {
134134
135-
not input.Meta.costcenter
135+
not input.job.Meta.costcenter
136136
msg := "Every job must have a costcenter metadata label"
137137
}
138138
139139
errors contains msg if {
140-
value := input.Meta.costcenter
140+
value := input.job.Meta.costcenter
141141
142142
not startswith(value, "cccode-")
143143
msg := sprintf("Costcenter code must start with `cccode-`; found `%v`", [value])

‎cmd/nacp/nacp.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,6 @@ func NewProxyHandler(nomadAddress *url.URL, jobHandler *admissionctrl.JobHandler
132132

133133
return func(w http.ResponseWriter, r *http.Request) {
134134

135-
appLogger.Info("Request received", "path", r.URL.Path, "method", r.Method)
136-
137135
ctx := r.Context()
138136
reqCtx := &config.RequestContext{
139137
ClientIP: getClientIP(r),
@@ -150,6 +148,9 @@ func NewProxyHandler(nomadAddress *url.URL, jobHandler *admissionctrl.JobHandler
150148
reqCtx.AccessorID = tokenInfo.AccessorID
151149
reqCtx.TokenInfo = tokenInfo
152150
}
151+
appLogger.Info("Request received", "path", r.URL.Path, "method", r.Method, "clientIP", reqCtx.ClientIP, "accessorID", reqCtx.AccessorID)
152+
} else {
153+
appLogger.Info("Request received", "path", r.URL.Path, "method", r.Method, "clientIP", reqCtx.ClientIP)
153154
}
154155

155156
// Store context

0 commit comments

Comments
 (0)