mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-11 14:11:14 +00:00
Decouple apiserver from codec implementation
The apiserver on initialization must be provided with a codec for encoding and decoding all handled objects including api.Status and api.ServerOp. In addition, the RESTStorage Extract() method has been changed to New(), which returns a pointer object that the codec must decode into (the internal object). Switched registry methods to use pointers for Create/Update instead of values.
This commit is contained in:
@@ -56,7 +56,7 @@ func (s *APIServer) handleOperation(w http.ResponseWriter, req *http.Request) {
|
||||
if len(parts) == 0 {
|
||||
// List outstanding operations.
|
||||
list := s.ops.List()
|
||||
writeJSON(http.StatusOK, list, w)
|
||||
writeJSON(http.StatusOK, s.codec, list, w)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -68,9 +68,9 @@ func (s *APIServer) handleOperation(w http.ResponseWriter, req *http.Request) {
|
||||
|
||||
obj, complete := op.StatusOrResult()
|
||||
if complete {
|
||||
writeJSON(http.StatusOK, obj, w)
|
||||
writeJSON(http.StatusOK, s.codec, obj, w)
|
||||
} else {
|
||||
writeJSON(http.StatusAccepted, obj, w)
|
||||
writeJSON(http.StatusAccepted, s.codec, obj, w)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user