Documentation
¶
Overview ¶
Package config loads TinyRaven runtime configuration. Precedence, highest first (ADR 0032): explicit env (TINYBIRD_*/TR_*) > project .tr/config.yml > home ~/.tinyraven/config.yml > built-in defaults. Hand-rolled — no viper; the only file parser is yaml.v3 (ADR 0032).
Index ¶
Constants ¶
const ( // HomeConfigPath holds secrets (token); see WriteConfigFile perms. HomeConfigPath = "~/.tinyraven/config.yml" // ProjectConfigPath is non-secret project state (host/workspace), checked in. ProjectConfigPath = ".tr/config.yml" )
Variables ¶
This section is empty.
Functions ¶
func WriteConfigFile ¶
func WriteConfigFile(path string, c FileConfig) error
WriteConfigFile writes c to path as YAML, creating parent dirs. The file holds a token, so it is written 0600 under a 0700 directory (for `tr login`).
Types ¶
type Config ¶
type Config struct {
HTTPAddr string // listen address, e.g. ":8000"
CHHTTPURL string // ClickHouse HTTP, e.g. "http://localhost:8123"
CHNativeAddr string // ClickHouse native TCP, e.g. "localhost:9000"
CHDatabase string // target database, e.g. "tr_main"
CHUser string
CHPassword string
RedisAddr string // e.g. "localhost:6379"
ProjectDir string // dir holding .datasource/.pipe files
AdminToken string // bootstrap ADMIN token; empty disables bootstrap
PipeRateLimit int // per-token req/s on /v0/pipes (ADR 0015); 0 disables
CHROUser string // dedicated read-only CH user for reads (ADR 0011); empty = use CHUser
CHROPassword string
DocsEnabled bool // serve /tr/v1/docs (ADR 0017); off by default
// Client-facing config, Tinybird-compatible (read from config.yml / env).
Host string // API host the `tr` CLI talks to, e.g. "http://localhost:8000"
Token string // bearer token for API calls
Workspace string // active Tinybird-style workspace (deployment); branch→DB is separate
}
Config is the resolved server + CLI configuration.
type FileConfig ¶
type FileConfig struct {
Host string `yaml:"host,omitempty"`
Token string `yaml:"token,omitempty"`
Workspace string `yaml:"workspace,omitempty"`
}
FileConfig is the on-disk shape of ~/.tinyraven/config.yml — byte-compatible with Tinybird's ~/.tinybird/config.yml (host, token, optional workspace).
func LoadConfigFile ¶
func LoadConfigFile(path string) (FileConfig, error)
LoadConfigFile reads and parses a config.yml. A leading "~" is resolved via os.UserHomeDir. Missing-file and parse errors are returned to the caller (a future `tr login` distinguishes them); Load swallows missing files itself.