Skip to content

Commit 5f9f227

Browse files
authored
fix(instance): fix data source image exact name (#544)
1 parent e4f9560 commit 5f9f227

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

scaleway/data_source_instance_image.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,15 @@ func dataSourceScalewayInstanceImageRead(d *schema.ResourceData, m interface{})
116116
sort.Slice(res.Images, func(i, j int) bool {
117117
return res.Images[i].ModificationDate.After(*res.Images[j].ModificationDate)
118118
})
119-
imageID = res.Images[0].ID
119+
for _, image := range res.Images {
120+
if image.Name == d.Get("name").(string) {
121+
imageID = image.ID
122+
break
123+
}
124+
}
125+
if imageID == "" {
126+
return fmt.Errorf("no image found with the name %s and architecture %s in zone %s", d.Get("name"), d.Get("architecture"), zone)
127+
}
120128
}
121129

122130
zonedID := datasourceNewZonedID(imageID, zone)

0 commit comments

Comments
 (0)