Help us shape the future of Go! Take the 2026 Go Developer Survey

setup

package
v0.43.4 Latest Latest
Warning

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

Go to latest
Published: May 22, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package setup provides worktree provisioning orchestration. It coordinates resource allocation, database cloning, environment file generation, setup command execution, and editor configuration.

Index

Constants

This section is empty.

Variables

View Source
var RegistryPath string

RegistryPath overrides the default registry location. Empty uses the standard path. Exposed so tests (and the MCP server) can inject a temporary registry without affecting global state at runtime.

Functions

func BuildEnvVars

func BuildEnvVars(pc *config.ProjectConfig, alloc interpolation.Allocation, redisURL string) map[string]string

BuildEnvVars resolves the env template from a project config against an allocation. Exported so gtl start can inject vars into the child process without going through a full Setup.

func BuildEnvVarsWithResolver

func BuildEnvVarsWithResolver(pc *config.ProjectConfig, alloc interpolation.Allocation, redisURL string, resolver interpolation.ResolveFunc) (map[string]string, error)

BuildEnvVarsWithResolver resolves env templates including {resolve:...} cross-worktree tokens. Returns an error if any resolve target is missing.

func InjectRouterTokens

func InjectRouterTokens(alloc interpolation.Allocation, project, branch, routerDomain, tunnelDomain string)

InjectRouterTokens adds router_url, router_host, tunnel_host, and tunnel_url to an allocation map so the corresponding env tokens can be resolved. router_* tokens are blank when the local router is disabled; tunnel_* tokens are blank when no tunnel domain is configured. router_domain is also populated as a backwards-compatible alias for router_host.

func RegenerateEnvFile

func RegenerateEnvFile(worktreePath string, uc *config.UserConfig) error

RegenerateEnvFile re-resolves env vars (including {resolve:...} tokens) and rewrites the env file for an existing allocation. Used by gtl link/unlink to immediately apply link changes without running full setup.

func RunHookCommands

func RunHookCommands(hookName string, cmds []string, dir string, log func(string, ...any)) error

RunHookCommands executes a list of hook commands in the given directory. The log function receives formatted status messages. Returns on first failure.

Types

type EditorResult

type EditorResult struct {
	Label string
	Path  string
	Err   error
}

EditorResult captures the outcome of writing to one editor target.

func ConfigureEditor

func ConfigureEditor(worktreePath string, pc *config.ProjectConfig, uc *config.UserConfig, port int, branch string) []EditorResult

ConfigureEditor resolves editor settings from project/user config and writes to all detected editor targets. Extracted so both gtl setup and gtl editor refresh can share the same logic.

type Options

type Options struct {
	DryRun      bool
	RefreshOnly bool
}

Options controls setup behavior. DryRun prints what would happen without making changes. RefreshOnly re-applies environment files without running setup commands or cloning databases.

type Setup

type Setup struct {
	WorktreePath  string
	MainRepo      string
	UserConfig    *config.UserConfig
	ProjectConfig *config.ProjectConfig
	Registry      *registry.Registry
	Allocator     *allocator.Allocator
	Log           io.Writer
	Options       Options
	Resolver      interpolation.ResolveFunc
}

Setup orchestrates worktree provisioning. It combines allocation, database cloning, environment file generation, and setup command execution.

func New

func New(worktreePath string, mainRepo string, uc *config.UserConfig) *Setup

New creates a Setup that loads .treeline.yml from the worktree path, not the main repo — branch-specific config is respected. The mainRepo path is still used for copy_files source and SQLite template paths.

All callers operate on worktrees that already exist (either just created by git worktree add, or resuming an existing one). The initial project detection before worktree creation happens in the cmd layer (e.g. cmd/new.go loads config from mainRepo to get the project name, then passes the worktree path here after creation).

func (*Setup) Run

func (s *Setup) Run() (*allocator.Allocation, error)

Jump to

Keyboard shortcuts

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