diff --git a/main.go b/main.go index 15fcf59..f64b9b8 100755 --- a/main.go +++ b/main.go @@ -10,6 +10,12 @@ import ( ) func getClusterInfo(w http.ResponseWriter, _ *http.Request, client *http.Client) { + // Check if client is nil + if client == nil { + http.Error(w, "HTTP client is nil: cannot proceed with metadata retrieval", http.StatusInternalServerError) + return + } + // GCP metadata URL to retrieve the GKE cluster name metadataURL := "http://metadata.google.internal/computeMetadata/v1/instance/attributes/cluster-name"