grouping

package
v1.28.1 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2026 License: MIT Imports: 10 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssignSecondary

func AssignSecondary(main, secondary *config.Site, label string, shareDB bool) error

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

func CascadeMainDomainChange(main *config.Site) error

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

func ComputeSecondaryDomain(mainPrimary, label string) string

ComputeSecondaryDomain returns the domain a secondary occupies on the group main's base domain.

func DissolveGroup

func DissolveGroup(group string) error

DissolveGroup ungroups every secondary in the group, restoring standalone domains, then clears the main's group key.

func MainDBName

func MainDBName(main *config.Site) string

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

func SetSecondaryLabel(secondary *config.Site, newLabel string) error

SetSecondaryLabel changes the subdomain a secondary occupies on its group main's base domain.

func SetSecondarySharedDB

func SetSecondarySharedDB(secondary *config.Site, shareDB bool) error

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

func SharedDBNameFor(s *config.Site) (string, bool)

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

func UnassignSecondary(secondary *config.Site) error

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

func ValidateLabel(label string) error

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.

func WorktreeLabelTaken

func WorktreeLabelTaken(main *config.Site, label string) (bool, error)

WorktreeLabelTaken reports whether the main site has an active git worktree whose subdomain would collide with the given label.

Types

This section is empty.

Jump to

Keyboard shortcuts

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