config

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2026 License: BlueOak-1.0.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const ConfigSwatchPath = ".tailor.yml"

ConfigSwatchPath is the path of the config swatch entry, which is excluded from merge because it describes the config file itself.

Variables

This section is empty.

Functions

func Exists

func Exists(dir string) bool

Exists reports whether .tailor.yml is present in dir.

func MergeDefaultLabels

func MergeDefaultLabels(cfg *Config) bool

MergeDefaultLabels populates cfg.Labels from the embedded default configuration when the slice is empty. Both present-but-empty (labels: []) and absent (no labels key) result in len==0 after YAML unmarshalling, so both cases receive the default labels. If cfg.Labels already contains entries, the function leaves them unchanged and returns false.

func MergeDefaultRepoSettings

func MergeDefaultRepoSettings(cfg *Config) bool

MergeDefaultRepoSettings fills nil pointer fields in cfg.Repository from the embedded default configuration. It skips Description, Homepage, and Topics. If cfg.Repository is nil, it allocates a new RepositorySettings. Returns true when at least one field was added.

func MergeRepoSettings

func MergeRepoSettings(cfg *Config, live *model.RepositorySettings, description string)

MergeRepoSettings replaces cfg.Repository with the live settings retrieved from the GitHub API. The description flag, when non-empty, overrides whatever the live settings carried. Empty string pointer fields for Description and Homepage are normalised to nil so they are omitted from YAML.

func ValidateDuplicatePaths

func ValidateDuplicatePaths(cfg *Config) error

ValidateDuplicatePaths checks that no two swatches share a path. Returns an error identifying the duplicate.

func ValidateLabels

func ValidateLabels(cfg *Config) error

ValidateLabels checks that every label entry has valid name, color, and description fields. Rejects duplicate names (case-insensitive).

func ValidatePaths

func ValidatePaths(cfg *Config) error

ValidatePaths checks that every swatch path in cfg matches a known embedded swatch. Returns an error listing the unrecognised path and all valid paths.

func ValidateRepoSettings

func ValidateRepoSettings(cfg *Config) error

ValidateRepoSettings checks that every field name in cfg.Repository matches the supported settings list. Returns an error identifying the unrecognised field and listing all valid field names.

func ValidateTopics

func ValidateTopics(cfg *Config) error

ValidateTopics checks that every topic, if set, starts with a lowercase letter or number, contains only lowercase alphanumerics and hyphens, and does not exceed 50 characters.

func ValidateWorkflowPermissions

func ValidateWorkflowPermissions(cfg *Config) error

ValidateWorkflowPermissions checks that default_workflow_permissions, if set, is either "read" or "write".

func Write

func Write(dir string, cfg *Config, date string, verb string) error

Write renders cfg to <dir>/.tailor.yml with the given header date and verb.

Types

type Config

type Config struct {
	License    string                    `yaml:"license"`
	Repository *model.RepositorySettings `yaml:"repository,omitempty"`
	Labels     []model.LabelEntry        `yaml:"labels,omitempty"`
	Swatches   []SwatchEntry             `yaml:"swatches"`
}

Config represents the contents of .tailor.yml.

func DefaultConfig

func DefaultConfig(license string) (*Config, error)

DefaultConfig returns the embedded default configuration with the given license. It parses swatches/.tailor.yml from the embedded filesystem, validates its contents, and overrides the license field.

func Load

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

Load reads and parses .tailor.yml from dir, returning the validated Config or an error.

type SwatchEntry

type SwatchEntry struct {
	Path       string                `yaml:"path"`
	Alteration swatch.AlterationMode `yaml:"alteration"`
}

SwatchEntry describes a single swatch entry in the config file.

func MergeDefaultSwatches

func MergeDefaultSwatches(cfg *Config) []SwatchEntry

MergeDefaultSwatches appends missing default swatch entries to cfg.Swatches. It skips the config swatch itself. Existing entries are matched by path, so an altered mode does not cause duplication. It returns the slice of newly added entries.

func MergeDefaults

func MergeDefaults(cfg *Config) (swatchesAdded []SwatchEntry, repoMerged bool, labelsMerged bool)

MergeDefaults calls DefaultConfig once and delegates to the three merge functions, avoiding redundant YAML parses. Returns the newly added swatch entries and whether repo settings or labels were merged.

Jump to

Keyboard shortcuts

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