Skip to content

Commit

Permalink
Bump github.com/grafana/grafana-plugin-sdk-go and remove deprecated e…
Browse files Browse the repository at this point in the history
…xperimental error source
  • Loading branch information
ivanahuckova committed Jan 17, 2025
1 parent 86191e4 commit 4304e52
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 23 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/ClickHouse/clickhouse-go/v2 v2.30.0
github.com/docker/docker v27.4.0+incompatible
github.com/docker/go-units v0.5.0
github.com/grafana/grafana-plugin-sdk-go v0.262.0
github.com/grafana/grafana-plugin-sdk-go v0.263.0
github.com/grafana/sqlds/v4 v4.1.7
github.com/paulmach/orb v0.11.1
github.com/pkg/errors v0.9.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
github.com/grafana/dataplane/sdata v0.0.9 h1:AGL1LZnCUG4MnQtnWpBPbQ8ZpptaZs14w6kE/MWfg7s=
github.com/grafana/dataplane/sdata v0.0.9/go.mod h1:Jvs5ddpGmn6vcxT7tCTWAZ1mgi4sbcdFt9utQx5uMAU=
github.com/grafana/grafana-plugin-sdk-go v0.262.0 h1:R2DV6lwBQE5zaogxX3PorD9Seo8CXA8YuStf84oqwkk=
github.com/grafana/grafana-plugin-sdk-go v0.262.0/go.mod h1:U43Cnrj/9DNYyvFcNdeUWNjMXTKNB0jcTcQGpWKd2gw=
github.com/grafana/grafana-plugin-sdk-go v0.263.0 h1:y8vo7hUm50Ei7rdeNNivgehHNsOmCjc8wRmBat5yA3w=
github.com/grafana/grafana-plugin-sdk-go v0.263.0/go.mod h1:U43Cnrj/9DNYyvFcNdeUWNjMXTKNB0jcTcQGpWKd2gw=
github.com/grafana/otel-profiling-go v0.5.1 h1:stVPKAFZSa7eGiqbYuG25VcqYksR6iWvF3YH66t4qL8=
github.com/grafana/otel-profiling-go v0.5.1/go.mod h1:ftN/t5A/4gQI19/8MoWurBEtC6gFw8Dns1sJZ9W4Tls=
github.com/grafana/pyroscope-go/godeltaprof v0.1.8 h1:iwOtYXeeVSAeYefJNaxDytgjKtUuKQbJqgAIjlnicKg=
Expand Down
14 changes: 7 additions & 7 deletions pkg/macros/macros.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (

"github.com/grafana/sqlds/v4"

"github.com/grafana/grafana-plugin-sdk-go/backend"
"github.com/grafana/grafana-plugin-sdk-go/data/sqlutil"
"github.com/grafana/grafana-plugin-sdk-go/experimental/errorsource"
)

