Skip to content

Commit

Permalink
Merge pull request #189 from haad/feat/on_empty_error
Browse files Browse the repository at this point in the history
add if empty error option
  • Loading branch information
tombokombo authored Nov 30, 2023
2 parents 5060490 + d0f4e40 commit 338a967
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion resource/template/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ type TemplateResource struct {
Src string
Mkdirs bool `toml:"make_directories"`
Lang string `toml:"lang"`
OnEmptyError bool `toml:"on_empty_error"`
StageFile *os.File
Uid int
funcMap map[string]interface{}
Expand Down Expand Up @@ -224,7 +225,9 @@ func (t *TemplateResource) setVars() error {
return err
}
log.Debug("Got the following map from store: %v", result)

if t.OnEmptyError && len(result) == 0 {
log.Fatal("on empty error enabled, empty result returned, exiting")
}
t.store.Purge()

for k, v := range result {
Expand Down

0 comments on commit 338a967

Please sign in to comment.