Documentation
¶
Overview ¶
Package xf provides utilities for XenForo installation detection and management.
Index ¶
- Constants
- Variables
- func GenerateInstanceName(dirName string) string
- func GetXenForoDir(startDir string) (string, error)
- func MetadataPath(xfDir string) string
- func ReadEnvFile(path string) (map[string]string, error)
- func StripQuotes(s string) string
- func UpdateMetadataVersion(xfDir string, version *Version) error
- func WriteEnvFile(path string, values map[string]string) error
- func WriteMetadata(xfDir string, meta *Metadata) error
- type Metadata
- type Stability
- type Version
Constants ¶
const MaxInstanceNameLength = 48
MaxInstanceNameLength bounds every generated Docker instance name.
Instance names become Compose project names, container and volume name prefixes, image tags and hostnames. The tightest of those is a DNS label, at 63 characters; 48 leaves room for that while keeping URLs and container names short enough to read.
Variables ¶
var ( // ErrInvalidInput indicates invalid input was provided. ErrInvalidInput = errors.New("invalid input") // ErrMetadataNotFound is returned when the metadata file cannot be found. ErrMetadataNotFound = errors.New("metadata not found") )
Functions ¶
func GenerateInstanceName ¶
GenerateInstanceName generates a Docker-safe instance name from a directory name.
func GetXenForoDir ¶
GetXenForoDir finds the XenForo root directory by traversing up from startDir. It also checks the XF_DIR environment variable as a fallback.
func MetadataPath ¶
MetadataPath returns the path to the metadata file.
func ReadEnvFile ¶
ReadEnvFile reads environment variables from an .env file.
func StripQuotes ¶
StripQuotes removes surrounding single or double quotes from a string.
func UpdateMetadataVersion ¶
UpdateMetadataVersion updates the version information in the metadata.
func WriteEnvFile ¶
WriteEnvFile writes values to an .env file. It preserves comments and formatting from an existing file if present.
func WriteMetadata ¶
WriteMetadata writes metadata to the metadata file.
Types ¶
type Metadata ¶
type Metadata struct {
// LicenseKey is the license key used for this installation
LicenseKey string `json:"license_key"`
// InstanceName is the Docker instance name
InstanceName string `json:"instance_name"`
// InstalledProducts tracks which products were installed
InstalledProducts []string `json:"installed_products"`
// InstalledVersion is the version that was installed
InstalledVersion string `json:"installed_version"`
// InstalledVersionID is the version ID that was installed
InstalledVersionID int `json:"installed_version_id"`
// CreatedAt is when the installation was created
CreatedAt time.Time `json:"created_at"`
// UpdatedAt is when the metadata was last updated
UpdatedAt time.Time `json:"updated_at"`
}
Metadata stores CLI-specific information about a XenForo installation. This file is created during `init` and used by `upgrade` to remember settings.
func ReadMetadata ¶
ReadMetadata reads the metadata file. Returns nil (not an error) if the file doesn't exist.
type Stability ¶
type Stability string
Stability represents the release stability of a XenForo version.
type Version ¶
type Version struct {
String string // e.g., "2.3.8"
ID int // e.g., 2030871
Major int // e.g., 2
Minor int // e.g., 3
Patch int // e.g., 8
Stability Stability // alpha, beta, rc, stable, pl
StabNum int // stability number (1=alpha, 3=beta, 5=rc, 7=stable, 9=pl)
PLLevel int // patch level (0-9)
}
Version represents a XenForo version with both string and ID representations.
func DetectVersion ¶
DetectVersion parses src/XF.php for the version string and ID.
func ParseVersionID ¶
ParseVersionID converts a version ID into a Version structure.
func ParseVersionString ¶
ParseVersionString parses a version string into a Version structure.