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 ¶
- func BuildRepoFullNameIndex(repos []config.RepoConfig) map[string]config.RepoConfig
- func ConciseSummary(err error, host string) string
- func DeployTarget(ctx context.Context, env *bootstrap.Config, target planner.DeployTarget, ...) error
- func DrainResults(results <-chan runner.Result)
- func FindAddedDeployTargets(oldConfig, newConfig *config.Config) []planner.DeployTarget
- func MakePushHandler(getConfig func() *config.Config, env *bootstrap.Config, ...) func(context.Context, planner.RepoEvent)
- func MakeWebhookPushHandler(getConfig func() *config.Config, store *state.FileStore, ...) func(context.Context, webhook.PushEvent)
- func ReconcileAdditions(ctx context.Context, oldConfig, newConfig *config.Config, ...)
- func ReconcileProjectChanges(ctx context.Context, oldConfig, newConfig *config.Config, ...)
- func ReconcileRemovals(ctx context.Context, oldConfig, newConfig *config.Config, ...)
- func RepoFullName(repoURL string) string
- func ResumeIncompleteDeploys(ctx context.Context, deployConfig *config.Config, store *state.FileStore, ...)
- func ShouldSkipDeploy(store *state.FileStore, project, host, sha string) bool
- func TargetDesired(deployConfig *config.Config, project, host string) bool
- type TeardownTarget
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 ¶
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 ¶
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 ¶
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 ¶
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.