Skip to content

Commit 9c19232

Browse files
authored
Merge pull request #56 from sjauld/bugfix/data_source_404
Check for data source 404 in the correct place
2 parents f825776 + de90bc4 commit 9c19232

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

grafana/resource_data_source.go

+5-6
Original file line numberDiff line numberDiff line change
@@ -167,17 +167,16 @@ func ReadDataSource(d *schema.ResourceData, meta interface{}) error {
167167
idStr := d.Id()
168168
id, err := strconv.ParseInt(idStr, 10, 64)
169169
if err != nil {
170-
if err.Error() == "404 Not Found" {
171-
log.Printf("[WARN] removing datasource %s from state because it no longer exists in grafana", d.Get("name").(string))
172-
d.SetId("")
173-
return nil
174-
}
175170
return fmt.Errorf("Invalid id: %#v", idStr)
176171
}
177172

178173
dataSource, err := client.DataSource(id)
179174
if err != nil {
180-
175+
if err.Error() == "404 Not Found" {
176+
log.Printf("[WARN] removing datasource %s from state because it no longer exists in grafana", d.Get("name").(string))
177+
d.SetId("")
178+
return nil
179+
}
181180
return err
182181
}
183182

0 commit comments

Comments
 (0)