mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-13 13:14:05 +00:00
Make redirect handle namespaces just like proxy (which is weird and needs to be fixed but at least this will be consistent).
This commit is contained in:
@@ -30,7 +30,11 @@ type RedirectHandler struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *RedirectHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
func (r *RedirectHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
ctx := api.NewContext()
|
ctx := api.NewDefaultContext()
|
||||||
|
namespace := req.URL.Query().Get("namespace")
|
||||||
|
if len(namespace) > 0 {
|
||||||
|
ctx = api.WithNamespace(ctx, namespace)
|
||||||
|
}
|
||||||
parts := splitPath(req.URL.Path)
|
parts := splitPath(req.URL.Path)
|
||||||
if len(parts) != 2 || req.Method != "GET" {
|
if len(parts) != 2 || req.Method != "GET" {
|
||||||
notFound(w, req)
|
notFound(w, req)
|
||||||
|
@@ -27,6 +27,7 @@ import (
|
|||||||
func TestRedirect(t *testing.T) {
|
func TestRedirect(t *testing.T) {
|
||||||
simpleStorage := &SimpleRESTStorage{
|
simpleStorage := &SimpleRESTStorage{
|
||||||
errors: map[string]error{},
|
errors: map[string]error{},
|
||||||
|
expectedResourceNamespace: "default",
|
||||||
}
|
}
|
||||||
handler := Handle(map[string]RESTStorage{
|
handler := Handle(map[string]RESTStorage{
|
||||||
"foo": simpleStorage,
|
"foo": simpleStorage,
|
||||||
|
Reference in New Issue
Block a user