mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +00:00 
			
		
		
		
	move install of version handler to genericapiserver
This commit is contained in:
		@@ -1,14 +1,14 @@
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
  "swaggerVersion": "1.2",
 | 
					  "swaggerVersion": "1.2",
 | 
				
			||||||
  "apis": [
 | 
					  "apis": [
 | 
				
			||||||
   {
 | 
					 | 
				
			||||||
    "path": "/apis",
 | 
					 | 
				
			||||||
    "description": "get available API versions"
 | 
					 | 
				
			||||||
   },
 | 
					 | 
				
			||||||
   {
 | 
					   {
 | 
				
			||||||
    "path": "/version",
 | 
					    "path": "/version",
 | 
				
			||||||
    "description": "git code version from which this is built"
 | 
					    "description": "git code version from which this is built"
 | 
				
			||||||
   },
 | 
					   },
 | 
				
			||||||
 | 
					   {
 | 
				
			||||||
 | 
					    "path": "/apis",
 | 
				
			||||||
 | 
					    "description": "get available API versions"
 | 
				
			||||||
 | 
					   },
 | 
				
			||||||
   {
 | 
					   {
 | 
				
			||||||
    "path": "/api/v1",
 | 
					    "path": "/api/v1",
 | 
				
			||||||
    "description": "API at /api/v1"
 | 
					    "description": "API at /api/v1"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -92,6 +92,7 @@ func TestRun(t *testing.T) {
 | 
				
			|||||||
		t.Fatalf("%v", err)
 | 
							t.Fatalf("%v", err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	testSwaggerSpec(t)
 | 
						testSwaggerSpec(t)
 | 
				
			||||||
 | 
						testSupport(t)
 | 
				
			||||||
	testAPIGroupList(t)
 | 
						testAPIGroupList(t)
 | 
				
			||||||
	testAPIGroup(t)
 | 
						testAPIGroup(t)
 | 
				
			||||||
	testAPIResourceList(t)
 | 
						testAPIResourceList(t)
 | 
				
			||||||
@@ -131,6 +132,14 @@ func testSwaggerSpec(t *testing.T) {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func testSupport(t *testing.T) {
 | 
				
			||||||
 | 
						serverURL := serverIP + "/version"
 | 
				
			||||||
 | 
						_, err := readResponse(serverURL)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							t.Fatalf("%v", err)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func findGroup(groups []unversioned.APIGroup, groupName string) *unversioned.APIGroup {
 | 
					func findGroup(groups []unversioned.APIGroup, groupName string) *unversioned.APIGroup {
 | 
				
			||||||
	for _, group := range groups {
 | 
						for _, group := range groups {
 | 
				
			||||||
		if group.Name == groupName {
 | 
							if group.Name == groupName {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -36,7 +36,6 @@ import (
 | 
				
			|||||||
	"k8s.io/kubernetes/pkg/api/rest"
 | 
						"k8s.io/kubernetes/pkg/api/rest"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api/unversioned"
 | 
						"k8s.io/kubernetes/pkg/api/unversioned"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/apiserver/metrics"
 | 
						"k8s.io/kubernetes/pkg/apiserver/metrics"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/healthz"
 | 
					 | 
				
			||||||
	"k8s.io/kubernetes/pkg/runtime"
 | 
						"k8s.io/kubernetes/pkg/runtime"
 | 
				
			||||||
	utilerrors "k8s.io/kubernetes/pkg/util/errors"
 | 
						utilerrors "k8s.io/kubernetes/pkg/util/errors"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/util/flushwriter"
 | 
						"k8s.io/kubernetes/pkg/util/flushwriter"
 | 
				
			||||||
@@ -163,10 +162,8 @@ func (g *APIGroupVersion) newInstaller() *APIInstaller {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// TODO: document all handlers
 | 
					// TODO: document all handlers
 | 
				
			||||||
// InstallSupport registers the APIServer support functions
 | 
					// InstallVersionHandler registers the APIServer's `/version` handler
 | 
				
			||||||
func InstallSupport(mux Mux, checks ...healthz.HealthzChecker) []*restful.WebService {
 | 
					func InstallVersionHandler(mux Mux, container *restful.Container) {
 | 
				
			||||||
	// TODO: convert healthz and metrics to restful and remove container arg
 | 
					 | 
				
			||||||
	healthz.InstallHandler(mux, checks...)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Set up a service to return the git code version.
 | 
						// Set up a service to return the git code version.
 | 
				
			||||||
	versionWS := new(restful.WebService)
 | 
						versionWS := new(restful.WebService)
 | 
				
			||||||
@@ -179,7 +176,7 @@ func InstallSupport(mux Mux, checks ...healthz.HealthzChecker) []*restful.WebSer
 | 
				
			|||||||
			Produces(restful.MIME_JSON).
 | 
								Produces(restful.MIME_JSON).
 | 
				
			||||||
			Consumes(restful.MIME_JSON))
 | 
								Consumes(restful.MIME_JSON))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return []*restful.WebService{versionWS}
 | 
						container.Add(versionWS)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// InstallLogsSupport registers the APIServer log support function into a mux.
 | 
					// InstallLogsSupport registers the APIServer log support function into a mux.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -317,10 +317,8 @@ func handleInternal(storage map[string]rest.Storage, admissionControl admission.
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	webservices := InstallSupport(mux)
 | 
						InstallVersionHandler(mux, container)
 | 
				
			||||||
	for i := range webservices {
 | 
					
 | 
				
			||||||
		container.Add(webservices[i])
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return &defaultAPIServer{mux, container}
 | 
						return &defaultAPIServer{mux, container}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -3263,10 +3261,7 @@ func TestXGSubresource(t *testing.T) {
 | 
				
			|||||||
		panic(fmt.Sprintf("unable to install container %s: %v", group.GroupVersion, err))
 | 
							panic(fmt.Sprintf("unable to install container %s: %v", group.GroupVersion, err))
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	webservices := InstallSupport(mux)
 | 
						InstallVersionHandler(mux, container)
 | 
				
			||||||
	for i := range webservices {
 | 
					 | 
				
			||||||
		container.Add(webservices[i])
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	handler := defaultAPIServer{mux, container}
 | 
						handler := defaultAPIServer{mux, container}
 | 
				
			||||||
	server := httptest.NewServer(handler)
 | 
						server := httptest.NewServer(handler)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -454,6 +454,8 @@ func (s *GenericAPIServer) init(c *Config) {
 | 
				
			|||||||
		s.mux.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
 | 
							s.mux.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						apiserver.InstallVersionHandler(s.MuxHelper, s.HandlerContainer)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	handler := http.Handler(s.mux.(*http.ServeMux))
 | 
						handler := http.Handler(s.mux.(*http.ServeMux))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// TODO: handle CORS and auth using go-restful
 | 
						// TODO: handle CORS and auth using go-restful
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -226,9 +226,7 @@ func (m *Master) InstallAPIs(c *Config) {
 | 
				
			|||||||
			Help: "The time since the last successful synchronization of the SSH tunnels for proxy requests.",
 | 
								Help: "The time since the last successful synchronization of the SSH tunnels for proxy requests.",
 | 
				
			||||||
		}, func() float64 { return float64(m.tunneler.SecondsSinceSync()) })
 | 
							}, func() float64 { return float64(m.tunneler.SecondsSinceSync()) })
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						healthz.InstallHandler(m.MuxHelper, healthzChecks...)
 | 
				
			||||||
	// TODO(nikhiljindal): Refactor generic parts of support services (like /versions) to genericapiserver.
 | 
					 | 
				
			||||||
	webservices := apiserver.InstallSupport(m.MuxHelper, healthzChecks...)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if c.EnableProfiling {
 | 
						if c.EnableProfiling {
 | 
				
			||||||
		m.MuxHelper.HandleFunc("/metrics", MetricsWithReset)
 | 
							m.MuxHelper.HandleFunc("/metrics", MetricsWithReset)
 | 
				
			||||||
@@ -236,10 +234,6 @@ func (m *Master) InstallAPIs(c *Config) {
 | 
				
			|||||||
		m.MuxHelper.HandleFunc("/metrics", defaultMetricsHandler)
 | 
							m.MuxHelper.HandleFunc("/metrics", defaultMetricsHandler)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for i := range webservices {
 | 
					 | 
				
			||||||
		m.HandlerContainer.Add(webservices[i])
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	// allGroups records all supported groups at /apis
 | 
						// allGroups records all supported groups at /apis
 | 
				
			||||||
	allGroups := []unversioned.APIGroup{}
 | 
						allGroups := []unversioned.APIGroup{}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user