diff --git a/CHANGELOG.md b/CHANGELOG.md index bb2b7170f..33515fdc2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# 1.3.0 (Unreleased) + +BUG FIXES: + +* data/opennebula_template: fix filtering (#479) + # 1.3.0 (July 28th, 2023) FEATURES: @@ -16,7 +22,7 @@ DEPRECATION: BUG FIXES: -* data/opennebula_template: fix filtering and documentation (#470) +* data/opennebula_templates: fix filtering and documentation (#470) * resources/opennebula_virtual_machine: fix a check on context * resources/opennebula_image: remove useless group checks (#460) * resources/opennebula_security_group: remove useless group checks (#460) diff --git a/opennebula/data_opennebula_template.go b/opennebula/data_opennebula_template.go index b0b4252c3..145c4ece1 100644 --- a/opennebula/data_opennebula_template.go +++ b/opennebula/data_opennebula_template.go @@ -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