Documentation
¶
Overview ¶
Package pathcheck reports, once at startup, every filesystem path a binary is configured with: where the value came from (set, or the built-in default), the absolute path it resolves to from the working directory, and whether the file or directory is there and usable by the process user.
Each path is one log line with the message "startup path", so
docker logs <container> 2>&1 | grep 'startup path'
shows the whole picture, and problems are logged at WARN. The report never stops startup. A misconfigured path often fails silently (a missing plugin config file loads no plugins, a missing .env file is skipped), and this is where that shows up.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Log ¶
Log writes one "startup path" line per result, after a line giving the working directory and process user that relative paths and permissions depend on. Problems are logged at WARN, everything else at INFO. It returns the number of problems.
func SQLitePath ¶
SQLitePath reduces a SQLite DSN or path to the file it opens. onDisk is false for in-memory databases.
Types ¶
type Entry ¶
type Entry struct {
// Name is how the path is set, usually its environment variable
// ("PLUGINS_CONFIG_PATH") or a flag ("-env").
Name string
// Value is the value the binary uses, after defaults are applied.
Value string
// Default is the value used when Name is not set ("" when there is none).
Default string
// Kind decides what is checked.
Kind Kind
// Required marks a path the binary cannot work without in its current
// mode. An unset required path is a problem; an unset optional one just
// means the feature that uses it is off.
Required bool
// Use says what the path is for, in a few words.
Use string
// Source overrides the source derived from the environment. Set it for
// values that do not come from an environment variable (flags).
Source Source
}
Entry is one configured path.
type Kind ¶
type Kind string
Kind says how a path is used, which decides what is checked.
const ( // File is read: it must exist and be readable. File Kind = "file" // Dir is written: it must be a writable directory, or be creatable // under a writable parent. Dir Kind = "dir" // SQLite is a SQLite database, given as a file path or a DSN // ("file:./data/x.db?mode=rwc"). It is opened read-write and created on // first use, but its directory must already exist, and be writable for // the journal/WAL files. SQLite Kind = "sqlite" // OutputFile is appended to (a log file): writable if it exists, or // creatable under a writable parent. OutputFile Kind = "output_file" )
type Result ¶
type Result struct {
Entry
Source Source
Path string // the filesystem path checked (a DSN reduced to its file)
Resolved string // Path made absolute against the working directory
Status Status
Detail string // why a check failed
}
Result is the outcome of checking one Entry.
func Check ¶
Check examines every entry. It only reads the filesystem, except that a directory's writability is tested by creating and removing a temporary file in it.
func (Result) Problem ¶
Problem reports whether the result should be flagged. A path that was set, or is required, must work. A default file that is absent is not a problem (a default .env is normally absent in containers), but a default directory or database the binary will write to must be usable.
type Status ¶
type Status string
Status is the outcome of checking one path.
const ( StatusOK Status = "ok" StatusUnset Status = "unset" // not configured StatusWillCreate Status = "will_create" // absent, and the parent is writable StatusMissing Status = "missing" // absent, and cannot be created StatusNotReadable Status = "not_readable" StatusNotWritable Status = "not_writable" StatusWrongType Status = "wrong_type" // a directory where a file is expected, or the reverse StatusInMemory Status = "in_memory" // an in-memory SQLite DSN; nothing on disk )