engine

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 23, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package engine connects push events to Docker Compose deployments. It routes events to project-host targets, transfers bundles over SSH, runs docker compose up, and reconciles config changes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildRepoFullNameIndex

func BuildRepoFullNameIndex(repos []config.RepoConfig) map[string]config.RepoConfig

Extracts the "owner/repo" full name from each repo's URL and maps it to the RepoConfig.

func ConciseSummary

func ConciseSummary(err error, host string) string

Returns a short status description for a deploy outcome.

func DeployTarget

func DeployTarget(
	ctx context.Context,
	env *bootstrap.Config,
	target planner.DeployTarget,
	event planner.RepoEvent,
	sshEnv []string,
	dialer ssh.Dialer,
	store *state.FileStore,
	deployReporter reporter.Reporter,
	logger *slog.Logger,
) error

Performs the full deploy for one project-host target.

func DrainResults

func DrainResults(results <-chan runner.Result)

Drains the runner's results channel so completed jobs do not block on send.

func FindAddedDeployTargets

func FindAddedDeployTargets(oldConfig, newConfig *config.Config) []planner.DeployTarget

Compares oldConfig to newConfig and returns the full DeployTarget objects for every new project-host pair.

func MakePushHandler

func MakePushHandler(
	getConfig func() *config.Config,
	env *bootstrap.Config,
	deployRunner *runner.Runner,
	dialer ssh.Dialer,
	store *state.FileStore,
	deployReporter reporter.Reporter,
	sshEnv []string,
	logger *slog.Logger,
) func(context.Context, planner.RepoEvent)

Returns the onDeploy callback shared by the webhook handler and the poller.

func MakeWebhookPushHandler

func MakeWebhookPushHandler(
	getConfig func() *config.Config,
	store *state.FileStore,
	onDeploy func(context.Context, planner.RepoEvent),
	logger *slog.Logger,
) func(context.Context, webhook.PushEvent)

Returns the callback passed to the webhook handler.

func ReconcileAdditions

func ReconcileAdditions(
	ctx context.Context,
	oldConfig, newConfig *config.Config,
	store *state.FileStore,
	getMirrorHead func(repoURL, branch string) (string, bool),
	onDeploy func(context.Context, planner.RepoEvent),
	logger *slog.Logger,
)

Dispatches a deploy event for every repo that gained new project-host pairs. Only the new targets are deployed, without redeploying existing targets.

func ReconcileProjectChanges

func ReconcileProjectChanges(
	ctx context.Context,
	oldConfig, newConfig *config.Config,
	store *state.FileStore,
	onDeploy func(context.Context, planner.RepoEvent),
	logger *slog.Logger,
)

Dispatches a redeploy for every existing project-host pair whose deploy configuration changed between oldConfig and newConfig.

func ReconcileRemovals

func ReconcileRemovals(
	ctx context.Context,
	oldConfig, newConfig *config.Config,
	env *bootstrap.Config,
	store *state.FileStore,
	dialer ssh.Dialer,
	jobRunner *runner.Runner,
	getConfig func() *config.Config,
	logger *slog.Logger,
)

Tears down every target returned by FindTeardownTargets that has a deployment record. Each teardown is level-triggered, if the target was re-added the teardown is skipped.

func RepoFullName

func RepoFullName(repoURL string) string

Extracts "owner/repo" from a git clone URL.

func ResumeIncompleteDeploys

func ResumeIncompleteDeploys(
	ctx context.Context,
	deployConfig *config.Config,
	store *state.FileStore,
	getMirrorHead func(repoURL, branch string) (string, bool),
	onDeploy func(context.Context, planner.RepoEvent),
	logger *slog.Logger,
)

Brings every configured target up to its repo's last-known commit when not already deployed there, recovering targets whose queued jobs were dropped when the daemon stopped after a push had deployed only some of its targets.

func ShouldSkipDeploy

func ShouldSkipDeploy(store *state.FileStore, project, host, sha string) bool

func TargetDesired

func TargetDesired(deployConfig *config.Config, project, host string) bool

Reports whether deployConfig still declares project as a deployment to host.

Types

type TeardownTarget

type TeardownTarget struct {
	ProjectName  string
	Host         config.Host
	RemoteDir    string
	ComposeFiles []string
	RemoveState  bool
}

func FindTeardownTargets

func FindTeardownTargets(oldConfig, newConfig *config.Config) []TeardownTarget

Compares oldConfig to newConfig and returns every project-host pair that needs to be torn down.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL