@@ -41,21 +41,21 @@ func init() {
41
41
42
42
var _ http.Handler = & Webhook {}
43
43
44
- func (wh Webhook ) ServeHTTP (w http.ResponseWriter , r * http.Request ) {
44
+ func (wh * Webhook ) ServeHTTP (w http.ResponseWriter , r * http.Request ) {
45
45
var body []byte
46
46
var err error
47
47
48
48
var reviewResponse Response
49
49
if r .Body != nil {
50
50
if body , err = ioutil .ReadAll (r .Body ); err != nil {
51
- log .Error (err , "unable to read the body from the incoming request" )
51
+ wh . log .Error (err , "unable to read the body from the incoming request" )
52
52
reviewResponse = Errored (http .StatusBadRequest , err )
53
53
wh .writeResponse (w , reviewResponse )
54
54
return
55
55
}
56
56
} else {
57
57
err = errors .New ("request body is empty" )
58
- log .Error (err , "bad request" )
58
+ wh . log .Error (err , "bad request" )
59
59
reviewResponse = Errored (http .StatusBadRequest , err )
60
60
wh .writeResponse (w , reviewResponse )
61
61
return
@@ -65,7 +65,7 @@ func (wh Webhook) ServeHTTP(w http.ResponseWriter, r *http.Request) {
65
65
contentType := r .Header .Get ("Content-Type" )
66
66
if contentType != "application/json" {
67
67
err = fmt .Errorf ("contentType=%s, expected application/json" , contentType )
68
- log .Error (err , "unable to process a request with an unknown content type" , "content type" , contentType )
68
+ wh . log .Error (err , "unable to process a request with an unknown content type" , "content type" , contentType )
69
69
reviewResponse = Errored (http .StatusBadRequest , err )
70
70
wh .writeResponse (w , reviewResponse )
71
71
return
@@ -77,7 +77,7 @@ func (wh Webhook) ServeHTTP(w http.ResponseWriter, r *http.Request) {
77
77
Request : & req .AdmissionRequest ,
78
78
}
79
79
if _ , _ , err := admissionCodecs .UniversalDeserializer ().Decode (body , nil , & ar ); err != nil {
80
- log .Error (err , "unable to decode the request" )
80
+ wh . log .Error (err , "unable to decode the request" )
81
81
reviewResponse = Errored (http .StatusBadRequest , err )
82
82
wh .writeResponse (w , reviewResponse )
83
83
return
@@ -95,7 +95,7 @@ func (wh *Webhook) writeResponse(w io.Writer, response Response) {
95
95
}
96
96
err := encoder .Encode (responseAdmissionReview )
97
97
if err != nil {
98
- log .Error (err , "unable to encode the response" )
98
+ wh . log .Error (err , "unable to encode the response" )
99
99
wh .writeResponse (w , Errored (http .StatusInternalServerError , err ))
100
100
}
101
101
}
0 commit comments