Chore: Bump Go to 1.23.0 (#92105)
* chore: Bump Go to 1.23.0 Signed-off-by: Dave Henderson <dave.henderson@grafana.com> * update swagger files Signed-off-by: Dave Henderson <dave.henderson@grafana.com> * chore: update .bingo/README.md formatting to satisfy prettier Signed-off-by: Dave Henderson <dave.henderson@grafana.com> * chore(lint): Fix new lint errors found by golangci-lint 1.60.1 and Go 1.23 Signed-off-by: Dave Henderson <dave.henderson@grafana.com> * keep golden file * update openapi * add name to expected output * chore(lint): rearrange imports to a sensible order Signed-off-by: Dave Henderson <dave.henderson@grafana.com> --------- Signed-off-by: Dave Henderson <dave.henderson@grafana.com> Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
This commit is contained in:
co-authored by
Ryan McKinley
parent
02c820382d
commit
df3d8915ba
@@ -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,12 +2,13 @@ package annotationsimpl
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"sort"
|
||||
|
||||
"github.com/grafana/grafana/pkg/infra/log"
|
||||
|
||||
"github.com/grafana/dskit/concurrency"
|
||||
|
||||
"github.com/grafana/grafana/pkg/infra/log"
|
||||
"github.com/grafana/grafana/pkg/services/annotations"
|
||||
"github.com/grafana/grafana/pkg/services/annotations/accesscontrol"
|
||||
)
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -5,11 +5,10 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/protobuf/types/known/wrapperspb"
|
||||
|
||||
openfgav1 "github.com/openfga/api/proto/openfga/v1"
|
||||
"github.com/openfga/language/pkg/go/transformer"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/protobuf/types/known/wrapperspb"
|
||||
|
||||
"github.com/grafana/grafana/pkg/infra/log"
|
||||
"github.com/grafana/grafana/pkg/services/authz/zanzana/schema"
|
||||
@@ -61,7 +60,7 @@ func New(ctx context.Context, cc grpc.ClientConnInterface, opts ...ClientOption)
|
||||
c.tenantID = "stack-default"
|
||||
}
|
||||
|
||||
if c.modules == nil || len(c.modules) == 0 {
|
||||
if len(c.modules) == 0 {
|
||||
c.modules = schema.SchemaModules
|
||||
}
|
||||
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -212,8 +212,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)
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ func (s *OSSService) SearchUser(c *contextmodel.ReqContext) (*user.SearchUserQue
|
||||
}
|
||||
|
||||
searchQuery := c.Query("query")
|
||||
filters := make([]user.Filter, 0)
|
||||
filters := []user.Filter{}
|
||||
for filterName := range s.searchUserFilter.GetFilterList() {
|
||||
filter := s.searchUserFilter.GetFilter(filterName, c.QueryStrings(filterName))
|
||||
if filter != nil {
|
||||
@@ -112,11 +112,9 @@ 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 {
|
||||
for _, authModule := range user.AuthModule {
|
||||
user.AuthLabels = append(user.AuthLabels, login.GetAuthProviderLabel(authModule))
|
||||
}
|
||||
user.AuthLabels = make([]string, len(user.AuthModule))
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -153,6 +153,8 @@ func ProvideService(
|
||||
|
||||
// all externally-defined storages lie under the "content" root
|
||||
root.UnderContentRoot = true
|
||||
|
||||
// TODO: remove unused second argument
|
||||
s, err := newStorage(root, filepath.Join(cfg.DataPath, "storage", "cache", root.Prefix))
|
||||
if err != nil {
|
||||
grafanaStorageLogger.Warn("Error loading storage config", "error", err)
|
||||
|
||||
Reference in New Issue
Block a user