Move kubelet api paths to constants

This commit is contained in:
Jordan Liggitt 2016-10-08 00:44:13 -04:00
parent 426caf5bd1
commit a602ae77b8
No known key found for this signature in database
GPG Key ID: 24E7ADF9A3B42012
2 changed files with 13 additions and 6 deletions

View File

@ -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() {
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() {
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"))

View File

@ -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 {