@@ -18,6 +18,7 @@
|
||||
package resources
|
||||
|
||||
import (
|
||||
"kubesphere.io/kubesphere/pkg/constants"
|
||||
"kubesphere.io/kubesphere/pkg/informers"
|
||||
"kubesphere.io/kubesphere/pkg/params"
|
||||
"kubesphere.io/kubesphere/pkg/utils/k8sutil"
|
||||
@@ -55,6 +56,12 @@ func (*clusterRoleSearcher) match(match map[string]string, item *rbac.ClusterRol
|
||||
if !strings.Contains(item.Name, v) && !searchFuzzy(item.Labels, "", v) && !searchFuzzy(item.Annotations, "", v) {
|
||||
return false
|
||||
}
|
||||
case "userfacing":
|
||||
if v == "true" {
|
||||
if !isUserFacingClusterRole(item) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
default:
|
||||
if item.Labels[k] != v {
|
||||
return false
|
||||
@@ -134,3 +141,10 @@ func (s *clusterRoleSearcher) search(namespace string, conditions *params.Condit
|
||||
}
|
||||
return r, nil
|
||||
}
|
||||
|
||||
func isUserFacingClusterRole(role *rbac.ClusterRole) bool {
|
||||
if role.Labels[constants.CreatorLabelKey] != "" && role.Labels[constants.WorkspaceLabelKey] == "" {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -103,24 +103,15 @@ type resourceSearchInterface interface {
|
||||
search(namespace string, conditions *params.Conditions, orderBy string, reverse bool) ([]interface{}, error)
|
||||
}
|
||||
|
||||
func ListResourcesByName(namespace, resource string, names []string) (*models.PageableResponse, error) {
|
||||
items := make([]interface{}, 0)
|
||||
func GetResource(namespace, resource, name string) (interface{}, error) {
|
||||
if searcher, ok := resources[resource]; ok {
|
||||
for _, name := range names {
|
||||
item, err := searcher.get(namespace, name)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
items = append(items, item)
|
||||
resource, err := searcher.get(namespace, name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
} else {
|
||||
return nil, fmt.Errorf("not found")
|
||||
return resource, nil
|
||||
}
|
||||
|
||||
return &models.PageableResponse{TotalCount: len(items), Items: items}, nil
|
||||
return nil, fmt.Errorf("resource %s not found", resource)
|
||||
}
|
||||
|
||||
func ListResources(namespace, resource string, conditions *params.Conditions, orderBy string, reverse bool, limit, offset int) (*models.PageableResponse, error) {
|
||||
|
||||
Reference in New Issue
Block a user