schema

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2026 License: GPL-3.0 Imports: 4 Imported by: 0

README

schema

A precomputed, zero-reflection inventory of the magus config struct, layered on github.com/kkyr/fig. Every config-backed CLI flag and MAGUS_* env var is available as a structured Field for O(1) lookup.

API

Symbol Description
var Fields []Field Every config-backed field (go path, yaml path, env var, flag, kind, usage)
FieldByEnv(name) (Field, bool) Lookup by MAGUS_* env-var name
FieldByGoPath(path) (Field, bool) Lookup by Go field path (e.g. "Cache.Dir")
EnvPrefix The MAGUS env-var prefix
UseEnv() fig.Option Shorthand for fig.UseEnv(EnvPrefix), for fig.Load
ParseBool(v, fallback) Parses env-style booleans (true/1/yes, false/0/no)

magus doctor uses Fields to flag unknown MAGUS_* vars in the environment.

Regenerating

Fields is code-generated from internal/config/config.go by cmd/magus-utils config/. After changing a config field:

cd magus && go generate ./cmd/magus/...

TestSchemaNotDrifted verifies the committed generated files are up to date.

Documentation

Overview

Package schema provides a code-generated, zero-reflection schema for the magus Config struct. Every config-backed CLI flag and MAGUS_* env var is available in Fields for O(1) lookup. Regenerate with: cd magus && go generate ./cmd/magus/...

Index

Constants

View Source
const EnvPrefix = "MAGUS"

EnvPrefix is the prefix shared by every env var in Fields.

Variables

View Source
var Fields []Field

Fields is the precomputed inventory of every config-backed CLI flag and MAGUS_* env var.

Functions

func ParseBool

func ParseBool(v string, fallback bool) bool

ParseBool parses a boolean environment variable value using a case-insensitive comparison. "true", "1", "yes" → true; "false", "0", "no" → false. Any unrecognized value returns fallback unchanged.

func UseEnv

func UseEnv() fig.Option

UseEnv returns a fig.Option for schema's env scheme (equivalent to fig.UseEnv(EnvPrefix)).

Types

type Field

type Field = fieldtype.Field

Field aliases fieldtype.Field: one scalar config field exposed as a flag and/or env var.

func FieldByEnv

func FieldByEnv(name string) (Field, bool)

FieldByEnv returns the Field for the given MAGUS_* env-var name. Returns false if the name is not a known config-backed env var.

func FieldByGoPath

func FieldByGoPath(path string) (Field, bool)

FieldByGoPath returns the Field for the given Go field path (e.g. "Cache.Dir"). Returns false if the path is not a known config-backed field.

type FlagNames

type FlagNames = fieldtype.FlagNames

FlagNames aliases fieldtype.FlagNames: the long/short CLI flag names for a field.

type Kind

type Kind = fieldtype.Kind

Kind aliases fieldtype.Kind: the scalar kind of a config field.

const (
	KindString      Kind = fieldtype.KindString
	KindInt         Kind = fieldtype.KindInt
	KindBool        Kind = fieldtype.KindBool
	KindFloat64     Kind = fieldtype.KindFloat64
	KindBoolPtr     Kind = fieldtype.KindBoolPtr
	KindDuration    Kind = fieldtype.KindDuration
	KindStringSlice Kind = fieldtype.KindStringSlice
)

The Kind constants mirror fieldtype's scalar config-field kinds.

Directories

Path Synopsis
Package fieldtype holds the hand-written config-field types (Kind, Field, FlagNames) that the generated inventory in schema/gen populates.
Package fieldtype holds the hand-written config-field types (Kind, Field, FlagNames) that the generated inventory in schema/gen populates.
Code generated by magus-utils config; DO NOT EDIT.
Code generated by magus-utils config; DO NOT EDIT.

Jump to

Keyboard shortcuts

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