package modules import ( "context" "io" "log/slog" "code.icb4dc0.de/buildr/buildr/modules/state" "github.com/hashicorp/hcl/v2" ) type ExecutionContext interface { context.Context Name() string WorkingDir() string OutDir() string BinariesDir() string StdOut() io.Writer StdErr() io.Writer Logger() *slog.Logger GetState(ctx context.Context, key string) ([]byte, state.Metadata, error) SetState(ctx context.Context, key string, value []byte) error } type StateEncoder[T any] interface { Get(ctx context.Context, key string) (val T, ok bool, meta state.Metadata, err error) Set(ctx context.Context, key string, val T) error } type ModuleWithMeta interface { Module Unwrap() Module SetModule(m Module) ID() string Name() string SetName(name string) ShouldSkip() bool Dependencies() []string InputMappings() map[string]string OutDir() string ContainerSpec() *ContainerSpec UnmarshalHCL(body hcl.Body, ctx *hcl.EvalContext) hcl.Diagnostics } type Initializer interface { Init(hclCtx *hcl.EvalContext) (Module, error) } type Helper interface { Help(ctx context.Context) (help Help, err error) } type Module interface { Execute(ctx ExecutionContext) error Category() Category Type() string } type BinaryNamer interface { BinaryName(ctx context.Context) (binaryName string, err error) } type ToolModule interface { Module BinaryNamer } type Factory interface { Create() ModuleWithMeta } var _ Factory = (*ModuleFactoryFunc)(nil) type ModuleFactoryFunc func() ModuleWithMeta func (f ModuleFactoryFunc) Create() ModuleWithMeta { return f() }