Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
水淹萌龙
kubesphere
提交
d55fcdcf
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看板
未验证
提交
d55fcdcf
编写于
3月 30, 2020
作者:
R
runzexia
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove check role
Signed-off-by:
N
runzexia
<
runzexia@yunify.com
>
上级
8892c63a
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
2 addition
and
72 deletion
+2
-72
pkg/kapis/devops/v1alpha2/member.go
pkg/kapis/devops/v1alpha2/member.go
+1
-33
pkg/kapis/devops/v1alpha2/pipeline_sonar.go
pkg/kapis/devops/v1alpha2/pipeline_sonar.go
+0
-16
pkg/kapis/devops/v1alpha2/project.go
pkg/kapis/devops/v1alpha2/project.go
+0
-15
pkg/models/devops/project_handler.go
pkg/models/devops/project_handler.go
+0
-1
pkg/models/tenant/devops.go
pkg/models/tenant/devops.go
+1
-7
未找到文件。
pkg/kapis/devops/v1alpha2/member.go
浏览文件 @
d55fcdcf
...
...
@@ -28,14 +28,7 @@ import (
func
(
h
ProjectPipelineHandler
)
GetDevOpsProjectMembersHandler
(
request
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
projectId
:=
request
.
PathParameter
(
"devops"
)
username
:=
request
.
HeaderParameter
(
constants
.
UserNameHeader
)
err
:=
h
.
projectOperator
.
CheckProjectUserInRole
(
username
,
projectId
,
devops
.
AllRoleSlice
)
if
err
!=
nil
{
klog
.
Errorf
(
"%+v"
,
err
)
api
.
HandleForbidden
(
resp
,
nil
,
err
)
return
}
orderBy
:=
request
.
QueryParameter
(
params
.
OrderByParam
)
reverse
:=
params
.
GetBoolValueWithDefault
(
request
,
params
.
ReverseParam
,
false
)
limit
,
offset
:=
params
.
ParsePaging
(
request
)
...
...
@@ -56,15 +49,8 @@ func (h ProjectPipelineHandler) GetDevOpsProjectMembersHandler(request *restful.
func
(
h
ProjectPipelineHandler
)
GetDevOpsProjectMemberHandler
(
request
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
projectId
:=
request
.
PathParameter
(
"devops"
)
username
:=
request
.
HeaderParameter
(
constants
.
UserNameHeader
)
member
:=
request
.
PathParameter
(
"member"
)
err
:=
h
.
projectOperator
.
CheckProjectUserInRole
(
username
,
projectId
,
devops
.
AllRoleSlice
)
if
err
!=
nil
{
klog
.
Errorf
(
"%+v"
,
err
)
api
.
HandleForbidden
(
resp
,
nil
,
err
)
return
}
project
,
err
:=
h
.
projectMemberOperator
.
GetProjectMember
(
projectId
,
member
)
if
err
!=
nil
{
...
...
@@ -101,12 +87,6 @@ func (h ProjectPipelineHandler) AddDevOpsProjectMemberHandler(request *restful.R
api
.
HandleBadRequest
(
resp
,
request
,
err
)
return
}
err
=
h
.
projectOperator
.
CheckProjectUserInRole
(
username
,
projectId
,
[]
string
{
devops
.
ProjectOwner
})
if
err
!=
nil
{
klog
.
Errorf
(
"%+v"
,
err
)
api
.
HandleForbidden
(
resp
,
nil
,
err
)
return
}
member
.
GrantBy
=
username
project
,
err
:=
h
.
projectMemberOperator
.
AddProjectMember
(
projectId
,
member
)
...
...
@@ -153,12 +133,6 @@ func (h ProjectPipelineHandler) UpdateDevOpsProjectMemberHandler(request *restfu
return
}
err
=
h
.
projectOperator
.
CheckProjectUserInRole
(
username
,
projectId
,
[]
string
{
devops
.
ProjectOwner
})
if
err
!=
nil
{
klog
.
Errorf
(
"%+v"
,
err
)
api
.
HandleForbidden
(
resp
,
nil
,
err
)
return
}
project
,
err
:=
h
.
projectMemberOperator
.
UpdateProjectMember
(
projectId
,
member
)
if
err
!=
nil
{
...
...
@@ -177,13 +151,7 @@ func (h ProjectPipelineHandler) DeleteDevOpsProjectMemberHandler(request *restfu
username
:=
request
.
HeaderParameter
(
constants
.
UserNameHeader
)
member
:=
request
.
PathParameter
(
"member"
)
err
:=
h
.
projectOperator
.
CheckProjectUserInRole
(
username
,
projectId
,
[]
string
{
devops
.
ProjectOwner
})
if
err
!=
nil
{
klog
.
Errorf
(
"%+v"
,
err
)
api
.
HandleForbidden
(
resp
,
nil
,
err
)
return
}
username
,
err
=
h
.
projectMemberOperator
.
DeleteProjectMember
(
projectId
,
member
)
username
,
err
:=
h
.
projectMemberOperator
.
DeleteProjectMember
(
projectId
,
member
)
if
err
!=
nil
{
klog
.
Errorf
(
"%+v"
,
err
)
api
.
HandleInternalError
(
resp
,
nil
,
err
)
...
...
pkg/kapis/devops/v1alpha2/pipeline_sonar.go
浏览文件 @
d55fcdcf
...
...
@@ -4,20 +4,11 @@ import (
"github.com/emicklei/go-restful"
"k8s.io/klog"
"kubesphere.io/kubesphere/pkg/api"
"kubesphere.io/kubesphere/pkg/constants"
"kubesphere.io/kubesphere/pkg/simple/client/devops"
)
func
(
h
PipelineSonarHandler
)
GetPipelineSonarStatusHandler
(
request
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
projectId
:=
request
.
PathParameter
(
"devops"
)
username
:=
request
.
HeaderParameter
(
constants
.
UserNameHeader
)
pipelineId
:=
request
.
PathParameter
(
"pipeline"
)
err
:=
h
.
projectOperator
.
CheckProjectUserInRole
(
username
,
projectId
,
devops
.
AllRoleSlice
)
if
err
!=
nil
{
klog
.
Errorf
(
"%+v"
,
err
)
api
.
HandleForbidden
(
resp
,
nil
,
err
)
return
}
sonarStatus
,
err
:=
h
.
pipelineSonarGetter
.
GetPipelineSonar
(
projectId
,
pipelineId
)
if
err
!=
nil
{
klog
.
Errorf
(
"%+v"
,
err
)
...
...
@@ -29,15 +20,8 @@ func (h PipelineSonarHandler) GetPipelineSonarStatusHandler(request *restful.Req
func
(
h
PipelineSonarHandler
)
GetMultiBranchesPipelineSonarStatusHandler
(
request
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
projectId
:=
request
.
PathParameter
(
"devops"
)
username
:=
request
.
HeaderParameter
(
constants
.
UserNameHeader
)
pipelineId
:=
request
.
PathParameter
(
"pipeline"
)
branchId
:=
request
.
PathParameter
(
"branch"
)
err
:=
h
.
projectOperator
.
CheckProjectUserInRole
(
username
,
projectId
,
devops
.
AllRoleSlice
)
if
err
!=
nil
{
klog
.
Errorf
(
"%+v"
,
err
)
api
.
HandleForbidden
(
resp
,
nil
,
err
)
return
}
sonarStatus
,
err
:=
h
.
pipelineSonarGetter
.
GetMultiBranchPipelineSonar
(
projectId
,
pipelineId
,
branchId
)
if
err
!=
nil
{
klog
.
Errorf
(
"%+v"
,
err
)
...
...
pkg/kapis/devops/v1alpha2/project.go
浏览文件 @
d55fcdcf
...
...
@@ -18,21 +18,13 @@ import (
"k8s.io/klog"
"kubesphere.io/kubesphere/pkg/api"
"kubesphere.io/kubesphere/pkg/api/devops/v1alpha2"
"kubesphere.io/kubesphere/pkg/constants"
"kubesphere.io/kubesphere/pkg/simple/client/devops"
)
func
(
h
ProjectPipelineHandler
)
GetDevOpsProjectHandler
(
request
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
projectId
:=
request
.
PathParameter
(
"devops"
)
username
:=
request
.
HeaderParameter
(
constants
.
UserNameHeader
)
err
:=
h
.
projectOperator
.
CheckProjectUserInRole
(
username
,
projectId
,
devops
.
AllRoleSlice
)
if
err
!=
nil
{
klog
.
Errorf
(
"%+v"
,
err
)
api
.
HandleForbidden
(
resp
,
nil
,
err
)
return
}
project
,
err
:=
h
.
projectOperator
.
GetProject
(
projectId
)
if
err
!=
nil
{
...
...
@@ -48,7 +40,6 @@ func (h ProjectPipelineHandler) GetDevOpsProjectHandler(request *restful.Request
func
(
h
ProjectPipelineHandler
)
UpdateProjectHandler
(
request
*
restful
.
Request
,
resp
*
restful
.
Response
)
{
projectId
:=
request
.
PathParameter
(
"devops"
)
username
:=
request
.
HeaderParameter
(
constants
.
UserNameHeader
)
var
project
*
v1alpha2
.
DevOpsProject
err
:=
request
.
ReadEntity
(
&
project
)
if
err
!=
nil
{
...
...
@@ -57,12 +48,6 @@ func (h ProjectPipelineHandler) UpdateProjectHandler(request *restful.Request, r
return
}
project
.
ProjectId
=
projectId
err
=
h
.
projectOperator
.
CheckProjectUserInRole
(
username
,
projectId
,
[]
string
{
devops
.
ProjectOwner
})
if
err
!=
nil
{
klog
.
Errorf
(
"%+v"
,
err
)
api
.
HandleForbidden
(
resp
,
nil
,
err
)
return
}
project
,
err
=
h
.
projectOperator
.
UpdateProject
(
project
)
if
err
!=
nil
{
...
...
pkg/models/devops/project_handler.go
浏览文件 @
d55fcdcf
...
...
@@ -30,7 +30,6 @@ import (
type
ProjectOperator
interface
{
GetProject
(
projectId
string
)
(
*
v1alpha2
.
DevOpsProject
,
error
)
UpdateProject
(
project
*
v1alpha2
.
DevOpsProject
)
(
*
v1alpha2
.
DevOpsProject
,
error
)
CheckProjectUserInRole
(
username
,
projectId
string
,
roles
[]
string
)
error
}
type
projectOperator
struct
{
...
...
pkg/models/tenant/devops.go
浏览文件 @
d55fcdcf
...
...
@@ -145,13 +145,7 @@ func (o *devopsProjectOperator) GetDevOpsProjectsCount(username string) (uint32,
}
func
(
o
*
devopsProjectOperator
)
DeleteDevOpsProject
(
projectId
,
username
string
)
error
{
err
:=
o
.
ksProjectOperator
.
CheckProjectUserInRole
(
username
,
projectId
,
[]
string
{
dsClient
.
ProjectOwner
})
if
err
!=
nil
{
klog
.
Errorf
(
"%+v"
,
err
)
return
restful
.
NewError
(
http
.
StatusForbidden
,
err
.
Error
())
}
err
=
o
.
dsProject
.
DeleteDevOpsProject
(
projectId
)
err
:=
o
.
dsProject
.
DeleteDevOpsProject
(
projectId
)
if
err
!=
nil
{
klog
.
Errorf
(
"%+v"
,
err
)
return
err
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录