template / files / internal / core / postscript.go
postscript.go
| 1 | package core |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | ) |
| 6 | |
| 7 | func createPostScriptArrays( |
| 8 | profile Profile, |
| 9 | postPatternData PostPatternData) ([]string, error) { |
| 10 | array := make([]string, 0) |
| 11 | |
| 12 | if len(profile.PostScripts) == 0 { |
| 13 | return nil, fmt.Errorf("no post scripts specified") |
| 14 | } |
| 15 | |
| 16 | for _, postScriptPattern := range profile.PostScripts { |
| 17 | postScript, err := parseAndExecTemplate(newTemplate(), postScriptPattern, postPatternData) |
| 18 | if err != nil { |
| 19 | return nil, fmt.Errorf("error parsing post script: %w", err) |
| 20 | } |
| 21 | |
| 22 | array = append(array, postScript) |
| 23 | } |
| 24 | |
| 25 | return array, nil |
| 26 | } |