fix terminal api

Signed-off-by: hongming <talonwan@yunify.com>
This commit is contained in:
hongming
2019-04-12 12:27:33 +08:00
committed by zryfish
parent eea2bb3724
commit 8e862cafb2
34 changed files with 259 additions and 194 deletions

View File

@@ -24,7 +24,9 @@ import (
"kubesphere.io/kubesphere/pkg/constants"
"kubesphere.io/kubesphere/pkg/informers"
"kubesphere.io/kubesphere/pkg/models/iam"
"kubesphere.io/kubesphere/pkg/models/resources"
"kubesphere.io/kubesphere/pkg/params"
"kubesphere.io/kubesphere/pkg/utils/sliceutil"
"sort"
"strings"
)
@@ -36,11 +38,12 @@ type workspaceSearcher struct {
func (*workspaceSearcher) match(match map[string]string, item *v1alpha1.Workspace) bool {
for k, v := range match {
switch k {
case "name":
if item.Name != v && item.Labels[constants.DisplayNameLabelKey] != v {
case resources.Name:
names := strings.Split(v, "|")
if !sliceutil.HasString(names, item.Name) {
return false
}
case "keyword":
case resources.Keyword:
if !strings.Contains(item.Name, v) && !contains(item.Labels, "", v) && !contains(item.Annotations, "", v) {
return false
}
@@ -57,8 +60,8 @@ func (*workspaceSearcher) fuzzy(fuzzy map[string]string, item *v1alpha1.Workspac
for k, v := range fuzzy {
switch k {
case "name":
if !strings.Contains(item.Name, v) && !strings.Contains(item.Labels["displayName"], v) {
case resources.Name:
if !strings.Contains(item.Name, v) && !strings.Contains(item.Annotations[constants.DisplayNameAnnotationKey], v) {
return false
}
default:
@@ -71,9 +74,9 @@ func (*workspaceSearcher) fuzzy(fuzzy map[string]string, item *v1alpha1.Workspac
func (*workspaceSearcher) compare(a, b *v1alpha1.Workspace, orderBy string) bool {
switch orderBy {
case "createTime":
case resources.CreateTime:
return a.CreationTimestamp.Time.Before(b.CreationTimestamp.Time)
case "name":
case resources.Name:
fallthrough
default:
return strings.Compare(a.Name, b.Name) <= 0