Cleanup docker build output before saving (#23)
This commit is contained in:
@@ -4,7 +4,6 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@@ -141,13 +140,7 @@ func ExecutePipeline(pe PipelineExecution, db database.Database, pipelineConf co
|
||||
return
|
||||
}
|
||||
|
||||
response, err := ioutil.ReadAll(buildResponse.Body)
|
||||
if err != nil {
|
||||
log.Errorf("could no read build response: %w", err)
|
||||
return
|
||||
}
|
||||
|
||||
err = db.UpdateRunBuildOutput(pe.Run.Id, string(response))
|
||||
err = db.UpdateRunBuildOutput(pe.Run.Id, cleanupBuildOutput(buildResponse.Body))
|
||||
if err != nil {
|
||||
log.Errorf("could not update build output for run: %w", err)
|
||||
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