Utilify runner tag printing function

This commit is contained in:
2023-03-07 23:09:49 -07:00
parent d9ba14550e
commit f190274bce
3 changed files with 25 additions and 20 deletions
+4 -10
View File
@@ -10,6 +10,7 @@ import (
apiv2 "git.ohea.xyz/cursorius/pipeline-api/go/api/v2"
"git.ohea.xyz/cursorius/pipeline-api/go/api/v2/apiv2connect"
"git.ohea.xyz/cursorius/server/runnermanager"
"git.ohea.xyz/cursorius/server/util"
"github.com/bufbuild/connect-go"
"github.com/google/uuid"
"github.com/op/go-logging"
@@ -61,22 +62,15 @@ func (s *ApiServer) GetRunner(
RespChan: respChan,
}
var runnerTagsStr strings.Builder
if len(req.Msg.Tags) > 0 {
fmt.Fprintf(&runnerTagsStr, "[%v", req.Msg.Tags[0])
for _, tag := range req.Msg.Tags[1:] {
fmt.Fprintf(&runnerTagsStr, ", %v", tag)
}
fmt.Fprintf(&runnerTagsStr, "]")
}
tagsStr := util.FormatTags(req.Msg.Tags)
response := <-respChan
if response.Err != nil {
log.Errorf("Could not get runner with tags \"%v\": %v", runnerTagsStr.String(), response.Err)
log.Errorf("Could not get runner with tags \"%v\": %v", tagsStr, response.Err)
return nil, connect.NewError(connect.CodeNotFound, fmt.Errorf("Could not get runner"))
}
log.Infof("Got runner with tags: %v", runnerTagsStr.String())
log.Infof("Got runner with tags: %v", tagsStr)
runnerUuid := uuid.New()