Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

B-479: fix data template name #480

Merged
merged 2 commits into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 1.3.0 (Unreleased)

BUG FIXES:

* data/opennebula_template: fix filtering (#479)

# 1.3.0 (July 28th, 2023)

FEATURES:
Expand All @@ -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)
Expand Down
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
Loading