fix: implicit workspace info in query
Signed-off-by: hongming <talonwan@yunify.com>
This commit is contained in:
@@ -29,6 +29,7 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
"k8s.io/klog"
|
"k8s.io/klog"
|
||||||
"kubesphere.io/kubesphere/pkg/api"
|
"kubesphere.io/kubesphere/pkg/api"
|
||||||
|
"kubesphere.io/kubesphere/pkg/constants"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@@ -193,6 +194,15 @@ func (r *RequestInfoFactory) NewRequestInfo(req *http.Request) (*RequestInfo, er
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
selector := req.URL.Query().Get("labelSelector")
|
||||||
|
// URL forms: /api/v1/watch/namespaces?labelSelector=kubesphere.io/workspace=system-workspace
|
||||||
|
if strings.HasPrefix(selector, workspaceSelectorPrefix) {
|
||||||
|
workspace := strings.TrimPrefix(selector, workspaceSelectorPrefix)
|
||||||
|
// URL forms: /api/v1/watch/namespaces?labelSelector=kubesphere.io/workspace==system-workspace
|
||||||
|
workspace = strings.TrimPrefix(workspace, "=")
|
||||||
|
requestInfo.Workspace = workspace
|
||||||
|
}
|
||||||
|
|
||||||
// URL forms: /namespaces/{namespace}/{kind}/*, where parts are adjusted to be relative to kind
|
// URL forms: /namespaces/{namespace}/{kind}/*, where parts are adjusted to be relative to kind
|
||||||
if currentParts[0] == "namespaces" {
|
if currentParts[0] == "namespaces" {
|
||||||
if len(currentParts) > 1 {
|
if len(currentParts) > 1 {
|
||||||
@@ -295,6 +305,7 @@ const (
|
|||||||
ClusterScope = "Cluster"
|
ClusterScope = "Cluster"
|
||||||
WorkspaceScope = "Workspace"
|
WorkspaceScope = "Workspace"
|
||||||
NamespaceScope = "Namespace"
|
NamespaceScope = "Namespace"
|
||||||
|
workspaceSelectorPrefix = constants.WorkspaceLabelKey + "="
|
||||||
)
|
)
|
||||||
|
|
||||||
func (r *RequestInfoFactory) resolveResourceScope(request RequestInfo) string {
|
func (r *RequestInfoFactory) resolveResourceScope(request RequestInfo) string {
|
||||||
|
|||||||
Reference in New Issue
Block a user