swatch

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: BlueOak-1.0.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const LicenseDestination = "LICENSE"

LicenseDestination is the destination path for the licence file. Licences are not embedded swatches; they are fetched via gh at alter time.

Variables

This section is empty.

Functions

func Content

func Content(path string) ([]byte, error)

Content returns the embedded bytes for the swatch identified by path. The path is relative to swatches/, e.g. ".github/workflows/tailor.yml".

func EvaluateTrigger

func EvaluateTrigger(path string, repo any) bool

EvaluateTrigger returns true when the path has no trigger condition or when the matching field on repo satisfies the condition. It returns false if repo is nil and a trigger exists, or if the field value does not match. The repo parameter must be a pointer to a struct with yaml-tagged fields.

func Paths

func Paths() []string

Paths returns the paths of all registered swatches, sorted lexicographically.

Types

type AlterationMode

type AlterationMode string

AlterationMode controls how a swatch is applied to a project.

const (
	Always    AlterationMode = "always"
	FirstFit  AlterationMode = "first-fit"
	Triggered AlterationMode = "triggered"
	Never     AlterationMode = "never"
)

type Category

type Category string

Category classifies a swatch as either a community health file or a development tooling file.

const (
	Health      Category = "health"
	Development Category = "development"
)

type Swatch

type Swatch struct {
	Path              string
	DefaultAlteration AlterationMode
	Category          Category
}

Swatch describes a single template file with its path, default alteration mode, and category.

func All

func All() []Swatch

All returns every registered swatch in definition order.

func HealthSwatches

func HealthSwatches() []Swatch

HealthSwatches returns only the swatches categorised as health.

type TriggerCondition

type TriggerCondition struct {
	ConfigField string
	Value       any
}

TriggerCondition maps a swatch path to a config field and the value that must match for the swatch to be deployed.

func LookupTrigger

func LookupTrigger(path string) (TriggerCondition, bool)

LookupTrigger returns the trigger condition for the given swatch path and true if one exists, or a zero value and false otherwise.

Jump to

Keyboard shortcuts

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