config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package config loads vp.yaml and resolves affected components.

Index

Constants

View Source
const (
	ConsumedDelete  = "delete"
	ConsumedArchive = "archive"
)

Allowed values for plans.consumed.

View Source
const (
	FormatJSON = "json"
	FormatYAML = "yaml"
	FormatTOML = "toml"
	FormatText = "text"
)

Allowed values for components[*].version.format.

View Source
const Filename = "vp.yaml"

Filename is the canonical name of the vp config file.

Variables

View Source
var ErrNotFound = errors.New("vp.yaml not found")

ErrNotFound is returned by FindUpwards (and Load) when no vp.yaml exists in startDir or any of its ancestors.

Functions

func FindUpwards

func FindUpwards(startDir string) (string, error)

FindUpwards searches startDir and its ancestors for a vp.yaml file, returning the absolute path to the first match. ErrNotFound is returned if no ancestor contains one.

func Starter

func Starter() []byte

Starter returns the bytes of the starter vp.yaml that `vp init` writes.

Types

type Component

type Component struct {
	Paths   []string      `yaml:"paths"`
	Version VersionTarget `yaml:"version"`
	Tag     string        `yaml:"tag"`
}

Component is one independently-versioned unit declared in vp.yaml.

type Config

type Config struct {
	Plans      PlansConfig          `yaml:"plans"`
	Components map[string]Component `yaml:"components"`

	// Dir is the directory that contained the loaded vp.yaml.
	Dir string `yaml:"-"`
}

Config is a parsed vp.yaml. After Load, all path-shaped fields (Plans.Dir, Plans.ArchiveDir, Components[*].Version.File) are absolute paths rooted at Dir. Components[*].Paths are kept as relative globs — they are matched against repo-relative file paths by future Affected logic.

func Load

func Load(startDir string) (*Config, error)

Load finds vp.yaml by searching upward from startDir, parses it, validates required fields, and resolves all relative paths against the directory that contained the file.

func (*Config) Affected

func (cfg *Config) Affected(changedPaths []string) ([]string, error)

Affected returns the sorted set of component names whose path globs match at least one entry in changedPaths. Paths under cfg.Plans.Dir and the vp.yaml file itself are ignored — planning churn never triggers a coverage check.

changedPaths must be relative to cfg.Dir (the directory containing vp.yaml).

type PlansConfig

type PlansConfig struct {
	Dir        string `yaml:"dir"`
	Consumed   string `yaml:"consumed"`
	ArchiveDir string `yaml:"archive_dir"`
}

PlansConfig configures the plans directory and how plans are consumed.

type VersionTarget

type VersionTarget struct {
	File   string `yaml:"file"`
	Format string `yaml:"format"`
	Path   string `yaml:"path"`
}

VersionTarget points at the file owning a component's canonical version.

Jump to

Keyboard shortcuts

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