Compare commits
3 Commits
bbf96498aa
..
v0.2.0
| Author | SHA1 | Date | |
|---|---|---|---|
| e1382e50ea | |||
| 7f44e5ed41 | |||
| bcc53dfbe0 |
@@ -56,6 +56,12 @@ func (s *ApiServer) GetRunnerFromMap(u uuid.UUID) (*RunnerWrapper, bool) {
|
||||
return runner, ok
|
||||
}
|
||||
|
||||
func (s *ApiServer) AddRunnerToMap(u uuid.UUID, runner *runnermanager.Runner) {
|
||||
s.allocatedRunnersMutex.Lock()
|
||||
defer s.allocatedRunnersMutex.Unlock()
|
||||
s.allocatedRunners[u] = &RunnerWrapper{runner: runner}
|
||||
}
|
||||
|
||||
func (s *ApiServer) GetRunner(
|
||||
ctx context.Context,
|
||||
req *connect.Request[apiv2.GetRunnerRequest],
|
||||
@@ -114,9 +120,7 @@ func (s *ApiServer) GetRunner(
|
||||
|
||||
runnerUuid := uuid.New()
|
||||
|
||||
s.allocatedRunnersMutex.Lock()
|
||||
s.allocatedRunners[runnerUuid] = &RunnerWrapper{runner: response.Runner}
|
||||
s.allocatedRunnersMutex.Unlock()
|
||||
s.AddRunnerToMap(runnerUuid, response.Runner)
|
||||
|
||||
res := connect.NewResponse(&apiv2.GetRunnerResponse{
|
||||
Id: runnerUuid.String(),
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -45,6 +45,10 @@ func (r *Runner) Id() uuid.UUID {
|
||||
|
||||
func (r *Runner) RunCommand(cmd string, args []string) (returnCode int64, stdout string, stderr string, err error) {
|
||||
|
||||
if r.conn == nil {
|
||||
return 0, "", "", fmt.Errorf("runner with id %v has nil conn, THIS IS A BUG", r.id)
|
||||
}
|
||||
|
||||
// Write RunCommand message to client
|
||||
serverToRunnerMsg := &runner_api.ServerToRunnerMsg{
|
||||
Msg: &runner_api.ServerToRunnerMsg_RunCommandMsg{
|
||||
|
||||
Reference in New Issue
Block a user