Documentation
¶
Index ¶
- func AddSite(site Site) error
- func BackupBinaryFile() string
- func BackupTrayFile() string
- func BackupVersionFile() string
- func BinDir() string
- func CertsDir() string
- func ConfigDir() string
- func ContainerHostsFile() string
- func CountSitesUsingPHP(version string) int
- func CountSitesUsingService(name string) int
- func CustomServicesDependingOn(name string) []string
- func CustomServicesDir() string
- func DataDir() string
- func DataSubDir(name string) string
- func DetectFramework(dir string) (string, bool)
- func DetectPublicDir(dir string) string
- func DnsmasqDir() string
- func ErrorPagesDir() string
- func FrameworksDir() string
- func GetConsoleCommand(projectDir string) (string, error)
- func GlobalConfigFile() string
- func IgnoreSite(name string) error
- func InferFamily(name string) string
- func IsKnownFamily(name string) bool
- func MatchesRule(dir string, rule FrameworkRule) bool
- func MaterializeServiceFiles(svc *CustomService) error
- func NginxConfD() string
- func NginxDir() string
- func PHPConfFile(version string) string
- func PHPImageHashFile() string
- func PHPUserIniFile(version string) string
- func PausedDir() string
- func PresetExists(name string) bool
- func QuadletDir() string
- func RemoveCustomService(name string) error
- func RemoveFramework(name string) error
- func RemoveSite(name string) error
- func ResolveDynamicEnv(svc *CustomService) error
- func SanitizeImageTag(tag string) string
- func SaveCustomService(svc *CustomService) error
- func SaveFramework(fw *Framework) error
- func SaveGlobal(cfg *GlobalConfig) error
- func SaveProjectConfig(dir string, cfg *ProjectConfig) error
- func SaveSites(reg *SiteRegistry) error
- func ServiceFilePath(svcName string, target string) string
- func ServiceFilesDir(name string) string
- func ServiceIsManuallyStarted(name string) bool
- func ServiceIsPaused(name string) bool
- func ServiceIsPinned(name string) bool
- func ServicesInFamily(family string) []string
- func SetServiceManuallyStarted(name string, v bool) error
- func SetServicePaused(name string, paused bool) error
- func SetServicePinned(name string, v bool) error
- func SitesFile() string
- func SystemdUserDir() string
- func UpdateCheckFile() string
- type CustomService
- type EnvDetect
- type FileMount
- type Framework
- type FrameworkEnvConf
- type FrameworkLogSource
- type FrameworkRule
- type FrameworkServiceDef
- type FrameworkServiceDetect
- type FrameworkSetupCmd
- type FrameworkWorker
- type GlobalConfig
- func (c *GlobalConfig) AddExtension(version, ext string)
- func (c *GlobalConfig) GetExtensions(version string) []string
- func (c *GlobalConfig) IsXdebugEnabled(version string) bool
- func (c *GlobalConfig) RemoveExtension(version, ext string)
- func (c *GlobalConfig) SetXdebug(version string, enabled bool)
- type Preset
- type PresetMeta
- type PresetVersion
- type ProjectConfig
- type ProjectService
- type ServiceConfig
- type Site
- type SiteInit
- type SiteRegistry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BackupBinaryFile ¶ added in v1.5.0
func BackupBinaryFile() string
BackupBinaryFile returns the path to the backup lerd binary used for rollback.
func BackupTrayFile ¶ added in v1.5.0
func BackupTrayFile() string
BackupTrayFile returns the path to the backup lerd-tray binary used for rollback.
func BackupVersionFile ¶ added in v1.5.0
func BackupVersionFile() string
BackupVersionFile returns the path to the file storing the pre-update version string.
func ConfigDir ¶
func ConfigDir() string
ConfigDir returns ~/.config/lerd/ (or $XDG_CONFIG_HOME/lerd/).
func ContainerHostsFile ¶ added in v1.2.4
func ContainerHostsFile() string
ContainerHostsFile returns the path to the shared hosts file mounted into PHP containers.
func CountSitesUsingPHP ¶ added in v1.4.0
CountSitesUsingPHP returns how many non-ignored, non-paused sites are registered with the given PHP version.
func CountSitesUsingService ¶ added in v1.0.0
CountSitesUsingService returns how many active (non-ignored, non-paused) site .env files reference lerd-{name}, i.e. are configured to use the service.
func CustomServicesDependingOn ¶ added in v1.0.0
CustomServicesDependingOn returns the names of all custom services that declare name in their depends_on list.
func CustomServicesDir ¶ added in v0.5.4
func CustomServicesDir() string
CustomServicesDir returns the directory for custom service YAML files.
func DataDir ¶
func DataDir() string
DataDir returns ~/.local/share/lerd/ (or $XDG_DATA_HOME/lerd/).
func DataSubDir ¶
DataSubDir returns a named subdirectory under data.
func DetectFramework ¶ added in v1.0.0
DetectFramework inspects dir and returns the detected framework name. It checks laravel first (built-in), then user-defined frameworks in FrameworksDir(). Returns ("", false) if no framework matches.
func DetectPublicDir ¶ added in v1.0.0
DetectPublicDir inspects dir for a well-known PHP public directory and returns it. It checks directories used by common PHP frameworks in priority order. A candidate is accepted only if it contains an index.php file, ensuring the directory is actually the document root and not an empty placeholder. Returns "." if no valid candidate is found (serve from project root).
func ErrorPagesDir ¶ added in v1.5.0
func ErrorPagesDir() string
ErrorPagesDir returns the directory where nginx error page HTML files are stored.
func FrameworksDir ¶ added in v1.0.0
func FrameworksDir() string
FrameworksDir returns the directory for user-defined framework YAML files.
func GetConsoleCommand ¶ added in v1.2.0
GetConsoleCommand returns the console binary (without the "php" prefix) for the framework detected in projectDir. It checks the site registry first, then falls back to auto-detection. For Laravel the default is "artisan".
func GlobalConfigFile ¶
func GlobalConfigFile() string
GlobalConfigFile returns the path to config.yaml.
func IgnoreSite ¶ added in v0.3.0
IgnoreSite marks a site as ignored (used for parked sites that have been unlinked).
func InferFamily ¶ added in v1.9.0
InferFamily returns the family for a custom service whose name follows the versioned-alternate template <family>-<digit...>, or the bare family name when the service is the canonical preset (e.g. "mongo"). Returns empty when neither pattern matches a known family.
func IsKnownFamily ¶ added in v1.9.0
IsKnownFamily reports whether name is a recognised service family.
func MatchesRule ¶ added in v1.6.0
func MatchesRule(dir string, rule FrameworkRule) bool
MatchesRule returns true if the given rule matches the project directory.
func MaterializeServiceFiles ¶ added in v1.9.0
func MaterializeServiceFiles(svc *CustomService) error
MaterializeServiceFiles writes each FileMount in svc to its host path, creating the parent directory and applying the requested mode.
func PHPConfFile ¶ added in v0.4.0
PHPConfFile returns the host path for the per-version xdebug ini file.
func PHPImageHashFile ¶ added in v0.1.25
func PHPImageHashFile() string
PHPImageHashFile returns the path to the stored PHP-FPM Containerfile hash.
func PHPUserIniFile ¶ added in v0.5.5
PHPUserIniFile returns the host path for the per-version user php.ini file.
func PausedDir ¶ added in v1.0.0
func PausedDir() string
PausedDir returns the directory where paused-site landing page HTML files are stored.
func PresetExists ¶ added in v1.9.0
PresetExists reports whether a bundled preset with the given name exists.
func RemoveCustomService ¶ added in v0.5.4
RemoveCustomService deletes a custom service config file.
func RemoveFramework ¶ added in v1.0.0
RemoveFramework deletes a user-defined framework YAML. For "laravel" it only removes the user workers overlay (the built-in definition remains).
func RemoveSite ¶
RemoveSite removes a site by name from the registry.
func ResolveDynamicEnv ¶ added in v1.9.0
func ResolveDynamicEnv(svc *CustomService) error
ResolveDynamicEnv applies any dynamic_env directives on svc, writing the computed values into svc.Environment. Called immediately before quadlet generation so the resolved values land in the rendered .container file.
func SanitizeImageTag ¶ added in v1.9.0
SanitizeImageTag returns a container-name-safe form of an image tag by replacing every character that systemd/podman do not accept in unit names with a hyphen. "5.7" -> "5-7", "8.0.34" -> "8-0-34", "11.4+focal" -> "11-4-focal".
func SaveCustomService ¶ added in v0.5.4
func SaveCustomService(svc *CustomService) error
SaveCustomService validates and writes a custom service config to disk.
func SaveFramework ¶ added in v1.0.0
SaveFramework writes a framework definition to FrameworksDir()/{name}.yaml. For the laravel built-in, only the Workers field is persisted (other fields come from the built-in definition and are always merged in by GetFramework).
func SaveGlobal ¶
func SaveGlobal(cfg *GlobalConfig) error
SaveGlobal writes the configuration to config.yaml.
func SaveProjectConfig ¶ added in v1.2.0
func SaveProjectConfig(dir string, cfg *ProjectConfig) error
SaveProjectConfig writes cfg to .lerd.yaml in dir.
func SaveSites ¶
func SaveSites(reg *SiteRegistry) error
SaveSites writes the registry to sites.yaml.
func ServiceFilePath ¶ added in v1.9.0
ServiceFilePath returns the deterministic host path for a single FileMount belonging to the named service. Both the materialiser and the quadlet generator use this so they agree on layout without explicit plumbing.
func ServiceFilesDir ¶ added in v1.9.0
ServiceFilesDir returns the directory holding rendered FileMount content for the named custom service. Each file is bind-mounted into the container at its declared target path.
func ServiceIsManuallyStarted ¶ added in v1.0.0
ServiceIsManuallyStarted returns true if the service was explicitly started by the user (via `lerd service start` or the dashboard), making it exempt from auto-stop when no sites reference it.
func ServiceIsPaused ¶ added in v0.6.0
ServiceIsPaused returns true if the service was manually stopped by the user.
func ServiceIsPinned ¶ added in v1.0.0
ServiceIsPinned returns true if the service has been pinned by the user, meaning it will never be auto-stopped even when no sites reference it.
func ServicesInFamily ¶ added in v1.9.0
ServicesInFamily returns the container hostnames (lerd-<name>) of every installed service that belongs to the named family. Built-ins match against builtinFamilies; custom services match by their Family field, with a fallback that infers family from the name prefix (e.g. mysql-5-7 -> mysql) so services installed before the explicit field existed still discover. Names are returned in deterministic order so the resulting env var stays stable across regenerations.
func SetServiceManuallyStarted ¶ added in v1.0.0
SetServiceManuallyStarted marks or clears the manually-started flag for the named service.
func SetServicePaused ¶ added in v0.6.0
SetServicePaused marks or clears the manual-stop flag for the named service.
func SetServicePinned ¶ added in v1.0.0
SetServicePinned marks or clears the pinned flag for the named service.
func SystemdUserDir ¶
func SystemdUserDir() string
SystemdUserDir returns the systemd user unit directory.
func UpdateCheckFile ¶ added in v0.9.0
func UpdateCheckFile() string
UpdateCheckFile returns the path to the cached update-check state file.
Types ¶
type CustomService ¶ added in v0.5.4
type CustomService struct {
Name string `yaml:"name"`
Image string `yaml:"image"`
Ports []string `yaml:"ports,omitempty"`
Environment map[string]string `yaml:"environment,omitempty"`
DataDir string `yaml:"data_dir,omitempty"`
Exec string `yaml:"exec,omitempty"`
EnvVars []string `yaml:"env_vars,omitempty"`
EnvDetect *EnvDetect `yaml:"env_detect,omitempty"`
SiteInit *SiteInit `yaml:"site_init,omitempty"`
Dashboard string `yaml:"dashboard,omitempty"`
ConnectionURL string `yaml:"connection_url,omitempty"`
Description string `yaml:"description,omitempty"`
DependsOn []string `yaml:"depends_on,omitempty"`
Files []FileMount `yaml:"files,omitempty"`
// Family groups related services so admin UIs can auto-discover every
// member. e.g. the mysql preset declares family: mysql, and phpMyAdmin
// uses dynamic_env to read all family members at quadlet generation time.
Family string `yaml:"family,omitempty"`
// Preset is the bundled preset name this service was installed from.
// Set by InstallPresetByName. Used so the init wizard can store a
// preset reference in .lerd.yaml instead of an inlined definition.
Preset string `yaml:"preset,omitempty"`
// PresetVersion is the picked version tag for multi-version presets.
// Empty for single-version presets.
PresetVersion string `yaml:"preset_version,omitempty"`
// DynamicEnv declares container env vars whose value is computed at
// quadlet generation time. Currently supported directive:
// discover_family:<name> -> comma-joined hostnames of every installed
// service in the named family (built-in or custom).
DynamicEnv map[string]string `yaml:"dynamic_env,omitempty"`
}
CustomService represents a user-defined OCI-based service.
func ListCustomServices ¶ added in v0.5.4
func ListCustomServices() ([]*CustomService, error)
ListCustomServices returns all custom services defined in the services directory.
func LoadCustomService ¶ added in v0.5.4
func LoadCustomService(name string) (*CustomService, error)
LoadCustomService loads a custom service by name from the services directory.
func LoadCustomServiceFromFile ¶ added in v0.5.4
func LoadCustomServiceFromFile(path string) (*CustomService, error)
LoadCustomServiceFromFile parses a CustomService from any YAML file path.
type EnvDetect ¶ added in v0.5.4
type EnvDetect struct {
Key string `yaml:"key"`
ValuePrefix string `yaml:"value_prefix,omitempty"`
}
EnvDetect defines auto-detection rules for `lerd env`.
type FileMount ¶ added in v1.9.0
type FileMount struct {
// Target is the absolute path inside the container where the file appears.
Target string `yaml:"target"`
// Content is the literal file body, written verbatim.
Content string `yaml:"content"`
// Mode is the octal permission bits, e.g. "0600". Defaults to "0644".
Mode string `yaml:"mode,omitempty"`
// Chown adds the :U flag to the volume mount so podman re-chowns the file
// to match the container's expected UID. Required when the in-container
// process runs as a non-root user (e.g. pgAdmin runs as uid 5050) and the
// file mode would otherwise hide it from that user (e.g. 0600).
Chown bool `yaml:"chown,omitempty"`
}
FileMount is a single file rendered to disk on the host and bind-mounted into a custom service container. It exists so presets can ship config files (e.g. pgAdmin's servers.json, a pgpass) without requiring the user to manage any host paths themselves.
type Framework ¶ added in v1.0.0
type Framework struct {
Name string `yaml:"name"`
Label string `yaml:"label"`
Detect []FrameworkRule `yaml:"detect,omitempty"`
PublicDir string `yaml:"public_dir"`
Env FrameworkEnvConf `yaml:"env,omitempty"`
Composer string `yaml:"composer,omitempty"` // auto | true | false
NPM string `yaml:"npm,omitempty"` // auto | true | false
Workers map[string]FrameworkWorker `yaml:"workers,omitempty"`
Setup []FrameworkSetupCmd `yaml:"setup,omitempty"`
// Console is the console command to run (without 'php' prefix).
// Example: "artisan", "bin/console"
Console string `yaml:"console,omitempty"`
// Create is the scaffold command used by "lerd new". The target directory is appended automatically.
// Example: "composer create-project --no-install --no-plugins --no-scripts laravel/laravel"
Create string `yaml:"create,omitempty"`
// Logs defines where application log files live for this framework.
Logs []FrameworkLogSource `yaml:"logs,omitempty"`
}
Framework describes a PHP project framework type.
func GetFramework ¶ added in v1.0.0
GetFramework returns the framework definition for the given name. For non-laravel frameworks it checks user-defined YAMLs in FrameworksDir(). For laravel it always starts from the built-in and merges any user-defined workers on top, so queue/schedule/reverb are always available. Returns (nil, false) if the framework is not found.
func ListFrameworks ¶ added in v1.0.0
func ListFrameworks() []*Framework
ListFrameworks returns all available framework definitions: the laravel built-in plus any user-defined YAMLs in FrameworksDir().
type FrameworkEnvConf ¶ added in v1.0.0
type FrameworkEnvConf struct {
File string `yaml:"file,omitempty"` // primary env file (relative to project)
ExampleFile string `yaml:"example_file,omitempty"` // example to copy from if File missing
Format string `yaml:"format,omitempty"` // dotenv | php-const (default: dotenv)
FallbackFile string `yaml:"fallback_file,omitempty"` // used when File doesn't exist
FallbackFormat string `yaml:"fallback_format,omitempty"` // format for FallbackFile
// URLKey is the env key that holds the application URL (default: APP_URL).
URLKey string `yaml:"url_key,omitempty"`
// Services defines per-service detection rules and env vars to apply.
// Keys match the built-in service names: mysql, postgres, redis, meilisearch, rustfs, mailpit.
Services map[string]FrameworkServiceDef `yaml:"services,omitempty"`
}
FrameworkEnvConf describes how the framework manages its env file.
func (FrameworkEnvConf) Resolve ¶ added in v1.0.0
func (e FrameworkEnvConf) Resolve(projectDir string) (file, format string)
Resolve returns the env file path and format to use for the given project directory. It returns the primary file if it exists, otherwise the fallback. Defaults to ".env" with "dotenv" format if nothing is configured.
type FrameworkLogSource ¶ added in v1.7.0
type FrameworkLogSource struct {
Path string `yaml:"path"` // glob relative to project root, e.g. "storage/logs/*.log"
Format string `yaml:"format,omitempty"` // "monolog" | "raw" (default: "raw")
}
FrameworkLogSource describes where application log files live for a framework.
type FrameworkRule ¶ added in v1.0.0
type FrameworkRule struct {
File string `yaml:"file,omitempty"` // file must exist in project root
Composer string `yaml:"composer,omitempty"` // package must be in composer.json require/require-dev
}
FrameworkRule is a single detection rule for a framework. Any matching rule is sufficient to identify the framework.
type FrameworkServiceDef ¶ added in v1.0.0
type FrameworkServiceDef struct {
// Detect lists env key conditions; any match signals the service is in use.
Detect []FrameworkServiceDetect `yaml:"detect,omitempty"`
// Vars is the list of KEY=VALUE pairs to apply when the service is detected.
// Use {{site}} for the per-project database name.
Vars []string `yaml:"vars,omitempty"`
}
FrameworkServiceDef describes how a service is detected and configured for a framework.
type FrameworkServiceDetect ¶ added in v1.0.0
type FrameworkServiceDetect struct {
Key string `yaml:"key"`
ValuePrefix string `yaml:"value_prefix,omitempty"`
}
FrameworkServiceDetect is a single detection condition. The service is considered active when Key exists in the env file and, if ValuePrefix is set, its value starts with that prefix.
type FrameworkSetupCmd ¶ added in v1.6.0
type FrameworkSetupCmd struct {
Label string `yaml:"label"`
Command string `yaml:"command"`
Default bool `yaml:"default,omitempty"`
Check *FrameworkRule `yaml:"check,omitempty"` // only show when check passes (file exists or composer package installed)
}
FrameworkSetupCmd describes a one-off bootstrap command run during project setup.
type FrameworkWorker ¶ added in v1.0.0
type FrameworkWorker struct {
Label string `yaml:"label,omitempty"`
Command string `yaml:"command"`
Restart string `yaml:"restart,omitempty"` // always | on-failure (default: always)
Check *FrameworkRule `yaml:"check,omitempty"` // only show when check passes (file exists or composer package installed)
}
FrameworkWorker describes a long-running process managed as a systemd service. The Command is executed inside the PHP-FPM container for the site.
type GlobalConfig ¶
type GlobalConfig struct {
PHP struct {
DefaultVersion string `yaml:"default_version" mapstructure:"default_version"`
XdebugEnabled map[string]bool `yaml:"xdebug_enabled" mapstructure:"xdebug_enabled"`
Extensions map[string][]string `yaml:"extensions" mapstructure:"extensions"`
} `yaml:"php" mapstructure:"php"`
Node struct {
DefaultVersion string `yaml:"default_version" mapstructure:"default_version"`
} `yaml:"node" mapstructure:"node"`
Nginx struct {
HTTPPort int `yaml:"http_port" mapstructure:"http_port"`
HTTPSPort int `yaml:"https_port" mapstructure:"https_port"`
} `yaml:"nginx" mapstructure:"nginx"`
DNS struct {
TLD string `yaml:"tld" mapstructure:"tld"`
} `yaml:"dns" mapstructure:"dns"`
LAN struct {
// Exposed controls whether lerd's services are reachable from
// other devices on the local network. When false (the default,
// safe-on-coffee-shop-wifi state) every container PublishPort is
// rewritten to bind 127.0.0.1, lerd-ui binds 127.0.0.1:7073, and
// the lerd-dns-forwarder is stopped. When true, container ports
// bind 0.0.0.0, lerd-ui binds 0.0.0.0:7073, dnsmasq is rewritten
// to answer .test queries with the host's LAN IP, and the
// userspace lerd-dns-forwarder runs to bridge LAN-IP:5300 to the
// loopback-only DNS container.
//
// Toggled via `lerd lan:expose on/off`. The previous standalone
// `dns:expose` flag was folded in here because there is no
// meaningful state where the DNS resolver answers the LAN but
// the actual services don't.
Exposed bool `yaml:"exposed,omitempty" mapstructure:"exposed"`
} `yaml:"lan,omitempty" mapstructure:"lan"`
Autostart struct {
// Disabled controls whether lerd boots itself at login. The
// zero value (false) means lerd autostarts as it always has:
// every lerd-* container quadlet ships with its [Install]
// section, the podman generator wires it into
// default.target.wants on every daemon-reload, and the
// lerd-ui / lerd-watcher / per-site worker units are enabled.
// Setting this to true makes WriteQuadletDiff strip the
// [Install] section before write (so the generator stops
// emitting wants symlinks), disables ui/watcher and every
// per-site worker, and stops them. Toggled via
// `lerd autostart enable / disable` and the dashboard / tray
// switches.
//
// Inverted form (Disabled rather than Enabled) so the YAML zero
// value preserves the historical autostart-on behaviour for
// every existing install — users who never touch the toggle
// see no change.
Disabled bool `yaml:"disabled,omitempty" mapstructure:"disabled"`
} `yaml:"autostart,omitempty" mapstructure:"autostart"`
UI struct {
// RemoteControl gates non-loopback access to the lerd dashboard.
// Empty PasswordHash = disabled = LAN clients get 403. With a hash
// set, LAN clients must present matching HTTP Basic auth. Loopback
// (127.0.0.1, ::1) always bypasses both checks.
Username string `yaml:"username,omitempty" mapstructure:"username"`
PasswordHash string `yaml:"password_hash,omitempty" mapstructure:"password_hash"`
} `yaml:"ui,omitempty" mapstructure:"ui"`
ParkedDirectories []string `yaml:"parked_directories" mapstructure:"parked_directories"`
Services map[string]ServiceConfig `yaml:"services" mapstructure:"services"`
}
GlobalConfig is the top-level lerd configuration.
func LoadGlobal ¶
func LoadGlobal() (*GlobalConfig, error)
LoadGlobal reads config.yaml via viper, returning defaults if the file is absent.
func (*GlobalConfig) AddExtension ¶ added in v0.5.5
func (c *GlobalConfig) AddExtension(version, ext string)
AddExtension adds ext to the custom extension list for version (no-op if already present).
func (*GlobalConfig) GetExtensions ¶ added in v0.5.5
func (c *GlobalConfig) GetExtensions(version string) []string
GetExtensions returns the custom extensions configured for the given PHP version.
func (*GlobalConfig) IsXdebugEnabled ¶ added in v0.4.0
func (c *GlobalConfig) IsXdebugEnabled(version string) bool
IsXdebugEnabled returns true if Xdebug is enabled for the given PHP version.
func (*GlobalConfig) RemoveExtension ¶ added in v0.5.5
func (c *GlobalConfig) RemoveExtension(version, ext string)
RemoveExtension removes ext from the custom extension list for version.
func (*GlobalConfig) SetXdebug ¶ added in v0.4.0
func (c *GlobalConfig) SetXdebug(version string, enabled bool)
SetXdebug enables or disables Xdebug for the given PHP version.
type Preset ¶ added in v1.9.0
type Preset struct {
CustomService `yaml:",inline"`
Versions []PresetVersion `yaml:"versions,omitempty"`
DefaultVersion string `yaml:"default_version,omitempty"`
}
Preset is the parsed YAML for a bundled service preset. It embeds CustomService for the shared fields and adds an optional Versions list + DefaultVersion for families that ship multiple selectable image tags. After the user picks a tag, Resolve() materialises a concrete CustomService whose Name and Image are version-specific while every other field stays shared.
func LoadPreset ¶ added in v1.9.0
LoadPreset returns the parsed Preset for a bundled file by name.
func (*Preset) Resolve ¶ added in v1.9.0
func (p *Preset) Resolve(version string) (*CustomService, error)
Resolve materialises the preset into a concrete CustomService for the picked version. For single-version presets the embedded CustomService is returned as-is and version is ignored. For multi-version presets, version names a tag in Versions; an empty version selects DefaultVersion. The resolved service's Name is "<family>-<sanitized-tag>" and its Image is taken from the version entry. EnvVars and ConnectionURL are scanned for {{tag}} and {{tag_safe}} placeholders so the family-shared template can reference the picked tag.
type PresetMeta ¶ added in v1.9.0
type PresetMeta struct {
Name string `json:"name"`
Description string `json:"description"`
Dashboard string `json:"dashboard,omitempty"`
DependsOn []string `json:"depends_on,omitempty"`
Image string `json:"image"`
Versions []PresetVersion `json:"versions,omitempty"`
DefaultVersion string `json:"default_version,omitempty"`
}
PresetMeta is the lightweight description of a bundled preset, suitable for listing in CLI tables and the web UI without parsing every field.
func ListPresets ¶ added in v1.9.0
func ListPresets() ([]PresetMeta, error)
ListPresets returns the metadata for all bundled service presets, sorted by name.
type PresetVersion ¶ added in v1.9.0
type PresetVersion struct {
Tag string `yaml:"tag" json:"tag"`
Label string `yaml:"label,omitempty" json:"label,omitempty"`
Image string `yaml:"image" json:"image"`
// HostPort is the host-side port published for this specific version.
// Each version gets its own fixed port so multiple alternates can run
// side by side without colliding. Substituted into the family's
// templated ports, env_vars and connection_url via {{host_port}}.
HostPort int `yaml:"host_port,omitempty" json:"host_port,omitempty"`
}
PresetVersion is a single selectable image tag for a multi-version preset family (e.g. mysql 5.7, mysql 5.6, mariadb 11). Single-version presets like phpmyadmin or pgadmin omit Versions entirely and use the embedded CustomService image directly.
type ProjectConfig ¶ added in v1.2.0
type ProjectConfig struct {
Domains []string `yaml:"domains,omitempty"`
PHPVersion string `yaml:"php_version,omitempty"`
NodeVersion string `yaml:"node_version,omitempty"`
Framework string `yaml:"framework,omitempty"`
FrameworkDef *Framework `yaml:"framework_def,omitempty"`
Secured bool `yaml:"secured,omitempty"`
Services []ProjectService `yaml:"services,omitempty"`
Workers []string `yaml:"workers,omitempty"`
// AppURL, when set, is the value lerd writes to the project's APP_URL (or
// the framework-configured URL key) on every `lerd env` run. Committed to
// the repo so the choice is shared across machines. Takes precedence over
// the per-machine override in sites.yaml.
AppURL string `yaml:"app_url,omitempty"`
}
ProjectConfig holds per-project configuration stored in .lerd.yaml.
func LoadProjectConfig ¶ added in v1.2.0
func LoadProjectConfig(dir string) (*ProjectConfig, error)
LoadProjectConfig reads .lerd.yaml from dir, returning an empty config if the file does not exist.
func (*ProjectConfig) ServiceNames ¶ added in v1.3.0
func (p *ProjectConfig) ServiceNames() []string
ServiceNames returns the name of every service in the config, for callers that only need the list of names (e.g. the init wizard multi-select).
type ProjectService ¶ added in v1.3.0
type ProjectService struct {
Name string
Preset string // empty unless this is a preset reference
PresetVersion string // empty for single-version presets
Custom *CustomService // nil unless this is an inline definition
}
ProjectService entries take three YAML shapes:
- redis # named reference (built-in)
- mysql: # preset reference, optional version preset: mysql version: "5.6"
- mongodb: # inline custom definition (legacy / hand-rolled) image: mongo:7 ...
Preset references are the preferred form for services installed via `lerd service preset` because each machine resolves the embedded preset locally — picking up bug fixes, default tweaks, and per-machine port allocations without churn in .lerd.yaml.
func (ProjectService) MarshalYAML ¶ added in v1.3.0
func (s ProjectService) MarshalYAML() (interface{}, error)
MarshalYAML serialises back to the compact form: plain string for named references, single-key preset map for preset references, single-key custom map for inline definitions.
func (ProjectService) Resolve ¶ added in v1.9.0
func (s ProjectService) Resolve() (*CustomService, error)
Resolve returns the concrete CustomService for this entry. Preset references are resolved against the embedded preset library; inline definitions are returned as-is. Named built-in references return (nil, nil) — callers handle built-ins separately.
func (*ProjectService) UnmarshalYAML ¶ added in v1.3.0
func (s *ProjectService) UnmarshalYAML(value *yaml.Node) error
UnmarshalYAML accepts the three shapes documented on ProjectService.
type ServiceConfig ¶
type ServiceConfig struct {
Enabled bool `yaml:"enabled" mapstructure:"enabled"`
Image string `yaml:"image" mapstructure:"image"`
Port int `yaml:"port" mapstructure:"port"`
ExtraPorts []string `yaml:"extra_ports" mapstructure:"extra_ports"`
}
ServiceConfig holds configuration for an optional service.
type Site ¶
type Site struct {
Name string `yaml:"-"`
Domains []string `yaml:"-"`
Path string `yaml:"path"`
PHPVersion string `yaml:"php_version"`
NodeVersion string `yaml:"node_version"`
Secured bool `yaml:"secured"`
Ignored bool `yaml:"ignored,omitempty"`
Paused bool `yaml:"paused,omitempty"`
PausedWorkers []string `yaml:"paused_workers,omitempty"`
Framework string `yaml:"framework,omitempty"`
PublicDir string `yaml:"public_dir,omitempty"`
// AppURL, when set, is the per-machine override for APP_URL in the
// project's env file. Lower priority than ProjectConfig.AppURL (which is
// committed to the repo) and higher priority than the default generator
// (`<scheme>://<primary-domain>`). Use this for personal customizations
// you don't want to share via .lerd.yaml.
AppURL string `yaml:"app_url,omitempty"`
}
Site represents a single registered Lerd site.
func FindSiteByDomain ¶ added in v0.1.37
FindSiteByDomain returns the site that has the given domain (checks all domains), or an error if not found.
func FindSiteByPath ¶ added in v0.3.0
FindSiteByPath returns the site whose path matches, or an error if not found.
func IsDomainUsed ¶ added in v1.5.0
IsDomainUsed checks if any site already uses this domain. Returns the site that uses it, or nil if the domain is free.
The check is strict: a domain may only belong to one site, regardless of TLS scheme. Two sites cannot share the same domain even if one runs on HTTPS and the other on HTTP — DNS and browser caches don't reliably disambiguate by scheme, and the resulting setup is fragile.
func (*Site) IsLaravel ¶ added in v1.0.0
IsLaravel returns true if this site uses the Laravel framework.
func (*Site) PrimaryDomain ¶ added in v1.5.0
PrimaryDomain returns the first (primary) domain for the site.
type SiteInit ¶ added in v0.5.4
type SiteInit struct {
// Container to exec into. Defaults to lerd-<service name>.
Container string `yaml:"container,omitempty"`
// Exec is passed to sh -c inside the container.
Exec string `yaml:"exec"`
}
SiteInit defines an optional command to run inside the service container once per project when `lerd env` detects this service. Use it for any per-site setup: creating a database, a user, indexes, etc. The exec string may contain {{site}} and {{site_testing}} placeholders, which are replaced with the project site handle at runtime.
type SiteRegistry ¶
type SiteRegistry struct {
Sites []Site
}
SiteRegistry holds all registered sites.
func LoadSites ¶
func LoadSites() (*SiteRegistry, error)
LoadSites reads sites.yaml, returning an empty registry if the file does not exist.