templatecatalog

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2026 License: GPL-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package templatecatalog reads and validates Galaxio template registries and packs.

Index

Constants

View Source
const (
	DefaultRegistrySource = "github:galax-io/galaxio-template-registry"
)

Variables

View Source
var ErrTemplateNotFound = errors.New("template not found")

ErrTemplateNotFound is returned when a registry does not contain a requested template reference.

Functions

func CacheDir added in v0.4.0

func CacheDir() (string, error)

func ClearCache added in v0.4.0

func ClearCache() (string, error)

func ValidatePack

func ValidatePack(pack Pack) error

ValidatePack validates pack-level invariants.

func ValidateRegistry

func ValidateRegistry(registry Registry) error

ValidateRegistry validates registry-level invariants.

func ValidateTemplate

func ValidateTemplate(template Template) error

ValidateTemplate validates template-level invariants.

Types

type Pack

type Pack struct {
	APIVersion  string         `yaml:"apiVersion"`
	Kind        string         `yaml:"kind"`
	Name        string         `yaml:"name"`
	Version     string         `yaml:"version"`
	Description string         `yaml:"description"`
	Templates   []PackTemplate `yaml:"templates"`
}

Pack describes templates available in one template pack repository.

type PackTemplate

type PackTemplate struct {
	Name        string `yaml:"name"`
	Version     string `yaml:"version"`
	Path        string `yaml:"path"`
	Description string `yaml:"description"`
}

PackTemplate points to one template manifest inside a pack.

type Registry

type Registry struct {
	APIVersion string         `yaml:"apiVersion"`
	Kind       string         `yaml:"kind"`
	Version    string         `yaml:"version,omitempty"`
	Packs      []RegistryPack `yaml:"packs"`
}

Registry is the root index of available template packs.

type RegistryPack

type RegistryPack struct {
	Name        string `yaml:"name"`
	Source      string `yaml:"source"`
	Description string `yaml:"description"`
}

RegistryPack describes one template pack source.

type RenderOptions added in v0.4.0

type RenderOptions struct {
	RegistrySource string
	TemplateName   string
	Destination    string
	Values         map[string]string
}

RenderOptions configures template rendering.

type RenderResult added in v0.4.0

type RenderResult struct {
	Template    string `json:"template"`
	Version     string `json:"version,omitempty"`
	PackVersion string `json:"packVersion"`
	Source      string `json:"source"`
	Destination string `json:"destination"`
	Files       int    `json:"files"`
	Status      string `json:"status"`
}

RenderResult describes rendered template output.

type SourceError added in v0.3.1

type SourceError struct {
	Source string
	What   string
	Err    error
}

SourceError adds user-facing context to source loading failures.

func (SourceError) Error added in v0.3.1

func (e SourceError) Error() string

func (SourceError) Unwrap added in v0.3.1

func (e SourceError) Unwrap() error

type SourceFetcher

type SourceFetcher struct {
	HTTPClient *http.Client
}

SourceFetcher loads manifest files from local paths or remote sources.

func (SourceFetcher) FindTemplate added in v0.3.1

func (f SourceFetcher) FindTemplate(ctx context.Context, registrySource string, name string) (TemplateRef, error)

FindTemplate resolves a template reference from a registry.

func (SourceFetcher) ListTemplates added in v0.3.1

func (f SourceFetcher) ListTemplates(ctx context.Context, registrySource string) ([]TemplateRef, error)

ListTemplates reads the registry and resolves templates from referenced packs.

func (SourceFetcher) LoadPack

func (f SourceFetcher) LoadPack(ctx context.Context, source string) (Pack, error)

LoadPack loads and validates a template pack from source.

func (SourceFetcher) LoadRegistry

func (f SourceFetcher) LoadRegistry(ctx context.Context, source string) (Registry, error)

LoadRegistry loads and validates a registry manifest from source.

func (SourceFetcher) LoadTemplate

func (f SourceFetcher) LoadTemplate(ctx context.Context, packSource string, templatePath string) (Template, error)

LoadTemplate loads and validates a template manifest from a pack source.

func (SourceFetcher) Render added in v0.4.0

Render resolves a template from a registry and renders it into a destination.

func (SourceFetcher) ValidateSource

func (f SourceFetcher) ValidateSource(ctx context.Context, source string) error

ValidateSource validates a template pack source and its template manifests.

type Template

type Template struct {
	APIVersion  string                   `yaml:"apiVersion"`
	Kind        string                   `yaml:"kind"`
	Name        string                   `yaml:"name"`
	DisplayName string                   `yaml:"displayName"`
	Description string                   `yaml:"description"`
	Engine      string                   `yaml:"engine"`
	Tags        []string                 `yaml:"tags"`
	Inputs      map[string]TemplateInput `yaml:"inputs"`
	Files       []TemplateFile           `yaml:"files"`
}

Template describes one renderable template.

type TemplateFile

type TemplateFile struct {
	From string `yaml:"from"`
	To   string `yaml:"to"`
	If   string `yaml:"if"`
}

TemplateFile describes one file mapping in a template.

type TemplateInput added in v0.4.0

type TemplateInput struct {
	Type        string `yaml:"type"`
	Default     any    `yaml:"default"`
	Description string `yaml:"description"`
}

TemplateInput describes one configurable template input.

type TemplateRef

type TemplateRef struct {
	Name        string `json:"name"`
	Pack        string `json:"pack"`
	PackVersion string `json:"packVersion"`
	Version     string `json:"version,omitempty"`
	Path        string `json:"-"`
	Source      string `json:"source"`
	Description string `json:"description,omitempty"`
	Templates   int    `json:"templates"`
	Placeholder bool   `json:"placeholder"`
}

TemplateRef is a resolved template available to users.

Jump to

Keyboard shortcuts

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