Skip to content

Commit 479f643

Browse files
authored
Merge pull request #249 from brewkode/fix/http_datasource
fix: int64 conversion for collector_id in datasource + add docs
2 parents d03f2c8 + de4661a commit 479f643

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

sumologic/data_source_sumologic_http_source.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,16 @@ func dataSourceSumologicHTTPSourceRead(d *schema.ResourceData, meta interface{})
5555
c := meta.(*Client)
5656

5757
id, _ := strconv.Atoi(d.Id())
58-
source, err := c.GetSourceName(d.Get("collector_id").(int64), d.Get("name").(string))
58+
var collectorId int64
59+
switch cid := d.Get("collector_id").(type) {
60+
case int:
61+
collectorId = int64(cid)
62+
case int64:
63+
collectorId = cid
64+
default:
65+
return fmt.Errorf("unknown data type of collector_id: %T, value: %v", cid, cid)
66+
}
67+
source, err := c.GetSourceName(collectorId, d.Get("name").(string))
5968

6069
if err != nil {
6170
return err

0 commit comments

Comments
 (0)