layout

package
v0.22.1 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package layout decides where runner keeps its files: FHS locations for root and the XDG base directories for everyone else, with macOS logs under ~/Library/Logs where Console.app and launchd expect them.

Index

Constants

View Source
const (
	SystemConfigFile = "/etc/runner/config.toml"
	SystemLogRoot    = "/var/log"
	SystemLogFile    = "/var/log/runner/runner.log"
)
View Source
const ServiceScopeEnv = "RUNNER_SERVICE_SCOPE"

ServiceScopeEnv names the installation scope a generated service definition was written for; it selects the system or user layout.

Variables

This section is empty.

Functions

func SystemLogsDirectory

func SystemLogsDirectory(logFile string) (string, bool)

SystemLogsDirectory reports logFile's directory relative to SystemLogRoot when it is strictly below it and every component uses only characters systemd's LogsDirectory= accepts unescaped. The system unit and root's runtime log decision share this rule so they always agree.

Types

type Identity

type Identity struct {
	// ServiceScope describes the installation, not the process privilege.
	// It selects paths only and never grants access to them.
	ServiceScope  string
	GOOS          string // "linux" or "darwin"
	Root          bool   // effective UID is 0
	Home          string // $HOME as seen by this process; "" when unset
	XDGConfigHome string // honored only when absolute
	XDGStateHome  string // honored only when absolute
}

Identity is everything that decides where runner keeps its files.

func CurrentIdentity

func CurrentIdentity() Identity

CurrentIdentity describes the running process. It never fails: root needs no home directory, and users need one only where XDG does not apply.

func (Identity) ConfigHome

func (id Identity) ConfigHome() (string, error)

ConfigHome is $XDG_CONFIG_HOME when absolute, otherwise ~/.config.

func (Identity) DirPerm

func (id Identity) DirPerm() os.FileMode

DirPerm is the mode for directories runner creates: world-readable system directories, private per-user ones as the XDG specification requires.

func (Identity) StateHome

func (id Identity) StateHome() (string, error)

StateHome is $XDG_STATE_HOME when absolute, otherwise ~/.local/state.

func (Identity) System added in v0.13.0

func (id Identity) System() bool

System reports a system installation, including a dedicated non-root service. Existing root invocations retain their supported system layout.

type Layout

type Layout struct {
	ConfigFile string
	LogFile    string
}

Layout holds the default locations for one identity.

func For

func For(id Identity) (Layout, error)

For returns the default locations for id. Root never fails; a user fails only when a needed base directory has neither $HOME nor an absolute XDG variable.

Jump to

Keyboard shortcuts

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