Documentation
¶
Overview ¶
Package grouping manages site groups: a main site that owns a base domain and one or more secondary sites that each occupy a chosen subdomain label of that base domain (e.g. astrolov.test + admin.astrolov.test). A secondary is a fully independent site; grouping only computes its primary domain as <label>.<main-domain> and drives the same nginx/cert/env regeneration the domain commands use. nginx routes the exact subdomain to the secondary over the main's *.<domain> wildcard, the identical mechanism worktree subdomains rely on.
Index ¶
- func AssignSecondary(main, secondary *config.Site, label string, shareDB bool) error
- func CascadeMainDomainChange(main *config.Site) error
- func ComputeSecondaryDomain(mainPrimary, label string) string
- func DissolveGroup(group string) error
- func MainDBName(main *config.Site) string
- func SetSecondaryLabel(secondary *config.Site, newLabel string) error
- func SetSecondarySharedDB(secondary *config.Site, shareDB bool) error
- func SharedDBNameFor(s *config.Site) (string, bool)
- func UnassignSecondary(secondary *config.Site) error
- func ValidateLabel(label string) error
- func WorktreeLabelTaken(main *config.Site, label string) (bool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssignSecondary ¶
AssignSecondary groups an existing site under main as a secondary occupying the given subdomain label. The secondary's old standalone domain is replaced by <label>.<main-primary>. main is promoted to a group main on first use. When shareDB is true the secondary's DB_DATABASE is pointed at the main's database instead of keeping its own. If regeneration fails the registry is rolled back so the site doesn't end up grouped with no serving vhost.
func CascadeMainDomainChange ¶
CascadeMainDomainChange recomputes every secondary's domain against the group main's current primary domain and regenerates each. Call it after the main's own domain has changed (e.g. via a domain edit) so the subdomains follow.
func ComputeSecondaryDomain ¶
ComputeSecondaryDomain returns the domain a secondary occupies on the group main's base domain.
func DissolveGroup ¶
DissolveGroup ungroups every secondary in the group, restoring standalone domains, then clears the main's group key.
func MainDBName ¶
MainDBName returns the database name a shared-DB secondary should use: the group main's DB_DATABASE, falling back to the main's canonical slug.
func SetSecondaryLabel ¶
SetSecondaryLabel changes the subdomain a secondary occupies on its group main's base domain.
func SetSecondarySharedDB ¶
SetSecondarySharedDB toggles whether a grouped secondary shares the group main's database. Turning it on rewrites the secondary's DB_DATABASE to the main's; turning it off restores the secondary's own database name.
func SharedDBNameFor ¶
SharedDBNameFor returns the database name a site should use when it is a shared-DB group secondary, and whether that override applies. The env setup path consults this so it never resets a shared secondary back to its own DB.
func UnassignSecondary ¶
UnassignSecondary removes a secondary from its group, restoring a standalone domain derived from its directory name. When the group main is left with no secondaries its group key is cleared too.
func ValidateLabel ¶
ValidateLabel checks that label is a non-empty, DNS-safe subdomain label in its canonical form (lowercase, no transformation needed). It reuses the same sanitiser worktree branches go through so a label can never collide with a reserved name or produce an invalid host.
Types ¶
This section is empty.