From 587044d5fccedff17fee060728078418d287d87a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leandro=20L=C3=B3pez=20=28inkel=29?= Date: Mon, 7 Feb 2022 11:54:11 -0300 Subject: [PATCH] Fix passing Sentry URL attribute MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sentry's provider expects this value to be configured using the JSON data payload and not from the attribute itself. Signed-off-by: Leandro López (inkel) --- datasource.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/datasource.go b/datasource.go index a44e13ed..085976bc 100644 --- a/datasource.go +++ b/datasource.go @@ -49,6 +49,14 @@ func (ds *DataSource) MarshalJSON() ([]byte, error) { dataSource.JSONData.httpHeaderNames = append(dataSource.JSONData.httpHeaderNames, name) dataSource.SecureJSONData.httpHeaderValues = append(dataSource.SecureJSONData.httpHeaderValues, value) } + + // Sentry provider expects this value in the JSON data payload, + // ignoring the url attribute. This hack allows passing the URL as + // an attribute but then sends it in the payload. + if ds.Type == "grafana-sentry-datasource" { + dataSource.JSONData.URL = ds.URL + } + return json.Marshal(dataSource) } @@ -152,6 +160,7 @@ type JSONData struct { // Used by Sentry OrgSlug string `json:"orgSlug,omitempty"` + URL string `json:"url,omitempty"` // Sentry is not using the datasource URL attribute } // Required to avoid recursion during (un)marshal