Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
水淹萌龙
kubesphere
提交
8e862caf
K
kubesphere
项目概览
水淹萌龙
/
kubesphere
与 Fork 源项目一致
Fork自
KubeSphere / kubesphere
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
kubesphere
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
8e862caf
编写于
4月 12, 2019
作者:
H
hongming
提交者:
zryfish
4月 15, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix terminal api
Signed-off-by:
N
hongming
<
talonwan@yunify.com
>
上级
eea2bb37
变更
34
隐藏空白更改
内联
并排
Showing
34 changed file
with
256 addition
and
191 deletion
+256
-191
pkg/apigateway/caddy-plugin/authenticate/authenticate.go
pkg/apigateway/caddy-plugin/authenticate/authenticate.go
+1
-1
pkg/apigateway/caddy-plugin/authentication/authentication.go
pkg/apigateway/caddy-plugin/authentication/authentication.go
+27
-32
pkg/apis/terminal/v1alpha2/register.go
pkg/apis/terminal/v1alpha2/register.go
+2
-2
pkg/apiserver/iam/workspaces.go
pkg/apiserver/iam/workspaces.go
+1
-1
pkg/constants/constants.go
pkg/constants/constants.go
+2
-2
pkg/controller/namespace/namespace_controller.go
pkg/controller/namespace/namespace_controller.go
+1
-1
pkg/controller/workspace/workspace_controller.go
pkg/controller/workspace/workspace_controller.go
+6
-3
pkg/models/iam/am.go
pkg/models/iam/am.go
+2
-2
pkg/models/resources/clusterroles.go
pkg/models/resources/clusterroles.go
+9
-7
pkg/models/resources/configmaps.go
pkg/models/resources/configmaps.go
+9
-6
pkg/models/resources/cronjobs.go
pkg/models/resources/cronjobs.go
+9
-6
pkg/models/resources/daemonsets.go
pkg/models/resources/daemonsets.go
+9
-6
pkg/models/resources/deployments.go
pkg/models/resources/deployments.go
+9
-6
pkg/models/resources/ingresses.go
pkg/models/resources/ingresses.go
+9
-6
pkg/models/resources/jobs.go
pkg/models/resources/jobs.go
+9
-6
pkg/models/resources/namespaces.go
pkg/models/resources/namespaces.go
+9
-6
pkg/models/resources/nodes.go
pkg/models/resources/nodes.go
+9
-6
pkg/models/resources/persistentvolumeclaims.go
pkg/models/resources/persistentvolumeclaims.go
+9
-6
pkg/models/resources/pods.go
pkg/models/resources/pods.go
+9
-6
pkg/models/resources/resources.go
pkg/models/resources/resources.go
+3
-4
pkg/models/resources/roles.go
pkg/models/resources/roles.go
+9
-6
pkg/models/resources/s2ibuilder.go
pkg/models/resources/s2ibuilder.go
+9
-6
pkg/models/resources/s2ibuildertemplate.go
pkg/models/resources/s2ibuildertemplate.go
+9
-6
pkg/models/resources/s2irun.go
pkg/models/resources/s2irun.go
+9
-6
pkg/models/resources/secrets.go
pkg/models/resources/secrets.go
+9
-6
pkg/models/resources/services.go
pkg/models/resources/services.go
+9
-6
pkg/models/resources/statefulsets.go
pkg/models/resources/statefulsets.go
+14
-7
pkg/models/resources/storageclasses.go
pkg/models/resources/storageclasses.go
+9
-6
pkg/models/resources/workspaces.go
pkg/models/resources/workspaces.go
+9
-6
pkg/models/tenant/namespaces.go
pkg/models/tenant/namespaces.go
+8
-5
pkg/models/tenant/tenant.go
pkg/models/tenant/tenant.go
+1
-1
pkg/models/tenant/workspaces.go
pkg/models/tenant/workspaces.go
+10
-7
pkg/models/terminal/terminal.go
pkg/models/terminal/terminal.go
+6
-7
pkg/models/workspaces/workspaces.go
pkg/models/workspaces/workspaces.go
+1
-1
未找到文件。
pkg/apigateway/caddy-plugin/authenticate/authenticate.go
浏览文件 @
8e862caf
...
...
@@ -131,7 +131,7 @@ func (h Auth) InjectContext(req *http.Request, token *jwt.Token) (*http.Request,
}
// hard code, support jenkins auth plugin
if
httpserver
.
Path
(
req
.
URL
.
Path
)
.
Matches
(
"/apis/jenkins.kubesphere.io"
)
||
httpserver
.
Path
(
req
.
URL
.
Path
)
.
Matches
(
"job"
)
{
if
httpserver
.
Path
(
req
.
URL
.
Path
)
.
Matches
(
"/
k
apis/jenkins.kubesphere.io"
)
||
httpserver
.
Path
(
req
.
URL
.
Path
)
.
Matches
(
"job"
)
{
req
.
SetBasicAuth
(
username
,
token
.
Raw
)
}
...
...
pkg/apigateway/caddy-plugin/authentication/authentication.go
浏览文件 @
8e862caf
...
...
@@ -23,6 +23,7 @@ import (
"fmt"
"k8s.io/apiserver/pkg/authorization/authorizer"
"k8s.io/apiserver/pkg/endpoints/request"
"kubesphere.io/kubesphere/pkg/utils/k8sutil"
"net/http"
"strings"
...
...
@@ -31,7 +32,6 @@ import (
k8serr
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/kubernetes/pkg/util/slice"
"kubesphere.io/kubesphere/pkg/informers"
"kubesphere.io/kubesphere/pkg/utils/sliceutil"
)
...
...
@@ -132,21 +132,19 @@ func roleValidate(attrs authorizer.Attributes) (bool, error) {
}
for
_
,
roleBinding
:=
range
roleBindings
{
if
k8sutil
.
ContainsUser
(
roleBinding
.
Subjects
,
attrs
.
GetUser
()
.
GetName
())
{
role
,
err
:=
roleLister
.
Roles
(
attrs
.
GetNamespace
())
.
Get
(
roleBinding
.
RoleRef
.
Name
)
for
_
,
subj
:=
range
roleBinding
.
Subjects
{
if
(
subj
.
Kind
==
v1
.
UserKind
&&
subj
.
Name
==
attrs
.
GetUser
()
.
GetName
())
||
(
subj
.
Kind
==
v1
.
GroupKind
&&
slice
.
ContainsString
(
attrs
.
GetUser
()
.
GetGroups
(),
subj
.
Name
,
nil
))
{
role
,
err
:=
roleLister
.
Roles
(
attrs
.
GetNamespace
())
.
Get
(
roleBinding
.
RoleRef
.
Name
)
if
err
!=
nil
{
return
false
,
err
if
err
!=
nil
{
if
k8serr
.
IsNotFound
(
err
)
{
continue
}
return
false
,
err
}
for
_
,
rule
:=
range
role
.
Rules
{
if
ruleMatchesRequest
(
rule
,
attrs
.
GetAPIGroup
(),
""
,
attrs
.
GetResource
(),
attrs
.
GetSubresource
(),
attrs
.
GetName
(),
attrs
.
GetVerb
())
{
return
true
,
nil
}
for
_
,
rule
:=
range
role
.
Rules
{
if
ruleMatchesRequest
(
rule
,
attrs
.
GetAPIGroup
(),
""
,
attrs
.
GetResource
(),
attrs
.
GetSubresource
(),
attrs
.
GetName
(),
attrs
.
GetVerb
())
{
return
true
,
nil
}
}
}
...
...
@@ -165,31 +163,28 @@ func clusterRoleValidate(attrs authorizer.Attributes) (bool, error) {
for
_
,
clusterRoleBinding
:=
range
clusterRoleBindings
{
for
_
,
subject
:=
range
clusterRoleBinding
.
Subjects
{
if
(
subject
.
Kind
==
v1
.
UserKind
&&
subject
.
Name
==
attrs
.
GetUser
()
.
GetName
())
||
(
subject
.
Kind
==
v1
.
GroupKind
&&
sliceutil
.
HasString
(
attrs
.
GetUser
()
.
GetGroups
(),
subject
.
Name
))
{
clusterRole
,
err
:=
clusterRoleLister
.
Get
(
clusterRoleBinding
.
RoleRef
.
Name
)
if
k8sutil
.
ContainsUser
(
clusterRoleBinding
.
Subjects
,
attrs
.
GetUser
()
.
GetName
())
{
clusterRole
,
err
:=
clusterRoleLister
.
Get
(
clusterRoleBinding
.
RoleRef
.
Name
)
if
err
!=
nil
{
return
false
,
err
if
err
!=
nil
{
if
k8serr
.
IsNotFound
(
err
)
{
continue
}
return
false
,
err
}
for
_
,
rule
:=
range
clusterRole
.
Rules
{
if
attrs
.
IsResourceRequest
()
{
if
ruleMatchesRequest
(
rule
,
attrs
.
GetAPIGroup
(),
""
,
attrs
.
GetResource
(),
attrs
.
GetSubresource
(),
attrs
.
GetName
(),
attrs
.
GetVerb
())
{
return
true
,
nil
}
}
else
{
if
ruleMatchesRequest
(
rule
,
""
,
attrs
.
GetPath
(),
""
,
""
,
""
,
attrs
.
GetVerb
())
{
return
true
,
nil
}
for
_
,
rule
:=
range
clusterRole
.
Rules
{
if
attrs
.
IsResourceRequest
()
{
if
ruleMatchesRequest
(
rule
,
attrs
.
GetAPIGroup
(),
""
,
attrs
.
GetResource
(),
attrs
.
GetSubresource
(),
attrs
.
GetName
(),
attrs
.
GetVerb
())
{
return
true
,
nil
}
}
else
{
if
ruleMatchesRequest
(
rule
,
""
,
attrs
.
GetPath
(),
""
,
""
,
""
,
attrs
.
GetVerb
())
{
return
true
,
nil
}
}
}
}
}
...
...
pkg/apis/terminal/v1alpha2/register.go
浏览文件 @
8e862caf
...
...
@@ -41,14 +41,14 @@ func addWebService(c *restful.Container) error {
tags
:=
[]
string
{
"Terminal"
}
webservice
.
Route
(
webservice
.
GET
(
"/namespaces/{namespace}/pods/{pod
s
}"
)
.
webservice
.
Route
(
webservice
.
GET
(
"/namespaces/{namespace}/pods/{pod}"
)
.
To
(
terminal
.
CreateTerminalSession
)
.
Doc
(
"create terminal session"
)
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
tags
)
.
Writes
(
models
.
PodInfo
{}))
path
:=
runtime
.
ApiRootPath
+
"/"
+
GroupVersion
.
String
()
+
"/sockjs"
c
.
Handle
(
path
,
terminal
.
NewTerminalHandler
(
path
))
c
.
Handle
(
path
+
"/"
,
terminal
.
NewTerminalHandler
(
path
))
c
.
Add
(
webservice
)
...
...
pkg/apiserver/iam/workspaces.go
浏览文件 @
8e862caf
...
...
@@ -98,7 +98,7 @@ func DescribeWorkspaceUser(req *restful.Request, resp *restful.Response) {
return
}
user
.
WorkspaceRole
=
workspaceRole
.
Labels
[
constants
.
DisplayNameLabel
Key
]
user
.
WorkspaceRole
=
workspaceRole
.
Annotations
[
constants
.
DisplayNameAnnotation
Key
]
resp
.
WriteAsJson
(
user
)
}
...
...
pkg/constants/constants.go
浏览文件 @
8e862caf
...
...
@@ -32,8 +32,8 @@ const (
IngressControllerPrefix
=
"kubesphere-router-"
WorkspaceLabelKey
=
"kubesphere.io/workspace"
DisplayName
LabelKey
=
"displayName"
CreatorLabel
Key
=
"creator"
DisplayName
AnnotationKey
=
"displayName"
CreatorLabel
AnnotationKey
=
"creator"
OpenPitrixRuntimeAnnotationKey
=
"openpitrix_runtime"
WorkspaceAdmin
=
"workspace-admin"
ClusterAdmin
=
"cluster-admin"
...
...
pkg/controller/namespace/namespace_controller.go
浏览文件 @
8e862caf
...
...
@@ -195,7 +195,7 @@ func (r *ReconcileNamespace) checkAndCreateRoles(namespace *corev1.Namespace) er
func
(
r
*
ReconcileNamespace
)
checkAndCreateRoleBindings
(
namespace
*
corev1
.
Namespace
)
error
{
workspaceName
:=
namespace
.
Labels
[
constants
.
WorkspaceLabelKey
]
creatorName
:=
namespace
.
Labels
[
constants
.
CreatorLabel
Key
]
creatorName
:=
namespace
.
Annotations
[
constants
.
CreatorLabelAnnotation
Key
]
creator
:=
rbac
.
Subject
{
APIGroup
:
"rbac.authorization.k8s.io"
,
Kind
:
"User"
,
Name
:
creatorName
}
...
...
pkg/controller/workspace/workspace_controller.go
浏览文件 @
8e862caf
...
...
@@ -473,7 +473,8 @@ func getWorkspaceViewerRoleBindingName(workspaceName string) string {
func
getWorkspaceAdmin
(
workspaceName
string
)
*
rbac
.
ClusterRole
{
admin
:=
&
rbac
.
ClusterRole
{}
admin
.
Name
=
getWorkspaceAdminRoleName
(
workspaceName
)
admin
.
Labels
=
map
[
string
]
string
{
constants
.
WorkspaceLabelKey
:
workspaceName
,
constants
.
DisplayNameLabelKey
:
constants
.
WorkspaceAdmin
}
admin
.
Labels
=
map
[
string
]
string
{
constants
.
WorkspaceLabelKey
:
workspaceName
}
admin
.
Annotations
=
map
[
string
]
string
{
constants
.
DisplayNameAnnotationKey
:
constants
.
WorkspaceAdmin
}
admin
.
Rules
=
[]
rbac
.
PolicyRule
{
{
Verbs
:
[]
string
{
"*"
},
...
...
@@ -494,7 +495,8 @@ func getWorkspaceAdmin(workspaceName string) *rbac.ClusterRole {
func
getWorkspaceRegular
(
workspaceName
string
)
*
rbac
.
ClusterRole
{
regular
:=
&
rbac
.
ClusterRole
{}
regular
.
Name
=
getWorkspaceRegularRoleName
(
workspaceName
)
regular
.
Labels
=
map
[
string
]
string
{
constants
.
WorkspaceLabelKey
:
workspaceName
,
constants
.
DisplayNameLabelKey
:
constants
.
WorkspaceRegular
}
regular
.
Labels
=
map
[
string
]
string
{
constants
.
WorkspaceLabelKey
:
workspaceName
}
regular
.
Annotations
=
map
[
string
]
string
{
constants
.
DisplayNameAnnotationKey
:
constants
.
WorkspaceRegular
}
regular
.
Rules
=
[]
rbac
.
PolicyRule
{
{
Verbs
:
[]
string
{
"get"
},
...
...
@@ -521,7 +523,8 @@ func getWorkspaceRegular(workspaceName string) *rbac.ClusterRole {
func
getWorkspaceViewer
(
workspaceName
string
)
*
rbac
.
ClusterRole
{
viewer
:=
&
rbac
.
ClusterRole
{}
viewer
.
Name
=
getWorkspaceViewerRoleName
(
workspaceName
)
viewer
.
Labels
=
map
[
string
]
string
{
constants
.
WorkspaceLabelKey
:
workspaceName
,
constants
.
DisplayNameLabelKey
:
constants
.
WorkspaceViewer
}
viewer
.
Labels
=
map
[
string
]
string
{
constants
.
WorkspaceLabelKey
:
workspaceName
}
viewer
.
Annotations
=
map
[
string
]
string
{
constants
.
DisplayNameAnnotationKey
:
constants
.
WorkspaceViewer
}
viewer
.
Rules
=
[]
rbac
.
PolicyRule
{
{
Verbs
:
[]
string
{
"get"
,
"list"
},
...
...
pkg/models/iam/am.go
浏览文件 @
8e862caf
...
...
@@ -413,7 +413,7 @@ func ListWorkspaceRoles(workspace string, conditions *params.Conditions, orderBy
for
i
,
item
:=
range
result
.
Items
{
if
role
,
ok
:=
item
.
(
*
v1
.
ClusterRole
);
ok
{
role
=
role
.
DeepCopy
()
role
.
Name
=
role
.
Labels
[
constants
.
DisplayNameLabel
Key
]
role
.
Name
=
role
.
Annotations
[
constants
.
DisplayNameAnnotation
Key
]
result
.
Items
[
i
]
=
role
}
}
...
...
@@ -477,7 +477,7 @@ func GetUserWorkspaceSimpleRules(workspace, username string) ([]models.SimpleRul
if
err
!=
nil
{
return
nil
,
err
}
return
GetWorkspaceRoleSimpleRules
(
workspace
,
workspaceRole
.
Labels
[
constants
.
DisplayNameLabel
Key
]),
nil
return
GetWorkspaceRoleSimpleRules
(
workspace
,
workspaceRole
.
Annotations
[
constants
.
DisplayNameAnnotation
Key
]),
nil
}
func
GetWorkspaceRoleSimpleRules
(
workspace
,
roleName
string
)
[]
models
.
SimpleRule
{
...
...
pkg/models/resources/clusterroles.go
浏览文件 @
8e862caf
...
...
@@ -22,6 +22,7 @@ import (
"kubesphere.io/kubesphere/pkg/informers"
"kubesphere.io/kubesphere/pkg/params"
"kubesphere.io/kubesphere/pkg/utils/k8sutil"
"kubesphere.io/kubesphere/pkg/utils/sliceutil"
"sort"
"strings"
...
...
@@ -48,11 +49,12 @@ func (*clusterRoleSearcher) match(match map[string]string, item *rbac.ClusterRol
if
!
k8sutil
.
IsControlledBy
(
item
.
OwnerReferences
,
kind
,
name
)
{
return
false
}
case
name
:
if
item
.
Name
!=
v
&&
item
.
Labels
[
displayName
]
!=
v
{
case
Name
:
names
:=
strings
.
Split
(
v
,
"|"
)
if
!
sliceutil
.
HasString
(
names
,
item
.
Name
)
{
return
false
}
case
k
eyword
:
case
K
eyword
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
searchFuzzy
(
item
.
Labels
,
""
,
v
)
&&
!
searchFuzzy
(
item
.
Annotations
,
""
,
v
)
{
return
false
}
...
...
@@ -75,8 +77,8 @@ func (*clusterRoleSearcher) match(match map[string]string, item *rbac.ClusterRol
func
(
*
clusterRoleSearcher
)
fuzzy
(
fuzzy
map
[
string
]
string
,
item
*
rbac
.
ClusterRole
)
bool
{
for
k
,
v
:=
range
fuzzy
{
switch
k
{
case
n
ame
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
strings
.
Contains
(
item
.
Labels
[
displayName
],
v
)
{
case
N
ame
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
strings
.
Contains
(
item
.
Annotations
[
constants
.
DisplayNameAnnotationKey
],
v
)
{
return
false
}
case
label
:
...
...
@@ -101,7 +103,7 @@ func (*clusterRoleSearcher) compare(a, b *rbac.ClusterRole, orderBy string) bool
switch
orderBy
{
case
CreateTime
:
return
a
.
CreationTimestamp
.
Time
.
Before
(
b
.
CreationTimestamp
.
Time
)
case
n
ame
:
case
N
ame
:
fallthrough
default
:
return
strings
.
Compare
(
a
.
Name
,
b
.
Name
)
<=
0
...
...
@@ -143,7 +145,7 @@ func (s *clusterRoleSearcher) search(namespace string, conditions *params.Condit
}
func
isUserFacingClusterRole
(
role
*
rbac
.
ClusterRole
)
bool
{
if
role
.
Labels
[
constants
.
CreatorLabel
Key
]
!=
""
&&
role
.
Labels
[
constants
.
WorkspaceLabelKey
]
==
""
{
if
role
.
Annotations
[
constants
.
CreatorLabelAnnotation
Key
]
!=
""
&&
role
.
Labels
[
constants
.
WorkspaceLabelKey
]
==
""
{
return
true
}
return
false
...
...
pkg/models/resources/configmaps.go
浏览文件 @
8e862caf
...
...
@@ -18,8 +18,10 @@
package
resources
import
(
"kubesphere.io/kubesphere/pkg/constants"
"kubesphere.io/kubesphere/pkg/informers"
"kubesphere.io/kubesphere/pkg/params"
"kubesphere.io/kubesphere/pkg/utils/sliceutil"
"sort"
"strings"
...
...
@@ -38,11 +40,12 @@ func (*configMapSearcher) get(namespace, name string) (interface{}, error) {
func
(
*
configMapSearcher
)
match
(
match
map
[
string
]
string
,
item
*
v1
.
ConfigMap
)
bool
{
for
k
,
v
:=
range
match
{
switch
k
{
case
name
:
if
item
.
Name
!=
v
&&
item
.
Labels
[
displayName
]
!=
v
{
case
Name
:
names
:=
strings
.
Split
(
v
,
"|"
)
if
!
sliceutil
.
HasString
(
names
,
item
.
Name
)
{
return
false
}
case
k
eyword
:
case
K
eyword
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
searchFuzzy
(
item
.
Labels
,
""
,
v
)
&&
!
searchFuzzy
(
item
.
Annotations
,
""
,
v
)
{
return
false
}
...
...
@@ -59,8 +62,8 @@ func (*configMapSearcher) match(match map[string]string, item *v1.ConfigMap) boo
func
(
*
configMapSearcher
)
fuzzy
(
fuzzy
map
[
string
]
string
,
item
*
v1
.
ConfigMap
)
bool
{
for
k
,
v
:=
range
fuzzy
{
switch
k
{
case
n
ame
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
strings
.
Contains
(
item
.
Labels
[
displayName
],
v
)
{
case
N
ame
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
strings
.
Contains
(
item
.
Annotations
[
constants
.
DisplayNameAnnotationKey
],
v
)
{
return
false
}
case
label
:
...
...
@@ -89,7 +92,7 @@ func (*configMapSearcher) compare(a, b *v1.ConfigMap, orderBy string) bool {
switch
orderBy
{
case
CreateTime
:
return
a
.
CreationTimestamp
.
Time
.
Before
(
b
.
CreationTimestamp
.
Time
)
case
n
ame
:
case
N
ame
:
fallthrough
default
:
return
strings
.
Compare
(
a
.
Name
,
b
.
Name
)
<=
0
...
...
pkg/models/resources/cronjobs.go
浏览文件 @
8e862caf
...
...
@@ -18,8 +18,10 @@
package
resources
import
(
"kubesphere.io/kubesphere/pkg/constants"
"kubesphere.io/kubesphere/pkg/informers"
"kubesphere.io/kubesphere/pkg/params"
"kubesphere.io/kubesphere/pkg/utils/sliceutil"
"sort"
"strings"
...
...
@@ -46,15 +48,16 @@ func cronJobStatus(item *v1beta1.CronJob) string {
func
(
*
cronJobSearcher
)
match
(
match
map
[
string
]
string
,
item
*
v1beta1
.
CronJob
)
bool
{
for
k
,
v
:=
range
match
{
switch
k
{
case
name
:
if
item
.
Name
!=
v
&&
item
.
Labels
[
displayName
]
!=
v
{
case
Name
:
names
:=
strings
.
Split
(
v
,
"|"
)
if
!
sliceutil
.
HasString
(
names
,
item
.
Name
)
{
return
false
}
case
status
:
if
cronJobStatus
(
item
)
!=
v
{
return
false
}
case
k
eyword
:
case
K
eyword
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
searchFuzzy
(
item
.
Labels
,
""
,
v
)
&&
!
searchFuzzy
(
item
.
Annotations
,
""
,
v
)
{
return
false
}
...
...
@@ -71,8 +74,8 @@ func (*cronJobSearcher) fuzzy(fuzzy map[string]string, item *v1beta1.CronJob) bo
for
k
,
v
:=
range
fuzzy
{
switch
k
{
case
n
ame
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
strings
.
Contains
(
item
.
Labels
[
displayName
],
v
)
{
case
N
ame
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
strings
.
Contains
(
item
.
Annotations
[
constants
.
DisplayNameAnnotationKey
],
v
)
{
return
false
}
case
label
:
...
...
@@ -112,7 +115,7 @@ func (*cronJobSearcher) compare(a, b *v1beta1.CronJob, orderBy string) bool {
return
a
.
CreationTimestamp
.
Time
.
Before
(
b
.
CreationTimestamp
.
Time
)
default
:
fallthrough
case
n
ame
:
case
N
ame
:
return
strings
.
Compare
(
a
.
Name
,
b
.
Name
)
<=
0
}
}
...
...
pkg/models/resources/daemonsets.go
浏览文件 @
8e862caf
...
...
@@ -18,8 +18,10 @@
package
resources
import
(
"kubesphere.io/kubesphere/pkg/constants"
"kubesphere.io/kubesphere/pkg/informers"
"kubesphere.io/kubesphere/pkg/params"
"kubesphere.io/kubesphere/pkg/utils/sliceutil"
"sort"
"strings"
...
...
@@ -52,11 +54,12 @@ func (*daemonSetSearcher) match(match map[string]string, item *v1.DaemonSet) boo
if
daemonSetStatus
(
item
)
!=
v
{
return
false
}
case
name
:
if
item
.
Name
!=
v
&&
item
.
Labels
[
displayName
]
!=
v
{
case
Name
:
names
:=
strings
.
Split
(
v
,
"|"
)
if
!
sliceutil
.
HasString
(
names
,
item
.
Name
)
{
return
false
}
case
k
eyword
:
case
K
eyword
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
searchFuzzy
(
item
.
Labels
,
""
,
v
)
&&
!
searchFuzzy
(
item
.
Annotations
,
""
,
v
)
{
return
false
}
...
...
@@ -73,8 +76,8 @@ func (*daemonSetSearcher) fuzzy(fuzzy map[string]string, item *v1.DaemonSet) boo
for
k
,
v
:=
range
fuzzy
{
switch
k
{
case
n
ame
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
strings
.
Contains
(
item
.
Labels
[
displayName
],
v
)
{
case
N
ame
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
strings
.
Contains
(
item
.
Annotations
[
constants
.
DisplayNameAnnotationKey
],
v
)
{
return
false
}
case
label
:
...
...
@@ -104,7 +107,7 @@ func (*daemonSetSearcher) compare(a, b *v1.DaemonSet, orderBy string) bool {
switch
orderBy
{
case
CreateTime
:
return
a
.
CreationTimestamp
.
Time
.
Before
(
b
.
CreationTimestamp
.
Time
)
case
n
ame
:
case
N
ame
:
fallthrough
default
:
return
strings
.
Compare
(
a
.
Name
,
b
.
Name
)
<=
0
...
...
pkg/models/resources/deployments.go
浏览文件 @
8e862caf
...
...
@@ -18,8 +18,10 @@
package
resources
import
(
"kubesphere.io/kubesphere/pkg/constants"
"kubesphere.io/kubesphere/pkg/informers"
"kubesphere.io/kubesphere/pkg/params"
"kubesphere.io/kubesphere/pkg/utils/sliceutil"
"sort"
"strings"
...
...
@@ -56,11 +58,12 @@ func (*deploymentSearcher) match(match map[string]string, item *v1.Deployment) b
if
deploymentStatus
(
item
)
!=
v
{
return
false
}
case
name
:
if
item
.
Name
!=
v
&&
item
.
Labels
[
displayName
]
!=
v
{
case
Name
:
names
:=
strings
.
Split
(
v
,
"|"
)
if
!
sliceutil
.
HasString
(
names
,
item
.
Name
)
{
return
false
}
case
k
eyword
:
case
K
eyword
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
searchFuzzy
(
item
.
Labels
,
""
,
v
)
&&
!
searchFuzzy
(
item
.
Annotations
,
""
,
v
)
{
return
false
}
...
...
@@ -77,8 +80,8 @@ func (*deploymentSearcher) fuzzy(fuzzy map[string]string, item *v1.Deployment) b
for
k
,
v
:=
range
fuzzy
{
switch
k
{
case
n
ame
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
strings
.
Contains
(
item
.
Labels
[
displayName
],
v
)
{
case
N
ame
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
strings
.
Contains
(
item
.
Annotations
[
constants
.
DisplayNameAnnotationKey
],
v
)
{
return
false
}
case
label
:
...
...
@@ -108,7 +111,7 @@ func (*deploymentSearcher) compare(a, b *v1.Deployment, orderBy string) bool {
switch
orderBy
{
case
CreateTime
:
return
a
.
CreationTimestamp
.
Time
.
Before
(
b
.
CreationTimestamp
.
Time
)
case
n
ame
:
case
N
ame
:
fallthrough
default
:
return
strings
.
Compare
(
a
.
Name
,
b
.
Name
)
<=
0
...
...
pkg/models/resources/ingresses.go
浏览文件 @
8e862caf
...
...
@@ -18,8 +18,10 @@
package
resources
import
(
"kubesphere.io/kubesphere/pkg/constants"
"kubesphere.io/kubesphere/pkg/informers"
"kubesphere.io/kubesphere/pkg/params"
"kubesphere.io/kubesphere/pkg/utils/sliceutil"
"sort"
"strings"
...
...
@@ -39,11 +41,12 @@ func (*ingressSearcher) get(namespace, name string) (interface{}, error) {
func
(
*
ingressSearcher
)
match
(
match
map
[
string
]
string
,
item
*
extensions
.
Ingress
)
bool
{
for
k
,
v
:=
range
match
{
switch
k
{
case
name
:
if
item
.
Name
!=
v
&&
item
.
Labels
[
displayName
]
!=
v
{
case
Name
:
names
:=
strings
.
Split
(
v
,
"|"
)
if
!
sliceutil
.
HasString
(
names
,
item
.
Name
)
{
return
false
}
case
k
eyword
:
case
K
eyword
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
searchFuzzy
(
item
.
Labels
,
""
,
v
)
&&
!
searchFuzzy
(
item
.
Annotations
,
""
,
v
)
{
return
false
}
...
...
@@ -60,8 +63,8 @@ func (*ingressSearcher) match(match map[string]string, item *extensions.Ingress)
func
(
*
ingressSearcher
)
fuzzy
(
fuzzy
map
[
string
]
string
,
item
*
extensions
.
Ingress
)
bool
{
for
k
,
v
:=
range
fuzzy
{
switch
k
{
case
n
ame
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
strings
.
Contains
(
item
.
Labels
[
displayName
],
v
)
{
case
N
ame
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
strings
.
Contains
(
item
.
Annotations
[
constants
.
DisplayNameAnnotationKey
],
v
)
{
return
false
}
case
label
:
...
...
@@ -90,7 +93,7 @@ func (*ingressSearcher) compare(a, b *extensions.Ingress, orderBy string) bool {
switch
orderBy
{
case
CreateTime
:
return
a
.
CreationTimestamp
.
Time
.
Before
(
b
.
CreationTimestamp
.
Time
)
case
n
ame
:
case
N
ame
:
fallthrough
default
:
return
strings
.
Compare
(
a
.
Name
,
b
.
Name
)
<=
0
...
...
pkg/models/resources/jobs.go
浏览文件 @
8e862caf
...
...
@@ -18,8 +18,10 @@
package
resources
import
(
"kubesphere.io/kubesphere/pkg/constants"
"kubesphere.io/kubesphere/pkg/informers"
"kubesphere.io/kubesphere/pkg/params"
"kubesphere.io/kubesphere/pkg/utils/sliceutil"
"sort"
"strings"
"time"
...
...
@@ -58,11 +60,12 @@ func (*jobSearcher) match(match map[string]string, item *batchv1.Job) bool {
if
jobStatus
(
item
)
!=
v
{
return
false
}
case
name
:
if
item
.
Name
!=
v
&&
item
.
Labels
[
displayName
]
!=
v
{
case
Name
:
names
:=
strings
.
Split
(
v
,
"|"
)
if
!
sliceutil
.
HasString
(
names
,
item
.
Name
)
{
return
false
}
case
k
eyword
:
case
K
eyword
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
searchFuzzy
(
item
.
Labels
,
""
,
v
)
&&
!
searchFuzzy
(
item
.
Annotations
,
""
,
v
)
{
return
false
}
...
...
@@ -79,8 +82,8 @@ func (*jobSearcher) fuzzy(fuzzy map[string]string, item *batchv1.Job) bool {
for
k
,
v
:=
range
fuzzy
{
switch
k
{
case
n
ame
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
strings
.
Contains
(
item
.
Labels
[
displayName
],
v
)
{
case
N
ame
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
strings
.
Contains
(
item
.
Annotations
[
constants
.
DisplayNameAnnotationKey
],
v
)
{
return
false
}
case
label
:
...
...
@@ -125,7 +128,7 @@ func (*jobSearcher) compare(a, b *batchv1.Job, orderBy string) bool {
return
a
.
CreationTimestamp
.
Time
.
Before
(
b
.
CreationTimestamp
.
Time
)
case
updateTime
:
return
jobUpdateTime
(
a
)
.
Before
(
jobUpdateTime
(
b
))
case
n
ame
:
case
N
ame
:
fallthrough
default
:
return
strings
.
Compare
(
a
.
Name
,
b
.
Name
)
<=
0
...
...
pkg/models/resources/namespaces.go
浏览文件 @
8e862caf
...
...
@@ -18,8 +18,10 @@
package
resources
import
(
"kubesphere.io/kubesphere/pkg/constants"
"kubesphere.io/kubesphere/pkg/informers"
"kubesphere.io/kubesphere/pkg/params"
"kubesphere.io/kubesphere/pkg/utils/sliceutil"
"sort"
"strings"
...
...
@@ -38,11 +40,12 @@ func (*namespaceSearcher) get(namespace, name string) (interface{}, error) {
func
(
*
namespaceSearcher
)
match
(
match
map
[
string
]
string
,
item
*
v1
.
Namespace
)
bool
{
for
k
,
v
:=
range
match
{
switch
k
{
case
name
:
if
item
.
Name
!=
v
&&
item
.
Labels
[
displayName
]
!=
v
{
case
Name
:
names
:=
strings
.
Split
(
v
,
"|"
)
if
!
sliceutil
.
HasString
(
names
,
item
.
Name
)
{
return
false
}
case
k
eyword
:
case
K
eyword
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
searchFuzzy
(
item
.
Labels
,
""
,
v
)
&&
!
searchFuzzy
(
item
.
Annotations
,
""
,
v
)
{
return
false
}
...
...
@@ -59,8 +62,8 @@ func (*namespaceSearcher) match(match map[string]string, item *v1.Namespace) boo
func
(
*
namespaceSearcher
)
fuzzy
(
fuzzy
map
[
string
]
string
,
item
*
v1
.
Namespace
)
bool
{
for
k
,
v
:=
range
fuzzy
{
switch
k
{
case
n
ame
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
strings
.
Contains
(
item
.
Labels
[
displayName
],
v
)
{
case
N
ame
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
strings
.
Contains
(
item
.
Annotations
[
constants
.
DisplayNameAnnotationKey
],
v
)
{
return
false
}
case
label
:
...
...
@@ -89,7 +92,7 @@ func (*namespaceSearcher) compare(a, b *v1.Namespace, orderBy string) bool {
switch
orderBy
{
case
CreateTime
:
return
a
.
CreationTimestamp
.
Time
.
Before
(
b
.
CreationTimestamp
.
Time
)
case
n
ame
:
case
N
ame
:
fallthrough
default
:
return
strings
.
Compare
(
a
.
Name
,
b
.
Name
)
<=
0
...
...
pkg/models/resources/nodes.go
浏览文件 @
8e862caf
...
...
@@ -18,8 +18,10 @@
package
resources
import
(
"kubesphere.io/kubesphere/pkg/constants"
"kubesphere.io/kubesphere/pkg/informers"
"kubesphere.io/kubesphere/pkg/params"
"kubesphere.io/kubesphere/pkg/utils/sliceutil"
"sort"
"strings"
...
...
@@ -38,11 +40,12 @@ func (*nodeSearcher) get(namespace, name string) (interface{}, error) {
func
(
*
nodeSearcher
)
match
(
match
map
[
string
]
string
,
item
*
v1
.
Node
)
bool
{
for
k
,
v
:=
range
match
{
switch
k
{
case
name
:
if
item
.
Name
!=
v
&&
item
.
Labels
[
displayName
]
!=
v
{
case
Name
:
names
:=
strings
.
Split
(
v
,
"|"
)
if
!
sliceutil
.
HasString
(
names
,
item
.
Name
)
{
return
false
}
case
k
eyword
:
case
K
eyword
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
searchFuzzy
(
item
.
Labels
,
""
,
v
)
&&
!
searchFuzzy
(
item
.
Annotations
,
""
,
v
)
{
return
false
}
...
...
@@ -59,8 +62,8 @@ func (*nodeSearcher) match(match map[string]string, item *v1.Node) bool {
func
(
*
nodeSearcher
)
fuzzy
(
fuzzy
map
[
string
]
string
,
item
*
v1
.
Node
)
bool
{
for
k
,
v
:=
range
fuzzy
{
switch
k
{
case
n
ame
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
strings
.
Contains
(
item
.
Labels
[
displayName
],
v
)
{
case
N
ame
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
strings
.
Contains
(
item
.
Annotations
[
constants
.
DisplayNameAnnotationKey
],
v
)
{
return
false
}
case
label
:
...
...
@@ -89,7 +92,7 @@ func (*nodeSearcher) compare(a, b *v1.Node, orderBy string) bool {
switch
orderBy
{
case
CreateTime
:
return
a
.
CreationTimestamp
.
Time
.
Before
(
b
.
CreationTimestamp
.
Time
)
case
n
ame
:
case
N
ame
:
fallthrough
default
:
return
strings
.
Compare
(
a
.
Name
,
b
.
Name
)
<=
0
...
...
pkg/models/resources/persistentvolumeclaims.go
浏览文件 @
8e862caf
...
...
@@ -18,8 +18,10 @@
package
resources
import
(
"kubesphere.io/kubesphere/pkg/constants"
"kubesphere.io/kubesphere/pkg/informers"
"kubesphere.io/kubesphere/pkg/params"
"kubesphere.io/kubesphere/pkg/utils/sliceutil"
"sort"
"strings"
...
...
@@ -38,11 +40,12 @@ func (*persistentVolumeClaimSearcher) get(namespace, name string) (interface{},
func
(
*
persistentVolumeClaimSearcher
)
match
(
match
map
[
string
]
string
,
item
*
v1
.
PersistentVolumeClaim
)
bool
{
for
k
,
v
:=
range
match
{
switch
k
{
case
name
:
if
item
.
Name
!=
v
&&
item
.
Labels
[
displayName
]
!=
v
{
case
Name
:
names
:=
strings
.
Split
(
v
,
"|"
)
if
!
sliceutil
.
HasString
(
names
,
item
.
Name
)
{
return
false
}
case
k
eyword
:
case
K
eyword
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
searchFuzzy
(
item
.
Labels
,
""
,
v
)
&&
!
searchFuzzy
(
item
.
Annotations
,
""
,
v
)
{
return
false
}
...
...
@@ -59,8 +62,8 @@ func (*persistentVolumeClaimSearcher) match(match map[string]string, item *v1.Pe
func
(
*
persistentVolumeClaimSearcher
)
fuzzy
(
fuzzy
map
[
string
]
string
,
item
*
v1
.
PersistentVolumeClaim
)
bool
{
for
k
,
v
:=
range
fuzzy
{
switch
k
{
case
n
ame
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
strings
.
Contains
(
item
.
Labels
[
displayName
],
v
)
{
case
N
ame
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
strings
.
Contains
(
item
.
Annotations
[
constants
.
DisplayNameAnnotationKey
],
v
)
{
return
false
}
case
label
:
...
...
@@ -89,7 +92,7 @@ func (*persistentVolumeClaimSearcher) compare(a, b *v1.PersistentVolumeClaim, or
switch
orderBy
{
case
CreateTime
:
return
a
.
CreationTimestamp
.
Time
.
Before
(
b
.
CreationTimestamp
.
Time
)
case
n
ame
:
case
N
ame
:
fallthrough
default
:
return
strings
.
Compare
(
a
.
Name
,
b
.
Name
)
<=
0
...
...
pkg/models/resources/pods.go
浏览文件 @
8e862caf
...
...
@@ -19,8 +19,10 @@ package resources
import
(
v12
"k8s.io/api/apps/v1"
"kubesphere.io/kubesphere/pkg/constants"
"kubesphere.io/kubesphere/pkg/informers"
"kubesphere.io/kubesphere/pkg/params"
"kubesphere.io/kubesphere/pkg/utils/sliceutil"
"sort"
"strings"
...
...
@@ -168,11 +170,12 @@ func (*podSearcher) match(match map[string]string, item *v1.Pod) bool {
if
!
podBelongToService
(
item
,
v
)
{
return
false
}
case
name
:
if
item
.
Name
!=
v
&&
item
.
Labels
[
displayName
]
!=
v
{
case
Name
:
names
:=
strings
.
Split
(
v
,
"|"
)
if
!
sliceutil
.
HasString
(
names
,
item
.
Name
)
{
return
false
}
case
k
eyword
:
case
K
eyword
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
searchFuzzy
(
item
.
Labels
,
""
,
v
)
&&
!
searchFuzzy
(
item
.
Annotations
,
""
,
v
)
{
return
false
}
...
...
@@ -189,8 +192,8 @@ func (*podSearcher) match(match map[string]string, item *v1.Pod) bool {
func
(
*
podSearcher
)
fuzzy
(
fuzzy
map
[
string
]
string
,
item
*
v1
.
Pod
)
bool
{
for
k
,
v
:=
range
fuzzy
{
switch
k
{
case
n
ame
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
strings
.
Contains
(
item
.
Labels
[
displayName
],
v
)
{
case
N
ame
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
strings
.
Contains
(
item
.
Annotations
[
constants
.
DisplayNameAnnotationKey
],
v
)
{
return
false
}
case
label
:
...
...
@@ -219,7 +222,7 @@ func (*podSearcher) compare(a, b *v1.Pod, orderBy string) bool {
switch
orderBy
{
case
CreateTime
:
return
a
.
CreationTimestamp
.
Time
.
Before
(
b
.
CreationTimestamp
.
Time
)
case
n
ame
:
case
N
ame
:
fallthrough
default
:
return
strings
.
Compare
(
a
.
Name
,
b
.
Name
)
<=
0
...
...
pkg/models/resources/resources.go
浏览文件 @
8e862caf
...
...
@@ -55,18 +55,17 @@ var (
)
const
(
n
ame
=
"name"
N
ame
=
"name"
label
=
"label"
ownerKind
=
"ownerKind"
ownerName
=
"ownerName"
CreateTime
=
"
C
reateTime"
CreateTime
=
"
c
reateTime"
updateTime
=
"updateTime"
lastScheduleTime
=
"lastScheduleTime"
displayName
=
"displayName"
chart
=
"chart"
release
=
"release"
annotation
=
"annotation"
k
eyword
=
"keyword"
K
eyword
=
"keyword"
status
=
"status"
running
=
"running"
paused
=
"paused"
...
...
pkg/models/resources/roles.go
浏览文件 @
8e862caf
...
...
@@ -18,8 +18,10 @@
package
resources
import
(
"kubesphere.io/kubesphere/pkg/constants"
"kubesphere.io/kubesphere/pkg/informers"
"kubesphere.io/kubesphere/pkg/params"
"kubesphere.io/kubesphere/pkg/utils/sliceutil"
"sort"
"strings"
...
...
@@ -38,11 +40,12 @@ func (*roleSearcher) get(namespace, name string) (interface{}, error) {
func
(
*
roleSearcher
)
match
(
match
map
[
string
]
string
,
item
*
rbac
.
Role
)
bool
{
for
k
,
v
:=
range
match
{
switch
k
{
case
name
:
if
item
.
Name
!=
v
&&
item
.
Labels
[
displayName
]
!=
v
{
case
Name
:
names
:=
strings
.
Split
(
v
,
"|"
)
if
!
sliceutil
.
HasString
(
names
,
item
.
Name
)
{
return
false
}
case
k
eyword
:
case
K
eyword
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
searchFuzzy
(
item
.
Labels
,
""
,
v
)
&&
!
searchFuzzy
(
item
.
Annotations
,
""
,
v
)
{
return
false
}
...
...
@@ -59,8 +62,8 @@ func (*roleSearcher) match(match map[string]string, item *rbac.Role) bool {
func
(
*
roleSearcher
)
fuzzy
(
fuzzy
map
[
string
]
string
,
item
*
rbac
.
Role
)
bool
{
for
k
,
v
:=
range
fuzzy
{
switch
k
{
case
n
ame
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
strings
.
Contains
(
item
.
Labels
[
displayName
],
v
)
{
case
N
ame
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
strings
.
Contains
(
item
.
Annotations
[
constants
.
DisplayNameAnnotationKey
],
v
)
{
return
false
}
case
label
:
...
...
@@ -85,7 +88,7 @@ func (*roleSearcher) compare(a, b *rbac.Role, orderBy string) bool {
switch
orderBy
{
case
CreateTime
:
return
a
.
CreationTimestamp
.
Time
.
Before
(
b
.
CreationTimestamp
.
Time
)
case
n
ame
:
case
N
ame
:
fallthrough
default
:
return
strings
.
Compare
(
a
.
Name
,
b
.
Name
)
<=
0
...
...
pkg/models/resources/s2ibuilder.go
浏览文件 @
8e862caf
...
...
@@ -21,8 +21,10 @@ package resources
import
(
"github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1"
"k8s.io/apimachinery/pkg/labels"
"kubesphere.io/kubesphere/pkg/constants"
"kubesphere.io/kubesphere/pkg/informers"
"kubesphere.io/kubesphere/pkg/params"
"kubesphere.io/kubesphere/pkg/utils/sliceutil"
"sort"
"strings"
)
...
...
@@ -38,11 +40,12 @@ func (*s2iBuilderSearcher) get(namespace, name string) (interface{}, error) {
func
(
*
s2iBuilderSearcher
)
match
(
match
map
[
string
]
string
,
item
*
v1alpha1
.
S2iBuilder
)
bool
{
for
k
,
v
:=
range
match
{
switch
k
{
case
name
:
if
item
.
Name
!=
v
&&
item
.
Labels
[
displayName
]
!=
v
{
case
Name
:
names
:=
strings
.
Split
(
v
,
"|"
)
if
!
sliceutil
.
HasString
(
names
,
item
.
Name
)
{
return
false
}
case
k
eyword
:
case
K
eyword
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
searchFuzzy
(
item
.
Labels
,
""
,
v
)
&&
!
searchFuzzy
(
item
.
Annotations
,
""
,
v
)
{
return
false
}
...
...
@@ -59,8 +62,8 @@ func (*s2iBuilderSearcher) match(match map[string]string, item *v1alpha1.S2iBuil
func
(
*
s2iBuilderSearcher
)
fuzzy
(
fuzzy
map
[
string
]
string
,
item
*
v1alpha1
.
S2iBuilder
)
bool
{
for
k
,
v
:=
range
fuzzy
{
switch
k
{
case
n
ame
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
strings
.
Contains
(
item
.
Labels
[
displayName
],
v
)
{
case
N
ame
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
strings
.
Contains
(
item
.
Annotations
[
constants
.
DisplayNameAnnotationKey
],
v
)
{
return
false
}
case
label
:
...
...
@@ -89,7 +92,7 @@ func (*s2iBuilderSearcher) compare(a, b *v1alpha1.S2iBuilder, orderBy string) bo
switch
orderBy
{
case
CreateTime
:
return
a
.
CreationTimestamp
.
Time
.
Before
(
b
.
CreationTimestamp
.
Time
)
case
n
ame
:
case
N
ame
:
fallthrough
default
:
return
strings
.
Compare
(
a
.
Name
,
b
.
Name
)
<=
0
...
...
pkg/models/resources/s2ibuildertemplate.go
浏览文件 @
8e862caf
...
...
@@ -19,8 +19,10 @@ package resources
import
(
"github.com/kubesphere/s2ioperator/pkg/apis/devops/v1alpha1"
"kubesphere.io/kubesphere/pkg/constants"
"kubesphere.io/kubesphere/pkg/informers"
"kubesphere.io/kubesphere/pkg/params"
"kubesphere.io/kubesphere/pkg/utils/sliceutil"
"sort"
"strings"
...
...
@@ -38,11 +40,12 @@ func (*s2iBuilderTemplateSearcher) get(namespace, name string) (interface{}, err
func
(
*
s2iBuilderTemplateSearcher
)
match
(
match
map
[
string
]
string
,
item
*
v1alpha1
.
S2iBuilderTemplate
)
bool
{
for
k
,
v
:=
range
match
{
switch
k
{
case
name
:
if
item
.
Name
!=
v
&&
item
.
Labels
[
displayName
]
!=
v
{
case
Name
:
names
:=
strings
.
Split
(
v
,
"|"
)
if
!
sliceutil
.
HasString
(
names
,
item
.
Name
)
{
return
false
}
case
k
eyword
:
case
K
eyword
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
searchFuzzy
(
item
.
Labels
,
""
,
v
)
&&
!
searchFuzzy
(
item
.
Annotations
,
""
,
v
)
{
return
false
}
...
...
@@ -59,8 +62,8 @@ func (*s2iBuilderTemplateSearcher) match(match map[string]string, item *v1alpha1
func
(
*
s2iBuilderTemplateSearcher
)
fuzzy
(
fuzzy
map
[
string
]
string
,
item
*
v1alpha1
.
S2iBuilderTemplate
)
bool
{
for
k
,
v
:=
range
fuzzy
{
switch
k
{
case
n
ame
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
strings
.
Contains
(
item
.
Labels
[
displayName
],
v
)
{
case
N
ame
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
strings
.
Contains
(
item
.
Annotations
[
constants
.
DisplayNameAnnotationKey
],
v
)
{
return
false
}
case
label
:
...
...
@@ -85,7 +88,7 @@ func (*s2iBuilderTemplateSearcher) compare(a, b *v1alpha1.S2iBuilderTemplate, or
switch
orderBy
{
case
CreateTime
:
return
a
.
CreationTimestamp
.
Time
.
Before
(
b
.
CreationTimestamp
.
Time
)
case
n
ame
:
case
N
ame
:
fallthrough
default
:
return
strings
.
Compare
(
a
.
Name
,
b
.
Name
)
<=
0
...
...
pkg/models/resources/s2irun.go
浏览文件 @
8e862caf
...
...
@@ -19,6 +19,8 @@
package
resources
import
(
"kubesphere.io/kubesphere/pkg/constants"
"kubesphere.io/kubesphere/pkg/utils/sliceutil"
"sort"
"strings"
...
...
@@ -41,15 +43,16 @@ func (*s2iRunSearcher) get(namespace, name string) (interface{}, error) {
func
(
*
s2iRunSearcher
)
match
(
match
map
[
string
]
string
,
item
*
v1alpha1
.
S2iRun
)
bool
{
for
k
,
v
:=
range
match
{
switch
k
{
case
name
:
if
item
.
Name
!=
v
&&
item
.
Labels
[
displayName
]
!=
v
{
case
Name
:
names
:=
strings
.
Split
(
v
,
"|"
)
if
!
sliceutil
.
HasString
(
names
,
item
.
Name
)
{
return
false
}
case
status
:
if
string
(
item
.
Status
.
RunState
)
!=
v
{
return
false
}
case
k
eyword
:
case
K
eyword
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
searchFuzzy
(
item
.
Labels
,
""
,
v
)
&&
!
searchFuzzy
(
item
.
Annotations
,
""
,
v
)
{
return
false
}
...
...
@@ -66,8 +69,8 @@ func (*s2iRunSearcher) match(match map[string]string, item *v1alpha1.S2iRun) boo
func
(
*
s2iRunSearcher
)
fuzzy
(
fuzzy
map
[
string
]
string
,
item
*
v1alpha1
.
S2iRun
)
bool
{
for
k
,
v
:=
range
fuzzy
{
switch
k
{
case
n
ame
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
strings
.
Contains
(
item
.
Labels
[
displayName
],
v
)
{
case
N
ame
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
strings
.
Contains
(
item
.
Annotations
[
constants
.
DisplayNameAnnotationKey
],
v
)
{
return
false
}
case
label
:
...
...
@@ -96,7 +99,7 @@ func (*s2iRunSearcher) compare(a, b *v1alpha1.S2iRun, orderBy string) bool {
switch
orderBy
{
case
CreateTime
:
return
a
.
CreationTimestamp
.
Time
.
Before
(
b
.
CreationTimestamp
.
Time
)
case
n
ame
:
case
N
ame
:
fallthrough
default
:
return
strings
.
Compare
(
a
.
Name
,
b
.
Name
)
<=
0
...
...
pkg/models/resources/secrets.go
浏览文件 @
8e862caf
...
...
@@ -18,8 +18,10 @@
package
resources
import
(
"kubesphere.io/kubesphere/pkg/constants"
"kubesphere.io/kubesphere/pkg/informers"
"kubesphere.io/kubesphere/pkg/params"
"kubesphere.io/kubesphere/pkg/utils/sliceutil"
"sort"
"strings"
...
...
@@ -38,15 +40,16 @@ func (*secretSearcher) get(namespace, name string) (interface{}, error) {
func
(
*
secretSearcher
)
match
(
match
map
[
string
]
string
,
item
*
v1
.
Secret
)
bool
{
for
k
,
v
:=
range
match
{
switch
k
{
case
name
:
if
item
.
Name
!=
v
&&
item
.
Labels
[
displayName
]
!=
v
{
case
Name
:
names
:=
strings
.
Split
(
v
,
"|"
)
if
!
sliceutil
.
HasString
(
names
,
item
.
Name
)
{
return
false
}
case
"type"
:
if
string
(
item
.
Type
)
!=
v
{
return
false
}
case
k
eyword
:
case
K
eyword
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
searchFuzzy
(
item
.
Labels
,
""
,
v
)
&&
!
searchFuzzy
(
item
.
Annotations
,
""
,
v
)
{
return
false
}
...
...
@@ -63,8 +66,8 @@ func (*secretSearcher) match(match map[string]string, item *v1.Secret) bool {
func
(
*
secretSearcher
)
fuzzy
(
fuzzy
map
[
string
]
string
,
item
*
v1
.
Secret
)
bool
{
for
k
,
v
:=
range
fuzzy
{
switch
k
{
case
n
ame
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
strings
.
Contains
(
item
.
Labels
[
displayName
],
v
)
{
case
N
ame
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
strings
.
Contains
(
item
.
Annotations
[
constants
.
DisplayNameAnnotationKey
],
v
)
{
return
false
}
case
label
:
...
...
@@ -93,7 +96,7 @@ func (*secretSearcher) compare(a, b *v1.Secret, orderBy string) bool {
switch
orderBy
{
case
CreateTime
:
return
a
.
CreationTimestamp
.
Time
.
Before
(
b
.
CreationTimestamp
.
Time
)
case
n
ame
:
case
N
ame
:
fallthrough
default
:
return
strings
.
Compare
(
a
.
Name
,
b
.
Name
)
<=
0
...
...
pkg/models/resources/services.go
浏览文件 @
8e862caf
...
...
@@ -18,8 +18,10 @@
package
resources
import
(
"kubesphere.io/kubesphere/pkg/constants"
"kubesphere.io/kubesphere/pkg/informers"
"kubesphere.io/kubesphere/pkg/params"
"kubesphere.io/kubesphere/pkg/utils/sliceutil"
"sort"
"strings"
...
...
@@ -38,11 +40,12 @@ func (*serviceSearcher) get(namespace, name string) (interface{}, error) {
func
(
*
serviceSearcher
)
match
(
match
map
[
string
]
string
,
item
*
v1
.
Service
)
bool
{
for
k
,
v
:=
range
match
{
switch
k
{
case
name
:
if
item
.
Name
!=
v
&&
item
.
Labels
[
displayName
]
!=
v
{
case
Name
:
names
:=
strings
.
Split
(
v
,
"|"
)
if
!
sliceutil
.
HasString
(
names
,
item
.
Name
)
{
return
false
}
case
k
eyword
:
case
K
eyword
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
searchFuzzy
(
item
.
Labels
,
""
,
v
)
&&
!
searchFuzzy
(
item
.
Annotations
,
""
,
v
)
{
return
false
}
...
...
@@ -59,8 +62,8 @@ func (*serviceSearcher) match(match map[string]string, item *v1.Service) bool {
func
(
*
serviceSearcher
)
fuzzy
(
fuzzy
map
[
string
]
string
,
item
*
v1
.
Service
)
bool
{
for
k
,
v
:=
range
fuzzy
{
switch
k
{
case
n
ame
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
strings
.
Contains
(
item
.
Labels
[
displayName
],
v
)
{
case
N
ame
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
strings
.
Contains
(
item
.
Annotations
[
constants
.
DisplayNameAnnotationKey
],
v
)
{
return
false
}
case
label
:
...
...
@@ -89,7 +92,7 @@ func (*serviceSearcher) compare(a, b *v1.Service, orderBy string) bool {
switch
orderBy
{
case
CreateTime
:
return
a
.
CreationTimestamp
.
Time
.
Before
(
b
.
CreationTimestamp
.
Time
)
case
n
ame
:
case
N
ame
:
fallthrough
default
:
return
strings
.
Compare
(
a
.
Name
,
b
.
Name
)
<=
0
...
...
pkg/models/resources/statefulsets.go
浏览文件 @
8e862caf
...
...
@@ -18,8 +18,10 @@
package
resources
import
(
"kubesphere.io/kubesphere/pkg/constants"
"kubesphere.io/kubesphere/pkg/informers"
"kubesphere.io/kubesphere/pkg/params"
"kubesphere.io/kubesphere/pkg/utils/sliceutil"
"sort"
"strings"
...
...
@@ -51,6 +53,15 @@ func statefulSetStatus(item *v1.StatefulSet) string {
func
(
*
statefulSetSearcher
)
match
(
match
map
[
string
]
string
,
item
*
v1
.
StatefulSet
)
bool
{
for
k
,
v
:=
range
match
{
switch
k
{
case
Name
:
names
:=
strings
.
Split
(
v
,
"|"
)
if
!
sliceutil
.
HasString
(
names
,
item
.
Name
)
{
return
false
}
case
Keyword
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
searchFuzzy
(
item
.
Labels
,
""
,
v
)
&&
!
searchFuzzy
(
item
.
Annotations
,
""
,
v
)
{
return
false
}
case
status
:
if
statefulSetStatus
(
item
)
!=
v
{
return
false
...
...
@@ -68,8 +79,8 @@ func (*statefulSetSearcher) fuzzy(fuzzy map[string]string, item *v1.StatefulSet)
for
k
,
v
:=
range
fuzzy
{
switch
k
{
case
n
ame
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
strings
.
Contains
(
item
.
Labels
[
displayName
],
v
)
{
case
N
ame
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
strings
.
Contains
(
item
.
Annotations
[
constants
.
DisplayNameAnnotationKey
],
v
)
{
return
false
}
case
label
:
...
...
@@ -85,10 +96,6 @@ func (*statefulSetSearcher) fuzzy(fuzzy map[string]string, item *v1.StatefulSet)
if
!
strings
.
Contains
(
item
.
Labels
[
chart
],
v
)
&&
!
strings
.
Contains
(
item
.
Labels
[
release
],
v
)
{
return
false
}
case
keyword
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
searchFuzzy
(
item
.
Labels
,
""
,
v
)
&&
!
searchFuzzy
(
item
.
Annotations
,
""
,
v
)
{
return
false
}
default
:
if
!
searchFuzzy
(
item
.
Labels
,
k
,
v
)
&&
!
searchFuzzy
(
item
.
Annotations
,
k
,
v
)
{
return
false
...
...
@@ -103,7 +110,7 @@ func (*statefulSetSearcher) compare(a, b *v1.StatefulSet, orderBy string) bool {
switch
orderBy
{
case
CreateTime
:
return
a
.
CreationTimestamp
.
Time
.
Before
(
b
.
CreationTimestamp
.
Time
)
case
n
ame
:
case
N
ame
:
fallthrough
default
:
return
strings
.
Compare
(
a
.
Name
,
b
.
Name
)
<=
0
...
...
pkg/models/resources/storageclasses.go
浏览文件 @
8e862caf
...
...
@@ -18,8 +18,10 @@
package
resources
import
(
"kubesphere.io/kubesphere/pkg/constants"
"kubesphere.io/kubesphere/pkg/informers"
"kubesphere.io/kubesphere/pkg/params"
"kubesphere.io/kubesphere/pkg/utils/sliceutil"
"sort"
"strings"
...
...
@@ -38,11 +40,12 @@ func (*storageClassesSearcher) get(namespace, name string) (interface{}, error)
func
(
*
storageClassesSearcher
)
match
(
match
map
[
string
]
string
,
item
*
v1
.
StorageClass
)
bool
{
for
k
,
v
:=
range
match
{
switch
k
{
case
name
:
if
item
.
Name
!=
v
&&
item
.
Labels
[
displayName
]
!=
v
{
case
Name
:
names
:=
strings
.
Split
(
v
,
"|"
)
if
!
sliceutil
.
HasString
(
names
,
item
.
Name
)
{
return
false
}
case
k
eyword
:
case
K
eyword
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
searchFuzzy
(
item
.
Labels
,
""
,
v
)
&&
!
searchFuzzy
(
item
.
Annotations
,
""
,
v
)
{
return
false
}
...
...
@@ -59,8 +62,8 @@ func (*storageClassesSearcher) match(match map[string]string, item *v1.StorageCl
func
(
*
storageClassesSearcher
)
fuzzy
(
fuzzy
map
[
string
]
string
,
item
*
v1
.
StorageClass
)
bool
{
for
k
,
v
:=
range
fuzzy
{
switch
k
{
case
n
ame
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
strings
.
Contains
(
item
.
Labels
[
displayName
],
v
)
{
case
N
ame
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
strings
.
Contains
(
item
.
Annotations
[
constants
.
DisplayNameAnnotationKey
],
v
)
{
return
false
}
case
label
:
...
...
@@ -85,7 +88,7 @@ func (*storageClassesSearcher) compare(a, b *v1.StorageClass, orderBy string) bo
switch
orderBy
{
case
CreateTime
:
return
a
.
CreationTimestamp
.
Time
.
Before
(
b
.
CreationTimestamp
.
Time
)
case
n
ame
:
case
N
ame
:
fallthrough
default
:
return
strings
.
Compare
(
a
.
Name
,
b
.
Name
)
<=
0
...
...
pkg/models/resources/workspaces.go
浏览文件 @
8e862caf
...
...
@@ -19,8 +19,10 @@ package resources
import
(
tenantv1alpha1
"kubesphere.io/kubesphere/pkg/apis/tenant/v1alpha1"
"kubesphere.io/kubesphere/pkg/constants"
"kubesphere.io/kubesphere/pkg/informers"
"kubesphere.io/kubesphere/pkg/params"
"kubesphere.io/kubesphere/pkg/utils/sliceutil"
"sort"
"strings"
...
...
@@ -38,11 +40,12 @@ func (*workspaceSearcher) get(namespace, name string) (interface{}, error) {
func
(
*
workspaceSearcher
)
match
(
match
map
[
string
]
string
,
item
*
tenantv1alpha1
.
Workspace
)
bool
{
for
k
,
v
:=
range
match
{
switch
k
{
case
name
:
if
item
.
Name
!=
v
&&
item
.
Labels
[
displayName
]
!=
v
{
case
Name
:
names
:=
strings
.
Split
(
v
,
"|"
)
if
!
sliceutil
.
HasString
(
names
,
item
.
Name
)
{
return
false
}
case
k
eyword
:
case
K
eyword
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
searchFuzzy
(
item
.
Labels
,
""
,
v
)
&&
!
searchFuzzy
(
item
.
Annotations
,
""
,
v
)
{
return
false
}
...
...
@@ -59,8 +62,8 @@ func (*workspaceSearcher) match(match map[string]string, item *tenantv1alpha1.Wo
func
(
*
workspaceSearcher
)
fuzzy
(
fuzzy
map
[
string
]
string
,
item
*
tenantv1alpha1
.
Workspace
)
bool
{
for
k
,
v
:=
range
fuzzy
{
switch
k
{
case
n
ame
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
strings
.
Contains
(
item
.
Labels
[
displayName
],
v
)
{
case
N
ame
:
if
!
strings
.
Contains
(
item
.
Name
,
v
)
&&
!
strings
.
Contains
(
item
.
Annotations
[
constants
.
DisplayNameAnnotationKey
],
v
)
{
return
false
}
case
label
:
...
...
@@ -89,7 +92,7 @@ func (*workspaceSearcher) compare(a, b *tenantv1alpha1.Workspace, orderBy string
switch
orderBy
{
case
CreateTime
:
return
a
.
CreationTimestamp
.
Time
.
Before
(
b
.
CreationTimestamp
.
Time
)
case
n
ame
:
case
N
ame
:
fallthrough
default
:
return
strings
.
Compare
(
a
.
Name
,
b
.
Name
)
<=
0
...
...
pkg/models/tenant/namespaces.go
浏览文件 @
8e862caf
...
...
@@ -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 namespaceSearcher struct {
func
(
*
namespaceSearcher
)
match
(
match
map
[
string
]
string
,
item
*
v1
.
Namespace
)
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 (*namespaceSearcher) fuzzy(fuzzy map[string]string, item *v1.Namespace) boo
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
:
...
...
pkg/models/tenant/tenant.go
浏览文件 @
8e862caf
...
...
@@ -39,7 +39,7 @@ func CreateNamespace(workspaceName string, namespace *v1.Namespace, username str
namespace
.
Labels
=
make
(
map
[
string
]
string
,
0
)
}
if
username
!=
""
{
namespace
.
Labels
[
constants
.
CreatorLabel
Key
]
=
username
namespace
.
Annotations
[
constants
.
CreatorLabelAnnotation
Key
]
=
username
}
namespace
.
Labels
[
constants
.
WorkspaceLabelKey
]
=
workspaceName
...
...
pkg/models/tenant/workspaces.go
浏览文件 @
8e862caf
...
...
@@ -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
...
...
pkg/models/terminal/terminal.go
浏览文件 @
8e862caf
...
...
@@ -248,34 +248,33 @@ func isValidShell(validShells []string, shell string) bool {
// Waits for the SockJS connection to be opened by the client the session to be bound in handleTerminalSession
func
WaitingForConnection
(
shell
string
,
namespace
,
podName
,
containerName
string
,
sessionId
string
)
{
glog
.
Infof
(
"WaitingForConnection, ID:%s"
,
sessionId
)
session
:=
terminalSessions
[
sessionId
]
select
{
case
<-
session
.
bound
:
close
(
session
.
bound
)
case
<-
terminalSessions
[
sessionId
]
.
bound
:
close
(
terminalSessions
[
sessionId
]
.
bound
)
defer
delete
(
terminalSessions
,
sessionId
)
var
err
error
validShells
:=
[]
string
{
"sh"
,
"bash"
}
if
isValidShell
(
validShells
,
shell
)
{
cmd
:=
[]
string
{
shell
}
err
=
startProcess
(
namespace
,
podName
,
containerName
,
cmd
,
session
)
err
=
startProcess
(
namespace
,
podName
,
containerName
,
cmd
,
terminalSessions
[
sessionId
]
)
}
else
{
// No shell given or it was not valid: try some shells until one succeeds or all fail
// FIXME: if the first shell fails then the first keyboard event is lost
for
_
,
testShell
:=
range
validShells
{
cmd
:=
[]
string
{
testShell
}
if
err
=
startProcess
(
namespace
,
podName
,
containerName
,
cmd
,
session
);
err
==
nil
{
if
err
=
startProcess
(
namespace
,
podName
,
containerName
,
cmd
,
terminalSessions
[
sessionId
]
);
err
==
nil
{
break
}
}
}
if
err
!=
nil
{
session
.
Close
(
2
,
err
.
Error
())
terminalSessions
[
sessionId
]
.
Close
(
2
,
err
.
Error
())
return
}
session
.
Close
(
1
,
"Process exited"
)
terminalSessions
[
sessionId
]
.
Close
(
1
,
"Process exited"
)
}
}
...
...
pkg/models/workspaces/workspaces.go
浏览文件 @
8e862caf
...
...
@@ -109,7 +109,7 @@ func RemoveUser(workspaceName string, username string) error {
if
err
!=
nil
{
return
err
}
err
=
DeleteWorkspaceRoleBinding
(
workspaceName
,
username
,
workspaceRole
.
Labels
[
constants
.
DisplayNameLabel
Key
])
err
=
DeleteWorkspaceRoleBinding
(
workspaceName
,
username
,
workspaceRole
.
Annotations
[
constants
.
DisplayNameAnnotation
Key
])
if
err
!=
nil
{
return
err
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录