// Converts a time.Time to a Date
Expand Down Expand Up @@ -49,7 +49,7 @@ func ToTimeFilterMs(query *sqlutil.Query, args []string) (string, error) {

func TimeFilter(query *sqlutil.Query, args []string) (string, error) {
if len(args) != 1 {
return "", errorsource.DownstreamError(fmt.Errorf("%w: expected 1 argument, received %d", sqlutil.ErrorBadArgumentCount, len(args)), false)
return "", backend.DownstreamError(fmt.Errorf("%w: expected 1 argument, received %d", sqlutil.ErrorBadArgumentCount, len(args)))
}

var (
Expand All @@ -63,7 +63,7 @@ func TimeFilter(query *sqlutil.Query, args []string) (string, error) {

func TimeFilterMs(query *sqlutil.Query, args []string) (string, error) {
if len(args) != 1 {
return "", errorsource.DownstreamError(fmt.Errorf("%w: expected 1 argument, received %d", sqlutil.ErrorBadArgumentCount, len(args)), false)
return "", backend.DownstreamError(fmt.Errorf("%w: expected 1 argument, received %d", sqlutil.ErrorBadArgumentCount, len(args)))
}

var (
Expand All @@ -77,7 +77,7 @@ func TimeFilterMs(query *sqlutil.Query, args []string) (string, error) {

func DateFilter(query *sqlutil.Query, args []string) (string, error) {
if len(args) != 1 {
return "", errorsource.DownstreamError(fmt.Errorf("%w: expected 1 argument, received %d", sqlutil.ErrorBadArgumentCount, len(args)), false)
return "", backend.DownstreamError(fmt.Errorf("%w: expected 1 argument, received %d", sqlutil.ErrorBadArgumentCount, len(args)))
}
var (
column = args[0]
Expand All @@ -90,7 +90,7 @@ func DateFilter(query *sqlutil.Query, args []string) (string, error) {

func DateTimeFilter(query *sqlutil.Query, args []string) (string, error) {
if len(args) != 2 {
return "", errorsource.DownstreamError(fmt.Errorf("%w: expected 2 arguments, received %d", sqlutil.ErrorBadArgumentCount, len(args)), false)
return "", backend.DownstreamError(fmt.Errorf("%w: expected 2 arguments, received %d", sqlutil.ErrorBadArgumentCount, len(args)))
}
var (
dateColumn = args[0]
Expand All @@ -106,7 +106,7 @@ func DateTimeFilter(query *sqlutil.Query, args []string) (string, error) {

func TimeInterval(query *sqlutil.Query, args []string) (string, error) {
if len(args) != 1 {
return "", errorsource.DownstreamError(fmt.Errorf("%w: expected 1 argument, received %d", sqlutil.ErrorBadArgumentCount, len(args)), false)
return "", backend.DownstreamError(fmt.Errorf("%w: expected 1 argument, received %d", sqlutil.ErrorBadArgumentCount, len(args)))
}

seconds := math.Max(query.Interval.Seconds(), 1)
Expand All @@ -115,7 +115,7 @@ func TimeInterval(query *sqlutil.Query, args []string) (string, error) {

func TimeIntervalMs(query *sqlutil.Query, args []string) (string, error) {
if len(args) != 1 {
return "", errorsource.DownstreamError(fmt.Errorf("%w: expected 1 argument, received %d", sqlutil.ErrorBadArgumentCount, len(args)), false)
return "", backend.DownstreamError(fmt.Errorf("%w: expected 1 argument, received %d", sqlutil.ErrorBadArgumentCount, len(args)))
}

milliseconds := math.Max(float64(query.Interval.Milliseconds()), 1)
Expand Down
7 changes: 3 additions & 4 deletions pkg/plugin/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"github.com/grafana/grafana-plugin-sdk-go/build"
"github.com/grafana/grafana-plugin-sdk-go/data"
"github.com/grafana/grafana-plugin-sdk-go/data/sqlutil"
"github.com/grafana/grafana-plugin-sdk-go/experimental/errorsource"
"github.com/grafana/sqlds/v4"
"github.com/pkg/errors"
"golang.org/x/net/proxy"
Expand All @@ -41,7 +40,7 @@ func getTLSConfig(settings Settings) (*tls.Config, error) {
if settings.TlsAuthWithCACert && len(settings.TlsCACert) > 0 {
caPool := x509.NewCertPool()
if ok := caPool.AppendCertsFromPEM([]byte(settings.TlsCACert)); !ok {
return nil, errorsource.DownstreamError(ErrorInvalidCACertificate, false)
return nil, backend.DownstreamError(ErrorInvalidCACertificate)
}
tlsConfig.RootCAs = caPool
}
Expand Down Expand Up @@ -121,11 +120,11 @@ func (h *Clickhouse) Connect(ctx context.Context, config backend.DataSourceInsta
}
t, err := strconv.Atoi(settings.DialTimeout)
if err != nil {
return nil, errorsource.DownstreamError(errors.New(fmt.Sprintf("invalid timeout: %s", settings.DialTimeout)), false)
return nil, backend.DownstreamError(errors.New(fmt.Sprintf("invalid timeout: %s", settings.DialTimeout)))
}
qt, err := strconv.Atoi(settings.QueryTimeout)
if err != nil {
return nil, errorsource.DownstreamError(errors.New(fmt.Sprintf("invalid query timeout: %s", settings.QueryTimeout)), false)
return nil, backend.DownstreamError(errors.New(fmt.Sprintf("invalid query timeout: %s", settings.QueryTimeout)))
}
protocol := clickhouse.Native
if settings.Protocol == "http" {
Expand Down
17 changes: 8 additions & 9 deletions pkg/plugin/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (

"github.com/grafana/grafana-plugin-sdk-go/backend"
"github.com/grafana/grafana-plugin-sdk-go/backend/proxy"
"github.com/grafana/grafana-plugin-sdk-go/experimental/errorsource"
)

// Settings - data loaded from grafana settings database
Expand Down Expand Up @@ -53,10 +52,10 @@ const secureHeaderKeyPrefix = "secureHttpHeaders."

func (settings *Settings) isValid() (err error) {
if settings.Host == "" {
return errorsource.DownstreamError(ErrorMessageInvalidHost, false)
return backend.DownstreamError(ErrorMessageInvalidHost)
}
if settings.Port == 0 {
return errorsource.DownstreamError(ErrorMessageInvalidPort, false)
return backend.DownstreamError(ErrorMessageInvalidPort)
}
return nil
}
Expand All @@ -80,7 +79,7 @@ func LoadSettings(ctx context.Context, config backend.DataSourceInstanceSettings
if port, ok := jsonData["port"].(string); ok {
settings.Port, err = strconv.ParseInt(port, 0, 64)
if err != nil {
return settings, errorsource.DownstreamError(fmt.Errorf("could not parse port value: %w", err), false)
return settings, backend.DownstreamError(fmt.Errorf("could not parse port value: %w", err))
}
} else {
settings.Port = int64(jsonData["port"].(float64))
Expand All @@ -93,7 +92,7 @@ func LoadSettings(ctx context.Context, config backend.DataSourceInstanceSettings
if secure, ok := jsonData["secure"].(string); ok {
settings.Secure, err = strconv.ParseBool(secure)
if err != nil {
return settings, errorsource.DownstreamError(fmt.Errorf("could not parse secure value: %w", err), false)
return settings, backend.DownstreamError(fmt.Errorf("could not parse secure value: %w", err))
}
} else {
settings.Secure = jsonData["secure"].(bool)
Expand All @@ -107,7 +106,7 @@ func LoadSettings(ctx context.Context, config backend.DataSourceInstanceSettings
if tlsSkipVerify, ok := jsonData["tlsSkipVerify"].(string); ok {
settings.InsecureSkipVerify, err = strconv.ParseBool(tlsSkipVerify)
if err != nil {
return settings, errorsource.DownstreamError(fmt.Errorf("could not parse tlsSkipVerify value: %w", err), false)
return settings, backend.DownstreamError(fmt.Errorf("could not parse tlsSkipVerify value: %w", err))
}
} else {
settings.InsecureSkipVerify = jsonData["tlsSkipVerify"].(bool)
Expand All @@ -117,7 +116,7 @@ func LoadSettings(ctx context.Context, config backend.DataSourceInstanceSettings
if tlsAuth, ok := jsonData["tlsAuth"].(string); ok {
settings.TlsClientAuth, err = strconv.ParseBool(tlsAuth)
if err != nil {
return settings, errorsource.DownstreamError(fmt.Errorf("could not parse tlsAuth value: %w", err), false)
return settings, backend.DownstreamError(fmt.Errorf("could not parse tlsAuth value: %w", err))
}
} else {
settings.TlsClientAuth = jsonData["tlsAuth"].(bool)
Expand All @@ -127,7 +126,7 @@ func LoadSettings(ctx context.Context, config backend.DataSourceInstanceSettings
if tlsAuthWithCACert, ok := jsonData["tlsAuthWithCACert"].(string); ok {
settings.TlsAuthWithCACert, err = strconv.ParseBool(tlsAuthWithCACert)
if err != nil {
return settings, errorsource.DownstreamError(fmt.Errorf("could not parse tlsAuthWithCACert value: %w", err), false)
return settings, backend.DownstreamError(fmt.Errorf("could not parse tlsAuthWithCACert value: %w", err))
}
} else {
settings.TlsAuthWithCACert = jsonData["tlsAuthWithCACert"].(bool)
Expand Down Expand Up @@ -175,7 +174,7 @@ func LoadSettings(ctx context.Context, config backend.DataSourceInstanceSettings
if forwardGrafanaHeaders, ok := jsonData["forwardGrafanaHeaders"].(string); ok {
settings.ForwardGrafanaHeaders, err = strconv.ParseBool(forwardGrafanaHeaders)
if err != nil {
return settings, errorsource.DownstreamError(fmt.Errorf("could not parse forwardGrafanaHeaders value: %w", err), false)
return settings, backend.DownstreamError(fmt.Errorf("could not parse forwardGrafanaHeaders value: %w", err))
}
} else {
settings.ForwardGrafanaHeaders = jsonData["forwardGrafanaHeaders"].(bool)
Expand Down

0 comments on commit 4304e52

Please sign in to comment.