config

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: MIT Imports: 5 Imported by: 0

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

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

func Known(name string) error

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

func RepoPath(dir string) (path string, inRepo bool)

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.

func Set

func Set(path, key, value string) error

Set writes key=value into the JSON file at path, creating the file and its directory if needed, preserving any keys it does not understand.

func Unset

func Unset(path, key string) error

Unset removes key from the file at path. Removing what is not there succeeds, including from a file that does not exist: the caller asked for a state, and that state already holds.

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

func Load(dir string, env func(string) string, o Overrides) (*Config, error)

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.

type Overrides

type Overrides struct {
	Workspace string // the --workspace flag
}

Overrides are the flags of the command being run, the strongest layer.

Jump to

Keyboard shortcuts

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