Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions agent/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ type Runner struct {
filter rpc.Filter
hostname string
counter *State
backend *backend.Backend
backend backend.Backend
}

func NewRunner(workEngine rpc.Peer, f rpc.Filter, h string, state *State, backend *backend.Backend) Runner {
func NewRunner(workEngine rpc.Peer, f rpc.Filter, h string, state *State, backend backend.Backend) Runner {
return Runner{
client: workEngine,
filter: f,
Expand Down Expand Up @@ -156,11 +156,11 @@ func (r *Runner) Run(runnerCtx, shutdownCtx context.Context) error {
// Run pipeline
err = pipeline_runtime.New(
workflow.Config,
r.backend,
pipeline_runtime.WithContext(workflowCtx),
pipeline_runtime.WithTaskUUID(fmt.Sprint(workflow.ID)),
pipeline_runtime.WithLogger(r.createLogger(logger, &uploads, workflow)),
pipeline_runtime.WithTracer(r.createTracer(ctxMeta, &uploads, logger, workflow)),
pipeline_runtime.WithBackend(*r.backend),
pipeline_runtime.WithDescription(map[string]string{
"workflow_id": workflow.ID,
"repo": repoName,
Expand Down
3 changes: 1 addition & 2 deletions cli/exec/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,11 +322,10 @@ func execWithAxis(ctx context.Context, c *cli.Command, file, repoPath string, ax
fmt.Printf("ctrl+c received, terminating current pipeline '%s'\n", confStr)
})

return pipeline_runtime.New(compiled,
return pipeline_runtime.New(compiled, backendEngine,
pipeline_runtime.WithContext(pipelineCtx), //nolint:contextcheck
pipeline_runtime.WithTracer(tracing.DefaultTracer),
pipeline_runtime.WithLogger(defaultLogger),
pipeline_runtime.WithBackend(backendEngine),
pipeline_runtime.WithDescription(map[string]string{
"CLI": "exec",
}),
Expand Down
2 changes: 1 addition & 1 deletion cmd/agent/core/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ func run(ctx context.Context, c *cli.Command, backends []types.Backend) error {
// https://go.dev/blog/go1.22 fixed scope for goroutines in loops
for i := range maxWorkflows {
serviceWaitingGroup.Go(func() error {
runner := agent.NewRunner(client, filter, hostname, counter, &backendEngine)
runner := agent.NewRunner(client, filter, hostname, counter, backendEngine)
log.Debug().Msgf("created new runner %d", i)

for {
Expand Down
8 changes: 0 additions & 8 deletions pipeline/runtime/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,13 @@ package runtime
import (
"context"

backend "go.woodpecker-ci.org/woodpecker/v3/pipeline/backend/types"
"go.woodpecker-ci.org/woodpecker/v3/pipeline/logging"
"go.woodpecker-ci.org/woodpecker/v3/pipeline/tracing"
)

// Option configures a Runtime.
type Option func(*Runtime)

// WithBackend sets the backend engine used to run steps.
func WithBackend(backend backend.Backend) Option {
return func(r *Runtime) {
r.engine = backend
}
}

// WithLogger sets the function used to stream step logs.
func WithLogger(logger logging.Logger) Option {
return func(r *Runtime) {
Expand Down
3 changes: 2 additions & 1 deletion pipeline/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,12 @@ type Runtime struct {
}

// New returns a new Runtime for the given workflow spec and options.
func New(spec *backend.Config, opts ...Option) *Runtime {
func New(spec *backend.Config, backend backend.Backend, opts ...Option) *Runtime {
r := new(Runtime)
r.err = utils.NewProtected[error](nil)
r.description = map[string]string{}
r.spec = spec
r.engine = backend
r.ctx = context.Background()
r.taskUUID = ulid.Make().String()
for _, opt := range opts {
Expand Down