@@ -136,6 +136,50 @@ func PipelineGet(c echo.Context) error {
136
136
return c .String (http .StatusNotFound , errPipelineNotFound .Error ())
137
137
}
138
138
139
+ // PipelineDelete accepts a pipeline id and deletes it from the
140
+ // store. It also removes the binary inside the pipeline folder.
141
+ func PipelineDelete (c echo.Context ) error {
142
+ pipelineIDStr := c .Param ("pipelineid" )
143
+
144
+ pipelineID , err := strconv .Atoi (pipelineIDStr )
145
+ if err != nil {
146
+ return c .String (http .StatusBadRequest , errInvalidPipelineID .Error ())
147
+ }
148
+
149
+ // Look up pipeline for the given id
150
+ var foundPipeline gaia.Pipeline
151
+ var index int
152
+ var deletedPipelineIndex int
153
+ for pipeline := range pipeline .GlobalActivePipelines .Iter () {
154
+ if pipeline .ID == pipelineID {
155
+ foundPipeline = pipeline
156
+ deletedPipelineIndex = index
157
+ }
158
+ index ++
159
+ }
160
+
161
+ if foundPipeline .Name == "" {
162
+ return c .String (http .StatusNotFound , err .Error ())
163
+ }
164
+
165
+ // Delete pipeline binary
166
+ err = pipeline .DeleteBinary (foundPipeline )
167
+ if err != nil {
168
+ return c .String (http .StatusInternalServerError , err .Error ())
169
+ }
170
+
171
+ // Delete pipeline from store
172
+ err = storeService .PipelineDelete (pipelineID )
173
+ if err != nil {
174
+ return c .String (http .StatusNotFound , err .Error ())
175
+ }
176
+
177
+ // Remove from active pipelines
178
+ pipeline .GlobalActivePipelines .Remove (deletedPipelineIndex )
179
+
180
+ return c .String (http .StatusOK , "Pipeline has been deleted" )
181
+ }
182
+
139
183
// PipelineStart starts a pipeline by the given id.
140
184
// Afterwards it returns the created/scheduled pipeline run.
141
185
func PipelineStart (c echo.Context ) error {
0 commit comments