未验证 提交 96aee0e6 编写于 作者: R runzexia 提交者: GitHub

Devops refactor (#1894)

* add devops client interface
Signed-off-by: Nrunzexia <runzexia@yunify.com>

* direct return jenkins
Signed-off-by: Nrunzexia <runzexia@yunify.com>

* add some interface
Signed-off-by: Nrunzexia <runzexia@yunify.com>

* update
Signed-off-by: Nrunzexia <runzexia@yunify.com>

* update interface
Signed-off-by: Nrunzexia <runzexia@yunify.com>

* update
Signed-off-by: Nrunzexia <runzexia@yunify.com>

* credential op structs
Signed-off-by: Nrunzexia <runzexia@yunify.com>

* status
Signed-off-by: Nzhuxiaoyang <sunzhu@yunify.com>

* update interface
Signed-off-by: Nzhuxiaoyang <sunzhu@yunify.com>

* credential handler
Signed-off-by: Nrunzexia <runzexia@yunify.com>

* update devopsoperator func
Signed-off-by: Nzhuxiaoyang <sunzhu@yunify.com>

* get build sonar
Signed-off-by: Nrunzexia <runzexia@yunify.com>

* sonar handler

* mv code to cilent
Signed-off-by: Nrunzexia <runzexia@yunify.com>

* update
Signed-off-by: Nrunzexia <runzexia@yunify.com>

* project member handler
Signed-off-by: Nrunzexia <runzexia@yunify.com>

* update pipeline operator interface
Signed-off-by: Nzhuxiaoyang <sunzhu@yunify.com>

* add tenant devops handler
Signed-off-by: Nrunzexia <runzexia@yunify.com>

* update merge
Signed-off-by: Nrunzexia <runzexia@yunify.com>

* clean
Signed-off-by: Nrunzexia <runzexia@yunify.com>

* fmt
Signed-off-by: Nrunzexia <runzexia@yunify.com>

* update ListPipelineRuns
Signed-off-by: Nzhuxiaoyang <sunzhu@yunify.com>

* complate pipelineOperator interface
Signed-off-by: Nzhuxiaoyang <sunzhu@yunify.com>

* update HttpParameters
Signed-off-by: Nzhuxiaoyang <sunzhu@yunify.com>

* add pipeline steps interface
Signed-off-by: Nzhuxiaoyang <sunzhu@yunify.com>

* update pipeline GetNodesDetail
Signed-off-by: Nzhuxiaoyang <sunzhu@yunify.com>

* add s2i api
Signed-off-by: Nrunzexia <runzexia@yunify.com>

* add branch pipeline interface and update handler
Signed-off-by: Nzhuxiaoyang <sunzhu@yunify.com>

* add scan branch interface and update handler
Signed-off-by: Nzhuxiaoyang <sunzhu@yunify.com>

* add common interface and update handler
Signed-off-by: Nzhuxiaoyang <sunzhu@yunify.com>

* add SCM interface and update handler
Signed-off-by: Nzhuxiaoyang <sunzhu@yunify.com>

* add handler
Signed-off-by: Nrunzexia <runzexia@yunify.com>

* add fake s3
Signed-off-by: Nrunzexia <runzexia@yunify.com>

* add webhook&check interface and update handler
Signed-off-by: Nzhuxiaoyang <sunzhu@yunify.com>

* clean
Signed-off-by: Nzhuxiaoyang <sunzhu@yunify.com>

* clean
Signed-off-by: Nzhuxiaoyang <sunzhu@yunify.com>

* format
Signed-off-by: Nzhuxiaoyang <sunzhu@yunify.com>

* add some func
Signed-off-by: Nrunzexia <runzexia@yunify.com>

* clean code
Signed-off-by: Nrunzexia <runzexia@yunify.com>

* implement interface
Signed-off-by: Nzhuxiaoyang <sunzhu@yunify.com>

* fix interface GetBranchArtifacts
Signed-off-by: Nzhuxiaoyang <sunzhu@yunify.com>

* add s2ibinary upload test
Signed-off-by: Nrunzexia <runzexia@yunify.com>

* tenant devops
Signed-off-by: Nrunzexia <runzexia@yunify.com>

* update tenant
Signed-off-by: Nrunzexia <runzexia@yunify.com>

* fake
Signed-off-by: Nzhuxiaoyang <sunzhu@yunify.com>

* add some unit test
Signed-off-by: Nzhuxiaoyang <sunzhu@yunify.com>

* add devops tenant handler
Signed-off-by: Nrunzexia <runzexia@yunify.com>

* status
Signed-off-by: Nzhuxiaoyang <sunzhu@yunify.com>

* status
Signed-off-by: Nzhuxiaoyang <sunzhu@yunify.com>

* status
Signed-off-by: Nzhuxiaoyang <sunzhu@yunify.com>

* update fake test
Signed-off-by: Nzhuxiaoyang <sunzhu@yunify.com>

* update unit test and fake data
Signed-off-by: Nzhuxiaoyang <sunzhu@yunify.com>

* update

* enable devops client
Signed-off-by: Nrunzexia <runzexia@yunify.com>

* enable devops client
Signed-off-by: Nrunzexia <runzexia@yunify.com>
Co-authored-by: NXiaoyang Zhu <sunzhu@yunify.com>
上级 c5a340a2
......@@ -211,7 +211,6 @@ func checkResourceQuotas(wokrspace *v1alpha1.Workspace) error {
return nil
}
func ListNamespaceRules(req *restful.Request, resp *restful.Response) {
namespace := req.PathParameter("namespace")
username := req.HeaderParameter(constants.UserNameHeader)
......
......@@ -20,6 +20,7 @@ type ProjectPipelineHandler struct {
type PipelineSonarHandler struct {
pipelineSonarGetter devops.PipelineSonarGetter
projectOperator devops.ProjectOperator
}
func NewProjectPipelineHandler(devopsClient devopsClient.Interface, dbClient *mysql.Database) ProjectPipelineHandler {
......@@ -32,12 +33,14 @@ func NewProjectPipelineHandler(devopsClient devopsClient.Interface, dbClient *my
}
}
func NewPipelineSonarHandler(devopsClient devopsClient.Interface, sonarClient sonarqube.SonarInterface) PipelineSonarHandler {
func NewPipelineSonarHandler(devopsClient devopsClient.Interface, dbClient *mysql.Database, sonarClient sonarqube.SonarInterface) PipelineSonarHandler {
return PipelineSonarHandler{
pipelineSonarGetter: devops.NewPipelineSonarGetter(devopsClient, sonarClient),
projectOperator: devops.NewProjectOperator(dbClient),
}
}
func NewS2iBinaryHandler(client versioned.Interface, informers externalversions.SharedInformerFactory, s3Client s3.Interface) S2iBinaryHandler {
return S2iBinaryHandler{devops.NewS2iBinaryUploader(client, informers, s3Client)}
}
......@@ -38,9 +38,9 @@ func (h ProjectPipelineHandler) GetDevOpsProjectMembersHandler(request *restful.
return
}
orderBy := request.QueryParameter(params.OrderByParam)
reverse := params.ParseReverse(request)
limit, offset := params.ParsePaging(request.QueryParameter(params.PagingParam))
conditions, err := params.ParseConditions(request.QueryParameter(params.ConditionsParam))
reverse := params.GetBoolValueWithDefault(request, params.ReverseParam, false)
limit, offset := params.ParsePaging(request)
conditions, err := params.ParseConditions(request)
project, err := h.projectMemberOperator.GetProjectMembers(projectId, conditions, orderBy, reverse, limit, offset)
......
......@@ -4,8 +4,8 @@ import (
"github.com/emicklei/go-restful"
"k8s.io/klog"
"kubesphere.io/kubesphere/pkg/constants"
"kubesphere.io/kubesphere/pkg/models/devops"
"kubesphere.io/kubesphere/pkg/server/errors"
"kubesphere.io/kubesphere/pkg/simple/client/devops"
"net/http"
)
......@@ -13,7 +13,7 @@ func (h PipelineSonarHandler) GetPipelineSonarStatusHandler(request *restful.Req
projectId := request.PathParameter("devops")
username := request.HeaderParameter(constants.UserNameHeader)
pipelineId := request.PathParameter("pipeline")
err := devops.CheckProjectUserInRole(username, projectId, devops.AllRoleSlice)
err := h.projectOperator.CheckProjectUserInRole(username, projectId, devops.AllRoleSlice)
if err != nil {
klog.Errorf("%+v", err)
errors.ParseSvcErr(restful.NewError(http.StatusForbidden, err.Error()), resp)
......@@ -33,7 +33,7 @@ func (h PipelineSonarHandler) GetMultiBranchesPipelineSonarStatusHandler(request
username := request.HeaderParameter(constants.UserNameHeader)
pipelineId := request.PathParameter("pipeline")
branchId := request.PathParameter("branch")
err := devops.CheckProjectUserInRole(username, projectId, devops.AllRoleSlice)
err := h.projectOperator.CheckProjectUserInRole(username, projectId, devops.AllRoleSlice)
if err != nil {
klog.Errorf("%+v", err)
errors.ParseSvcErr(restful.NewError(http.StatusForbidden, err.Error()), resp)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册