Move kubelet api paths to constants

parent 426caf5b
...@@ -62,6 +62,13 @@ import ( ...@@ -62,6 +62,13 @@ import (
"k8s.io/kubernetes/pkg/volume" "k8s.io/kubernetes/pkg/volume"
) )
const (
metricsPath = "/metrics"
specPath = "/spec/"
statsPath = "/stats/"
logsPath = "/logs/"
)
// Server is a http.Handler which exposes kubelet functionality over HTTP. // Server is a http.Handler which exposes kubelet functionality over HTTP.
type Server struct { type Server struct {
auth AuthInterface auth AuthInterface
...@@ -258,12 +265,12 @@ func (s *Server) InstallDefaultHandlers() { ...@@ -258,12 +265,12 @@ func (s *Server) InstallDefaultHandlers() {
Operation("getPods")) Operation("getPods"))
s.restfulCont.Add(ws) s.restfulCont.Add(ws)
s.restfulCont.Add(stats.CreateHandlers(s.host, s.resourceAnalyzer)) s.restfulCont.Add(stats.CreateHandlers(statsPath, s.host, s.resourceAnalyzer))
s.restfulCont.Handle("/metrics", prometheus.Handler()) s.restfulCont.Handle(metricsPath, prometheus.Handler())
ws = new(restful.WebService) ws = new(restful.WebService)
ws. ws.
Path("/spec/"). Path(specPath).
Produces(restful.MIME_JSON) Produces(restful.MIME_JSON)
ws.Route(ws.GET(""). ws.Route(ws.GET("").
To(s.getSpec). To(s.getSpec).
...@@ -336,7 +343,7 @@ func (s *Server) InstallDebuggingHandlers() { ...@@ -336,7 +343,7 @@ func (s *Server) InstallDebuggingHandlers() {
ws = new(restful.WebService) ws = new(restful.WebService)
ws. ws.
Path("/logs/") Path(logsPath)
ws.Route(ws.GET(""). ws.Route(ws.GET("").
To(s.getLogs). To(s.getLogs).
Operation("getLogs")) Operation("getLogs"))
......
...@@ -55,11 +55,11 @@ type handler struct { ...@@ -55,11 +55,11 @@ type handler struct {
summaryProvider SummaryProvider summaryProvider SummaryProvider
} }
func CreateHandlers(provider StatsProvider, summaryProvider SummaryProvider) *restful.WebService { func CreateHandlers(rootPath string, provider StatsProvider, summaryProvider SummaryProvider) *restful.WebService {
h := &handler{provider, summaryProvider} h := &handler{provider, summaryProvider}
ws := &restful.WebService{} ws := &restful.WebService{}
ws.Path("/stats/"). ws.Path(rootPath).
Produces(restful.MIME_JSON) Produces(restful.MIME_JSON)
endpoints := []struct { endpoints := []struct {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment