Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
水淹萌龙
kubesphere
提交
1f23f2ad
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看板
未验证
提交
1f23f2ad
编写于
6月 17, 2020
作者:
H
hongming
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: controller panic
Signed-off-by:
N
hongming
<
talonwan@yunify.com
>
上级
8aa934bf
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
0 addition
and
50 deletion
+0
-50
pkg/controller/workspace/workspace_controller.go
pkg/controller/workspace/workspace_controller.go
+0
-50
未找到文件。
pkg/controller/workspace/workspace_controller.go
浏览文件 @
1f23f2ad
...
...
@@ -17,19 +17,12 @@ limitations under the License.
package
workspace
import
(
"bytes"
"context"
"fmt"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/yaml"
"k8s.io/client-go/tools/record"
"k8s.io/klog"
iamv1alpha2
"kubesphere.io/kubesphere/pkg/apis/iam/v1alpha2"
tenantv1alpha1
"kubesphere.io/kubesphere/pkg/apis/tenant/v1alpha1"
"kubesphere.io/kubesphere/pkg/utils/sliceutil"
"reflect"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/handler"
...
...
@@ -124,48 +117,5 @@ func (r *ReconcileWorkspace) Reconcile(request reconcile.Request) (reconcile.Res
return
reconcile
.
Result
{},
nil
}
if
err
=
r
.
initRoles
(
instance
);
err
!=
nil
{
klog
.
Error
(
err
)
return
reconcile
.
Result
{},
err
}
return
reconcile
.
Result
{},
nil
}
func
(
r
*
ReconcileWorkspace
)
initRoles
(
workspace
*
tenantv1alpha1
.
Workspace
)
error
{
var
roleBases
iamv1alpha2
.
RoleBaseList
err
:=
r
.
List
(
context
.
Background
(),
&
roleBases
)
if
err
!=
nil
{
klog
.
Error
(
err
)
return
err
}
for
_
,
roleBase
:=
range
roleBases
.
Items
{
var
role
iamv1alpha2
.
WorkspaceRole
if
err
=
yaml
.
NewYAMLOrJSONDecoder
(
bytes
.
NewBuffer
(
roleBase
.
Role
.
Raw
),
1024
)
.
Decode
(
&
role
);
err
==
nil
{
var
old
iamv1alpha2
.
WorkspaceRole
err
:=
r
.
Client
.
Get
(
context
.
Background
(),
types
.
NamespacedName
{
Name
:
fmt
.
Sprintf
(
"%s-%s"
,
workspace
.
Name
,
role
.
Name
)},
&
old
)
if
err
!=
nil
{
if
errors
.
IsNotFound
(
err
)
{
role
.
Name
=
fmt
.
Sprintf
(
"%s-%s"
,
workspace
.
Name
,
role
.
Name
)
role
.
Labels
[
tenantv1alpha1
.
WorkspaceLabel
]
=
workspace
.
Name
return
r
.
Client
.
Create
(
context
.
Background
(),
&
role
)
}
}
if
!
reflect
.
DeepEqual
(
role
.
Labels
,
old
.
Labels
)
||
!
reflect
.
DeepEqual
(
role
.
Annotations
,
old
.
Annotations
)
||
!
reflect
.
DeepEqual
(
role
.
Rules
,
old
.
Rules
)
{
old
.
Labels
=
role
.
Labels
old
.
Annotations
=
role
.
Annotations
old
.
Rules
=
role
.
Rules
return
r
.
Update
(
context
.
Background
(),
&
old
)
}
}
}
return
nil
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录