From 65eeccc2df2de29430472aad8187c38bf930fba7 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Fri, 20 Mar 2026 13:12:24 +0100 Subject: [PATCH] Creating new engine runtime now requires backend as argument --- agent/runner.go | 6 +++--- cli/exec/exec.go | 3 +-- cmd/agent/core/agent.go | 2 +- pipeline/runtime/option.go | 8 -------- pipeline/runtime/runtime.go | 3 ++- 5 files changed, 7 insertions(+), 15 deletions(-) diff --git a/agent/runner.go b/agent/runner.go index 900221588cf..aae17fc5891 100644 --- a/agent/runner.go +++ b/agent/runner.go @@ -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, @@ -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, diff --git a/cli/exec/exec.go b/cli/exec/exec.go index 58c2139f7cf..4160904cb22 100644 --- a/cli/exec/exec.go +++ b/cli/exec/exec.go @@ -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", }), diff --git a/cmd/agent/core/agent.go b/cmd/agent/core/agent.go index bf9adec7635..32b63aa1c48 100644 --- a/cmd/agent/core/agent.go +++ b/cmd/agent/core/agent.go @@ -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 { diff --git a/pipeline/runtime/option.go b/pipeline/runtime/option.go index 28cd3009ef9..853b255f09e 100644 --- a/pipeline/runtime/option.go +++ b/pipeline/runtime/option.go @@ -17,7 +17,6 @@ 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" ) @@ -25,13 +24,6 @@ import ( // 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) { diff --git a/pipeline/runtime/runtime.go b/pipeline/runtime/runtime.go index 7cf4cb4a830..042491124b2 100644 --- a/pipeline/runtime/runtime.go +++ b/pipeline/runtime/runtime.go @@ -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 {