mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
K8s: Remove /k8s/ prefix (#75959)
This commit is contained in:
parent
5be52dfe21
commit
d9160553f9
@ -40,4 +40,4 @@ kubectl api-resources
|
|||||||
|
|
||||||
### Grafana API Access
|
### Grafana API Access
|
||||||
|
|
||||||
The Kubernetes compatible API can be accessed using existing Grafana AuthN at: [http://localhost:3000/k8s/apis/](http://localhost:3000/k8s/apis/).
|
The Kubernetes compatible API can be accessed using existing Grafana AuthN at: [http://localhost:3000/apis](http://localhost:3000/apis).
|
||||||
|
@ -6,7 +6,6 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"path"
|
"path"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/go-logr/logr"
|
"github.com/go-logr/logr"
|
||||||
"github.com/grafana/dskit/services"
|
"github.com/grafana/dskit/services"
|
||||||
@ -126,7 +125,7 @@ func ProvideService(
|
|||||||
// TODO: this is very hacky
|
// TODO: this is very hacky
|
||||||
// We need to register the routes in ProvideService to make sure
|
// We need to register the routes in ProvideService to make sure
|
||||||
// the routes are registered before the Grafana HTTP server starts.
|
// the routes are registered before the Grafana HTTP server starts.
|
||||||
s.rr.Group("/k8s", func(k8sRoute routing.RouteRegister) {
|
proxyHandler := func(k8sRoute routing.RouteRegister) {
|
||||||
handler := func(c *contextmodel.ReqContext) {
|
handler := func(c *contextmodel.ReqContext) {
|
||||||
if s.handler == nil {
|
if s.handler == nil {
|
||||||
c.Resp.WriteHeader(404)
|
c.Resp.WriteHeader(404)
|
||||||
@ -141,7 +140,10 @@ func ProvideService(
|
|||||||
}
|
}
|
||||||
k8sRoute.Any("/", middleware.ReqSignedIn, handler)
|
k8sRoute.Any("/", middleware.ReqSignedIn, handler)
|
||||||
k8sRoute.Any("/*", middleware.ReqSignedIn, handler)
|
k8sRoute.Any("/*", middleware.ReqSignedIn, handler)
|
||||||
})
|
}
|
||||||
|
|
||||||
|
s.rr.Group("/apis", proxyHandler)
|
||||||
|
s.rr.Group("/openapi", proxyHandler)
|
||||||
|
|
||||||
return s, nil
|
return s, nil
|
||||||
}
|
}
|
||||||
@ -277,7 +279,6 @@ func (s *service) start(ctx context.Context) error {
|
|||||||
// TODO: this is a hack. see note in ProvideService
|
// TODO: this is a hack. see note in ProvideService
|
||||||
s.handler = func(c *contextmodel.ReqContext) {
|
s.handler = func(c *contextmodel.ReqContext) {
|
||||||
req := c.Req
|
req := c.Req
|
||||||
req.URL.Path = strings.TrimPrefix(req.URL.Path, "/k8s")
|
|
||||||
if req.URL.Path == "" {
|
if req.URL.Path == "" {
|
||||||
req.URL.Path = "/"
|
req.URL.Path = "/"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user