Cleanup docker build output before saving (#23)
This commit is contained in:
@@ -4,7 +4,6 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -141,13 +140,7 @@ func ExecutePipeline(pe PipelineExecution, db database.Database, pipelineConf co
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
response, err := ioutil.ReadAll(buildResponse.Body)
|
err = db.UpdateRunBuildOutput(pe.Run.Id, cleanupBuildOutput(buildResponse.Body))
|
||||||
if err != nil {
|
|
||||||
log.Errorf("could no read build response: %w", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
err = db.UpdateRunBuildOutput(pe.Run.Id, string(response))
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("could not update build output for run: %w", err)
|
log.Errorf("could not update build output for run: %w", err)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package pipeline_executor
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bufio"
|
||||||
|
"encoding/json"
|
||||||
|
"io"
|
||||||
|
)
|
||||||
|
|
||||||
|
func cleanupBuildOutput(input io.ReadCloser) string {
|
||||||
|
output := ""
|
||||||
|
|
||||||
|
scanner := bufio.NewScanner(input)
|
||||||
|
for scanner.Scan() {
|
||||||
|
var log map[string]any
|
||||||
|
json.Unmarshal(scanner.Bytes(), &log)
|
||||||
|
|
||||||
|
if logVar, ok := log["stream"]; ok {
|
||||||
|
if log, ok := logVar.(string); ok {
|
||||||
|
output += log
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return output
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user