mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-06 16:06:51 +00:00
Extract RESTHandler and allow API groupings
Prepare for running multiple API versions on the same HTTP server by decoupling some of the mechanics of apiserver. Define a new APIGroup object which represents a version of the API.
This commit is contained in:
@@ -139,21 +139,11 @@ func (m *Master) init(cloud cloudprovider.Interface, podInfoGetter client.PodInf
|
||||
}
|
||||
}
|
||||
|
||||
// Run begins serving the Kubernetes API. It never returns.
|
||||
func (m *Master) Run(myAddress, apiPrefix string) error {
|
||||
s := &http.Server{
|
||||
Addr: myAddress,
|
||||
Handler: m.ConstructHandler(apiPrefix),
|
||||
ReadTimeout: 10 * time.Second,
|
||||
WriteTimeout: 10 * time.Second,
|
||||
MaxHeaderBytes: 1 << 20,
|
||||
// API_v1beta1 returns the resources and codec for API version v1beta1
|
||||
func (m *Master) API_v1beta1() (map[string]apiserver.RESTStorage, apiserver.Codec) {
|
||||
storage := make(map[string]apiserver.RESTStorage)
|
||||
for k, v := range m.storage {
|
||||
storage[k] = v
|
||||
}
|
||||
return s.ListenAndServe()
|
||||
}
|
||||
|
||||
// ConstructHandler returns an http.Handler which serves the Kubernetes API.
|
||||
// Instead of calling Run, you can call this function to get a handler for your own server.
|
||||
// It is intended for testing. Only call once.
|
||||
func (m *Master) ConstructHandler(apiPrefix string) http.Handler {
|
||||
return apiserver.New(m.storage, api.Codec, apiPrefix)
|
||||
return storage, api.Codec
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user