mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
chore: Updating linter, fixing some new warnings (#88863)
This commit is contained in:
@@ -51,7 +51,7 @@ func validateInput(c utils.CommandLine) error {
|
||||
|
||||
fileInfo, err := os.Stat(pluginsDir)
|
||||
if err != nil {
|
||||
if err = os.MkdirAll(pluginsDir, os.ModePerm); err != nil {
|
||||
if err = os.MkdirAll(pluginsDir, 0o750); err != nil {
|
||||
return fmt.Errorf("pluginsDir (%s) is not a writable directory", pluginsDir)
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -113,7 +113,7 @@ func runTests(createCases func() []fsTestCase, t *testing.T) {
|
||||
}
|
||||
|
||||
nestedPath := path.Join("a", "b")
|
||||
err = os.MkdirAll(path.Join(tmpDir, nestedPath), os.ModePerm)
|
||||
err = os.MkdirAll(path.Join(tmpDir, nestedPath), 0o750)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -467,7 +467,7 @@ func ReadLoggingConfig(modes []string, logsPath string, cfg *ini.File) error {
|
||||
case "file":
|
||||
fileName := sec.Key("file_name").MustString(filepath.Join(logsPath, "grafana.log"))
|
||||
dpath := filepath.Dir(fileName)
|
||||
if err := os.MkdirAll(dpath, os.ModePerm); err != nil {
|
||||
if err := os.MkdirAll(dpath, 0o750); err != nil {
|
||||
_ = level.Error(root).Log("Failed to create directory", "dpath", dpath, "err", err)
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ func TestLocalFS_Remove(t *testing.T) {
|
||||
|
||||
t.Run("Uninstall will search in nested dist folder for plugin.json", func(t *testing.T) {
|
||||
pluginDistDir := filepath.Join(t.TempDir(), "dist")
|
||||
err = os.Mkdir(pluginDistDir, os.ModePerm)
|
||||
err = os.Mkdir(pluginDistDir, 0o750)
|
||||
require.NoError(t, err)
|
||||
pluginJSON = filepath.Join(pluginDistDir, "plugin.json")
|
||||
//nolint:gosec
|
||||
@@ -59,7 +59,7 @@ func TestLocalFS_Remove(t *testing.T) {
|
||||
|
||||
t.Run("Uninstall will not delete folder if cannot recognize plugin structure", func(t *testing.T) {
|
||||
pluginDir = filepath.Join(t.TempDir(), "system32")
|
||||
err = os.Mkdir(pluginDir, os.ModePerm)
|
||||
err = os.Mkdir(pluginDir, 0o750)
|
||||
require.NoError(t, err)
|
||||
testFile := filepath.Join(pluginDir, "important.exe")
|
||||
//nolint:gosec
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
|
||||
func TestAdd(t *testing.T) {
|
||||
testDir := "./testdata/tmpInstallPluginDir"
|
||||
err := os.MkdirAll(testDir, os.ModePerm)
|
||||
err := os.MkdirAll(testDir, 0o750)
|
||||
require.NoError(t, err)
|
||||
|
||||
t.Cleanup(func() {
|
||||
|
||||
@@ -192,7 +192,7 @@ func (dbCfg *DatabaseConfig) buildConnectionString(cfg *setting.Cfg, features fe
|
||||
if !filepath.IsAbs(dbCfg.Path) {
|
||||
dbCfg.Path = filepath.Join(cfg.DataPath, dbCfg.Path)
|
||||
}
|
||||
if err := os.MkdirAll(path.Dir(dbCfg.Path), os.ModePerm); err != nil {
|
||||
if err := os.MkdirAll(path.Dir(dbCfg.Path), 0o750); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -1245,7 +1245,7 @@ func (nc *mockNotificationChannel) ServeHTTP(res http.ResponseWriter, req *http.
|
||||
nc.receivedNotifications[key] = append(nc.receivedNotifications[key], body)
|
||||
res.Header().Set("Content-Type", "application/json")
|
||||
res.WriteHeader(http.StatusOK)
|
||||
fmt.Fprint(res, nc.responses[paths[0]])
|
||||
_, _ = fmt.Fprint(res, nc.responses[paths[0]])
|
||||
}
|
||||
|
||||
func (nc *mockNotificationChannel) totalNotifications() int {
|
||||
|
||||
Reference in New Issue
Block a user