Documentation
¶
Overview ¶
Package setup provides worktree provisioning orchestration. It coordinates resource allocation, database cloning, environment file generation, setup command execution, and editor configuration.
Index ¶
- Variables
- func BuildEnvVars(pc *config.ProjectConfig, alloc interpolation.Allocation, redisURL string) map[string]string
- func BuildEnvVarsWithResolver(pc *config.ProjectConfig, alloc interpolation.Allocation, redisURL string, ...) (map[string]string, error)
- func InjectRouterTokens(alloc interpolation.Allocation, ...)
- func RegenerateEnvFile(worktreePath string, uc *config.UserConfig) error
- func RunHookCommands(hookName string, cmds []string, dir string, log func(string, ...any)) error
- type EditorResult
- type Options
- type Setup
Constants ¶
This section is empty.
Variables ¶
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.
Types ¶
type EditorResult ¶
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 ¶
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).