chilly-dream-30512
09/15/2024, 12:40 PMfunc (Validator) Create(ctx context.Context, name string, input ValidatorArgs, preview bool) (string, ValidatorState, error) {
state := ValidatorState{ValidatorArgs: input}
if preview {
return name, state, nil
}
// Load the template file
tmpl, err := template.ParseFiles("templates/validator/dummy.sh.tmpl")
if err != nil {
return "", ValidatorState{}, fmt.Errorf("failed to parse template: %w", err)
}
// Create a buffer to store the executed template
var scriptBuffer bytes.Buffer
err = tmpl.Execute(&scriptBuffer, input)
if err != nil {
return "", ValidatorState{}, fmt.Errorf("failed to execute template: %w", err)
}
...
chilly-dream-30512
09/15/2024, 12:47 PM//go:embed dummy.sh.tmpl
var dummyTemplate string