package executor
import (
"context"
"github.com/osmedeus/osmedeus-ng/internal/core"
"github.com/osmedeus/osmedeus-ng/internal/template"
)
type MyNewExecutor struct {
templateEngine *template.Engine
}
func NewMyNewExecutor(templateEngine *template.Engine) *MyNewExecutor {
return &MyNewExecutor{
templateEngine: templateEngine,
}
}
func (e *MyNewExecutor) Execute(
ctx context.Context,
step *core.Step,
execCtx *core.ExecutionContext,
) (*core.StepResult, error) {
// 1. Render templates in step fields
renderedField, err := e.templateEngine.Render(step.MyNewField, execCtx.Variables)
if err != nil {
return nil, fmt.Errorf("template render failed: %w", err)
}
// 2. Perform your step logic
output, err := e.doSomething(ctx, renderedField, step.MyNewConfig)
if err != nil {
return &core.StepResult{
Success: false,
Error: err,
}, nil
}
// 3. Return result
return &core.StepResult{
Success: true,
Output: output,
}, nil
}
func (e *MyNewExecutor) doSomething(
ctx context.Context,
field string,
config *core.MyNewConfig,
) (string, error) {
// Implementation here
return "result", nil
}