Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
水淹萌龙
kubesphere
提交
c7a9f103
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看板
未验证
提交
c7a9f103
编写于
6月 16, 2020
作者:
H
hongming
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: label filter
Signed-off-by:
N
hongming
<
talonwan@yunify.com
>
上级
4fcaa78b
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
9 addition
and
11 deletion
+9
-11
pkg/controller/namespace/namespace_controller.go
pkg/controller/namespace/namespace_controller.go
+1
-1
pkg/controller/workspacetemplate/workspacetemplate_controller.go
...troller/workspacetemplate/workspacetemplate_controller.go
+1
-1
pkg/models/iam/am/am.go
pkg/models/iam/am/am.go
+4
-4
pkg/models/resources/v1alpha3/interface.go
pkg/models/resources/v1alpha3/interface.go
+3
-5
未找到文件。
pkg/controller/namespace/namespace_controller.go
浏览文件 @
c7a9f103
...
...
@@ -265,7 +265,7 @@ func (r *ReconcileNamespace) initRoles(namespace *corev1.Namespace) error {
for
_
,
roleBase
:=
range
roleBases
.
Items
{
var
role
rbacv1
.
Role
if
err
=
yaml
.
NewYAMLOrJSONDecoder
(
bytes
.
NewBuffer
(
roleBase
.
Role
.
Raw
),
1024
)
.
Decode
(
&
role
);
err
==
nil
{
if
err
=
yaml
.
NewYAMLOrJSONDecoder
(
bytes
.
NewBuffer
(
roleBase
.
Role
.
Raw
),
1024
)
.
Decode
(
&
role
);
err
==
nil
&&
role
.
Kind
==
iamv1alpha2
.
ResourceKindRole
{
var
old
rbacv1
.
Role
err
:=
r
.
Client
.
Get
(
context
.
Background
(),
types
.
NamespacedName
{
Namespace
:
namespace
.
Name
,
Name
:
role
.
Name
},
&
old
)
if
err
!=
nil
{
...
...
pkg/controller/workspacetemplate/workspacetemplate_controller.go
浏览文件 @
c7a9f103
...
...
@@ -458,7 +458,7 @@ func (r *Controller) initRoles(workspace *tenantv1alpha2.WorkspaceTemplate) erro
for
_
,
roleBase
:=
range
roleBases
{
var
role
iamv1alpha2
.
WorkspaceRole
if
err
=
yaml
.
NewYAMLOrJSONDecoder
(
bytes
.
NewBuffer
(
roleBase
.
Role
.
Raw
),
1024
)
.
Decode
(
&
role
);
err
==
nil
{
if
err
=
yaml
.
NewYAMLOrJSONDecoder
(
bytes
.
NewBuffer
(
roleBase
.
Role
.
Raw
),
1024
)
.
Decode
(
&
role
);
err
==
nil
&&
role
.
Kind
==
iamv1alpha2
.
ResourceKindWorkspaceRole
{
old
,
err
:=
r
.
workspaceRoleLister
.
Get
(
fmt
.
Sprintf
(
"%s-%s"
,
workspace
.
Name
,
role
.
Name
))
if
err
!=
nil
{
if
errors
.
IsNotFound
(
err
)
{
...
...
pkg/models/iam/am/am.go
浏览文件 @
c7a9f103
...
...
@@ -114,7 +114,7 @@ func (am *amOperator) GetGlobalRoleOfUser(username string) (*iamv1alpha2.GlobalR
}
err
=
errors
.
NewNotFound
(
iamv1alpha2
.
Resource
(
iamv1alpha2
.
ResourcesSingularGlobalRoleBinding
),
username
)
klog
.
Error
(
err
)
klog
.
V
(
4
)
.
Info
(
err
)
return
nil
,
err
}
...
...
@@ -148,7 +148,7 @@ func (am *amOperator) GetWorkspaceRoleOfUser(username, workspace string) (*iamv1
}
err
=
errors
.
NewNotFound
(
iamv1alpha2
.
Resource
(
iamv1alpha2
.
ResourcesSingularWorkspaceRoleBinding
),
username
)
klog
.
Error
(
err
)
klog
.
V
(
4
)
.
Info
(
err
)
return
nil
,
err
}
...
...
@@ -179,7 +179,7 @@ func (am *amOperator) GetNamespaceRoleOfUser(username, namespace string) (*rbacv
}
err
=
errors
.
NewNotFound
(
iamv1alpha2
.
Resource
(
iamv1alpha2
.
ResourcesSingularRoleBinding
),
username
)
klog
.
Error
(
err
)
klog
.
V
(
4
)
.
Info
(
err
)
return
nil
,
err
}
...
...
@@ -211,7 +211,7 @@ func (am *amOperator) GetClusterRoleOfUser(username string) (*rbacv1.ClusterRole
}
err
=
errors
.
NewNotFound
(
iamv1alpha2
.
Resource
(
iamv1alpha2
.
ResourcesSingularClusterRoleBinding
),
username
)
klog
.
Error
(
err
)
klog
.
V
(
4
)
.
Info
(
err
)
return
nil
,
err
}
...
...
pkg/models/resources/v1alpha3/interface.go
浏览文件 @
c7a9f103
...
...
@@ -5,7 +5,6 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"kubesphere.io/kubesphere/pkg/api"
"kubesphere.io/kubesphere/pkg/apiserver/query"
"kubesphere.io/kubesphere/pkg/constants"
"sort"
"strings"
)
...
...
@@ -92,7 +91,7 @@ func DefaultObjectMetaFilter(item metav1.ObjectMeta, filter query.Filter) bool {
switch
filter
.
Field
{
case
query
.
FieldNames
:
for
_
,
name
:=
range
strings
.
Split
(
string
(
filter
.
Value
),
","
)
{
if
item
.
Name
==
name
||
item
.
Annotations
[
constants
.
DisplayNameAnnotationKey
]
==
name
{
if
item
.
Name
==
name
{
return
true
}
}
...
...
@@ -133,7 +132,6 @@ func DefaultObjectMetaFilter(item metav1.ObjectMeta, filter query.Filter) bool {
}
}
// Filter format (key!?=)?value,if the key is defined, the key must match exactly, value match according to strings.Contains.
func
labelMatch
(
labels
map
[
string
]
string
,
filter
string
)
bool
{
fields
:=
strings
.
SplitN
(
filter
,
"="
,
2
)
var
key
,
value
string
...
...
@@ -150,11 +148,11 @@ func labelMatch(labels map[string]string, filter string) bool {
}
for
k
,
v
:=
range
labels
{
if
opposite
{
if
(
key
==
""
||
k
==
key
)
&&
!
strings
.
Contains
(
v
,
value
)
{
if
(
key
==
""
||
k
==
key
)
&&
v
!=
value
{
return
true
}
}
else
{
if
(
key
==
""
||
k
==
key
)
&&
strings
.
Contains
(
v
,
value
)
{
if
(
key
==
""
||
k
==
key
)
&&
v
==
value
{
return
true
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录