feat(agent): job runner, compose override executor and swarm executor (#7)

This commit is contained in:
2026-10-12 18:45:44 +02:00
parent 32c30194c4
commit e313365686
18 changed files with 1617 additions and 165 deletions
+28
View File
@@ -0,0 +1,28 @@
package updater
import (
"context"
"fmt"
"io"
"github.com/shcizo/package-updater/internal/protocol"
)
type dispatch struct{ compose, swarm Executor }
// NewDispatch returns an Executor that picks compose or swarm by job.Kind.
// KindContainer and unknown kinds fail.
func NewDispatch(compose, swarm Executor) Executor {
return dispatch{compose: compose, swarm: swarm}
}
func (d dispatch) Execute(ctx context.Context, job protocol.JobStart, out io.Writer) (string, error) {
switch job.Kind {
case protocol.KindCompose:
return d.compose.Execute(ctx, job, out)
case protocol.KindSwarm:
return d.swarm.Execute(ctx, job, out)
default:
return "", fmt.Errorf("cannot update a service of kind %q", job.Kind)
}
}