Skip to content

Commit

Permalink
Fix Pipeline input failed in multi-branch mode
Browse files Browse the repository at this point in the history
Signed-off-by: rick <[email protected]>
  • Loading branch information
LinuxSuRen committed Mar 18, 2021
1 parent 3a79df0 commit bc0be03
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -765,4 +765,4 @@ replace (
sigs.k8s.io/yaml => sigs.k8s.io/yaml v1.2.0
sourcegraph.com/sourcegraph/appdash => sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0
vbom.ml/util => vbom.ml/util v0.0.0-20160121211510-db5cfe13f5cc
)
)
2 changes: 1 addition & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -865,4 +865,4 @@ sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q=
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU=
vbom.ml/util v0.0.0-20160121211510-db5cfe13f5cc h1:MksmcCZQWAQJCTA5T0jgI/0sJ51AVm4Z41MrmfczEoc=
vbom.ml/util v0.0.0-20160121211510-db5cfe13f5cc/go.mod h1:so/NYdZXCz+E3ZpW0uAoCj6uzU2+8OWDFv/HxUSs7kI=
vbom.ml/util v0.0.0-20160121211510-db5cfe13f5cc/go.mod h1:so/NYdZXCz+E3ZpW0uAoCj6uzU2+8OWDFv/HxUSs7kI=
6 changes: 3 additions & 3 deletions pkg/controller/pipeline/pipeline_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ func NewController(client clientset.Interface,
devopsInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
AddFunc: v.enqueuePipeline,
UpdateFunc: func(oldObj, newObj interface{}) {
old := oldObj.(*devopsv1alpha3.Pipeline)
new := newObj.(*devopsv1alpha3.Pipeline)
if old.ResourceVersion == new.ResourceVersion {
oldPipeline := oldObj.(*devopsv1alpha3.Pipeline)
newPipeline := newObj.(*devopsv1alpha3.Pipeline)
if oldPipeline.ResourceVersion == newPipeline.ResourceVersion {
return
}
v.enqueuePipeline(newObj)
Expand Down
10 changes: 9 additions & 1 deletion pkg/kapis/devops/v1alpha2/devops.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,10 +379,18 @@ func (h *ProjectPipelineHandler) hasSubmitPermission(req *restful.Request) (hasP
runId := req.PathParameter("run")
nodeId := req.PathParameter("node")
stepId := req.PathParameter("step")
branchName := req.PathParameter("branch")

// check if current user can approve this input
var res []clientDevOps.NodesDetail
if res, err = h.devopsOperator.GetNodesDetail(pipeParam.ProjectName, pipeParam.Name, runId, httpReq); err == nil {

if branchName == "" {
res, err = h.devopsOperator.GetNodesDetail(pipeParam.ProjectName, pipeParam.Name, runId, httpReq)
} else {
res, err = h.devopsOperator.GetBranchNodesDetail(pipeParam.ProjectName, pipeParam.Name, branchName, runId, httpReq)
}

if err == nil {
h.approvableCheck(res, parsePipelineParam(req))

for _, node := range res {
Expand Down
2 changes: 1 addition & 1 deletion pkg/simple/client/devops/jenkins/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func (p *Pipeline) ListPipelines() (*devops.PipelineList, error) {
}
klog.Errorf("API '%s' request response code is '%d'", p.Path, jErr.Code)
} else {
err = fmt.Errorf("unknow errors happend when coumunicate with Jenkins")
err = fmt.Errorf("unknow errors happend when communicate with Jenkins")
}
return nil, err
}
Expand Down

0 comments on commit bc0be03

Please sign in to comment.