Documentation
¶
Overview ¶
Package config defines the provr.yaml project configuration (schema v1).
Index ¶
- Constants
- Variables
- func FindRepoRoot(start string) (string, error)
- func Locate(cwd, override string) (path, repoRoot string, err error)
- func ReadProjectName(path string) (string, error)
- type Agents
- type Commands
- type Compose
- type GCP
- type Healthcheck
- type Host
- type Project
- type TTL
- type Tailscale
- type ValidationError
Constants ¶
const ( DefaultMachineType = "e2-standard-4" DefaultDiskGB = 100 DefaultMaxPreviews = 2 DefaultIdleStop = 45 * time.Minute DefaultDeleteAfter = 168 * time.Hour DefaultComposeFile = "docker-compose.yml" DefaultHealthcheck = 5 * time.Minute DefaultTTL = 4 * time.Hour DefaultMaxTTLValue = 12 * time.Hour DefaultTailscale = "tag:provr" // AutoPreviewOnChange and AutoPreviewOnRequest are the allowed values of // agents.auto_preview. AutoPreviewOnChange = "on_change" AutoPreviewOnRequest = "on_request" DefaultAutoPreview = AutoPreviewOnChange // MaxTTL is the hard upper limit for ttl.max. MaxTTL = 12 * time.Hour )
Defaults for schema v1.
const FileName = "provr.yaml"
FileName is the name of the project config file.
Variables ¶
var ErrInvalid = errors.New("invalid provr.yaml")
ErrInvalid is matched by errors.Is for any *ValidationError.
var ErrNoRepo = errors.New("not inside a git repository")
ErrNoRepo is returned when no enclosing git repository is found.
var ErrNotFound = errors.New("provr.yaml not found")
ErrNotFound is returned (in the error chain) when no provr.yaml exists where Locate looked. It is not returned for an explicit --config path that is missing.
Functions ¶
func FindRepoRoot ¶
FindRepoRoot walks upward from start to the first directory containing a .git entry (directory or file, so git worktrees work).
func Locate ¶
Locate finds the provr.yaml to use and the repo root it belongs to. A non-empty override is used as the config path verbatim.
func ReadProjectName ¶
ReadProjectName returns only the `project` field of the provr.yaml at path. It does not validate the file: a fresh starter may not validate yet.
Types ¶
type Agents ¶
type Agents struct {
// AutoPreview is "on_change" (default) or "on_request".
AutoPreview string `yaml:"auto_preview"`
}
Agents holds settings read by the Claude Code skill; the binary itself does not act on them.
type Healthcheck ¶
type Healthcheck struct {
Service string `yaml:"service"`
Path string `yaml:"path"`
Timeout time.Duration `yaml:"timeout"`
}
Healthcheck describes the optional readiness probe.
type Host ¶
type Host struct {
MachineType string `yaml:"machine_type"`
DiskGB int `yaml:"disk_gb"`
MaxPreviews int `yaml:"max_previews"`
IdleStop time.Duration `yaml:"idle_stop"`
DeleteAfter time.Duration `yaml:"delete_after"`
}
Host describes the preview host VM.
type Project ¶
type Project struct {
Version int `yaml:"version"`
Name string `yaml:"project"`
GCP GCP `yaml:"gcp"`
Host Host `yaml:"host"`
Compose Compose `yaml:"compose"`
// SecretsDir must live outside the repo. A relative value is relative to
// the repo root and is therefore always rejected; use "~/..." or an
// absolute path outside the repo.
SecretsDir string `yaml:"secrets_dir"`
Expose map[string]int `yaml:"expose"`
Healthcheck *Healthcheck `yaml:"healthcheck"`
Commands Commands `yaml:"commands"`
TTL TTL `yaml:"ttl"`
Tailscale Tailscale `yaml:"tailscale"`
Agents Agents `yaml:"agents"`
// RepoRoot is the absolute resolved repo root (filled by the loader).
RepoRoot string `yaml:"-"`
// Path is the absolute path of the loaded provr.yaml (filled by the loader).
Path string `yaml:"-"`
}
Project is the typed provr.yaml schema, version 1.
func Load ¶
Load reads and strictly decodes the provr.yaml at path, applies defaults, fills Path and RepoRoot and validates the result. It returns a valid Project or an error (a *ValidationError, see ErrInvalid, when the content is invalid).
func (*Project) ApplyDefaults ¶
func (p *Project) ApplyDefaults()
ApplyDefaults fills zero-valued fields with their documented defaults.
type Tailscale ¶
type Tailscale struct {
Tag string `yaml:"tag"`
}
Tailscale holds tailnet settings (credentials come from env vars only).
type ValidationError ¶
type ValidationError struct {
// Problems are formatted as "field: problem".
Problems []string
}
ValidationError collects every problem found in a config, in schema order.
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
Error renders one problem per line.
func (*ValidationError) Is ¶
func (e *ValidationError) Is(target error) bool
Is reports whether target is ErrInvalid.