"...+apps-releases/git@git.gitsec.cn:baidan/lens.git" did not exist on "0ce4e3d793cb788979a722b6a6d99903abc41a66"
Commit a46d5831 authored by Darren Shepherd's avatar Darren Shepherd
Browse files

Fix shell in ember UI

parent 7f398fb3
Showing with 7 additions and 5 deletions
+7 -5
......@@ -66,12 +66,10 @@ func NewProxyMiddleware(sar v1.SubjectAccessReviewInterface,
mux := gmux.NewRouter()
mux.UseEncodedPath()
mux.Path("/v1/management.cattle.io.clusters/{clusterID}").Queries("link", "shell").HandlerFunc(routeToProxy(localSupport, localCluster, mux, proxyHandler))
mux.Path("/v1/management.cattle.io.clusters/{clusterID}").Queries("link", "shell").HandlerFunc(routeToShellProxy(localSupport, localCluster, mux, proxyHandler))
mux.Path("/v3/clusters/{clusterID}").Queries("shell", "true").HandlerFunc(routeToShellProxy(localSupport, localCluster, mux, proxyHandler))
mux.Path("/{prefix:k8s/clusters/[^/]+}{suffix:/v1.*}").MatcherFunc(proxyHandler.MatchNonLegacy("/k8s/clusters/", true)).Handler(proxyHandler)
mux.Path("/{prefix:k8s/clusters/[^/]+}{suffix:.*}").MatcherFunc(proxyHandler.MatchNonLegacy("/k8s/clusters/", false)).Handler(proxyHandler)
mux.Path("/v3/clusters/{id}").Queries("shell", "true").HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
routeToShellLink(rw, req, mux.NotFoundHandler)
})
return func(handler http.Handler) http.Handler {
return http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
......@@ -95,7 +93,7 @@ func routeToShellLink(rw http.ResponseWriter, req *http.Request, next http.Handl
next.ServeHTTP(rw, req)
}
func routeToProxy(localSupport bool, localCluster http.Handler, mux *gmux.Router, proxyHandler *Handler) func(rw http.ResponseWriter, r *http.Request) {
func routeToShellProxy(localSupport bool, localCluster http.Handler, mux *gmux.Router, proxyHandler *Handler) func(rw http.ResponseWriter, r *http.Request) {
return func(rw http.ResponseWriter, r *http.Request) {
vars := gmux.Vars(r)
cluster := vars["clusterID"]
......@@ -109,6 +107,10 @@ func routeToProxy(localSupport bool, localCluster http.Handler, mux *gmux.Router
}
vars["prefix"] = "k8s/clusters/" + cluster
vars["suffix"] = "/v1/management.cattle.io.clusters/local"
// Ensure shell link is set
q := r.URL.Query()
q.Set("link", "shell")
r.URL.RawQuery = q.Encode()
r.URL.Path = "/k8s/clusters/" + cluster + "/v1/management.cattle.io.clusters/local"
proxyHandler.ServeHTTP(rw, r)
}
......
Supports Markdown
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