config

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: MIT Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

func Load(getenv func(string) string) (Config, error)

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

func (c Config) DocumentPath() string

DocumentPath is the JSON store's location on disk.

func (Config) SettingsPath

func (c Config) SettingsPath() string

SettingsPath is the settings file's location on disk.

func (Config) TrashPath

func (c Config) TrashPath() string

TrashPath is the Trash 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

func (s Secret) GoString() string

GoString implements fmt.GoStringer, which %#v uses.

func (Secret) LogValue

func (s Secret) LogValue() slog.Value

LogValue implements slog.LogValuer.

func (Secret) MarshalText

func (s Secret) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler, so encoding/json and slog's JSONHandler print the redacted form too.

func (Secret) Reveal

func (s Secret) Reveal() string

Reveal returns the secret itself. Call it only where the value is consumed.

func (Secret) String

func (s Secret) String() string

String implements fmt.Stringer, which %v and %s use, including for a Secret nested inside a struct.

Jump to

Keyboard shortcuts

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