mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-10-22 13:08:18 +00:00
Merge pull request #2125 from bradrydzewski/master
Pass agent hostname to server and persist
This commit is contained in:
@@ -10,6 +10,8 @@ import (
|
||||
|
||||
oldcontext "golang.org/x/net/context"
|
||||
|
||||
"google.golang.org/grpc/metadata"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/cncd/logging"
|
||||
"github.com/cncd/pipeline/pipeline/rpc"
|
||||
@@ -207,6 +209,14 @@ func (s *RPC) Upload(c context.Context, id string, file *rpc.File) error {
|
||||
return err
|
||||
}
|
||||
|
||||
metadata, ok := metadata.FromContext(c)
|
||||
if ok {
|
||||
hostname, ok := metadata["hostname"]
|
||||
if ok && len(hostname) != 0 {
|
||||
proc.Machine = hostname[0]
|
||||
}
|
||||
}
|
||||
|
||||
if file.Mime == "application/json+logs" {
|
||||
return s.store.LogSave(
|
||||
proc,
|
||||
@@ -238,6 +248,13 @@ func (s *RPC) Init(c context.Context, id string, state rpc.State) error {
|
||||
log.Printf("error: cannot find proc with id %d: %s", procID, err)
|
||||
return err
|
||||
}
|
||||
metadata, ok := metadata.FromContext(c)
|
||||
if ok {
|
||||
hostname, ok := metadata["hostname"]
|
||||
if ok && len(hostname) != 0 {
|
||||
proc.Machine = hostname[0]
|
||||
}
|
||||
}
|
||||
|
||||
build, err := s.store.GetBuild(proc.BuildID)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user