Compare commits

..

2 Commits

Author SHA1 Message Date
Brian Goff
4e399f93b1 Merge pull request #868 from cpuguy83/1.2_fix_missing_stats_route
Add GetStatsSummary to PodHandlerConfig
2020-07-30 14:02:41 -07:00
Vilmos Nebehaj
c621acc8d2 Add GetStatsSummary to PodHandlerConfig
If both the metrics routes and the pod routes are attached to the same
mux with the pattern "/", it will panic. Instead, add the stats handler
function to PodHandlerConfig and set up the route if it is not nil.

(cherry picked from commit 56b248c854)
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2020-07-30 10:25:34 -07:00

View File

@@ -36,6 +36,7 @@ type PodHandlerConfig struct {
RunInContainer ContainerExecHandlerFunc
GetContainerLogs ContainerLogsHandlerFunc
GetPods PodListerFunc
GetStatsSummary PodStatsSummaryHandlerFunc
}
// PodHandler creates an http handler for interacting with pods/containers.
@@ -49,6 +50,12 @@ func PodHandler(p PodHandlerConfig, debug bool) http.Handler {
}
r.HandleFunc("/containerLogs/{namespace}/{pod}/{container}", HandleContainerLogs(p.GetContainerLogs)).Methods("GET")
r.HandleFunc("/exec/{namespace}/{pod}/{container}", HandleContainerExec(p.RunInContainer)).Methods("POST")
if p.GetStatsSummary != nil {
f := HandlePodStatsSummary(p.GetStatsSummary)
r.HandleFunc("/stats/summary", f).Methods("GET")
r.HandleFunc("/stats/summary/", f).Methods("GET")
}
r.NotFoundHandler = http.HandlerFunc(NotFound)
return r
}