[release-11.2.8] Chore: Bump Go version to 1.23.7 (#101294)
* Chore: Bump Go version to 1.23.7 * Chore: Bump golangci-lint version to match Go version * Chore: Run yarn prettier:write * Chore: Bump godeltaprof to v0.1.8 to fix start-up * Chore: Fix wire updated error fixture * Chore: Fix OpenAPI spec diffs * Chore: Fix new linting errors from Go upgrade
This commit is contained in:
@@ -30,7 +30,7 @@ func GrafanaJavascriptAgentLogMessageHandler(store *frontendlogging.SourceMapSto
|
||||
|
||||
// Meta object is standard across event types, adding it globally.
|
||||
|
||||
if event.Logs != nil && len(event.Logs) > 0 {
|
||||
if len(event.Logs) > 0 {
|
||||
for _, logEntry := range event.Logs {
|
||||
var ctx = frontendlogging.CtxVector{}
|
||||
ctx = event.AddMetaToContext(ctx)
|
||||
@@ -64,7 +64,7 @@ func GrafanaJavascriptAgentLogMessageHandler(store *frontendlogging.SourceMapSto
|
||||
}
|
||||
}
|
||||
|
||||
if event.Measurements != nil && len(event.Measurements) > 0 {
|
||||
if len(event.Measurements) > 0 {
|
||||
for _, measurementEntry := range event.Measurements {
|
||||
for measurementName, measurementValue := range measurementEntry.Values {
|
||||
var ctx = frontendlogging.CtxVector{}
|
||||
@@ -75,7 +75,7 @@ func GrafanaJavascriptAgentLogMessageHandler(store *frontendlogging.SourceMapSto
|
||||
}
|
||||
}
|
||||
}
|
||||
if event.Exceptions != nil && len(event.Exceptions) > 0 {
|
||||
if len(event.Exceptions) > 0 {
|
||||
for _, exception := range event.Exceptions {
|
||||
var ctx = frontendlogging.CtxVector{}
|
||||
ctx = event.AddMetaToContext(ctx)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module github.com/grafana/grafana/pkg/apimachinery
|
||||
|
||||
go 1.22.7
|
||||
go 1.23.7
|
||||
|
||||
require (
|
||||
github.com/grafana/authlib v0.0.0-20240730122259-a0d13672efb1
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module github.com/grafana/grafana/pkg/apiserver
|
||||
|
||||
go 1.22.7
|
||||
go 1.23.7
|
||||
|
||||
require (
|
||||
github.com/google/go-cmp v0.6.0
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
module github.com/grafana/grafana/pkg/build
|
||||
|
||||
go 1.22.7
|
||||
go 1.23.7
|
||||
|
||||
// Override docker/docker to avoid:
|
||||
// go: github.com/drone-runners/drone-runner-docker@v1.8.2 requires
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module github.com/grafana/grafana/pkg/build/wire
|
||||
|
||||
go 1.22.7
|
||||
go 1.23.7
|
||||
|
||||
require (
|
||||
github.com/google/go-cmp v0.6.0
|
||||
|
||||
@@ -1 +1 @@
|
||||
example.com/foo/wire.go:x:y: foo not exported by package bar
|
||||
example.com/foo/wire.go:x:y: name foo not exported by package bar
|
||||
@@ -85,12 +85,7 @@ func initializeConflictResolver(cmd *utils.ContextCommandLine, f Formatter, ctx
|
||||
return nil, fmt.Errorf("%v: %w", "failed to get user service", err)
|
||||
}
|
||||
routing := routing.ProvideRegister()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%v: %w", "failed to initialize tracer config", err)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%v: %w", "failed to initialize tracer service", err)
|
||||
}
|
||||
|
||||
acService, err := acimpl.ProvideService(cfg, replstore, routing, nil, nil, nil, features, tracer, zanzana.NewNoopClient(), permreg.ProvidePermissionRegistry())
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%v: %w", "failed to get access control", err)
|
||||
@@ -123,9 +118,9 @@ func runListConflictUsers() func(context *cli.Context) error {
|
||||
logger.Info(color.GreenString("No Conflicting users found.\n\n"))
|
||||
return nil
|
||||
}
|
||||
logger.Infof("\n\nShowing conflicts\n\n")
|
||||
logger.Infof(r.ToStringPresentation())
|
||||
logger.Infof("\n")
|
||||
logger.Info("\n\nShowing conflicts\n\n")
|
||||
logger.Info(r.ToStringPresentation())
|
||||
logger.Info("\n")
|
||||
if len(r.DiscardedBlocks) != 0 {
|
||||
r.logDiscardedUsers()
|
||||
}
|
||||
@@ -461,7 +456,8 @@ func (r *ConflictResolver) showChanges() {
|
||||
}
|
||||
}
|
||||
b.WriteString("Keep the following user.\n")
|
||||
b.WriteString(fmt.Sprintf("%s\n", block))
|
||||
b.WriteString(block)
|
||||
b.WriteByte('\n')
|
||||
b.WriteString(color.GreenString(fmt.Sprintf("id: %s, email: %s, login: %s\n", mainUser.ID, mainUser.Email, mainUser.Login)))
|
||||
for _, r := range fmt.Sprintf("%s%s", mainUser.Email, mainUser.Login) {
|
||||
if unicode.IsUpper(r) {
|
||||
@@ -482,7 +478,7 @@ func (r *ConflictResolver) showChanges() {
|
||||
b.WriteString("\n\n")
|
||||
}
|
||||
logger.Info("\n\nChanges that will take place\n\n")
|
||||
logger.Infof(b.String())
|
||||
logger.Info(b.String())
|
||||
}
|
||||
|
||||
// Formatter make it possible for us to write to terminal and to a file
|
||||
|
||||
@@ -45,7 +45,7 @@ func (h *HysteresisCommand) Execute(ctx context.Context, now time.Time, vars mat
|
||||
if results.IsNoData() {
|
||||
return mathexp.Results{Values: mathexp.Values{mathexp.NewNoData()}}, nil
|
||||
}
|
||||
if h.LoadedDimensions == nil || len(h.LoadedDimensions) == 0 {
|
||||
if len(h.LoadedDimensions) == 0 {
|
||||
return h.LoadingThresholdFunc.Execute(traceCtx, now, vars, tracer)
|
||||
}
|
||||
var loadedVals, unloadedVals mathexp.Values
|
||||
|
||||
@@ -275,7 +275,7 @@ func handleQuery(t *testing.T, ctx context.Context, query interface{}, queryName
|
||||
file, fileFound, err := fs.Get(ctx, inputPath, options)
|
||||
require.NoError(t, err, "%s: should be able to get file %s", queryName, inputPath)
|
||||
|
||||
if q.checks != nil && len(q.checks) > 0 {
|
||||
if len(q.checks) > 0 {
|
||||
require.NotNil(t, file, "%s %s", queryName, inputPath)
|
||||
require.True(t, fileFound, "%s %s", queryName, inputPath)
|
||||
require.Equal(t, strings.ToLower(inputPath), strings.ToLower(file.FullPath), "%s %s", queryName, inputPath)
|
||||
@@ -289,7 +289,7 @@ func handleQuery(t *testing.T, ctx context.Context, query interface{}, queryName
|
||||
resp, err := fs.List(ctx, inputPath, q.input.paging, q.input.options)
|
||||
require.NoError(t, err, "%s: should be able to list files in %s", queryName, inputPath)
|
||||
require.NotNil(t, resp)
|
||||
if q.list != nil && len(q.list) > 0 {
|
||||
if len(q.list) > 0 {
|
||||
runChecks(t, queryName, inputPath, resp, q.list)
|
||||
} else {
|
||||
require.NotNil(t, resp, "%s %s", queryName, inputPath)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package filestorage
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -35,7 +34,7 @@ func TestFilestorage_getParentFolderPath(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(fmt.Sprintf(tt.name), func(t *testing.T) {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
require.Equal(t, tt.expected, getParentFolderPath(tt.path))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ func (s *SocialGenericOAuth) Validate(ctx context.Context, newSettings ssoModels
|
||||
return ssosettings.ErrInvalidOAuthConfig("If Team Ids are configured then Team Ids attribute path and Teams URL must be configured.")
|
||||
}
|
||||
|
||||
if info.AllowedGroups != nil && len(info.AllowedGroups) > 0 && info.GroupsAttributePath == "" {
|
||||
if len(info.AllowedGroups) > 0 && info.GroupsAttributePath == "" {
|
||||
return ssosettings.ErrInvalidOAuthConfig("If Allowed groups is configured then Groups attribute path must be configured.")
|
||||
}
|
||||
|
||||
@@ -517,7 +517,7 @@ func (s *SocialGenericOAuth) fetchPrivateEmail(ctx context.Context, client *http
|
||||
IsConfirmed bool `json:"is_confirmed"`
|
||||
}
|
||||
|
||||
response, err := s.httpGet(ctx, client, fmt.Sprintf(s.info.ApiUrl+"/emails"))
|
||||
response, err := s.httpGet(ctx, client, s.info.ApiUrl+"/emails")
|
||||
if err != nil {
|
||||
s.log.Error("Error getting email address", "url", s.info.ApiUrl+"/emails", "error", err)
|
||||
return "", fmt.Errorf("%v: %w", "Error getting email address", err)
|
||||
@@ -579,7 +579,7 @@ func (s *SocialGenericOAuth) fetchTeamMembershipsFromDeprecatedTeamsUrl(ctx cont
|
||||
Id int `json:"id"`
|
||||
}
|
||||
|
||||
response, err := s.httpGet(ctx, client, fmt.Sprintf(s.info.ApiUrl+"/teams"))
|
||||
response, err := s.httpGet(ctx, client, s.info.ApiUrl+"/teams")
|
||||
if err != nil {
|
||||
s.log.Error("Error getting team memberships", "url", s.info.ApiUrl+"/teams", "error", err)
|
||||
return []string{}, err
|
||||
@@ -606,7 +606,7 @@ func (s *SocialGenericOAuth) fetchTeamMembershipsFromTeamsUrl(ctx context.Contex
|
||||
return []string{}, nil
|
||||
}
|
||||
|
||||
response, err := s.httpGet(ctx, client, fmt.Sprintf(s.teamsUrl))
|
||||
response, err := s.httpGet(ctx, client, s.teamsUrl)
|
||||
if err != nil {
|
||||
s.log.Error("Error getting team memberships", "url", s.teamsUrl, "error", err)
|
||||
return nil, err
|
||||
@@ -620,7 +620,7 @@ func (s *SocialGenericOAuth) fetchOrganizations(ctx context.Context, client *htt
|
||||
Login string `json:"login"`
|
||||
}
|
||||
|
||||
response, err := s.httpGet(ctx, client, fmt.Sprintf(s.info.ApiUrl+"/orgs"))
|
||||
response, err := s.httpGet(ctx, client, s.info.ApiUrl+"/orgs")
|
||||
if err != nil {
|
||||
s.log.Error("Error getting organizations", "url", s.info.ApiUrl+"/orgs", "error", err)
|
||||
return nil, false
|
||||
|
||||
@@ -208,7 +208,7 @@ func (s *SocialGithub) fetchPrivateEmail(ctx context.Context, client *http.Clien
|
||||
Verified bool `json:"verified"`
|
||||
}
|
||||
|
||||
response, err := s.httpGet(ctx, client, fmt.Sprintf(s.info.ApiUrl+"/emails"))
|
||||
response, err := s.httpGet(ctx, client, s.info.ApiUrl+"/emails")
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("Error getting email address: %s", err)
|
||||
}
|
||||
@@ -231,7 +231,7 @@ func (s *SocialGithub) fetchPrivateEmail(ctx context.Context, client *http.Clien
|
||||
}
|
||||
|
||||
func (s *SocialGithub) fetchTeamMemberships(ctx context.Context, client *http.Client) ([]GithubTeam, error) {
|
||||
url := fmt.Sprintf(s.info.ApiUrl + "/teams?per_page=100")
|
||||
url := s.info.ApiUrl + "/teams?per_page=100"
|
||||
hasMore := true
|
||||
teams := make([]GithubTeam, 0)
|
||||
|
||||
@@ -365,7 +365,7 @@ func (s *SocialGithub) UserInfo(ctx context.Context, client *http.Client, token
|
||||
userInfo.Name = data.Name
|
||||
}
|
||||
|
||||
organizationsUrl := fmt.Sprintf(s.info.ApiUrl + "/orgs?per_page=100")
|
||||
organizationsUrl := s.info.ApiUrl + "/orgs?per_page=100"
|
||||
|
||||
if !s.isTeamMember(ctx, client) {
|
||||
return nil, ErrMissingTeamMembership.Errorf("User is not a member of any of the allowed teams: %v", s.teamIds)
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
module github.com/grafana/grafana/pkg/promlib
|
||||
|
||||
go 1.22.7
|
||||
go 1.23.7
|
||||
|
||||
require (
|
||||
github.com/grafana/grafana-plugin-sdk-go v0.241.0
|
||||
@@ -55,7 +55,7 @@ require (
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/gorilla/mux v1.8.1 // indirect
|
||||
github.com/grafana/otel-profiling-go v0.5.1 // indirect
|
||||
github.com/grafana/pyroscope-go/godeltaprof v0.1.7 // indirect
|
||||
github.com/grafana/pyroscope-go/godeltaprof v0.1.8 // indirect
|
||||
github.com/grafana/regexp v0.0.0-20221123153739-15dc172cd2db // indirect
|
||||
github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus v1.0.1 // indirect
|
||||
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.1.0 // indirect
|
||||
|
||||
+2
-3
@@ -100,8 +100,8 @@ github.com/grafana/grafana-plugin-sdk-go v0.241.0 h1:zBcSW9xV9gA9hD8UN+HjJtD7tES
|
||||
github.com/grafana/grafana-plugin-sdk-go v0.241.0/go.mod h1:2HjNwzGCfaFAyR2HGoECTwAmq8vSIn2L1/1yOt4XRS4=
|
||||
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.7 h1:C11j63y7gymiW8VugJ9ZW0pWfxTZugdSJyC48olk5KY=
|
||||
github.com/grafana/pyroscope-go/godeltaprof v0.1.7/go.mod h1:Tk376Nbldo4Cha9RgiU7ik8WKFkNpfds98aUzS8omLE=
|
||||
github.com/grafana/pyroscope-go/godeltaprof v0.1.8 h1:iwOtYXeeVSAeYefJNaxDytgjKtUuKQbJqgAIjlnicKg=
|
||||
github.com/grafana/pyroscope-go/godeltaprof v0.1.8/go.mod h1:2+l7K7twW49Ct4wFluZD3tZ6e0SjanjcUUBPVD/UuGU=
|
||||
github.com/grafana/regexp v0.0.0-20221123153739-15dc172cd2db h1:7aN5cccjIqCLTzedH7MZzRZt5/lsAHch6Z3L2ZGn5FA=
|
||||
github.com/grafana/regexp v0.0.0-20221123153739-15dc172cd2db/go.mod h1:M5qHK+eWfAv8VR/265dIuEpL3fNfeC21tXXp9itM24A=
|
||||
github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus v1.0.1 h1:qnpSQwGEnkcRpTqNOIR6bJbR0gAorgP9CSALpRcKoAA=
|
||||
@@ -137,7 +137,6 @@ github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7
|
||||
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
||||
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/klauspost/compress v1.17.3/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM=
|
||||
github.com/klauspost/compress v1.17.8 h1:YcnTYrq7MikUT7k0Yb5eceMmALQPYBW/Xltxn0NAMnU=
|
||||
github.com/klauspost/compress v1.17.8/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
|
||||
github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM=
|
||||
|
||||
@@ -2,6 +2,7 @@ package querydata
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"regexp"
|
||||
@@ -199,7 +200,7 @@ func (s *QueryData) instantQuery(ctx context.Context, c *client.Client, q *model
|
||||
// This is only for health check fall back scenario
|
||||
if res.StatusCode != 200 && q.RefId == "__healthcheck__" {
|
||||
return backend.DataResponse{
|
||||
Error: fmt.Errorf(res.Status),
|
||||
Error: errors.New(res.Status),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,6 @@ func (r *subProxyREST) NewConnectOptions() (runtime.Object, bool, string) {
|
||||
|
||||
func (r *subProxyREST) Connect(ctx context.Context, name string, opts runtime.Object, responder rest.Responder) (http.Handler, error) {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
||||
responder.Error(fmt.Errorf("TODO, proxy: " + r.pluginJSON.ID))
|
||||
responder.Error(fmt.Errorf("TODO, proxy: %s", r.pluginJSON.ID))
|
||||
}), nil
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ func (d *pluginRegistry) GetDatasourceGroupVersion(pluginId string) (schema.Grou
|
||||
var err error
|
||||
gv, ok := d.apis[pluginId]
|
||||
if !ok {
|
||||
err = fmt.Errorf("no API found for id: " + pluginId)
|
||||
err = fmt.Errorf("no API found for id: %s", pluginId)
|
||||
}
|
||||
return gv, err
|
||||
}
|
||||
|
||||
@@ -259,7 +259,7 @@ func (b *QueryAPIBuilder) executeConcurrentQueries(ctx context.Context, requests
|
||||
if theErr, ok := r.(error); ok {
|
||||
err = theErr
|
||||
} else if theErrString, ok := r.(string); ok {
|
||||
err = fmt.Errorf(theErrString)
|
||||
err = errors.New(theErrString)
|
||||
} else {
|
||||
err = fmt.Errorf("unexpected error - %s", b.userFacingDefaultError)
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
module github.com/grafana/grafana/pkg/semconv
|
||||
|
||||
go 1.22.7
|
||||
go 1.23.7
|
||||
|
||||
require go.opentelemetry.io/otel v1.28.0
|
||||
|
||||
|
||||
@@ -293,7 +293,7 @@ func (cmd *SaveExternalServiceRoleCommand) Validate() error {
|
||||
cmd.ExternalServiceID = slugify.Slugify(cmd.ExternalServiceID)
|
||||
|
||||
// Check and deduplicate permissions
|
||||
if cmd.Permissions == nil || len(cmd.Permissions) == 0 {
|
||||
if len(cmd.Permissions) == 0 {
|
||||
return errors.New("no permissions provided")
|
||||
}
|
||||
dedupMap := map[Permission]bool{}
|
||||
|
||||
@@ -2,6 +2,7 @@ package annotationsimpl
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"sort"
|
||||
|
||||
@@ -88,7 +89,7 @@ func handleJobPanic(logger log.Logger, storeType string, jobErr *error) {
|
||||
errMsg := "concurrent job panic"
|
||||
|
||||
if jobErr != nil {
|
||||
err := fmt.Errorf(errMsg)
|
||||
err := errors.New(errMsg)
|
||||
if panicErr, ok := r.(error); ok {
|
||||
err = fmt.Errorf("%s: %w", errMsg, panicErr)
|
||||
}
|
||||
|
||||
@@ -248,8 +248,7 @@ func verifyAndGenerateFile(t *testing.T, fpath string, gen string) {
|
||||
body, err := os.ReadFile(fpath)
|
||||
if err == nil {
|
||||
if diff := cmp.Diff(gen, string(body)); diff != "" {
|
||||
str := fmt.Sprintf("body mismatch (-want +got):\n%s\n", diff)
|
||||
err = fmt.Errorf(str)
|
||||
err = fmt.Errorf("body mismatch (-want +got):\n%s\n", diff)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -164,7 +164,7 @@ func (s *ServiceImpl) GetNavTree(c *contextmodel.ReqContext, prefs *pref.Prefere
|
||||
}
|
||||
|
||||
// remove user access if empty. Happens if grafana-auth-app is not injected
|
||||
if sec := treeRoot.FindById(navtree.NavIDCfgAccess); sec != nil && (sec.Children == nil || len(sec.Children) == 0) {
|
||||
if sec := treeRoot.FindById(navtree.NavIDCfgAccess); sec != nil && len(sec.Children) == 0 {
|
||||
treeRoot.RemoveSectionByID(navtree.NavIDCfgAccess)
|
||||
}
|
||||
|
||||
|
||||
@@ -14,9 +14,9 @@ var (
|
||||
)
|
||||
|
||||
func NewAuthorizationErrorWithPermissions(action string, eval ac.Evaluator) error {
|
||||
msg := fmt.Sprintf("user is not authorized to %s", action)
|
||||
err := ErrAuthorizationBase.Errorf(msg)
|
||||
err.PublicMessage = msg
|
||||
msg := "user is not authorized to %s"
|
||||
err := ErrAuthorizationBase.Errorf(msg, action)
|
||||
err.PublicMessage = fmt.Sprintf(msg, action)
|
||||
if eval != nil {
|
||||
err.PublicPayload = map[string]any{
|
||||
"permissions": eval.GoString(),
|
||||
|
||||
@@ -207,8 +207,9 @@ func messageExtractor(resp *response.NormalResponse) (any, error) {
|
||||
// ErrorResp creates a response with a visible error
|
||||
func ErrResp(status int, err error, msg string, args ...any) *response.NormalResponse {
|
||||
if msg != "" {
|
||||
formattedMsg := fmt.Sprintf(msg, args...)
|
||||
err = fmt.Errorf("%s: %w", formattedMsg, err)
|
||||
msg += ": %w"
|
||||
args = append(args, err)
|
||||
err = fmt.Errorf(msg, args...)
|
||||
}
|
||||
return response.Error(status, err.Error(), err)
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package plugins
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"os"
|
||||
@@ -90,18 +91,16 @@ func (cr *configReaderImpl) parsePluginConfig(path string, file fs.DirEntry) (*p
|
||||
|
||||
func validateRequiredField(apps []*pluginsAsConfig) error {
|
||||
for i := range apps {
|
||||
var errStrings []string
|
||||
errs := []error{}
|
||||
for index, app := range apps[i].Apps {
|
||||
if app.PluginID == "" {
|
||||
errStrings = append(
|
||||
errStrings,
|
||||
fmt.Sprintf("app item %d in configuration doesn't contain required field type", index+1),
|
||||
)
|
||||
err := fmt.Errorf("app item %d in configuration doesn't contain required field type", index+1)
|
||||
errs = append(errs, err)
|
||||
}
|
||||
}
|
||||
|
||||
if len(errStrings) != 0 {
|
||||
return fmt.Errorf(strings.Join(errStrings, "\n"))
|
||||
if len(errs) != 0 {
|
||||
return errors.Join(errs...)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package query
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"runtime"
|
||||
@@ -125,7 +126,7 @@ func (s *ServiceImpl) executeConcurrentQueries(ctx context.Context, user identit
|
||||
if theErr, ok := r.(error); ok {
|
||||
err = theErr
|
||||
} else if theErrString, ok := r.(string); ok {
|
||||
err = fmt.Errorf(theErrString)
|
||||
err = errors.New(theErrString)
|
||||
} else {
|
||||
err = fmt.Errorf("unexpected error - %s", s.cfg.UserFacingDefaultError)
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ func (s *OSSService) SearchUser(c *contextmodel.ReqContext) (*user.SearchUserQue
|
||||
for _, user := range res.Users {
|
||||
user.AvatarURL = dtos.GetGravatarUrl(s.cfg, user.Email)
|
||||
user.AuthLabels = make([]string, 0)
|
||||
if user.AuthModule != nil && len(user.AuthModule) > 0 {
|
||||
if len(user.AuthModule) > 0 {
|
||||
for _, authModule := range user.AuthModule {
|
||||
user.AuthLabels = append(user.AuthLabels, login.GetAuthProviderLabel(authModule))
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ func (rs *ReplStore) DB() *SQLStore {
|
||||
// ReadReplica returns the read-only SQLStore. If no read replica is configured,
|
||||
// it returns the main SQLStore.
|
||||
func (rs *ReplStore) ReadReplica() *SQLStore {
|
||||
if rs.repls == nil || len(rs.repls) == 0 {
|
||||
if len(rs.repls) == 0 {
|
||||
rs.log.Debug("ReadReplica not configured, using main SQLStore")
|
||||
return rs.SQLStore
|
||||
}
|
||||
|
||||
@@ -126,11 +126,11 @@ type StorageGCSConfig struct {
|
||||
CredentialsFile string `json:"credentialsFile"`
|
||||
}
|
||||
|
||||
func newStorage(cfg RootStorageConfig, localWorkCache string) (storageRuntime, error) {
|
||||
func newStorage(cfg RootStorageConfig, _ string) (storageRuntime, error) {
|
||||
switch cfg.Type {
|
||||
case rootStorageTypeDisk:
|
||||
return newDiskStorage(RootStorageMeta{}, cfg), nil
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("unsupported store: " + cfg.Type)
|
||||
return nil, fmt.Errorf("unsupported store: %s", cfg.Type)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module github.com/grafana/grafana/pkg/storage/unified/resource
|
||||
|
||||
go 1.22.7
|
||||
go 1.23.7
|
||||
|
||||
require (
|
||||
github.com/fullstorydev/grpchan v1.1.1
|
||||
|
||||
@@ -209,7 +209,7 @@ func (e *cloudWatchExecutor) executeStartQuery(ctx context.Context, logsClient c
|
||||
QueryString: aws.String(modifiedQueryString),
|
||||
}
|
||||
|
||||
if logsQuery.LogGroups != nil && len(logsQuery.LogGroups) > 0 && features.IsEnabled(ctx, features.FlagCloudWatchCrossAccountQuerying) {
|
||||
if len(logsQuery.LogGroups) > 0 && features.IsEnabled(ctx, features.FlagCloudWatchCrossAccountQuerying) {
|
||||
var logGroupIdentifiers []string
|
||||
for _, lg := range logsQuery.LogGroups {
|
||||
arn := lg.Arn
|
||||
|
||||
@@ -26,7 +26,7 @@ type CloudWatchSettings struct {
|
||||
func LoadCloudWatchSettings(ctx context.Context, config backend.DataSourceInstanceSettings) (CloudWatchSettings, error) {
|
||||
instance := CloudWatchSettings{}
|
||||
|
||||
if config.JSONData != nil && len(config.JSONData) > 1 {
|
||||
if len(config.JSONData) > 1 {
|
||||
if err := json.Unmarshal(config.JSONData, &instance); err != nil {
|
||||
return CloudWatchSettings{}, fmt.Errorf("could not unmarshal DatasourceSettings json: %w", err)
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ func (e *DataSourceHandler) executeQuery(query backend.DataQuery, wg *sync.WaitG
|
||||
if theErr, ok := r.(error); ok {
|
||||
queryResult.dataResponse.Error = theErr
|
||||
} else if theErrString, ok := r.(string); ok {
|
||||
queryResult.dataResponse.Error = fmt.Errorf(theErrString)
|
||||
queryResult.dataResponse.Error = errors.New(theErrString)
|
||||
} else {
|
||||
queryResult.dataResponse.Error = fmt.Errorf("unexpected error - %s", e.userError)
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ type SimulationEngine struct {
|
||||
|
||||
func (s *SimulationEngine) register(info simulationInfo) error {
|
||||
if info.create == nil {
|
||||
return fmt.Errorf("invalid simulation -- missing create function: " + info.Type)
|
||||
return fmt.Errorf("invalid simulation -- missing create function: %s", info.Type)
|
||||
}
|
||||
if info.Type == "" {
|
||||
return fmt.Errorf("missing type")
|
||||
|
||||
@@ -41,13 +41,13 @@ func executeQuery(ctx context.Context, logger log.Logger, query queryModel, runn
|
||||
// the error happens, there is not enough info to create a nice error message)
|
||||
var maxPointError maxPointsExceededError
|
||||
if errors.As(dr.Error, &maxPointError) {
|
||||
text := fmt.Sprintf("A query returned too many datapoints and the results have been truncated at %d points to prevent memory issues. At the current graph size, Grafana can only draw %d.", maxPointError.Count, query.MaxDataPoints)
|
||||
errMsg := "A query returned too many datapoints and the results have been truncated at %d points to prevent memory issues. At the current graph size, Grafana can only draw %d."
|
||||
// we recommend to the user to use AggregateWindow(), but only if it is not already used
|
||||
if !strings.Contains(query.RawQuery, "aggregateWindow(") {
|
||||
text += " Try using the aggregateWindow() function in your query to reduce the number of points returned."
|
||||
errMsg += " Try using the aggregateWindow() function in your query to reduce the number of points returned."
|
||||
}
|
||||
|
||||
dr.Error = fmt.Errorf(text)
|
||||
dr.Error = fmt.Errorf(errMsg, maxPointError.Count, query.MaxDataPoints)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -315,7 +315,7 @@ func TestNewFrame(t *testing.T) {
|
||||
},
|
||||
}
|
||||
if !cmp.Equal(expected, actual, cmp.Comparer(cmpFrame)) {
|
||||
log.Fatalf(cmp.Diff(expected, actual))
|
||||
log.Fatal(cmp.Diff(expected, actual))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package buffered
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"strings"
|
||||
@@ -36,12 +37,12 @@ func parse(buf io.Reader, statusCode int, query *models.Query) *backend.DataResp
|
||||
}
|
||||
|
||||
if response.Error != "" {
|
||||
return &backend.DataResponse{Error: fmt.Errorf(response.Error)}
|
||||
return &backend.DataResponse{Error: errors.New(response.Error)}
|
||||
}
|
||||
|
||||
result := response.Results[0]
|
||||
if result.Error != "" {
|
||||
return &backend.DataResponse{Error: fmt.Errorf(result.Error)}
|
||||
return &backend.DataResponse{Error: errors.New(result.Error)}
|
||||
}
|
||||
|
||||
if query.ResultFormat == "table" {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package converter
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -39,7 +40,7 @@ l1Fields:
|
||||
if err != nil {
|
||||
rsp.Error = err
|
||||
} else {
|
||||
rsp.Error = fmt.Errorf(v)
|
||||
rsp.Error = errors.New(v)
|
||||
}
|
||||
return rsp
|
||||
case "code":
|
||||
@@ -55,9 +56,6 @@ l1Fields:
|
||||
}
|
||||
return rspErr(fmt.Errorf("%s", v))
|
||||
case "":
|
||||
if err != nil {
|
||||
return rspErr(err)
|
||||
}
|
||||
break l1Fields
|
||||
default:
|
||||
v, err := iter.Read()
|
||||
|
||||
@@ -194,7 +194,7 @@ func execute(ctx context.Context, tracer trace.Tracer, dsInfo *models.Datasource
|
||||
resp = buffered.ResponseParse(res.Body, res.StatusCode, query)
|
||||
}
|
||||
|
||||
if resp.Frames != nil && len(resp.Frames) > 0 {
|
||||
if len(resp.Frames) > 0 {
|
||||
resp.Frames[0].Meta.Custom = readCustomMetadata(res)
|
||||
}
|
||||
|
||||
|
||||
@@ -214,7 +214,7 @@ func (e *DataSourceHandler) executeQuery(query backend.DataQuery, wg *sync.WaitG
|
||||
if theErr, ok := r.(error); ok {
|
||||
queryResult.dataResponse.Error = theErr
|
||||
} else if theErrString, ok := r.(string); ok {
|
||||
queryResult.dataResponse.Error = fmt.Errorf(theErrString)
|
||||
queryResult.dataResponse.Error = errors.New(theErrString)
|
||||
} else {
|
||||
queryResult.dataResponse.Error = fmt.Errorf("unexpected error - %s", e.userError)
|
||||
}
|
||||
|
||||
@@ -224,7 +224,7 @@ func (e *DataSourceHandler) executeQuery(query backend.DataQuery, wg *sync.WaitG
|
||||
if theErr, ok := r.(error); ok {
|
||||
queryResult.dataResponse.Error = theErr
|
||||
} else if theErrString, ok := r.(string); ok {
|
||||
queryResult.dataResponse.Error = fmt.Errorf(theErrString)
|
||||
queryResult.dataResponse.Error = errors.New(theErrString)
|
||||
} else {
|
||||
queryResult.dataResponse.Error = fmt.Errorf("unexpected error - %s", e.userError)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module github.com/grafana/grafana/pkg/util/xorm
|
||||
|
||||
go 1.21.10
|
||||
go 1.23.7
|
||||
|
||||
require (
|
||||
github.com/mattn/go-sqlite3 v1.14.22
|
||||
|
||||
Reference in New Issue
Block a user