Documentation
¶
Overview ¶
Package config reads the service's settings from the environment.
Only data locations are configurable. The bind interface is deliberately absent: it is a package constant in internal/web, because the no-authentication design (ADR-0001) holds only while the binary cannot listen beyond loopback. See ADR-0007.
Index ¶
Constants ¶
const ( // DefaultDataDir is the container's named volume mount point (§2.1). DefaultDataDir = "/var/lib/wherefolk" // DefaultPort is the port tailscale serve forwards to (§2.2). DefaultPort = 8080 // DefaultLogLevel is the threshold when WHEREFOLK_LOG_LEVEL is unset. DefaultLogLevel = slog.LevelInfo // DocumentName is the store's filename within the data directory. // The snapshots/ directory and trash.json live beside it, which is why // WHEREFOLK_DATA names a directory rather than a file (§2.1). DocumentName = "directory.json" // TrashName is the Trash's filename within the data directory, beside the // document (ADR-0012). TrashName = "trash.json" // SettingsName is the settings file's name within the data directory, // beside the document (ADR-0013). SettingsName = "settings.json" // DefaultTemplateDir is where the Typst layout lives inside the container. // It is a directory under the same volume as the document, so the Operator // edits the template through the same mount they already have (§2.1, // ADR-0004). DefaultTemplateDir = "/var/lib/wherefolk/template" // MinPassphraseLength is the shortest Full-tier passphrase accepted. The // passphrase is read out over the phone to relatives (§2.3), so it is a // phrase rather than a password; a short one is a configuration mistake. MinPassphraseLength = 8 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
DataDir string
Port int
// LogLevel is the threshold main installs on the logger it builds. The
// logger itself is not configuration: only the level is read from the
// environment, because only main knows where the log output goes.
LogLevel slog.Level
// TemplateDir holds the on-disk Typst layout. The template is not embedded
// in the binary, so that "the addresses look cramped" is a template edit and
// a restart rather than a rebuild (ADR-0004).
TemplateDir string
// FullPassphrase encrypts every Full-tier export (§5.2, ADR-0011). Empty
// means the Full tier is unavailable: the service still starts, because a
// missing passphrase should not take the whole address book offline to
// protect one of its four exports.
FullPassphrase Secret
}
Config is the service's runtime configuration.
func Load ¶
Load reads configuration from getenv, which is os.Getenv in production and a map lookup in tests. An unset variable takes its default; an invalid one is an error, never a silent fallback.
func (Config) DocumentPath ¶
DocumentPath is the JSON store's location on disk.
func (Config) SettingsPath ¶
SettingsPath is the settings file's location on disk.
type Secret ¶
type Secret string
Secret is a string that never prints itself. fmt's %v, %+v and %#v, and slog, all see "[redacted]" (or nothing, when unset); only Reveal returns the value, so every place the secret is actually used is a grep away.
It exists because Config is a plain struct that is easy to log whole while debugging, and one such line would put the family passphrase in the container's logs.
func (Secret) GoString ¶
GoString implements fmt.GoStringer, which %#v uses.
func (Secret) MarshalText ¶
MarshalText implements encoding.TextMarshaler, so encoding/json and slog's JSONHandler print the redacted form too.
func (Secret) String ¶
String implements fmt.Stringer, which %v and %s use, including for a Secret nested inside a struct.