Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
水淹萌龙
kubesphere
提交
6d364740
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看板
未验证
提交
6d364740
编写于
5月 25, 2020
作者:
S
shaowenchen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix devops api for tenant
上级
bb94d6da
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
84 addition
and
102 deletion
+84
-102
pkg/kapis/devops/v1alpha3/handler.go
pkg/kapis/devops/v1alpha3/handler.go
+28
-38
pkg/kapis/devops/v1alpha3/register.go
pkg/kapis/devops/v1alpha3/register.go
+35
-43
pkg/models/devops/devops.go
pkg/models/devops/devops.go
+21
-21
未找到文件。
pkg/kapis/devops/v1alpha3/handler.go
浏览文件 @
6d364740
...
...
@@ -50,9 +50,9 @@ func newDevOpsHandler(devopsClient devopsClient.Interface, k8sclient kubernetes.
// devopsproject handler about get/list/post/put/delete
func
(
h
*
devopsHandler
)
GetDevOpsProject
(
request
*
restful
.
Request
,
response
*
restful
.
Response
)
{
workspace
:=
request
.
PathParameter
(
"workspace"
)
projectName
:=
request
.
PathParameter
(
"projectName
"
)
devops
:=
request
.
PathParameter
(
"devops
"
)
project
,
err
:=
h
.
devops
.
GetDevOpsProject
(
workspace
,
projectName
)
project
,
err
:=
h
.
devops
.
GetDevOpsProject
(
workspace
,
devops
)
if
err
!=
nil
{
klog
.
Error
(
err
)
...
...
@@ -139,9 +139,9 @@ func (h *devopsHandler) UpdateDevOpsProject(request *restful.Request, response *
func
(
h
*
devopsHandler
)
DeleteDevOpsProject
(
request
*
restful
.
Request
,
response
*
restful
.
Response
)
{
workspace
:=
request
.
PathParameter
(
"workspace"
)
projectName
:=
request
.
PathParameter
(
"projectName
"
)
devops
:=
request
.
PathParameter
(
"devops
"
)
err
:=
h
.
devops
.
DeleteDevOpsProject
(
workspace
,
projectName
)
err
:=
h
.
devops
.
DeleteDevOpsProject
(
workspace
,
devops
)
if
err
!=
nil
{
klog
.
Error
(
err
)
...
...
@@ -158,11 +158,10 @@ func (h *devopsHandler) DeleteDevOpsProject(request *restful.Request, response *
// pipeline handler about get/list/post/put/delete
func
(
h
*
devopsHandler
)
GetPipeline
(
request
*
restful
.
Request
,
response
*
restful
.
Response
)
{
workspace
:=
request
.
PathParameter
(
"workspace"
)
projectName
:=
request
.
PathParameter
(
"projectName"
)
pipelineName
:=
request
.
PathParameter
(
"pipelineName"
)
devops
:=
request
.
PathParameter
(
"devops"
)
pipeline
:=
request
.
PathParameter
(
"pipeline"
)
obj
,
err
:=
h
.
devops
.
GetPipelineObj
(
workspace
,
projectName
,
pipelineNam
e
)
obj
,
err
:=
h
.
devops
.
GetPipelineObj
(
devops
,
pipelin
e
)
if
err
!=
nil
{
klog
.
Error
(
err
)
...
...
@@ -178,9 +177,8 @@ func (h *devopsHandler) GetPipeline(request *restful.Request, response *restful.
}
func
(
h
*
devopsHandler
)
ListPipeline
(
request
*
restful
.
Request
,
response
*
restful
.
Response
)
{
workspace
:=
request
.
PathParameter
(
"workspace"
)
projectName
:=
request
.
PathParameter
(
"projectName"
)
objs
,
err
:=
h
.
devops
.
ListPipelineObj
(
workspace
,
projectName
)
devops
:=
request
.
PathParameter
(
"devops"
)
objs
,
err
:=
h
.
devops
.
ListPipelineObj
(
devops
)
if
err
!=
nil
{
klog
.
Error
(
err
)
...
...
@@ -196,8 +194,7 @@ func (h *devopsHandler) ListPipeline(request *restful.Request, response *restful
}
func
(
h
*
devopsHandler
)
CreatePipeline
(
request
*
restful
.
Request
,
response
*
restful
.
Response
)
{
workspace
:=
request
.
PathParameter
(
"workspace"
)
projectName
:=
request
.
PathParameter
(
"projectName"
)
devops
:=
request
.
PathParameter
(
"devops"
)
var
pipeline
v1alpha3
.
Pipeline
err
:=
request
.
ReadEntity
(
&
pipeline
)
...
...
@@ -207,7 +204,7 @@ func (h *devopsHandler) CreatePipeline(request *restful.Request, response *restf
return
}
created
,
err
:=
h
.
devops
.
CreatePipelineObj
(
workspace
,
projectName
,
&
pipeline
)
created
,
err
:=
h
.
devops
.
CreatePipelineObj
(
devops
,
&
pipeline
)
if
err
!=
nil
{
klog
.
Error
(
err
)
...
...
@@ -223,8 +220,7 @@ func (h *devopsHandler) CreatePipeline(request *restful.Request, response *restf
}
func
(
h
*
devopsHandler
)
UpdatePipeline
(
request
*
restful
.
Request
,
response
*
restful
.
Response
)
{
workspace
:=
request
.
PathParameter
(
"workspace"
)
projectName
:=
request
.
PathParameter
(
"projectName"
)
devops
:=
request
.
PathParameter
(
"devops"
)
var
pipeline
v1alpha3
.
Pipeline
err
:=
request
.
ReadEntity
(
&
pipeline
)
...
...
@@ -235,7 +231,7 @@ func (h *devopsHandler) UpdatePipeline(request *restful.Request, response *restf
return
}
obj
,
err
:=
h
.
devops
.
UpdatePipelineObj
(
workspace
,
projectName
,
&
pipeline
)
obj
,
err
:=
h
.
devops
.
UpdatePipelineObj
(
devops
,
&
pipeline
)
if
err
!=
nil
{
klog
.
Error
(
err
)
...
...
@@ -251,11 +247,10 @@ func (h *devopsHandler) UpdatePipeline(request *restful.Request, response *restf
}
func
(
h
*
devopsHandler
)
DeletePipeline
(
request
*
restful
.
Request
,
response
*
restful
.
Response
)
{
workspace
:=
request
.
PathParameter
(
"workspace"
)
projectName
:=
request
.
PathParameter
(
"projectName"
)
pipelineName
:=
request
.
PathParameter
(
"pipelineName"
)
devops
:=
request
.
PathParameter
(
"devops"
)
pipeline
:=
request
.
PathParameter
(
"pipeline"
)
err
:=
h
.
devops
.
DeletePipelineObj
(
workspace
,
projectName
,
pipelineNam
e
)
err
:=
h
.
devops
.
DeletePipelineObj
(
devops
,
pipelin
e
)
if
err
!=
nil
{
klog
.
Error
(
err
)
...
...
@@ -272,11 +267,10 @@ func (h *devopsHandler) DeletePipeline(request *restful.Request, response *restf
//credential handler about get/list/post/put/delete
func
(
h
*
devopsHandler
)
GetCredential
(
request
*
restful
.
Request
,
response
*
restful
.
Response
)
{
workspace
:=
request
.
PathParameter
(
"workspace"
)
projectName
:=
request
.
PathParameter
(
"projectName"
)
credentialName
:=
request
.
PathParameter
(
"credentialName"
)
devops
:=
request
.
PathParameter
(
"devops"
)
credential
:=
request
.
PathParameter
(
"credential"
)
obj
,
err
:=
h
.
devops
.
GetCredentialObj
(
workspace
,
projectName
,
credentialName
)
obj
,
err
:=
h
.
devops
.
GetCredentialObj
(
devops
,
credential
)
if
err
!=
nil
{
klog
.
Error
(
err
)
...
...
@@ -292,10 +286,9 @@ func (h *devopsHandler) GetCredential(request *restful.Request, response *restfu
}
func
(
h
*
devopsHandler
)
ListCredential
(
request
*
restful
.
Request
,
response
*
restful
.
Response
)
{
workspace
:=
request
.
PathParameter
(
"workspace"
)
projectName
:=
request
.
PathParameter
(
"projectName"
)
devops
:=
request
.
PathParameter
(
"devops"
)
objs
,
err
:=
h
.
devops
.
ListCredentialObj
(
workspace
,
projectName
)
objs
,
err
:=
h
.
devops
.
ListCredentialObj
(
devops
)
if
err
!=
nil
{
klog
.
Error
(
err
)
...
...
@@ -311,8 +304,7 @@ func (h *devopsHandler) ListCredential(request *restful.Request, response *restf
}
func
(
h
*
devopsHandler
)
CreateCredential
(
request
*
restful
.
Request
,
response
*
restful
.
Response
)
{
workspace
:=
request
.
PathParameter
(
"workspace"
)
projectName
:=
request
.
PathParameter
(
"projectName"
)
devops
:=
request
.
PathParameter
(
"devops"
)
var
obj
v1
.
Secret
err
:=
request
.
ReadEntity
(
&
obj
)
...
...
@@ -322,7 +314,7 @@ func (h *devopsHandler) CreateCredential(request *restful.Request, response *res
return
}
created
,
err
:=
h
.
devops
.
CreateCredentialObj
(
workspace
,
projectName
,
&
obj
)
created
,
err
:=
h
.
devops
.
CreateCredentialObj
(
devops
,
&
obj
)
if
err
!=
nil
{
klog
.
Error
(
err
)
...
...
@@ -338,8 +330,7 @@ func (h *devopsHandler) CreateCredential(request *restful.Request, response *res
}
func
(
h
*
devopsHandler
)
UpdateCredential
(
request
*
restful
.
Request
,
response
*
restful
.
Response
)
{
workspace
:=
request
.
PathParameter
(
"workspace"
)
projectName
:=
request
.
PathParameter
(
"projectName"
)
devops
:=
request
.
PathParameter
(
"devops"
)
var
obj
v1
.
Secret
err
:=
request
.
ReadEntity
(
&
obj
)
...
...
@@ -349,7 +340,7 @@ func (h *devopsHandler) UpdateCredential(request *restful.Request, response *res
return
}
updated
,
err
:=
h
.
devops
.
UpdateCredentialObj
(
workspace
,
projectName
,
&
obj
)
updated
,
err
:=
h
.
devops
.
UpdateCredentialObj
(
devops
,
&
obj
)
if
err
!=
nil
{
klog
.
Error
(
err
)
...
...
@@ -365,11 +356,10 @@ func (h *devopsHandler) UpdateCredential(request *restful.Request, response *res
}
func
(
h
*
devopsHandler
)
DeleteCredential
(
request
*
restful
.
Request
,
response
*
restful
.
Response
)
{
workspace
:=
request
.
PathParameter
(
"workspace"
)
projectName
:=
request
.
PathParameter
(
"projectName"
)
credentialName
:=
request
.
PathParameter
(
"credentialName"
)
devops
:=
request
.
PathParameter
(
"devops"
)
credential
:=
request
.
PathParameter
(
"credential"
)
err
:=
h
.
devops
.
DeleteCredentialObj
(
workspace
,
projectName
,
credentialName
)
err
:=
h
.
devops
.
DeleteCredentialObj
(
devops
,
credential
)
if
err
!=
nil
{
klog
.
Error
(
err
)
...
...
pkg/kapis/devops/v1alpha3/register.go
浏览文件 @
6d364740
...
...
@@ -51,128 +51,120 @@ func AddToContainer(container *restful.Container, devopsClient devopsClient.Inte
ws
:=
runtime
.
NewWebService
(
GroupVersion
)
handler
:=
newDevOpsHandler
(
devopsClient
,
k8sclient
,
ksclient
,
ksInformers
,
k8sInformers
)
// credential
ws
.
Route
(
ws
.
GET
(
"/
workspaces/{workspace}/devopsprojects/{projectName}/credential/
"
)
.
ws
.
Route
(
ws
.
GET
(
"/
devops/{devops}/credentials
"
)
.
To
(
handler
.
ListCredential
)
.
Param
(
ws
.
PathParameter
(
"workspace"
,
"workspace name"
))
.
Param
(
ws
.
PathParameter
(
"projectName"
,
"devops name"
))
.
Doc
(
"list the credential of the specified devops for the current user"
)
.
Param
(
ws
.
PathParameter
(
"devops"
,
"devops name"
))
.
Doc
(
"list the credentials of the specified devops for the current user"
)
.
Returns
(
http
.
StatusOK
,
api
.
StatusOK
,
[]
v1alpha3
.
PipelineList
{})
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
DevOpsProjectTag
}))
ws
.
Route
(
ws
.
POST
(
"/
workspaces/{workspace}/devopsprojects/{projectName}/credential/
"
)
.
ws
.
Route
(
ws
.
POST
(
"/
devops/{devops}/credentials
"
)
.
To
(
handler
.
CreateCredential
)
.
Param
(
ws
.
PathParameter
(
"workspace"
,
"workspace name"
))
.
Param
(
ws
.
PathParameter
(
"projectName"
,
"devops name"
))
.
Param
(
ws
.
PathParameter
(
"devops"
,
"devops name"
))
.
Doc
(
"create the credential of the specified devops for the current user"
)
.
Returns
(
http
.
StatusOK
,
api
.
StatusOK
,
[]
v1alpha3
.
Pipeline
{})
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
DevOpsProjectTag
}))
ws
.
Route
(
ws
.
GET
(
"/
workspaces/{workspace}/devopsprojects/{projectName}/credential/{credentialName}/
"
)
.
ws
.
Route
(
ws
.
GET
(
"/
devops/{devops}/credentials/{credential}
"
)
.
To
(
handler
.
GetCredential
)
.
Param
(
ws
.
PathParameter
(
"workspace"
,
"workspace name"
))
.
Param
(
ws
.
PathParameter
(
"
projectName
"
,
"project name"
))
.
Param
(
ws
.
PathParameter
(
"
devops
"
,
"project name"
))
.
Param
(
ws
.
PathParameter
(
"credential"
,
"pipeline name"
))
.
Doc
(
"get the credential of the specified devops for the current user"
)
.
Returns
(
http
.
StatusOK
,
api
.
StatusOK
,
[]
v1
.
Secret
{})
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
DevOpsProjectTag
}))
ws
.
Route
(
ws
.
PUT
(
"/
workspaces/{workspace}/devopsprojects/{projectName}/credential/{credentialName}/
"
)
.
ws
.
Route
(
ws
.
PUT
(
"/
devops/{devops}/credentials/{credential}
"
)
.
To
(
handler
.
UpdateCredential
)
.
Param
(
ws
.
PathParameter
(
"workspace"
,
"workspace name"
))
.
Param
(
ws
.
PathParameter
(
"
projectName
"
,
"project name"
))
.
Param
(
ws
.
PathParameter
(
"credential
Name
"
,
"credential name"
))
.
Param
(
ws
.
PathParameter
(
"
devops
"
,
"project name"
))
.
Param
(
ws
.
PathParameter
(
"credential"
,
"credential name"
))
.
Doc
(
"put the credential of the specified devops for the current user"
)
.
Returns
(
http
.
StatusOK
,
api
.
StatusOK
,
[]
v1
.
Secret
{})
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
DevOpsProjectTag
}))
ws
.
Route
(
ws
.
DELETE
(
"/
workspaces/{workspace}/devopsprojects/{projectName}/credential/{credentialName}/
"
)
.
ws
.
Route
(
ws
.
DELETE
(
"/
devops/{devops}/credentials/{credential}
"
)
.
To
(
handler
.
DeleteCredential
)
.
Param
(
ws
.
PathParameter
(
"workspace"
,
"workspace name"
))
.
Param
(
ws
.
PathParameter
(
"projectName"
,
"project name"
))
.
Param
(
ws
.
PathParameter
(
"credentialName"
,
"credential name"
))
.
Param
(
ws
.
PathParameter
(
"devops"
,
"project name"
))
.
Param
(
ws
.
PathParameter
(
"credential"
,
"credential name"
))
.
Doc
(
"delete the credential of the specified devops for the current user"
)
.
Returns
(
http
.
StatusOK
,
api
.
StatusOK
,
[]
v1
.
Secret
{})
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
DevOpsPipelineTag
}))
// pipeline
ws
.
Route
(
ws
.
GET
(
"/
workspaces/{workspace}/devopsprojects/{projectName}/pipelines/
"
)
.
ws
.
Route
(
ws
.
GET
(
"/
devops/{devops}/pipelines
"
)
.
To
(
handler
.
ListPipeline
)
.
Param
(
ws
.
PathParameter
(
"workspace"
,
"workspace name"
))
.
Param
(
ws
.
PathParameter
(
"projectName"
,
"devops name"
))
.
Doc
(
"list the pipeline of the specified devops for the current user"
)
.
Param
(
ws
.
PathParameter
(
"devops"
,
"devops name"
))
.
Doc
(
"list the pipelines of the specified devops for the current user"
)
.
Returns
(
http
.
StatusOK
,
api
.
StatusOK
,
[]
v1alpha3
.
PipelineList
{})
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
DevOpsProjectTag
}))
ws
.
Route
(
ws
.
POST
(
"/
workspaces/{workspace}/devopsprojects/{projectName}/pipelines/
"
)
.
ws
.
Route
(
ws
.
POST
(
"/
devops/{devops}/pipelines
"
)
.
To
(
handler
.
CreatePipeline
)
.
Param
(
ws
.
PathParameter
(
"workspace"
,
"workspace name"
))
.
Param
(
ws
.
PathParameter
(
"projectName"
,
"devops name"
))
.
Param
(
ws
.
PathParameter
(
"devops"
,
"devops name"
))
.
Doc
(
"create the pipeline of the specified devops for the current user"
)
.
Returns
(
http
.
StatusOK
,
api
.
StatusOK
,
[]
v1alpha3
.
Pipeline
{})
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
DevOpsProjectTag
}))
ws
.
Route
(
ws
.
GET
(
"/
workspaces/{workspace}/devopsprojects/{projectName}/pipelines/{pipelineName}/
"
)
.
ws
.
Route
(
ws
.
GET
(
"/
devops/{devops}/pipelines/{pipeline}
"
)
.
To
(
handler
.
GetPipeline
)
.
Param
(
ws
.
PathParameter
(
"workspace"
,
"workspace name"
))
.
Param
(
ws
.
PathParameter
(
"projectName"
,
"project name"
))
.
Param
(
ws
.
PathParameter
(
"pipelineName"
,
"pipeline name"
))
.
Param
(
ws
.
PathParameter
(
"devops"
,
"project name"
))
.
Param
(
ws
.
PathParameter
(
"pipeline"
,
"pipeline name"
))
.
Doc
(
"get the pipeline of the specified devops for the current user"
)
.
Returns
(
http
.
StatusOK
,
api
.
StatusOK
,
[]
v1alpha3
.
Pipeline
{})
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
DevOpsProjectTag
}))
ws
.
Route
(
ws
.
PUT
(
"/
workspaces/{workspace}/devopsprojects/{projectName}/pipelines/{pipelineName}/
"
)
.
ws
.
Route
(
ws
.
PUT
(
"/
devops/{devops}/pipelines/{pipeline}
"
)
.
To
(
handler
.
UpdatePipeline
)
.
Param
(
ws
.
PathParameter
(
"workspace"
,
"workspace name"
))
.
Param
(
ws
.
PathParameter
(
"projectName"
,
"project name"
))
.
Param
(
ws
.
PathParameter
(
"pipelineName"
,
"pipeline name"
))
.
Param
(
ws
.
PathParameter
(
"devops"
,
"project name"
))
.
Param
(
ws
.
PathParameter
(
"pipeline"
,
"pipeline name"
))
.
Doc
(
"put the pipeline of the specified devops for the current user"
)
.
Returns
(
http
.
StatusOK
,
api
.
StatusOK
,
[]
v1alpha3
.
Pipeline
{})
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
DevOpsProjectTag
}))
ws
.
Route
(
ws
.
DELETE
(
"/
workspaces/{workspace}/devopsprojects/{projectName}/pipelines/{pipelineName}/
"
)
.
ws
.
Route
(
ws
.
DELETE
(
"/
devops/{devops}/pipelines/{pipeline}
"
)
.
To
(
handler
.
DeletePipeline
)
.
Param
(
ws
.
PathParameter
(
"workspace"
,
"workspace name"
))
.
Param
(
ws
.
PathParameter
(
"projectName"
,
"project name"
))
.
Param
(
ws
.
PathParameter
(
"pipelineName"
,
"pipeline name"
))
.
Param
(
ws
.
PathParameter
(
"devops"
,
"project name"
))
.
Param
(
ws
.
PathParameter
(
"pipeline"
,
"pipeline name"
))
.
Doc
(
"delete the pipeline of the specified devops for the current user"
)
.
Returns
(
http
.
StatusOK
,
api
.
StatusOK
,
[]
v1alpha3
.
Pipeline
{})
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
DevOpsPipelineTag
}))
// devops
ws
.
Route
(
ws
.
GET
(
"/workspaces/{workspace}/devops
projects/
"
)
.
ws
.
Route
(
ws
.
GET
(
"/workspaces/{workspace}/devops"
)
.
To
(
handler
.
ListDevOpsProject
)
.
Param
(
ws
.
PathParameter
(
"workspace"
,
"workspace name"
))
.
Doc
(
"List the devopsproject of the specified workspace for the current user"
)
.
Returns
(
http
.
StatusOK
,
api
.
StatusOK
,
[]
v1alpha3
.
DevOpsProjectList
{})
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
DevOpsProjectTag
}))
ws
.
Route
(
ws
.
POST
(
"/workspaces/{workspace}/devops
projects/
"
)
.
ws
.
Route
(
ws
.
POST
(
"/workspaces/{workspace}/devops"
)
.
To
(
handler
.
CreateDevOpsProject
)
.
Param
(
ws
.
PathParameter
(
"workspace"
,
"workspace name"
))
.
Doc
(
"Create the devopsproject of the specified workspace for the current user"
)
.
Returns
(
http
.
StatusOK
,
api
.
StatusOK
,
[]
v1alpha3
.
DevOpsProject
{})
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
DevOpsProjectTag
}))
ws
.
Route
(
ws
.
GET
(
"/workspaces/{workspace}/devops
projects/{projectName}/
"
)
.
ws
.
Route
(
ws
.
GET
(
"/workspaces/{workspace}/devops
/{devops}
"
)
.
To
(
handler
.
GetDevOpsProject
)
.
Param
(
ws
.
PathParameter
(
"workspace"
,
"workspace name"
))
.
Param
(
ws
.
PathParameter
(
"
projectName
"
,
"project name"
))
.
Param
(
ws
.
PathParameter
(
"
devops
"
,
"project name"
))
.
Doc
(
"Get the devopsproject of the specified workspace for the current user"
)
.
Returns
(
http
.
StatusOK
,
api
.
StatusOK
,
[]
v1alpha3
.
DevOpsProject
{})
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
DevOpsProjectTag
}))
ws
.
Route
(
ws
.
PUT
(
"/workspaces/{workspace}/devops
projects/{projectName}/
"
)
.
ws
.
Route
(
ws
.
PUT
(
"/workspaces/{workspace}/devops
/{devops}
"
)
.
To
(
handler
.
UpdateDevOpsProject
)
.
Param
(
ws
.
PathParameter
(
"workspace"
,
"workspace name"
))
.
Param
(
ws
.
PathParameter
(
"
projectName
"
,
"project name"
))
.
Param
(
ws
.
PathParameter
(
"
devops
"
,
"project name"
))
.
Doc
(
"Put the devopsproject of the specified workspace for the current user"
)
.
Returns
(
http
.
StatusOK
,
api
.
StatusOK
,
[]
v1alpha3
.
DevOpsProject
{})
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
DevOpsProjectTag
}))
ws
.
Route
(
ws
.
DELETE
(
"/workspaces/{workspace}/devops
projects/{projectName}/
"
)
.
ws
.
Route
(
ws
.
DELETE
(
"/workspaces/{workspace}/devops
/{devops}
"
)
.
To
(
handler
.
DeleteDevOpsProject
)
.
Param
(
ws
.
PathParameter
(
"workspace"
,
"workspace name"
))
.
Param
(
ws
.
PathParameter
(
"
projectName
"
,
"project name"
))
.
Param
(
ws
.
PathParameter
(
"
devops
"
,
"project name"
))
.
Doc
(
"Get the devopsproject of the specified workspace for the current user"
)
.
Returns
(
http
.
StatusOK
,
api
.
StatusOK
,
[]
v1alpha3
.
DevOpsProject
{})
.
Metadata
(
restfulspec
.
KeyOpenAPITags
,
[]
string
{
constants
.
DevOpsProjectTag
}))
...
...
pkg/models/devops/devops.go
浏览文件 @
6d364740
...
...
@@ -48,17 +48,17 @@ type DevopsOperator interface {
UpdateDevOpsProject
(
workspace
string
,
project
*
v1alpha3
.
DevOpsProject
)
(
*
v1alpha3
.
DevOpsProject
,
error
)
ListDevOpsProject
(
workspace
string
)
(
*
v1alpha3
.
DevOpsProjectList
,
error
)
CreatePipelineObj
(
workspace
string
,
projectName
string
,
pipeline
*
v1alpha3
.
Pipeline
)
(
*
v1alpha3
.
Pipeline
,
error
)
GetPipelineObj
(
workspace
string
,
projectName
string
,
pipelineName
string
)
(
*
v1alpha3
.
Pipeline
,
error
)
DeletePipelineObj
(
workspace
string
,
projectName
string
,
pipelineName
string
)
error
UpdatePipelineObj
(
workspace
string
,
projectName
string
,
pipeline
*
v1alpha3
.
Pipeline
)
(
*
v1alpha3
.
Pipeline
,
error
)
ListPipelineObj
(
workspace
string
,
projectName
string
)
(
*
v1alpha3
.
PipelineList
,
error
)
CreateCredentialObj
(
workspace
string
,
projectName
string
,
s
*
v1
.
Secret
)
(
*
v1
.
Secret
,
error
)
GetCredentialObj
(
workspace
string
,
projectName
string
,
secretName
string
)
(
*
v1
.
Secret
,
error
)
DeleteCredentialObj
(
workspace
string
,
projectName
string
,
secretName
string
)
error
UpdateCredentialObj
(
workspace
string
,
projectName
string
,
secret
*
v1
.
Secret
)
(
*
v1
.
Secret
,
error
)
ListCredentialObj
(
workspace
string
,
projectName
string
)
(
*
v1
.
SecretList
,
error
)
CreatePipelineObj
(
projectName
string
,
pipeline
*
v1alpha3
.
Pipeline
)
(
*
v1alpha3
.
Pipeline
,
error
)
GetPipelineObj
(
projectName
string
,
pipelineName
string
)
(
*
v1alpha3
.
Pipeline
,
error
)
DeletePipelineObj
(
projectName
string
,
pipelineName
string
)
error
UpdatePipelineObj
(
projectName
string
,
pipeline
*
v1alpha3
.
Pipeline
)
(
*
v1alpha3
.
Pipeline
,
error
)
ListPipelineObj
(
projectName
string
)
(
*
v1alpha3
.
PipelineList
,
error
)
CreateCredentialObj
(
projectName
string
,
s
*
v1
.
Secret
)
(
*
v1
.
Secret
,
error
)
GetCredentialObj
(
projectName
string
,
secretName
string
)
(
*
v1
.
Secret
,
error
)
DeleteCredentialObj
(
projectName
string
,
secretName
string
)
error
UpdateCredentialObj
(
projectName
string
,
secret
*
v1
.
Secret
)
(
*
v1
.
Secret
,
error
)
ListCredentialObj
(
projectName
string
)
(
*
v1
.
SecretList
,
error
)
GetPipeline
(
projectName
,
pipelineName
string
,
req
*
http
.
Request
)
(
*
devops
.
Pipeline
,
error
)
ListPipelines
(
req
*
http
.
Request
)
(
*
devops
.
PipelineList
,
error
)
...
...
@@ -164,7 +164,7 @@ func (d devopsOperator) ListDevOpsProject(workspace string) (*v1alpha3.DevOpsPro
}
// pipelineobj in crd
func
(
d
devopsOperator
)
CreatePipelineObj
(
workspace
string
,
projectName
string
,
pipeline
*
v1alpha3
.
Pipeline
)
(
*
v1alpha3
.
Pipeline
,
error
)
{
func
(
d
devopsOperator
)
CreatePipelineObj
(
projectName
string
,
pipeline
*
v1alpha3
.
Pipeline
)
(
*
v1alpha3
.
Pipeline
,
error
)
{
projectObj
,
err
:=
d
.
ksclient
.
DevopsV1alpha3
()
.
DevOpsProjects
()
.
Get
(
projectName
,
metav1
.
GetOptions
{})
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -172,7 +172,7 @@ func (d devopsOperator) CreatePipelineObj(workspace string, projectName string,
return
d
.
ksclient
.
DevopsV1alpha3
()
.
Pipelines
(
projectObj
.
Status
.
AdminNamespace
)
.
Create
(
pipeline
)
}
func
(
d
devopsOperator
)
GetPipelineObj
(
workspace
string
,
projectName
string
,
pipelineName
string
)
(
*
v1alpha3
.
Pipeline
,
error
)
{
func
(
d
devopsOperator
)
GetPipelineObj
(
projectName
string
,
pipelineName
string
)
(
*
v1alpha3
.
Pipeline
,
error
)
{
projectObj
,
err
:=
d
.
ksclient
.
DevopsV1alpha3
()
.
DevOpsProjects
()
.
Get
(
projectName
,
metav1
.
GetOptions
{})
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -180,7 +180,7 @@ func (d devopsOperator) GetPipelineObj(workspace string, projectName string, pip
return
d
.
ksclient
.
DevopsV1alpha3
()
.
Pipelines
(
projectObj
.
Status
.
AdminNamespace
)
.
Get
(
pipelineName
,
metav1
.
GetOptions
{})
}
func
(
d
devopsOperator
)
DeletePipelineObj
(
workspace
string
,
projectName
string
,
pipelineName
string
)
error
{
func
(
d
devopsOperator
)
DeletePipelineObj
(
projectName
string
,
pipelineName
string
)
error
{
projectObj
,
err
:=
d
.
ksclient
.
DevopsV1alpha3
()
.
DevOpsProjects
()
.
Get
(
projectName
,
metav1
.
GetOptions
{})
if
err
!=
nil
{
return
err
...
...
@@ -188,7 +188,7 @@ func (d devopsOperator) DeletePipelineObj(workspace string, projectName string,
return
d
.
ksclient
.
DevopsV1alpha3
()
.
Pipelines
(
projectObj
.
Status
.
AdminNamespace
)
.
Delete
(
pipelineName
,
metav1
.
NewDeleteOptions
(
0
))
}
func
(
d
devopsOperator
)
UpdatePipelineObj
(
workspace
string
,
projectName
string
,
pipeline
*
v1alpha3
.
Pipeline
)
(
*
v1alpha3
.
Pipeline
,
error
)
{
func
(
d
devopsOperator
)
UpdatePipelineObj
(
projectName
string
,
pipeline
*
v1alpha3
.
Pipeline
)
(
*
v1alpha3
.
Pipeline
,
error
)
{
projectObj
,
err
:=
d
.
ksclient
.
DevopsV1alpha3
()
.
DevOpsProjects
()
.
Get
(
projectName
,
metav1
.
GetOptions
{})
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -196,7 +196,7 @@ func (d devopsOperator) UpdatePipelineObj(workspace string, projectName string,
return
d
.
ksclient
.
DevopsV1alpha3
()
.
Pipelines
(
projectObj
.
Status
.
AdminNamespace
)
.
Update
(
pipeline
)
}
func
(
d
devopsOperator
)
ListPipelineObj
(
workspace
string
,
projectName
string
)
(
*
v1alpha3
.
PipelineList
,
error
)
{
func
(
d
devopsOperator
)
ListPipelineObj
(
projectName
string
)
(
*
v1alpha3
.
PipelineList
,
error
)
{
projectObj
,
err
:=
d
.
ksclient
.
DevopsV1alpha3
()
.
DevOpsProjects
()
.
Get
(
projectName
,
metav1
.
GetOptions
{})
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -205,7 +205,7 @@ func (d devopsOperator) ListPipelineObj(workspace string, projectName string) (*
}
//credentialobj in crd
func
(
d
devopsOperator
)
CreateCredentialObj
(
workspace
string
,
projectName
string
,
secret
*
v1
.
Secret
)
(
*
v1
.
Secret
,
error
)
{
func
(
d
devopsOperator
)
CreateCredentialObj
(
projectName
string
,
secret
*
v1
.
Secret
)
(
*
v1
.
Secret
,
error
)
{
projectObj
,
err
:=
d
.
ksclient
.
DevopsV1alpha3
()
.
DevOpsProjects
()
.
Get
(
projectName
,
metav1
.
GetOptions
{})
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -213,7 +213,7 @@ func (d devopsOperator) CreateCredentialObj(workspace string, projectName string
return
d
.
k8sclient
.
CoreV1
()
.
Secrets
(
projectObj
.
Status
.
AdminNamespace
)
.
Create
(
secret
)
}
func
(
d
devopsOperator
)
GetCredentialObj
(
workspace
string
,
projectName
string
,
secretName
string
)
(
*
v1
.
Secret
,
error
)
{
func
(
d
devopsOperator
)
GetCredentialObj
(
projectName
string
,
secretName
string
)
(
*
v1
.
Secret
,
error
)
{
projectObj
,
err
:=
d
.
ksclient
.
DevopsV1alpha3
()
.
DevOpsProjects
()
.
Get
(
projectName
,
metav1
.
GetOptions
{})
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -221,7 +221,7 @@ func (d devopsOperator) GetCredentialObj(workspace string, projectName string, s
return
d
.
k8sclient
.
CoreV1
()
.
Secrets
(
projectObj
.
Status
.
AdminNamespace
)
.
Get
(
secretName
,
metav1
.
GetOptions
{})
}
func
(
d
devopsOperator
)
DeleteCredentialObj
(
workspace
string
,
projectName
string
,
secret
string
)
error
{
func
(
d
devopsOperator
)
DeleteCredentialObj
(
projectName
string
,
secret
string
)
error
{
projectObj
,
err
:=
d
.
ksclient
.
DevopsV1alpha3
()
.
DevOpsProjects
()
.
Get
(
projectName
,
metav1
.
GetOptions
{})
if
err
!=
nil
{
return
err
...
...
@@ -229,7 +229,7 @@ func (d devopsOperator) DeleteCredentialObj(workspace string, projectName string
return
d
.
k8sclient
.
CoreV1
()
.
Secrets
(
projectObj
.
Status
.
AdminNamespace
)
.
Delete
(
secret
,
metav1
.
NewDeleteOptions
(
0
))
}
func
(
d
devopsOperator
)
UpdateCredentialObj
(
workspace
string
,
projectName
string
,
secret
*
v1
.
Secret
)
(
*
v1
.
Secret
,
error
)
{
func
(
d
devopsOperator
)
UpdateCredentialObj
(
projectName
string
,
secret
*
v1
.
Secret
)
(
*
v1
.
Secret
,
error
)
{
projectObj
,
err
:=
d
.
ksclient
.
DevopsV1alpha3
()
.
DevOpsProjects
()
.
Get
(
projectName
,
metav1
.
GetOptions
{})
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -237,7 +237,7 @@ func (d devopsOperator) UpdateCredentialObj(workspace string, projectName string
return
d
.
k8sclient
.
CoreV1
()
.
Secrets
(
projectObj
.
Status
.
AdminNamespace
)
.
Update
(
secret
)
}
func
(
d
devopsOperator
)
ListCredentialObj
(
workspace
string
,
projectName
string
)
(
*
v1
.
SecretList
,
error
)
{
func
(
d
devopsOperator
)
ListCredentialObj
(
projectName
string
)
(
*
v1
.
SecretList
,
error
)
{
projectObj
,
err
:=
d
.
ksclient
.
DevopsV1alpha3
()
.
DevOpsProjects
()
.
Get
(
projectName
,
metav1
.
GetOptions
{})
if
err
!=
nil
{
return
nil
,
err
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录