diff --git a/agent/logger.go b/agent/logger.go index b51d352e60e..502d07ae14c 100644 --- a/agent/logger.go +++ b/agent/logger.go @@ -27,7 +27,7 @@ import ( "github.com/woodpecker-ci/woodpecker/pipeline/rpc" ) -func (r *Runner) createLogger(logger zerolog.Logger, uploads *sync.WaitGroup, work *rpc.Pipeline) pipeline.LogFunc { +func (r *Runner) createLogger(logger zerolog.Logger, uploads *sync.WaitGroup, workflow *rpc.Workflow) pipeline.LogFunc { return func(step *backend.Step, rc multipart.Reader) error { loglogger := logger.With(). Str("image", step.Image). @@ -41,7 +41,7 @@ func (r *Runner) createLogger(logger zerolog.Logger, uploads *sync.WaitGroup, wo uploads.Add(1) var secrets []string - for _, secret := range work.Config.Secrets { + for _, secret := range workflow.Config.Secrets { if secret.Mask { secrets = append(secrets, secret.Value) } diff --git a/agent/rpc/client_grpc.go b/agent/rpc/client_grpc.go index 4bc59431813..c17dfced234 100644 --- a/agent/rpc/client_grpc.go +++ b/agent/rpc/client_grpc.go @@ -70,8 +70,8 @@ func (c *client) Version(ctx context.Context) (*rpc.Version, error) { }, nil } -// Next returns the next pipeline in the queue. -func (c *client) Next(ctx context.Context, f rpc.Filter) (*rpc.Pipeline, error) { +// Next returns the next workflow in the queue. +func (c *client) Next(ctx context.Context, f rpc.Filter) (*rpc.Workflow, error) { var res *proto.NextResponse var err error retry := c.newBackOff() @@ -115,17 +115,17 @@ func (c *client) Next(ctx context.Context, f rpc.Filter) (*rpc.Pipeline, error) return nil, nil } - p := new(rpc.Pipeline) - p.ID = res.GetPipeline().GetId() - p.Timeout = res.GetPipeline().GetTimeout() - p.Config = new(backend.Config) - if err := json.Unmarshal(res.GetPipeline().GetPayload(), p.Config); err != nil { - log.Error().Err(err).Msgf("could not unmarshal pipeline config of '%s'", p.ID) + w := new(rpc.Workflow) + w.ID = res.GetPipeline().GetId() + w.Timeout = res.GetPipeline().GetTimeout() + w.Config = new(backend.Config) + if err := json.Unmarshal(res.GetPipeline().GetPayload(), w.Config); err != nil { + log.Error().Err(err).Msgf("could not unmarshal workflow config of '%s'", w.ID) } - return p, nil + return w, nil } -// Wait blocks until the pipeline is complete. +// Wait blocks until the workflow is complete. func (c *client) Wait(ctx context.Context, id string) (err error) { retry := c.newBackOff() req := new(proto.WaitRequest) @@ -159,7 +159,7 @@ func (c *client) Wait(ctx context.Context, id string) (err error) { return nil } -// Init signals the pipeline is initialized. +// Init signals the workflow is initialized. func (c *client) Init(ctx context.Context, id string, state rpc.State) (err error) { retry := c.newBackOff() req := new(proto.InitRequest) @@ -200,7 +200,7 @@ func (c *client) Init(ctx context.Context, id string, state rpc.State) (err erro return nil } -// Done signals the pipeline is complete. +// Done signals the work is complete. func (c *client) Done(ctx context.Context, id string, state rpc.State) (err error) { retry := c.newBackOff() req := new(proto.DoneRequest) @@ -241,7 +241,7 @@ func (c *client) Done(ctx context.Context, id string, state rpc.State) (err erro return nil } -// Extend extends the pipeline deadline +// Extend extends the workflow deadline func (c *client) Extend(ctx context.Context, id string) (err error) { retry := c.newBackOff() req := new(proto.ExtendRequest) @@ -275,7 +275,7 @@ func (c *client) Extend(ctx context.Context, id string) (err error) { return nil } -// Update updates the pipeline state. +// Update updates the workflow state. func (c *client) Update(ctx context.Context, id string, state rpc.State) (err error) { retry := c.newBackOff() req := new(proto.UpdateRequest) @@ -316,7 +316,7 @@ func (c *client) Update(ctx context.Context, id string, state rpc.State) (err er return nil } -// Log writes the pipeline log entry. +// Log writes the workflow log entry. func (c *client) Log(ctx context.Context, logEntry *rpc.LogEntry) (err error) { retry := c.newBackOff() req := new(proto.LogRequest) diff --git a/agent/tracer.go b/agent/tracer.go index 64633210f43..09d93912770 100644 --- a/agent/tracer.go +++ b/agent/tracer.go @@ -26,7 +26,7 @@ import ( "github.com/woodpecker-ci/woodpecker/pipeline/rpc" ) -func (r *Runner) createTracer(ctxmeta context.Context, logger zerolog.Logger, work *rpc.Pipeline) pipeline.TraceFunc { +func (r *Runner) createTracer(ctxmeta context.Context, logger zerolog.Logger, workflow *rpc.Workflow) pipeline.TraceFunc { return func(state *pipeline.State) error { steplogger := logger.With(). Str("image", state.Pipeline.Step.Image). @@ -50,7 +50,7 @@ func (r *Runner) createTracer(ctxmeta context.Context, logger zerolog.Logger, wo defer func() { steplogger.Debug().Msg("update step status") - if uerr := r.client.Update(ctxmeta, work.ID, stepState); uerr != nil { + if uerr := r.client.Update(ctxmeta, workflow.ID, stepState); uerr != nil { steplogger.Debug(). Err(uerr). Msg("update step status error") diff --git a/pipeline/rpc/peer.go b/pipeline/rpc/peer.go index 69fea8d67d2..c13a557d6fd 100644 --- a/pipeline/rpc/peer.go +++ b/pipeline/rpc/peer.go @@ -27,7 +27,7 @@ type ( Labels map[string]string `json:"labels"` } - // State defines the pipeline state. + // State defines the workflow state. State struct { Step string `json:"step"` Exited bool `json:"exited"` @@ -37,8 +37,8 @@ type ( Error string `json:"error"` } - // Pipeline defines the pipeline execution details. - Pipeline struct { + // Workflow defines the workflow execution details. + Workflow struct { ID string `json:"id"` Config *backend.Config `json:"config"` Timeout int64 `json:"timeout"` @@ -55,25 +55,25 @@ type Peer interface { // Version returns the server- & grpc-version Version(c context.Context) (*Version, error) - // Next returns the next pipeline in the queue. - Next(c context.Context, f Filter) (*Pipeline, error) + // Next returns the next workflow in the queue + Next(c context.Context, f Filter) (*Workflow, error) - // Wait blocks until the pipeline is complete. + // Wait blocks until the workflow is complete Wait(c context.Context, id string) error - // Init signals the pipeline is initialized. + // Init signals the workflow is initialized Init(c context.Context, id string, state State) error - // Done signals the pipeline is complete. + // Done signals the workflow is complete Done(c context.Context, id string, state State) error - // Extend extends the pipeline deadline + // Extend extends the workflow deadline Extend(c context.Context, id string) error - // Update updates the pipeline state. + // Update updates the workflow state Update(c context.Context, id string, state State) error - // Log writes the pipeline log entry. + // Log writes the workflow log entry Log(c context.Context, logEntry *LogEntry) error // RegisterAgent register our agent to the server diff --git a/pipeline/rpc/proto/woodpecker.proto b/pipeline/rpc/proto/woodpecker.proto index 5603826fbcd..d780f71d2b3 100644 --- a/pipeline/rpc/proto/woodpecker.proto +++ b/pipeline/rpc/proto/woodpecker.proto @@ -61,7 +61,7 @@ message Filter { map labels = 1; } -message Pipeline { +message Workflow { string id = 1; int64 timeout = 2; bytes payload = 3; @@ -126,7 +126,7 @@ message VersionResponse { } message NextResponse { - Pipeline pipeline = 1; + Workflow workflow = 1; } message RegisterAgentResponse { diff --git a/server/grpc/rpc.go b/server/grpc/rpc.go index 69bae9b47eb..de6c8352d40 100644 --- a/server/grpc/rpc.go +++ b/server/grpc/rpc.go @@ -53,7 +53,7 @@ type RPC struct { } // Next implements the rpc.Next function -func (s *RPC) Next(c context.Context, agentFilter rpc.Filter) (*rpc.Pipeline, error) { +func (s *RPC) Next(c context.Context, agentFilter rpc.Filter) (*rpc.Workflow, error) { metadata, ok := grpcMetadata.FromIncomingContext(c) if ok { hostname, ok := metadata["hostname"] @@ -82,9 +82,9 @@ func (s *RPC) Next(c context.Context, agentFilter rpc.Filter) (*rpc.Pipeline, er } if task.ShouldRun() { - pipeline := new(rpc.Pipeline) - err = json.Unmarshal(task.Data, pipeline) - return pipeline, err + workflow := new(rpc.Workflow) + err = json.Unmarshal(task.Data, workflow) + return workflow, err } if err := s.Done(c, task.ID, rpc.State{}); err != nil { diff --git a/server/pipeline/queue.go b/server/pipeline/queue.go index efce2f649e6..50ff9011f33 100644 --- a/server/pipeline/queue.go +++ b/server/pipeline/queue.go @@ -42,7 +42,7 @@ func queuePipeline(repo *model.Repo, pipelineItems []*pipeline.Item) error { task.RunOn = item.RunsOn task.DepStatus = make(map[string]model.StatusValue) - task.Data, _ = json.Marshal(rpc.Pipeline{ + task.Data, _ = json.Marshal(rpc.Workflow{ ID: fmt.Sprint(item.Workflow.ID), Config: item.Config, Timeout: repo.Timeout,