Merge pull request #3279 from LinuxSuRen/fix-pipe-list
Fix the pipeline list with incorrect paging calculating
This commit is contained in:
@@ -94,31 +94,33 @@ func (h *ProjectPipelineHandler) ListPipelines(req *restful.Request, resp *restf
|
|||||||
// get all pipelines which come from ks
|
// get all pipelines which come from ks
|
||||||
pipelineList := &clientDevOps.PipelineList{
|
pipelineList := &clientDevOps.PipelineList{
|
||||||
Total: objs.TotalItems,
|
Total: objs.TotalItems,
|
||||||
Items: make([]clientDevOps.Pipeline, objs.TotalItems),
|
Items: make([]clientDevOps.Pipeline, len(objs.Items)),
|
||||||
}
|
}
|
||||||
pipelineMap := make(map[string]int, objs.TotalItems)
|
if pipelineList.Total > 0 && len(objs.Items) > 0 {
|
||||||
for i, item := range objs.Items {
|
pipelineMap := make(map[string]int, pipelineList.Total)
|
||||||
if pipeline, ok := item.(v1alpha3.Pipeline); !ok {
|
for i, item := range objs.Items {
|
||||||
continue
|
if pipeline, ok := item.(v1alpha3.Pipeline); !ok {
|
||||||
} else {
|
continue
|
||||||
pip := clientDevOps.Pipeline{
|
} else {
|
||||||
Name: pipeline.Name,
|
pip := clientDevOps.Pipeline{
|
||||||
|
Name: pipeline.Name,
|
||||||
|
}
|
||||||
|
|
||||||
|
pipelineMap[pipeline.Name] = i
|
||||||
|
pipelineList.Items[i] = pip
|
||||||
}
|
}
|
||||||
|
|
||||||
pipelineMap[pipeline.Name] = i
|
|
||||||
pipelineList.Items[i] = pip
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// get all pipelines which come from Jenkins
|
// get all pipelines which come from Jenkins
|
||||||
// fill out the rest fields
|
// fill out the rest fields
|
||||||
res, err := h.devopsOperator.ListPipelines(req.Request)
|
res, err := h.devopsOperator.ListPipelines(req.Request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
} else {
|
} else {
|
||||||
for _, item := range res.Items {
|
for _, item := range res.Items {
|
||||||
if index, ok := pipelineMap[item.Name]; ok {
|
if index, ok := pipelineMap[item.Name]; ok {
|
||||||
pipelineList.Items[index] = item
|
pipelineList.Items[index] = item
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user