Skip to content

Commit

Permalink
B #479: fix data template filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
treywelsh committed Aug 1, 2023
1 parent f8b4ff5 commit 8457174
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion opennebula/data_opennebula_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,20 @@ func templateFilter(d *schema.ResourceData, meta interface{}) (*templateSc.Templ
return nil, err
}

newMatched := make([]*templateSc.Template, 0)
var newMatched []*templateSc.Template

id := d.Get("id").(int)
if id != -1 {
newMatched = make([]*templateSc.Template, 0)

for _, tpl := range matched {
if tpl.ID != id {
continue
}
newMatched = append(newMatched, tpl)
}
} else {
newMatched = matched
}

// the template datasource should match at most one element
Expand Down

0 comments on commit 8457174

Please sign in to comment.