Skip to content

Commit

Permalink
Add more logging
Browse files Browse the repository at this point in the history
  • Loading branch information
mikejoh committed Nov 25, 2024
1 parent 0553c0b commit 09e05d7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ func main() {

func imagineHandler(imageName string) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
log.Printf("Received request: %s %s", r.Method, r.URL.Path)
if r.Method != http.MethodPost {
if r.Method == http.MethodGet {
w.WriteHeader(http.StatusOK)
Expand All @@ -78,6 +79,12 @@ func imagineHandler(imageName string) http.HandlerFunc {
return
}

if admissionReview.Request == nil {
log.Printf("AdmissionReview.Request is nil")
http.Error(w, "invalid admission review request", http.StatusBadRequest)
return
}

var pod corev1.Pod
if err := json.Unmarshal(admissionReview.Request.Object.Raw, &pod); err != nil {
log.Printf("Failed to decode pod spec: %v", err)
Expand Down

0 comments on commit 09e05d7

Please sign in to comment.