提交 d42f886f 编写于 作者: R runzexia

update api docs & fmt code

上级 a266d0e9
......@@ -48,6 +48,7 @@ func addWebService(c *restful.Container) error {
Doc("get devops project").
Metadata(restfulspec.KeyOpenAPITags, tags).
Param(webservice.PathParameter("devops", "projectId")).
Returns(http.StatusOK, "success", &devops.DevOpsProject{}).
Writes(&devops.DevOpsProject{}))
webservice.Route(webservice.PATCH("/devops/{devops}").
......@@ -55,57 +56,80 @@ func addWebService(c *restful.Container) error {
Doc("get devops project").
Metadata(restfulspec.KeyOpenAPITags, tags).
Param(webservice.PathParameter("devops", "projectId")).
Returns(http.StatusOK, "success", &devops.DevOpsProject{}).
Writes(&devops.DevOpsProject{}))
webservice.Route(webservice.GET("/devops/{devops}/defaultroles").
To(devopsapi.GetDevOpsProjectDefaultRoles).
Doc("get devops project defaultroles").
Metadata(restfulspec.KeyOpenAPITags, tags).
Param(webservice.PathParameter("devops", "projectId")).
Returns(http.StatusOK, "success", &devops.DefaultRoles).
Writes(&devops.DefaultRoles))
webservice.Route(webservice.GET("/devops/{devops}/members").
To(devopsapi.GetDevOpsProjectMembersHandler).
Doc("get devops project members").
Metadata(restfulspec.KeyOpenAPITags, tags).
Writes(&[]*devops.DevOpsProjectMembership{}))
Param(webservice.PathParameter("devops", "projectId")).
Returns(http.StatusOK, "success", []*devops.DevOpsProjectMembership{}).
Writes([]*devops.DevOpsProjectMembership{}))
webservice.Route(webservice.GET("/devops/{devops}/members/{members}").
To(devopsapi.GetDevOpsProjectMemberHandler).
Doc("get devops project member").
Metadata(restfulspec.KeyOpenAPITags, tags).
Param(webservice.PathParameter("devops", "projectId")).
Param(webservice.PathParameter("members", "username")).
Returns(http.StatusOK, "success", []*devops.DevOpsProjectMembership{}).
Writes(&devops.DevOpsProjectMembership{}))
webservice.Route(webservice.POST("/devops/{devops}/members").
To(devopsapi.AddDevOpsProjectMemberHandler).
Doc("add devops project members").
Metadata(restfulspec.KeyOpenAPITags, tags).
Param(webservice.PathParameter("devops", "projectId")).
Returns(http.StatusOK, "success", &devops.DevOpsProjectMembership{}).
Writes(&devops.DevOpsProjectMembership{}))
webservice.Route(webservice.POST("/devops/{devops}/pipelines").
To(devopsapi.CreateDevOpsProjectPipelineHandler).
Doc("add devops project pipeline").
Metadata(restfulspec.KeyOpenAPITags, tags).
Reads(devops.ProjectPipeline{}))
Param(webservice.PathParameter("devops", "projectId")).
Returns(http.StatusOK, "success", &devops.ProjectPipeline{}).
Writes(&devops.ProjectPipeline{}).
Reads(&devops.ProjectPipeline{}))
webservice.Route(webservice.PUT("/devops/{devops}/pipelines/{pipelines}").
To(devopsapi.UpdateDevOpsProjectPipelineHandler).
Doc("add devops project pipeline").
Doc("update devops project pipeline").
Param(webservice.PathParameter("devops", "projectId")).
Param(webservice.PathParameter("pipelines", "pipelineId")).
Metadata(restfulspec.KeyOpenAPITags, tags).
Reads(devops.ProjectPipeline{}))
Returns(http.StatusOK, "success", &devops.ProjectPipeline{}).
Writes(&devops.ProjectPipeline{}).
Reads(&devops.ProjectPipeline{}))
webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipelines}/config").
To(devopsapi.GetDevOpsProjectPipelineHandler).
Doc("get devops project pipeline config").
Metadata(restfulspec.KeyOpenAPITags, tags).
Param(webservice.PathParameter("devops", "projectId")).
Param(webservice.PathParameter("pipelines", "pipelineId")).
Returns(http.StatusOK, "ok", devops.ProjectPipeline{}).
Writes(devops.ProjectPipeline{}))
webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipelines}/sonarStatus").
To(devopsapi.GetPipelineSonarStatusHandler).
Doc("get devops project pipeline sonarStatus").
Metadata(restfulspec.KeyOpenAPITags, tags).
Param(webservice.PathParameter("devops", "projectId")).
Param(webservice.PathParameter("pipelines", "pipelineId")).
Returns(http.StatusOK, "ok", []devops.SonarStatus{}).
Writes([]devops.SonarStatus{}))
webservice.Route(webservice.GET("/devops/{devops}/pipelines/{pipelines}/branches/{branches}/sonarStatus").
To(devopsapi.GetMultiBranchesPipelineSonarStatusHandler).
Doc("get devops project pipeline sonarStatus").
Metadata(restfulspec.KeyOpenAPITags, tags).
Param(webservice.PathParameter("devops", "projectId")).
Param(webservice.PathParameter("pipelines", "pipelineId")).
Param(webservice.PathParameter("branches", "branchName")).
Returns(http.StatusOK, "ok", []devops.SonarStatus{}).
Writes([]devops.SonarStatus{}))
webservice.Route(webservice.DELETE("/devops/{devops}/pipelines/{pipelines}").
......
......@@ -314,9 +314,9 @@ func CheckProjectUserInRole(username, projectId string, roles []string) error {
return nil
}
func GetProjectUserRole(username, projectId string) (string ,error) {
func GetProjectUserRole(username, projectId string) (string, error) {
if username == KS_ADMIN {
return ProjectOwner,nil
return ProjectOwner, nil
}
dbconn := devops_mysql.OpenDatabase()
membership := &DevOpsProjectMembership{}
......@@ -326,8 +326,8 @@ func GetProjectUserRole(username, projectId string) (string ,error) {
db.Eq(DevOpsProjectMembershipUsernameColumn, username),
db.Eq(DevOpsProjectMembershipProjectIdColumn, projectId))).LoadOne(membership)
if err != nil {
return "",err
return "", err
}
return membership.Role,nil
return membership.Role, nil
}
......@@ -254,7 +254,7 @@ func CreateDevopsProject(username string, workspace string, req *devops.DevOpsPr
}
func GetUserDevopsSimpleRules(username, projectId string) ([]models.SimpleRule, error) {
role,err := devops.GetProjectUserRole(username,projectId)
role, err := devops.GetProjectUserRole(username, projectId)
if err != nil {
glog.Errorf("%+v", err)
return nil, restful.NewError(http.StatusForbidden, err.Error())
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册