Documentation
¶
Overview ¶
Package config is the layered configuration that lets a repository pin which workspace uploads from inside it go to, so an agent working in that checkout never has to name one. It depends on nothing but the standard library: the packages that do the work read configuration, and configuration must not need them back.
Index ¶
Constants ¶
const ( SourceGlobal = "global config" SourceRepo = "repo config" SourceEnv = "KROWK_WORKSPACE" SourceFlag = "--workspace" )
Where a resolved value came from, in the order they beat each other. These are what doctor and `config show` print, so they read as the thing a person would go and edit, not as an internal layer name.
Variables ¶
This section is empty.
Functions ¶
func GlobalPath ¶
func GlobalPath() string
GlobalPath is ~/.config/krowk/config.json, XDG_CONFIG_HOME honoured. Not os.UserConfigDir: that is ~/Library/Application Support on macOS, and the CLI documents one path on every platform.
func Known ¶ added in v0.2.1
Known reports whether key is in the schema. Writing a key krowk does not understand is refused rather than stored: a typo that lands in the file is a setting that never takes effect, and the file would sit there looking like it had.
func KnownKeys ¶
func KnownKeys() []string
KnownKeys lists every key this build understands, for help and errors.
func RepoPath ¶
RepoPath is where the repo config for dir lives ("" means the working directory), and whether dir is inside a git repository at all. The path is returned whether or not the file exists yet — it is where `config set` writes.
Types ¶
type Config ¶
type Config struct {
Workspace string
// Sources records where each key's value came from, keyed by config key
// name ("workspace"), so doctor and `config show` can say why. A key that
// nothing set is absent from the map rather than present and empty: "no one
// set this" is a different answer from "something set it to nothing".
Sources map[string]string
}
Config is the resolved configuration — every key as it came out of the layering, with no memory of the layers that lost.
func Load ¶
Load resolves the layered configuration as seen from dir ("" means the working directory).
Weakest to strongest: the global file, the repo file, the environment, then the flags. Each layer only speaks where it has something to say, so pinning a workspace in a repo does not stop KROWK_WORKSPACE from redirecting one command, and neither of them has to repeat what the global file already says.