Skip to content

Commit af4c8de

Browse files
committed
Fixed wrong pointer copy in backend.
1 parent 8efacb3 commit af4c8de

File tree

2 files changed

+29
-12
lines changed

2 files changed

+29
-12
lines changed

handlers/pipeline.go

+17-7
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,17 @@ func PipelineGet(c echo.Context) error {
121121
}
122122

123123
// Look up pipeline for the given id
124+
var foundPipeline gaia.Pipeline
124125
for pipeline := range pipeline.GlobalActivePipelines.Iter() {
125126
if pipeline.ID == pipelineID {
126-
return c.JSON(http.StatusOK, pipeline)
127+
foundPipeline = pipeline
127128
}
128129
}
129130

131+
if foundPipeline.Name != "" {
132+
return c.JSON(http.StatusOK, foundPipeline)
133+
}
134+
130135
// Pipeline not found
131136
return c.String(http.StatusNotFound, errPipelineNotFound.Error())
132137
}
@@ -143,14 +148,19 @@ func PipelineStart(c echo.Context) error {
143148
}
144149

145150
// Look up pipeline for the given id
151+
var foundPipeline gaia.Pipeline
146152
for pipeline := range pipeline.GlobalActivePipelines.Iter() {
147153
if pipeline.ID == pipelineID {
148-
pipelineRun, err := schedulerService.SchedulePipeline(&pipeline)
149-
if err != nil {
150-
return c.String(http.StatusBadRequest, err.Error())
151-
} else if pipelineRun != nil {
152-
return c.JSON(http.StatusCreated, pipelineRun)
153-
}
154+
foundPipeline = pipeline
155+
}
156+
}
157+
158+
if foundPipeline.Name != "" {
159+
pipelineRun, err := schedulerService.SchedulePipeline(&foundPipeline)
160+
if err != nil {
161+
return c.String(http.StatusBadRequest, err.Error())
162+
} else if pipelineRun != nil {
163+
return c.JSON(http.StatusCreated, pipelineRun)
154164
}
155165
}
156166

pipeline/pipeline.go

+12-5
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,18 @@ func (ap *ActivePipelines) Append(p gaia.Pipeline) {
8989

9090
// GetByName looks up the pipeline by the given name.
9191
func (ap *ActivePipelines) GetByName(n string) *gaia.Pipeline {
92+
var foundPipeline gaia.Pipeline
9293
for pipeline := range ap.Iter() {
9394
if pipeline.Name == n {
94-
return &pipeline
95+
foundPipeline = pipeline
9596
}
9697
}
97-
return nil
98+
99+
if foundPipeline.Name == "" {
100+
return nil
101+
}
102+
103+
return &foundPipeline
98104
}
99105

100106
// Replace takes the given pipeline and replaces it in the ActivePipelines
@@ -112,7 +118,7 @@ func (ap *ActivePipelines) Replace(p gaia.Pipeline) bool {
112118
}
113119

114120
// We got it?
115-
if i != -1 {
121+
if i == -1 {
116122
return false
117123
}
118124

@@ -140,13 +146,14 @@ func (ap *ActivePipelines) Iter() <-chan gaia.Pipeline {
140146
// Contains checks if the given pipeline name has been already appended
141147
// to the given ActivePipelines instance.
142148
func (ap *ActivePipelines) Contains(n string) bool {
149+
var foundPipeline bool
143150
for pipeline := range ap.Iter() {
144151
if pipeline.Name == n {
145-
return true
152+
foundPipeline = true
146153
}
147154
}
148155

149-
return false
156+
return foundPipeline
150157
}
151158

152159
// appendTypeToName appends the type to the output binary name.

0 commit comments

Comments
 (0)