template

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package template provides pipeline YAML building with topological sorting for correct job dependency ordering.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

type Builder struct{}

Builder builds pipeline YAML with proper job ordering.

func NewBuilder

func NewBuilder() *Builder

NewBuilder creates a new Builder.

func (*Builder) BuildOrder

func (b *Builder) BuildOrder(jobs []JobDep) ([]string, error)

BuildOrder returns jobs ordered by their dependencies. This is an alias for TopologicalSort for convenience.

func (*Builder) GetDependencyGraph

func (b *Builder) GetDependencyGraph(jobs []JobDep) map[string][]string

GetDependencyGraph returns a map of job name to its direct dependencies.

func (*Builder) GetReverseDependencyGraph

func (b *Builder) GetReverseDependencyGraph(jobs []JobDep) map[string][]string

GetReverseDependencyGraph returns a map of job name to jobs that depend on it.

func (*Builder) TopologicalSort

func (b *Builder) TopologicalSort(jobs []JobDep) ([]string, error)

TopologicalSort orders jobs based on their dependencies using Kahn's algorithm. Returns an error if a cycle is detected.

func (*Builder) ValidateDependencies

func (b *Builder) ValidateDependencies(jobs []JobDep) []string

ValidateDependencies checks that all job dependencies exist. Returns a list of missing dependencies.

type JobDep

type JobDep struct {
	Name         string   `json:"name"`
	Dependencies []string `json:"dependencies,omitempty"`
}

JobDep represents a job with its dependencies.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry manages pipeline templates stored in the .wetwire/templates directory.

func NewRegistry

func NewRegistry(baseDir string) *Registry

NewRegistry creates a new template registry rooted at the given directory.

func (*Registry) Add

func (r *Registry) Add(srcDir string) error

Add adds a template from the given directory to the registry.

func (*Registry) Get

func (r *Registry) Get(name string) (*TemplateMetadata, error)

Get retrieves a template by name.

func (*Registry) Init

func (r *Registry) Init(name, outputDir string, vars map[string]string) error

Init scaffolds a template to the output directory with the given variables.

func (*Registry) List

func (r *Registry) List() ([]TemplateMetadata, error)

List returns all available templates.

func (*Registry) Remove

func (r *Registry) Remove(name string) error

Remove removes a template from the registry.

func (*Registry) TemplatesDir

func (r *Registry) TemplatesDir() string

TemplatesDir returns the path to the templates directory.

type TemplateMetadata

type TemplateMetadata struct {
	Name        string             `yaml:"name" json:"name"`
	Description string             `yaml:"description,omitempty" json:"description,omitempty"`
	Variables   []TemplateVariable `yaml:"variables,omitempty" json:"variables,omitempty"`
	Path        string             `yaml:"-" json:"path,omitempty"` // Path to the template directory
}

TemplateMetadata contains metadata about a pipeline template.

type TemplateVariable

type TemplateVariable struct {
	Name        string `yaml:"name" json:"name"`
	Default     string `yaml:"default,omitempty" json:"default,omitempty"`
	Description string `yaml:"description,omitempty" json:"description,omitempty"`
}

TemplateVariable represents a variable that can be customized in a template.

func (TemplateVariable) HasDefault

func (v TemplateVariable) HasDefault() bool

HasDefault returns true if the variable has a default value.

Jump to

Keyboard shortcuts

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