Documentation
¶
Overview ¶
Package config loads and validates archdoc.json.
Index ¶
Constants ¶
const ( DefaultBranch = "main" DefaultRoot = "." DefaultStrict = true DefaultRefStaleDays = 180 )
Defaults for keys absent from archdoc.json. Name has no default and is required.
const Filename = "archdoc.json"
Filename is the name of the configuration file, searched for by Find.
Variables ¶
var ErrNotFound = errors.New("no archdoc.json found")
ErrNotFound reports that no archdoc.json exists in the starting directory or any of its ancestors.
Functions ¶
func Validate ¶
Validate is every check Load applies to a configuration, exported so that `archdoc init` can apply them to the settings it is about to write rather than discovering them when it reads the file back.
It used to discover them there: init wrote the whole scaffold and then failed loading its own archdoc.json, leaving a dead configuration behind that made init refuse to run again and every other command fail. The checks it did mirror ran before the interactive prompts, so a root typed at the prompt was checked by nothing at all.
func ValidateRoot ¶
ValidateRoot reports whether root names a directory inside the repository.
root exists so that a specification can live in a subdirectory of the project it documents, and nothing else: an unchecked "../victim" made archdoc write INDEX.md, and create a glossary, in a directory nobody named. The check is lexical, which is the same shape as the paths it guards.
Types ¶
type Config ¶
type Config struct {
Name string `json:"name"`
Branch string `json:"branch"`
Root string `json:"root"`
Strict bool `json:"strict"`
RefStaleDays int `json:"ref_stale_days"`
// Path is the absolute location of the archdoc.json this was loaded from.
// It is not part of the file, and naming it here keeps a document that
// mentions "path" an unknown-field error rather than a way to set it.
Path string `json:"-"`
}
Config is the contents of archdoc.json.
func Find ¶
Find walks up from dir looking for archdoc.json and loads the first one it finds. It returns ErrNotFound if it reaches the filesystem root first.