chickenzord / kube-annotate

Kubernetes mutating admission webhook to automatically annotate pods
MIT License
12 stars 3 forks source link

Cannot read a request stream more than once #1

Open drewhemm opened 3 years ago

drewhemm commented 3 years ago

https://github.com/chickenzord/kube-annotate/blob/d034d81284aea646355ccf54826082008124ef1c/annotator/handler.go#L13

https://github.com/chickenzord/kube-annotate/blob/d034d81284aea646355ccf54826082008124ef1c/annotator/handler.go#L15

Only the first read works, the second one returns empty as the stream has already been processed. See this post on Reddit:

https://www.reddit.com/r/golang/comments/8mfex0/why_requestbody_is_empty_after_decoding_or_reading/