Documentation
¶
Index ¶
- Constants
- Variables
- func BodyTypeToType(bodyType string) string
- func CheckBody(v any) error
- func CheckBodyValue(val reflect.Value) error
- func CheckModules(modules *[]Module) error
- func ExtractExprResult(raw string, data any) (string, error)
- func ExtractExprResultBool(raw string, data ExprData) (bool, error)
- func KebabToPascal(s string) string
- func ReadAndParseModules(target string) (*[]Module, error)
- func Register(typeName string, factory func() Body)
- func ResolveExpr(str string, exprData any) (string, error)
- func ResolveExprMap(strs map[string]string, data any) (map[string]string, error)
- func ResolveExprSlice(strs []string, data any) ([]string, error)
- func ResolveStruct(v any, data ExprData) error
- func SetLogger(l Logger)
- func SetTranslator(fn func(string) string)
- func ValidateConfigRecursive(cfg *Config, basePath string, version Version) error
- type Body
- type Codec
- type Config
- type Engine
- func (e *Engine) Build(ctx context.Context, bc RuntimeContext, modules []Module) error
- func (e *Engine) CollectOutput(text string)
- func (e *Engine) CollectedOutput() string
- func (e *Engine) ExecuteInclude(ctx context.Context, bc RuntimeContext, target string) (map[string]*MapModule, error)
- func (e *Engine) ExecuteModule(ctx context.Context, bc RuntimeContext, module Module, ...) (*MapModule, error)
- func (e *Engine) Hook(stage Stage, fn HookFunc)
- type Envs
- type ExprData
- type HookFunc
- type Logger
- type MapModule
- type Module
- type RuntimeContext
- type Stage
- type ValidationService
- type Version
Constants ¶
const ( StateBefore = "BEFORE" StateAfter = "AFTER" )
Progress event states (values match reply.State*).
Variables ¶
var T_ = func(msgID string) string { return msgID }
T_ is the translation hook; identity by default.
Functions ¶
func BodyTypeToType ¶
func CheckBodyValue ¶
func CheckModules ¶
func KebabToPascal ¶
func ReadAndParseModules ¶
ReadAndParseModules reads modules from a file or URL, codec by extension.
func ResolveExprMap ¶
func ResolveStruct ¶
func SetTranslator ¶
SetTranslator installs a translation function; nil is ignored.
Types ¶
type Body ¶
type Body interface {
Execute(context.Context, RuntimeContext) (any, error)
}
Body is a build module body; its returned value becomes the module output.
type Codec ¶
Codec decodes a build recipe document from one wire format, applying the same strict policy (unknown fields rejected) regardless of format.
type Config ¶
type Config struct {
// Environment vars
Env map[string]string `yaml:"env,omitempty" json:"env,omitempty"`
// Base image to build from
Image string `yaml:"image,omitempty" json:"image,omitempty"`
// Module list
Modules []Module `yaml:"modules,omitempty" json:"modules,omitempty"`
}
func ParseJsonConfigData ¶
func ParseYamlConfigData ¶
func ReadAndParseConfig ¶
ReadAndParseConfig reads a config from a file or URL, codec by extension.
func (*Config) CheckImage ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine is the neutral recipe executor: module loop, expr/env, includes, and stage hooks.
func (*Engine) Build ¶
Build runs the modules wrapped by stage hooks: PreModules → modules → PostModules → PostBuild.
func (*Engine) CollectOutput ¶
CollectOutput accumulates module output for the final report.
func (*Engine) CollectedOutput ¶
CollectedOutput returns the accumulated module output.
func (*Engine) ExecuteInclude ¶
func (*Engine) ExecuteModule ¶
type Logger ¶
type Logger interface {
Debug(args ...any)
Debugf(format string, args ...any)
Info(args ...any)
Warn(args ...any)
Warning(args ...any)
Error(args ...any)
}
Logger is the minimal logging interface.
type Module ¶
type Module struct {
// Module name, for logging
Name string `yaml:"name,omitempty" json:"name,omitempty"`
// Module body type
Type string `yaml:"type" json:"type"`
// Module ID
Id string `yaml:"id,omitempty" json:"id,omitempty"`
// Environmant vars for module
Env map[string]string `yaml:"env,omitempty" json:"env,omitempty"`
// Condition in expr language
If string `yaml:"if,omitempty" json:"if,omitempty"`
// Module body
Body Body `yaml:"body" json:"body"`
// Output data
Output map[string]string `yaml:"output,omitempty" json:"output,omitempty"`
}
func (*Module) UnmarshalJSON ¶
type RuntimeContext ¶
type RuntimeContext interface {
Runner() command.Runner
CollectOutput(text string)
EmitEvent(ctx context.Context, state, name, view string)
ExecuteInclude(ctx context.Context, target string) (map[string]*MapModule, error)
}
RuntimeContext is the engine's neutral capability set available to every module.
type ValidationService ¶
type ValidationService struct {
// contains filtered or unexported fields
}
ValidationService recursively validates a config and all its includes.
func NewValidationService ¶
func NewValidationService(exprData ExprData) *ValidationService
NewValidationService creates a validation service.