config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: Apache-2.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package config defines the provr.yaml project configuration (schema v1).

Index

Constants

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

View Source
const FileName = "provr.yaml"

FileName is the name of the project config file.

Variables

View Source
var ErrInvalid = errors.New("invalid provr.yaml")

ErrInvalid is matched by errors.Is for any *ValidationError.

View Source
var ErrNoRepo = errors.New("not inside a git repository")

ErrNoRepo is returned when no enclosing git repository is found.

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

func FindRepoRoot(start string) (string, error)

FindRepoRoot walks upward from start to the first directory containing a .git entry (directory or file, so git worktrees work).

func Locate

func Locate(cwd, override string) (path, repoRoot string, err error)

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

func ReadProjectName(path string) (string, error)

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 Commands

type Commands struct {
	Seed string `yaml:"seed"`
	Test string `yaml:"test"`
}

Commands are optional commands run inside the preview.

type Compose

type Compose struct {
	Files    []string `yaml:"files"`
	Profiles []string `yaml:"profiles"`
}

Compose lists the compose files and profiles to run.

type GCP

type GCP struct {
	Project string `yaml:"project"`
	Zone    string `yaml:"zone"`
}

GCP identifies where hosts are created.

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

func Load(path string) (*Project, error)

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 LoadFrom

func LoadFrom(cwd, override string) (*Project, error)

LoadFrom locates provr.yaml (see Locate) and loads it.

func (*Project) ApplyDefaults

func (p *Project) ApplyDefaults()

ApplyDefaults fills zero-valued fields with their documented defaults.

func (*Project) Validate

func (p *Project) Validate() error

Validate checks the whole config and reports every problem at once. It returns nil when valid, else a *ValidationError. It also expands a leading "~/" in SecretsDir (stored back on p.SecretsDir).

type TTL

type TTL struct {
	Default time.Duration `yaml:"default"`
	Max     time.Duration `yaml:"max"`
}

TTL bounds preview lifetime.

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.

Jump to

Keyboard shortcuts

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