From 0083a48e01bb9c66281030d2eb291939735cc5f6 Mon Sep 17 00:00:00 2001 From: hongming Date: Wed, 8 May 2019 13:14:47 +0800 Subject: [PATCH] add pvc filter Signed-off-by: hongming --- pkg/controller/namespace/namespace_controller.go | 6 +++--- pkg/models/resources/persistentvolumeclaims.go | 4 ++++ pkg/models/resources/resources.go | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/pkg/controller/namespace/namespace_controller.go b/pkg/controller/namespace/namespace_controller.go index 90857ef0..5f9bbca2 100644 --- a/pkg/controller/namespace/namespace_controller.go +++ b/pkg/controller/namespace/namespace_controller.go @@ -54,10 +54,10 @@ const ( var ( log = logf.Log.WithName("namespace-controller") defaultRoles = []rbac.Role{ - {ObjectMeta: metav1.ObjectMeta{Name: "admin", Annotations: map[string]string{constants.DescriptionAnnotationKey: adminDescription}}, Rules: []rbac.PolicyRule{{Verbs: []string{"*"}, APIGroups: []string{"*"}, Resources: []string{"*"}}}}, - {ObjectMeta: metav1.ObjectMeta{Name: "operator", Annotations: map[string]string{constants.DescriptionAnnotationKey: operatorDescription}}, Rules: []rbac.PolicyRule{{Verbs: []string{"get", "list", "watch"}, APIGroups: []string{"*"}, Resources: []string{"*"}}, + {ObjectMeta: metav1.ObjectMeta{Name: "admin", Annotations: map[string]string{constants.DescriptionAnnotationKey: adminDescription, constants.CreatorAnnotationKey: constants.System}}, Rules: []rbac.PolicyRule{{Verbs: []string{"*"}, APIGroups: []string{"*"}, Resources: []string{"*"}}}}, + {ObjectMeta: metav1.ObjectMeta{Name: "operator", Annotations: map[string]string{constants.DescriptionAnnotationKey: operatorDescription, constants.CreatorAnnotationKey: constants.System}}, Rules: []rbac.PolicyRule{{Verbs: []string{"get", "list", "watch"}, APIGroups: []string{"*"}, Resources: []string{"*"}}, {Verbs: []string{"*"}, APIGroups: []string{"", "apps", "extensions", "batch", "logging.kubesphere.io", "monitoring.kubesphere.io", "iam.kubesphere.io", "resources.kubesphere.io", "autoscaling", "alerting.kubesphere.io"}, Resources: []string{"*"}}}}, - {ObjectMeta: metav1.ObjectMeta{Name: "viewer", Annotations: map[string]string{constants.DescriptionAnnotationKey: viewerDescription}}, Rules: []rbac.PolicyRule{{Verbs: []string{"get", "list", "watch"}, APIGroups: []string{"*"}, Resources: []string{"*"}}}}, + {ObjectMeta: metav1.ObjectMeta{Name: "viewer", Annotations: map[string]string{constants.DescriptionAnnotationKey: viewerDescription, constants.CreatorAnnotationKey: constants.System}}, Rules: []rbac.PolicyRule{{Verbs: []string{"get", "list", "watch"}, APIGroups: []string{"*"}, Resources: []string{"*"}}}}, } ) diff --git a/pkg/models/resources/persistentvolumeclaims.go b/pkg/models/resources/persistentvolumeclaims.go index c65ad314..a27e0ccb 100644 --- a/pkg/models/resources/persistentvolumeclaims.go +++ b/pkg/models/resources/persistentvolumeclaims.go @@ -62,6 +62,10 @@ func (*persistentVolumeClaimSearcher) match(match map[string]string, item *v1.Pe if !sliceutil.HasString(statuses, pvcStatus(item)) { return false } + case storageClassName: + if item.Spec.StorageClassName == nil || *item.Spec.StorageClassName != v { + return false + } case Keyword: if !strings.Contains(item.Name, v) && !searchFuzzy(item.Labels, "", v) && !searchFuzzy(item.Annotations, "", v) { return false diff --git a/pkg/models/resources/resources.go b/pkg/models/resources/resources.go index c78e50fa..428ee70f 100644 --- a/pkg/models/resources/resources.go +++ b/pkg/models/resources/resources.go @@ -70,6 +70,7 @@ const ( Keyword = "keyword" Status = "status" includeCronJob = "includeCronJob" + storageClassName = "storageClassName" cronJobKind = "CronJob" s2iRunKind = "S2iRun" includeS2iRun = "includeS2iRun" -- GitLab