Skip to content
This repository was archived by the owner on Jan 15, 2024. It is now read-only.

Commit 8d1d81f

Browse files
authored
Merge pull request #58 from grafana/inkel/sentry-url-attribute
Fix passing Sentry URL attribute
2 parents fc20dfe + 587044d commit 8d1d81f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

datasource.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ func (ds *DataSource) MarshalJSON() ([]byte, error) {
4949
dataSource.JSONData.httpHeaderNames = append(dataSource.JSONData.httpHeaderNames, name)
5050
dataSource.SecureJSONData.httpHeaderValues = append(dataSource.SecureJSONData.httpHeaderValues, value)
5151
}
52+
53+
// Sentry provider expects this value in the JSON data payload,
54+
// ignoring the url attribute. This hack allows passing the URL as
55+
// an attribute but then sends it in the payload.
56+
if ds.Type == "grafana-sentry-datasource" {
57+
dataSource.JSONData.URL = ds.URL
58+
}
59+
5260
return json.Marshal(dataSource)
5361
}
5462

@@ -152,6 +160,7 @@ type JSONData struct {
152160

153161
// Used by Sentry
154162
OrgSlug string `json:"orgSlug,omitempty"`
163+
URL string `json:"url,omitempty"` // Sentry is not using the datasource URL attribute
155164
}
156165

157166
// Required to avoid recursion during (un)marshal

0 commit comments

Comments
 (0)