Documentation
¶
Index ¶
- Variables
- func CleanupRelink(path, newName string) bool
- func CustomNginxPath(domain string) string
- func FinishCustomLink(site config.Site, containerCfg *config.ContainerConfig) error
- func FinishFrankenPHPLink(site config.Site) error
- func FinishLink(site config.Site, phpVersion string) error
- func InheritCustomNginxConfig(parentDomain, worktreeDomain string) error
- func IsParkedSite(sitePath string, parkedDirs []string) bool
- func ListCustomNginxBackups(domain string) ([]cfgedit.Backup, error)
- func MoveCustomNginxConfig(oldPrimary, newPrimary string) error
- func ReadCustomNginx(domain string) (cfgedit.Content, error)
- func ReadCustomNginxBackup(domain, name string) ([]byte, error)
- func RegenerateSiteVhost(site *config.Site, oldPrimary string) error
- func RemoveCustomNginxConfig(domain string) error
- func ResetCustomNginx(domain string) error
- func RestoreCustomNginx(domain, name string) (cfgedit.RestoreResult, error)
- func SaveCustomNginx(domain, content string, backup bool) (cfgedit.SaveResult, error)
- func SetSecured(site *config.Site, secured bool) error
- func SiteForDomain(domain string) (*config.Site, error)
- func SiteNameAndDomain(dirName, tld string) (string, string)
- func SyncEnvIfPrimaryChanged(site *config.Site, oldPrimary string) error
- func UnlinkSiteCore(site *config.Site, parkedDirs []string) error
- func ValidNginxBackupName(domain, name string) bool
- func WorktreeDomain(site *config.Site, branch string) (string, error)
- type VersionResult
Constants ¶
This section is empty.
Variables ¶
var ( NginxTestFn = nginx.Test NginxReloadFn = nginx.Reload )
NginxTestFn / NginxReloadFn are indirections so tests can stub the podman-bound `nginx -t` and reload. The global-nginx editor reuses these so site and global saves share one validator/reload pair. Defaults are real.
Functions ¶
func CleanupRelink ¶
CleanupRelink handles the re-link scenario: when a site is being linked at a path that already has registrations, it carries over the secured state and removes stale entries (e.g. name changed). Returns the carried-over secured flag.
func CustomNginxPath ¶ added in v1.23.0
CustomNginxPath is the on-disk path of a domain's custom override.
func FinishCustomLink ¶ added in v1.15.0
func FinishCustomLink(site config.Site, containerCfg *config.ContainerConfig) error
FinishCustomLink performs the post-registration steps for a custom container site: build the image, write a dedicated quadlet, generate a proxy vhost, update container hosts, and reload nginx.
func FinishFrankenPHPLink ¶ added in v1.18.0
FinishFrankenPHPLink performs the post-registration steps for a site whose runtime is "frankenphp": ensure the image is pulled, write a per-site quadlet that runs the framework's entrypoint, generate an nginx proxy vhost, update container hosts, and reload nginx.
func FinishLink ¶
FinishLink performs the post-registration steps shared by link, park, and MCP: vhost generation, FPM quadlet setup, container hosts update, and nginx reload.
func InheritCustomNginxConfig ¶ added in v1.23.0
InheritCustomNginxConfig seeds a new worktree's override from its parent's: it copies custom.d/{parent}.conf to custom.d/{worktree}.conf only when the parent exists and the worktree override does not. Callers must invoke it only on genuine worktree creation — running it on every resync would resurrect an override the user deliberately reset (it can't tell "new" from "reset").
func IsParkedSite ¶
IsParkedSite checks whether a site's path is inside one of the parked directories.
func ListCustomNginxBackups ¶ added in v1.23.0
ListCustomNginxBackups returns a domain's override backups, newest first.
func MoveCustomNginxConfig ¶ added in v1.23.0
MoveCustomNginxConfig follows a site's hand-authored nginx overrides across a primary-domain rename. The main snippet lives at custom.d/{primary}.conf and each worktree's at custom.d/{branch}.{primary}.conf; the generated vhosts include them by name, so without this they are orphaned and the renamed site (and its worktrees) silently lose their custom config. Timestamped backups in custom.d.bkp/ are keyed the same way and moved too so the UI restore dropdown keeps working. Missing files are not an error; renames far outnumber edits.
func ReadCustomNginx ¶ added in v1.23.0
ReadCustomNginx returns the saved override, or the seeded template (Exists=false) when nothing is on disk yet.
func ReadCustomNginxBackup ¶ added in v1.23.0
ReadCustomNginxBackup returns the raw bytes of one backup (os.ErrNotExist when the name is invalid or the file is gone).
func RegenerateSiteVhost ¶
RegenerateSiteVhost regenerates the nginx vhost for a site after domain changes. If the primary domain changed, the old vhost file is removed. For secured sites the SSL vhost is generated and renamed to the main .conf path.
func RemoveCustomNginxConfig ¶ added in v1.23.0
RemoveCustomNginxConfig deletes a worktree's live override and every timestamped backup for that domain. Used when a worktree is removed.
func ResetCustomNginx ¶ added in v1.23.0
ResetCustomNginx deletes the override and reloads nginx. Backups are kept.
func RestoreCustomNginx ¶ added in v1.23.0
func RestoreCustomNginx(domain, name string) (cfgedit.RestoreResult, error)
RestoreCustomNginx swaps a backup over the live override and reloads nginx.
func SaveCustomNginx ¶ added in v1.23.0
func SaveCustomNginx(domain, content string, backup bool) (cfgedit.SaveResult, error)
SaveCustomNginx writes, validates with `nginx -t`, rolls back on a failure that names our file, and reloads nginx.
func SetSecured ¶ added in v1.20.2
SetSecured toggles the site's TLS state and runs every step the toggle depends on. It is the single source of truth for "what happens when a site is secured/unsecured"; CLI, UI, and MCP all call this with no per-caller variation so a new step added here applies everywhere.
Steps:
- Issue or remove the certificate (also regenerates the nginx vhost on disk).
- Persist site.Secured to the registry.
- Sync APP_URL and VITE_REVERB_HOST/SCHEME/PORT in the project's .env.
- Update the per-project .lerd.yaml secured flag.
- Reload nginx so the new vhost takes effect.
- Notify the daemon to refresh dependent listeners (Stripe webhook URL, LAN share proxy backend port). The daemon owns the in-process state for these, so even callers running inside the daemon hit the same HTTP endpoints; a tiny loopback roundtrip is the cost of having one identical post-toggle path.
func SiteForDomain ¶ added in v1.23.0
SiteForDomain resolves a domain to the site that owns it, accepting both a registered domain (primary/alias) and a worktree's subdomain. Worktree overrides are keyed by the worktree's full domain (custom.d/{wt}.conf), so the per-site nginx endpoints must recognise those too; the worktree is confirmed against live git detection so an arbitrary subdomain can't be used to reach outside custom.d.
func SiteNameAndDomain ¶
SiteNameAndDomain derives a clean site name and domain from a directory name. It strips one trailing TLD (either a gTLD from the curated list or any 2-letter ccTLD), then replaces remaining dots with dashes so the result is a valid DNS label. Examples:
"myapp" -> "myapp", "myapp.test" "myapp.com" -> "myapp", "myapp.test" "astrolov.ro" -> "astrolov", "astrolov.test" "admin.astrolov.com" -> "admin-astrolov", "admin-astrolov.test"
func SyncEnvIfPrimaryChanged ¶ added in v1.23.0
SyncEnvIfPrimaryChanged updates APP_URL and the VITE_REVERB_* keys in the site's project .env and rewrites APP_URL in each worktree .env to the new <branch>.<newPrimary> subdomain, but only when the primary domain has actually changed since oldPrimary. Returns the first non-nil error so callers can warn; a worktree-detection failure is treated as no worktrees rather than as a fatal error because the parent sync has already landed.
func UnlinkSiteCore ¶
UnlinkSiteCore performs the shared unlink steps: remove vhost, remove certs, update registry (ignore if parked, remove otherwise), update container hosts, and reload nginx. It does NOT stop workers or clean up unused services/FPMs — callers that need those should do them before calling this function.
func ValidNginxBackupName ¶ added in v1.23.0
ValidNginxBackupName reports whether name is a well-formed backup for domain.
func WorktreeDomain ¶ added in v1.23.0
WorktreeDomain resolves a site plus an optional branch to the domain whose custom nginx override applies: the site's primary domain when branch is empty, or the worktree's subdomain otherwise. It is the single source of truth for "branch -> {branch}.{primary}", shared by the CLI and MCP so they can't drift from how the daemon derives worktree domains.
Types ¶
type VersionResult ¶
type VersionResult struct {
PHP string // best installed PHP version (clamped to framework range)
Node string // detected Node version
PHPMin string // framework minimum PHP version (empty if no framework)
PHPMax string // framework maximum PHP version (empty if no framework)
SuggestedPHP string // better PHP version to install (empty if current is optimal)
FrameworkLabel string // human-readable framework name for messages
}
VersionResult holds the detected and suggested versions for a site.
func DetectSiteVersions ¶
func DetectSiteVersions(dir, framework, defaultPHP, defaultNode string) VersionResult
DetectSiteVersions resolves the framework, PHP version (clamped to framework range), and Node version for a project directory. When the best installed PHP version is below the framework's max, SuggestedPHP is set to the max version.