mirror of
https://github.com/grafana/grafana.git
synced 2026-08-18 17:15:08 -05:00
Handle ioutil deprecations (#53526)
* replace ioutil.ReadFile -> os.ReadFile * replace ioutil.ReadAll -> io.ReadAll * replace ioutil.TempFile -> os.CreateTemp * replace ioutil.NopCloser -> io.NopCloser * replace ioutil.WriteFile -> os.WriteFile * replace ioutil.TempDir -> os.MkdirTemp * replace ioutil.Discard -> io.Discard
This commit is contained in:
@@ -3,7 +3,7 @@ package alerting
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
@@ -34,7 +34,7 @@ func TestAlertingUsageStats(t *testing.T) {
|
||||
var createFake = func(file string) *simplejson.Json {
|
||||
// Ignore gosec warning G304 since it's a test
|
||||
// nolint:gosec
|
||||
content, err := ioutil.ReadFile(file)
|
||||
content, err := os.ReadFile(file)
|
||||
require.NoError(t, err, "expected to be able to read file")
|
||||
|
||||
j, err := simplejson.NewJson(content)
|
||||
@@ -104,7 +104,7 @@ func TestParsingAlertRuleSettings(t *testing.T) {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
var settings json.Marshaler
|
||||
if tc.file != "" {
|
||||
content, err := ioutil.ReadFile(tc.file)
|
||||
content, err := os.ReadFile(tc.file)
|
||||
require.NoError(t, err, "expected to be able to read file")
|
||||
|
||||
settings, err = simplejson.NewJson(content)
|
||||
|
||||
@@ -3,7 +3,7 @@ package alerting
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -27,7 +27,7 @@ func TestAlertRuleExtraction(t *testing.T) {
|
||||
defaultDs := &datasources.DataSource{Id: 12, OrgId: 1, Name: "I am default", IsDefault: true, Uid: "def-uid"}
|
||||
graphite2Ds := &datasources.DataSource{Id: 15, OrgId: 1, Name: "graphite2", Uid: "graphite2-uid"}
|
||||
|
||||
json, err := ioutil.ReadFile("./testdata/graphite-alert.json")
|
||||
json, err := os.ReadFile("./testdata/graphite-alert.json")
|
||||
require.Nil(t, err)
|
||||
|
||||
dsPermissions := permissions.NewMockDatasourcePermissionService()
|
||||
@@ -117,7 +117,7 @@ func TestAlertRuleExtraction(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("Panels missing id should return error", func(t *testing.T) {
|
||||
panelWithoutID, err := ioutil.ReadFile("./testdata/panels-missing-id.json")
|
||||
panelWithoutID, err := os.ReadFile("./testdata/panels-missing-id.json")
|
||||
require.Nil(t, err)
|
||||
|
||||
dashJSON, err := simplejson.NewJson(panelWithoutID)
|
||||
@@ -133,7 +133,7 @@ func TestAlertRuleExtraction(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("Panels missing id should return error", func(t *testing.T) {
|
||||
panelWithIDZero, err := ioutil.ReadFile("./testdata/panel-with-id-0.json")
|
||||
panelWithIDZero, err := os.ReadFile("./testdata/panel-with-id-0.json")
|
||||
require.Nil(t, err)
|
||||
|
||||
dashJSON, err := simplejson.NewJson(panelWithIDZero)
|
||||
@@ -149,7 +149,7 @@ func TestAlertRuleExtraction(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("Cannot save panel with query that is referenced by legacy alerting", func(t *testing.T) {
|
||||
panelWithQuery, err := ioutil.ReadFile("./testdata/panel-with-bad-query-id.json")
|
||||
panelWithQuery, err := os.ReadFile("./testdata/panel-with-bad-query-id.json")
|
||||
require.Nil(t, err)
|
||||
dashJSON, err := simplejson.NewJson(panelWithQuery)
|
||||
require.Nil(t, err)
|
||||
@@ -163,7 +163,7 @@ func TestAlertRuleExtraction(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("Panel does not have datasource configured, use the default datasource", func(t *testing.T) {
|
||||
panelWithoutSpecifiedDatasource, err := ioutil.ReadFile("./testdata/panel-without-specified-datasource.json")
|
||||
panelWithoutSpecifiedDatasource, err := os.ReadFile("./testdata/panel-without-specified-datasource.json")
|
||||
require.Nil(t, err)
|
||||
|
||||
dashJSON, err := simplejson.NewJson(panelWithoutSpecifiedDatasource)
|
||||
@@ -183,7 +183,7 @@ func TestAlertRuleExtraction(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("Parse alerts from dashboard without rows", func(t *testing.T) {
|
||||
json, err := ioutil.ReadFile("./testdata/v5-dashboard.json")
|
||||
json, err := os.ReadFile("./testdata/v5-dashboard.json")
|
||||
require.Nil(t, err)
|
||||
|
||||
dashJSON, err := simplejson.NewJson(json)
|
||||
@@ -210,7 +210,7 @@ func TestAlertRuleExtraction(t *testing.T) {
|
||||
err = sqlStore.CreateAlertNotificationCommand(context.Background(), &secondNotification)
|
||||
require.Nil(t, err)
|
||||
|
||||
json, err := ioutil.ReadFile("./testdata/influxdb-alert.json")
|
||||
json, err := os.ReadFile("./testdata/influxdb-alert.json")
|
||||
require.Nil(t, err)
|
||||
|
||||
dashJSON, err := simplejson.NewJson(json)
|
||||
@@ -236,7 +236,7 @@ func TestAlertRuleExtraction(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("Should be able to extract collapsed panels", func(t *testing.T) {
|
||||
json, err := ioutil.ReadFile("./testdata/collapsed-panels.json")
|
||||
json, err := os.ReadFile("./testdata/collapsed-panels.json")
|
||||
require.Nil(t, err)
|
||||
|
||||
dashJSON, err := simplejson.NewJson(json)
|
||||
@@ -255,7 +255,7 @@ func TestAlertRuleExtraction(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("Parse and validate dashboard without id and containing an alert", func(t *testing.T) {
|
||||
json, err := ioutil.ReadFile("./testdata/dash-without-id.json")
|
||||
json, err := os.ReadFile("./testdata/dash-without-id.json")
|
||||
require.Nil(t, err)
|
||||
|
||||
dashJSON, err := simplejson.NewJson(json)
|
||||
@@ -275,7 +275,7 @@ func TestAlertRuleExtraction(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("Extract data source given new DataSourceRef object model", func(t *testing.T) {
|
||||
json, err := ioutil.ReadFile("./testdata/panel-with-datasource-ref.json")
|
||||
json, err := os.ReadFile("./testdata/panel-with-datasource-ref.json")
|
||||
require.Nil(t, err)
|
||||
|
||||
dashJSON, err := simplejson.NewJson(json)
|
||||
@@ -308,7 +308,7 @@ func TestFilterPermissionsErrors(t *testing.T) {
|
||||
// mock data
|
||||
defaultDs := &datasources.DataSource{Id: 12, OrgId: 1, Name: "I am default", IsDefault: true, Uid: "def-uid"}
|
||||
|
||||
json, err := ioutil.ReadFile("./testdata/graphite-alert.json")
|
||||
json, err := os.ReadFile("./testdata/graphite-alert.json")
|
||||
require.Nil(t, err)
|
||||
dashJSON, err := simplejson.NewJson(json)
|
||||
require.Nil(t, err)
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"encoding/pem"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
@@ -66,7 +65,7 @@ func TestVerifyUsingJWKSetFile(t *testing.T) {
|
||||
configure := func(t *testing.T, cfg *setting.Cfg) {
|
||||
t.Helper()
|
||||
|
||||
file, err := ioutil.TempFile(os.TempDir(), "jwk-*.json")
|
||||
file, err := os.CreateTemp(os.TempDir(), "jwk-*.json")
|
||||
require.NoError(t, err)
|
||||
t.Cleanup(func() {
|
||||
if err := os.Remove(file.Name()); err != nil {
|
||||
@@ -402,7 +401,7 @@ func scenarioRunner(fn scenarioFunc, cbs ...configureFunc) func(t *testing.T) {
|
||||
func configurePKIXPublicKeyFile(t *testing.T, cfg *setting.Cfg) {
|
||||
t.Helper()
|
||||
|
||||
file, err := ioutil.TempFile(os.TempDir(), "public-key-*.pem")
|
||||
file, err := os.CreateTemp(os.TempDir(), "public-key-*.pem")
|
||||
require.NoError(t, err)
|
||||
t.Cleanup(func() {
|
||||
if err := os.Remove(file.Name()); err != nil {
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
@@ -83,7 +82,7 @@ func (s *AuthService) initKeySet() error {
|
||||
}
|
||||
}()
|
||||
|
||||
data, err := ioutil.ReadAll(file)
|
||||
data, err := io.ReadAll(file)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
@@ -144,7 +144,7 @@ func TestImportDashboardService(t *testing.T) {
|
||||
func loadTestDashboard(ctx context.Context, req *plugindashboards.LoadPluginDashboardRequest) (*plugindashboards.LoadPluginDashboardResponse, error) {
|
||||
// It's safe to ignore gosec warning G304 since this is a test and arguments comes from test configuration.
|
||||
// nolint:gosec
|
||||
bytes, err := ioutil.ReadFile(filepath.Join("testdata", req.Reference))
|
||||
bytes, err := os.ReadFile(filepath.Join("testdata", req.Reference))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package service
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
@@ -449,7 +449,7 @@ func TestService_GetHttpTransport(t *testing.T) {
|
||||
err := res.Body.Close()
|
||||
require.NoError(t, err)
|
||||
})
|
||||
body, err := ioutil.ReadAll(res.Body)
|
||||
body, err := io.ReadAll(res.Body)
|
||||
require.NoError(t, err)
|
||||
bodyStr := string(body)
|
||||
require.Equal(t, "Ok", bodyStr)
|
||||
|
||||
@@ -3,7 +3,6 @@ package export
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
@@ -108,7 +107,7 @@ func (ch *commitHelper) add(opts commitOptions) error {
|
||||
}
|
||||
}
|
||||
|
||||
err = ioutil.WriteFile(b.fpath, body, 0644)
|
||||
err = os.WriteFile(b.fpath, body, 0644)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package export
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
|
||||
func exportDashboardThumbnails(helper *commitHelper, job *gitExportJob) error {
|
||||
alias := make(map[string]string, 100)
|
||||
aliasLookup, err := ioutil.ReadFile(filepath.Join(helper.orgDir, "root-alias.json"))
|
||||
aliasLookup, err := os.ReadFile(filepath.Join(helper.orgDir, "root-alias.json"))
|
||||
if err != nil {
|
||||
return fmt.Errorf("missing dashboard alias files (must export dashboards first)")
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package featuremgmt
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
@@ -23,7 +23,7 @@ func readConfigFile(filename string) (*configBody, error) {
|
||||
|
||||
// Can ignore gosec G304 because the file path is forced within config subfolder
|
||||
//nolint:gosec
|
||||
yamlFile, err := ioutil.ReadFile(filename)
|
||||
yamlFile, err := os.ReadFile(filename)
|
||||
if err != nil {
|
||||
return cfg, err
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"html/template"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@@ -61,7 +60,7 @@ func TestFeatureToggleFiles(t *testing.T) {
|
||||
func verifyAndGenerateFile(t *testing.T, fpath string, gen string) {
|
||||
// nolint:gosec
|
||||
// We can ignore the gosec G304 warning since this is a test and the function is only called explicitly above
|
||||
body, err := ioutil.ReadFile(fpath)
|
||||
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)
|
||||
|
||||
@@ -5,9 +5,9 @@ import (
|
||||
"crypto/x509"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"net"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -101,7 +101,7 @@ func (server *Server) Dial() error {
|
||||
for _, caCertFile := range strings.Split(server.Config.RootCACert, " ") {
|
||||
// nolint:gosec
|
||||
// We can ignore the gosec G304 warning on this one because `caCertFile` comes from ldap config.
|
||||
pem, err := ioutil.ReadFile(caCertFile)
|
||||
pem, err := os.ReadFile(caCertFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package ldap
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"sync"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
@@ -123,7 +123,7 @@ func readConfig(configFile string) (*Config, error) {
|
||||
|
||||
// nolint:gosec
|
||||
// We can ignore the gosec G304 warning on this one because `filename` comes from grafana configuration file
|
||||
fileBytes, err := ioutil.ReadFile(configFile)
|
||||
fileBytes, err := os.ReadFile(configFile)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%v: %w", "Failed to load LDAP config file", err)
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
@@ -1124,7 +1124,7 @@ func (s *DryRunRuleStorage) ListChannelRules(_ context.Context, _ int64) ([]pipe
|
||||
|
||||
// HandlePipelineConvertTestHTTP ...
|
||||
func (g *GrafanaLive) HandlePipelineConvertTestHTTP(c *models.ReqContext) response.Response {
|
||||
body, err := ioutil.ReadAll(c.Req.Body)
|
||||
body, err := io.ReadAll(c.Req.Body)
|
||||
if err != nil {
|
||||
return response.Error(http.StatusInternalServerError, "Error reading body", err)
|
||||
}
|
||||
@@ -1169,7 +1169,7 @@ func (g *GrafanaLive) HandlePipelineConvertTestHTTP(c *models.ReqContext) respon
|
||||
|
||||
// HandleChannelRulesPostHTTP ...
|
||||
func (g *GrafanaLive) HandleChannelRulesPostHTTP(c *models.ReqContext) response.Response {
|
||||
body, err := ioutil.ReadAll(c.Req.Body)
|
||||
body, err := io.ReadAll(c.Req.Body)
|
||||
if err != nil {
|
||||
return response.Error(http.StatusInternalServerError, "Error reading body", err)
|
||||
}
|
||||
@@ -1189,7 +1189,7 @@ func (g *GrafanaLive) HandleChannelRulesPostHTTP(c *models.ReqContext) response.
|
||||
|
||||
// HandleChannelRulesPutHTTP ...
|
||||
func (g *GrafanaLive) HandleChannelRulesPutHTTP(c *models.ReqContext) response.Response {
|
||||
body, err := ioutil.ReadAll(c.Req.Body)
|
||||
body, err := io.ReadAll(c.Req.Body)
|
||||
if err != nil {
|
||||
return response.Error(http.StatusInternalServerError, "Error reading body", err)
|
||||
}
|
||||
@@ -1212,7 +1212,7 @@ func (g *GrafanaLive) HandleChannelRulesPutHTTP(c *models.ReqContext) response.R
|
||||
|
||||
// HandleChannelRulesDeleteHTTP ...
|
||||
func (g *GrafanaLive) HandleChannelRulesDeleteHTTP(c *models.ReqContext) response.Response {
|
||||
body, err := ioutil.ReadAll(c.Req.Body)
|
||||
body, err := io.ReadAll(c.Req.Body)
|
||||
if err != nil {
|
||||
return response.Error(http.StatusInternalServerError, "Error reading body", err)
|
||||
}
|
||||
@@ -1259,7 +1259,7 @@ func (g *GrafanaLive) HandleWriteConfigsListHTTP(c *models.ReqContext) response.
|
||||
|
||||
// HandleWriteConfigsPostHTTP ...
|
||||
func (g *GrafanaLive) HandleWriteConfigsPostHTTP(c *models.ReqContext) response.Response {
|
||||
body, err := ioutil.ReadAll(c.Req.Body)
|
||||
body, err := io.ReadAll(c.Req.Body)
|
||||
if err != nil {
|
||||
return response.Error(http.StatusInternalServerError, "Error reading body", err)
|
||||
}
|
||||
@@ -1279,7 +1279,7 @@ func (g *GrafanaLive) HandleWriteConfigsPostHTTP(c *models.ReqContext) response.
|
||||
|
||||
// HandleWriteConfigsPutHTTP ...
|
||||
func (g *GrafanaLive) HandleWriteConfigsPutHTTP(c *models.ReqContext) response.Response {
|
||||
body, err := ioutil.ReadAll(c.Req.Body)
|
||||
body, err := io.ReadAll(c.Req.Body)
|
||||
if err != nil {
|
||||
return response.Error(http.StatusInternalServerError, "Error reading body", err)
|
||||
}
|
||||
@@ -1323,7 +1323,7 @@ func (g *GrafanaLive) HandleWriteConfigsPutHTTP(c *models.ReqContext) response.R
|
||||
|
||||
// HandleWriteConfigsDeleteHTTP ...
|
||||
func (g *GrafanaLive) HandleWriteConfigsDeleteHTTP(c *models.ReqContext) response.Response {
|
||||
body, err := ioutil.ReadAll(c.Req.Body)
|
||||
body, err := io.ReadAll(c.Req.Body)
|
||||
if err != nil {
|
||||
return response.Error(http.StatusInternalServerError, "Error reading body", err)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package pipeline
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -19,7 +19,7 @@ func loadTestJson(t testing.TB, file string) []byte {
|
||||
t.Helper()
|
||||
// Safe to disable, this is a test.
|
||||
// nolint:gosec
|
||||
content, err := ioutil.ReadFile(filepath.Join("testdata", file+".json"))
|
||||
content, err := os.ReadFile(filepath.Join("testdata", file+".json"))
|
||||
require.NoError(t, err, "expected to be able to read file")
|
||||
require.True(t, len(content) > 0)
|
||||
return content
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
@@ -240,7 +239,7 @@ func (f *FileStorage) readRules() (ChannelRules, error) {
|
||||
ruleFile := f.ruleFilePath()
|
||||
// Safe to ignore gosec warning G304.
|
||||
// nolint:gosec
|
||||
ruleBytes, err := ioutil.ReadFile(ruleFile)
|
||||
ruleBytes, err := os.ReadFile(ruleFile)
|
||||
if err != nil {
|
||||
return ChannelRules{}, fmt.Errorf("can't read pipeline rules: %s: %w", f.ruleFilePath(), err)
|
||||
}
|
||||
@@ -309,7 +308,7 @@ func (f *FileStorage) readWriteConfigs() (WriteConfigs, error) {
|
||||
filePath := f.writeConfigsFilePath()
|
||||
// Safe to ignore gosec warning G304.
|
||||
// nolint:gosec
|
||||
bytes, err := ioutil.ReadFile(filePath)
|
||||
bytes, err := os.ReadFile(filePath)
|
||||
if err != nil {
|
||||
return WriteConfigs{}, fmt.Errorf("can't read %s file: %w", filePath, err)
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
@@ -18,7 +18,7 @@ func loadTestData(tb testing.TB, file string) []byte {
|
||||
tb.Helper()
|
||||
// Safe to disable, this is a test.
|
||||
// nolint:gosec
|
||||
content, err := ioutil.ReadFile(filepath.Join("testdata", file+".txt"))
|
||||
content, err := os.ReadFile(filepath.Join("testdata", file+".txt"))
|
||||
require.NoError(tb, err, "expected to be able to read file")
|
||||
require.True(tb, len(content) > 0)
|
||||
return content
|
||||
@@ -28,7 +28,7 @@ func checkTestData(t *testing.T, file string) *backend.DataResponse {
|
||||
t.Helper()
|
||||
// Safe to disable, this is a test.
|
||||
// nolint:gosec
|
||||
content, err := ioutil.ReadFile(filepath.Join("testdata", file+".txt"))
|
||||
content, err := os.ReadFile(filepath.Join("testdata", file+".txt"))
|
||||
require.NoError(t, err, "expected to be able to read file")
|
||||
require.True(t, len(content) > 0)
|
||||
|
||||
@@ -143,13 +143,13 @@ func TestConverter_Convert_NumFrameFields(t *testing.T) {
|
||||
frameJSON, err := json.MarshalIndent(frame, "", " ")
|
||||
require.NoError(t, err)
|
||||
if *update {
|
||||
if err := ioutil.WriteFile(goldenFile, frameJSON, 0600); err != nil {
|
||||
if err := os.WriteFile(goldenFile, frameJSON, 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
// Safe to disable, this is a test.
|
||||
// nolint:gosec
|
||||
want, err := ioutil.ReadFile(goldenFile)
|
||||
want, err := os.ReadFile(goldenFile)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -223,13 +223,13 @@ func TestConverter_Convert_NumFrameFields_LabelsColumn(t *testing.T) {
|
||||
frameJSON, err := json.MarshalIndent(frame, "", " ")
|
||||
require.NoError(t, err)
|
||||
if *update {
|
||||
if err := ioutil.WriteFile(goldenFile, frameJSON, 0600); err != nil {
|
||||
if err := os.WriteFile(goldenFile, frameJSON, 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
// Safe to disable, this is a test.
|
||||
// nolint:gosec
|
||||
want, err := ioutil.ReadFile(goldenFile)
|
||||
want, err := os.ReadFile(goldenFile)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ package main
|
||||
import (
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -22,7 +22,7 @@ func main() {
|
||||
}
|
||||
|
||||
//nolint
|
||||
b, err := ioutil.ReadFile(input)
|
||||
b, err := os.ReadFile(input)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@@ -101,7 +101,7 @@ func main() {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
err = ioutil.WriteFile(output, out, 0644)
|
||||
err = os.WriteFile(output, out, 0644)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package definitions
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
@@ -808,10 +808,10 @@ alertmanager_config: |
|
||||
func Test_GettableUserConfigRoundtrip(t *testing.T) {
|
||||
// raw contains secret fields. We'll unmarshal, re-marshal, and ensure
|
||||
// the fields are not redacted.
|
||||
yamlEncoded, err := ioutil.ReadFile("alertmanager_test_artifact.yaml")
|
||||
yamlEncoded, err := os.ReadFile("alertmanager_test_artifact.yaml")
|
||||
require.Nil(t, err)
|
||||
|
||||
jsonEncoded, err := ioutil.ReadFile("alertmanager_test_artifact.json")
|
||||
jsonEncoded, err := os.ReadFile("alertmanager_test_artifact.json")
|
||||
require.Nil(t, err)
|
||||
|
||||
// test GettableUserConfig (yamlDecode -> jsonEncode)
|
||||
@@ -1031,7 +1031,7 @@ routes:
|
||||
}
|
||||
|
||||
func Test_Marshaling_Validation(t *testing.T) {
|
||||
jsonEncoded, err := ioutil.ReadFile("alertmanager_test_artifact.json")
|
||||
jsonEncoded, err := os.ReadFile("alertmanager_test_artifact.json")
|
||||
require.Nil(t, err)
|
||||
|
||||
var tmp GettableUserConfig
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package channels
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
@@ -92,7 +91,7 @@ Labels:
|
||||
`
|
||||
|
||||
func templateForTests(t *testing.T) *template.Template {
|
||||
f, err := ioutil.TempFile("/tmp", "template")
|
||||
f, err := os.CreateTemp("/tmp", "template")
|
||||
require.NoError(t, err)
|
||||
defer func(f *os.File) {
|
||||
_ = f.Close()
|
||||
|
||||
@@ -2,7 +2,6 @@ package channels
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io/ioutil"
|
||||
"net/url"
|
||||
"os"
|
||||
"testing"
|
||||
@@ -56,7 +55,7 @@ func TestDefaultTemplateString(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
f, err := ioutil.TempFile("/tmp", "template")
|
||||
f, err := os.CreateTemp("/tmp", "template")
|
||||
require.NoError(t, err)
|
||||
defer func(f *os.File) {
|
||||
_ = f.Close()
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
@@ -268,7 +268,7 @@ func TestTeamsNotifier(t *testing.T) {
|
||||
expBody, err := json.Marshal(c.expMsg)
|
||||
require.NoError(t, err)
|
||||
|
||||
body, err := ioutil.ReadAll(clientStub.lastRequest.Body)
|
||||
body, err := io.ReadAll(clientStub.lastRequest.Body)
|
||||
require.NoError(t, err)
|
||||
require.JSONEq(t, string(expBody), string(body))
|
||||
})
|
||||
@@ -311,6 +311,6 @@ func newMockClient(resp *mockResponse) *mockClient {
|
||||
func makeResponse(status int, body string) *http.Response {
|
||||
return &http.Response{
|
||||
StatusCode: status,
|
||||
Body: ioutil.NopCloser(strings.NewReader(body)),
|
||||
Body: io.NopCloser(strings.NewReader(body)),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ func PersistTemplates(cfg *api.PostableUserConfig, path string) ([]string, bool,
|
||||
// Check if the template file already exists and if it has changed
|
||||
// We can safely ignore gosec here as we've previously checked the filename is clean
|
||||
// nolint:gosec
|
||||
if tmpl, err := ioutil.ReadFile(file); err == nil && string(tmpl) == content {
|
||||
if tmpl, err := os.ReadFile(file); err == nil && string(tmpl) == content {
|
||||
// Templates file is the same we have, no-op and continue.
|
||||
continue
|
||||
} else if err != nil && !os.IsNotExist(err) {
|
||||
@@ -45,7 +45,7 @@ func PersistTemplates(cfg *api.PostableUserConfig, path string) ([]string, bool,
|
||||
|
||||
// We can safely ignore gosec here as we've previously checked the filename is clean
|
||||
// nolint:gosec
|
||||
if err := ioutil.WriteFile(file, []byte(content), 0644); err != nil {
|
||||
if err := os.WriteFile(file, []byte(content), 0644); err != nil {
|
||||
return nil, false, fmt.Errorf("unable to create Alertmanager template file %q: %s", file, err)
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package notifier
|
||||
import (
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
@@ -71,7 +72,7 @@ func TestPersistTemplates(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
// Write "existing files"
|
||||
for name, content := range tt.existingTemplates {
|
||||
err := ioutil.WriteFile(filepath.Join(dir, name), []byte(content), 0644)
|
||||
err := os.WriteFile(filepath.Join(dir, name), []byte(content), 0644)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
c := &api.PostableUserConfig{TemplateFiles: tt.templates}
|
||||
@@ -87,7 +88,7 @@ func TestPersistTemplates(t *testing.T) {
|
||||
}
|
||||
// Safe to disable, this is a test.
|
||||
// nolint:gosec
|
||||
content, err := ioutil.ReadFile(filepath.Join(dir, f.Name()))
|
||||
content, err := os.ReadFile(filepath.Join(dir, f.Name()))
|
||||
// nolint:gosec
|
||||
require.NoError(t, err)
|
||||
files[f.Name()] = string(content)
|
||||
|
||||
@@ -2,7 +2,6 @@ package notifier
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
@@ -24,7 +23,7 @@ func TestFileStore_FilepathFor_DirectoryNotExist(t *testing.T) {
|
||||
r, err := fs.FilepathFor(context.Background(), filekey)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, filePath, r)
|
||||
f, err := ioutil.ReadFile(filepath.Clean(filePath))
|
||||
f, err := os.ReadFile(filepath.Clean(filePath))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "silence1,silence3", string(f))
|
||||
require.NoError(t, os.Remove(filePath))
|
||||
@@ -44,7 +43,7 @@ func TestFileStore_FilepathFor(t *testing.T) {
|
||||
r, err := fs.FilepathFor(context.Background(), filekey)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, filePath, r)
|
||||
f, err := ioutil.ReadFile(filepath.Clean(filePath))
|
||||
f, err := os.ReadFile(filepath.Clean(filePath))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "silence1,silence2", string(f))
|
||||
require.NoError(t, os.Remove(filePath))
|
||||
@@ -56,7 +55,7 @@ func TestFileStore_FilepathFor(t *testing.T) {
|
||||
r, err := fs.FilepathFor(context.Background(), filekey)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, filePath, r)
|
||||
f, err := ioutil.ReadFile(filepath.Clean(filePath))
|
||||
f, err := os.ReadFile(filepath.Clean(filePath))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "silence1,silence3", string(f))
|
||||
require.NoError(t, os.Remove(filePath))
|
||||
@@ -68,7 +67,7 @@ func TestFileStore_FilepathFor(t *testing.T) {
|
||||
r, err := fs.FilepathFor(context.Background(), filekey)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, filePath, r)
|
||||
_, err = ioutil.ReadFile(filepath.Clean(filePath))
|
||||
_, err = os.ReadFile(filepath.Clean(filePath))
|
||||
require.Error(t, err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package sender
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"sync"
|
||||
@@ -71,7 +71,7 @@ func (am *FakeExternalAlertmanager) Alerts() amv2.PostableAlerts {
|
||||
|
||||
func (am *FakeExternalAlertmanager) Handler() func(w http.ResponseWriter, r *http.Request) {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
b, err := ioutil.ReadAll(r.Body)
|
||||
b, err := io.ReadAll(r.Body)
|
||||
require.NoError(am.t, err)
|
||||
|
||||
a := amv2.PostableAlerts{}
|
||||
|
||||
@@ -2,7 +2,7 @@ package notifications
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
@@ -62,9 +62,9 @@ func TestEmailIntegrationTest(t *testing.T) {
|
||||
sentMsg := <-ns.mailQueue
|
||||
require.Equal(t, sentMsg.From, "Grafana Admin <from@address.com>")
|
||||
require.Equal(t, sentMsg.To[0], "asdf@asdf.com")
|
||||
err = ioutil.WriteFile("../../../tmp/test_email.html", []byte(sentMsg.Body["text/html"]), 0777)
|
||||
err = os.WriteFile("../../../tmp/test_email.html", []byte(sentMsg.Body["text/html"]), 0777)
|
||||
require.NoError(t, err)
|
||||
err = ioutil.WriteFile("../../../tmp/test_email.txt", []byte(sentMsg.Body["text/plain"]), 0777)
|
||||
err = os.WriteFile("../../../tmp/test_email.txt", []byte(sentMsg.Body["text/plain"]), 0777)
|
||||
require.NoError(t, err)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
"time"
|
||||
@@ -88,7 +88,7 @@ func (ns *NotificationService) sendWebRequestSync(ctx context.Context, webhook *
|
||||
}
|
||||
}()
|
||||
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
@@ -65,7 +66,7 @@ func (cr *rulesConfigReader) parseConfig(path string, file fs.FileInfo) (*Alerti
|
||||
filename, _ := filepath.Abs(filepath.Join(path, file.Name()))
|
||||
// nolint:gosec
|
||||
// We can ignore the gosec G304 warning on this one because `filename` comes from ps.Cfg.ProvisioningPath
|
||||
yamlFile, err := ioutil.ReadFile(filename)
|
||||
yamlFile, err := os.ReadFile(filename)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ func (cr *configReader) parseConfigs(file os.FileInfo) ([]*config, error) {
|
||||
|
||||
// nolint:gosec
|
||||
// We can ignore the gosec G304 warning on this one because `filename` comes from ps.Cfg.ProvisioningPath
|
||||
yamlFile, err := ioutil.ReadFile(filename)
|
||||
yamlFile, err := os.ReadFile(filename)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@@ -397,7 +397,7 @@ func (fr *FileReader) readDashboardFromFile(path string, lastModified time.Time,
|
||||
}
|
||||
}()
|
||||
|
||||
all, err := ioutil.ReadAll(reader)
|
||||
all, err := io.ReadAll(reader)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ func (cr *configReader) parseDatasourceConfig(path string, file os.FileInfo) (*c
|
||||
|
||||
// nolint:gosec
|
||||
// We can ignore the gosec G304 warning on this one because `filename` comes from ps.Cfg.ProvisioningPath
|
||||
yamlFile, err := ioutil.ReadFile(filename)
|
||||
yamlFile, err := os.ReadFile(filename)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ func (cr *configReader) parseNotificationConfig(path string, file os.FileInfo) (
|
||||
|
||||
// nolint:gosec
|
||||
// We can ignore the gosec G304 warning on this one because `filename` comes from ps.Cfg.ProvisioningPath
|
||||
yamlFile, err := ioutil.ReadFile(filename)
|
||||
yamlFile, err := os.ReadFile(filename)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ func (cr *configReaderImpl) parsePluginConfig(path string, file os.FileInfo) (*p
|
||||
|
||||
// nolint:gosec
|
||||
// We can ignore the gosec G304 warning on this one because `filename` comes from ps.Cfg.ProvisioningPath
|
||||
yamlFile, err := ioutil.ReadFile(filename)
|
||||
yamlFile, err := os.ReadFile(filename)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package values
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
@@ -311,7 +310,7 @@ func TestValues_readFile(t *testing.T) {
|
||||
Val StringValue `yaml:"val"`
|
||||
}
|
||||
|
||||
f, err := ioutil.TempFile(os.TempDir(), "file expansion *")
|
||||
f, err := os.CreateTemp(os.TempDir(), "file expansion *")
|
||||
require.NoError(t, err)
|
||||
file := f.Name()
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
@@ -356,7 +355,7 @@ func (i *searchIndex) reportSizeOfIndexDiskBackup(orgID int64) {
|
||||
defer cancel()
|
||||
|
||||
// create a temp directory to store the index
|
||||
tmpDir, err := ioutil.TempDir("", "grafana.dashboard_index")
|
||||
tmpDir, err := os.MkdirTemp("", "grafana.dashboard_index")
|
||||
if err != nil {
|
||||
i.logger.Error("can't create temp dir", "error", err)
|
||||
return
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"github.com/grafana/grafana/pkg/infra/log"
|
||||
)
|
||||
@@ -13,7 +13,7 @@ var tlslog = log.New("tls_mysql")
|
||||
|
||||
func makeCert(config DatabaseConfig) (*tls.Config, error) {
|
||||
rootCertPool := x509.NewCertPool()
|
||||
pem, err := ioutil.ReadFile(config.CaCertPath)
|
||||
pem, err := os.ReadFile(config.CaCertPath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not read DB CA Cert path %q: %w", config.CaCertPath, err)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package store
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
@@ -32,7 +31,7 @@ func LoadStorageConfig(cfg *setting.Cfg, features featuremgmt.FeatureToggles) (*
|
||||
if _, err := os.Stat(fpath); err == nil {
|
||||
// nolint:gosec
|
||||
// We can ignore the gosec G304 warning since the path is hardcoded above
|
||||
body, err := ioutil.ReadFile(fpath)
|
||||
body, err := os.ReadFile(fpath)
|
||||
if err != nil {
|
||||
return g, err
|
||||
}
|
||||
@@ -96,7 +95,7 @@ func (c *GlobalStorageConfig) save() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return ioutil.WriteFile(c.filepath, out, 0600)
|
||||
return os.WriteFile(c.filepath, out, 0600)
|
||||
}
|
||||
|
||||
type RootStorageConfig struct {
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
@@ -114,7 +113,7 @@ func (s *standardStorageService) doUpload(c *models.ReqContext) response.Respons
|
||||
if err != nil {
|
||||
return response.Error(500, "Internal Server Error", err)
|
||||
}
|
||||
data, err := ioutil.ReadAll(file)
|
||||
data, err := io.ReadAll(file)
|
||||
if err != nil {
|
||||
return response.Error(500, "Internal Server Error", err)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package store
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
@@ -24,9 +24,9 @@ var (
|
||||
AllowUnsanitizedSvgUpload: true,
|
||||
},
|
||||
}
|
||||
htmlBytes, _ = ioutil.ReadFile("testdata/page.html")
|
||||
jpgBytes, _ = ioutil.ReadFile("testdata/image.jpg")
|
||||
svgBytes, _ = ioutil.ReadFile("testdata/image.svg")
|
||||
htmlBytes, _ = os.ReadFile("testdata/page.html")
|
||||
jpgBytes, _ = os.ReadFile("testdata/image.jpg")
|
||||
svgBytes, _ = os.ReadFile("testdata/image.svg")
|
||||
dummyUser = &user.SignedInUser{OrgId: 1}
|
||||
allowAllAuthService = newStaticStorageAuthService(func(ctx context.Context, user *user.SignedInUser, storageName string) map[string]filestorage.PathFilter {
|
||||
return map[string]filestorage.PathFilter{
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
@@ -388,7 +387,7 @@ func (hs *thumbService) SetImage(c *models.ReqContext) {
|
||||
hs.log.Info("File Size: %+v\n", handler.Size)
|
||||
hs.log.Info("MIME Header: %+v\n", handler.Header)
|
||||
|
||||
fileBytes, err := ioutil.ReadAll(file)
|
||||
fileBytes, err := io.ReadAll(file)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
c.JSON(400, map[string]string{"error": "error reading file"})
|
||||
|
||||
@@ -3,7 +3,7 @@ package updatechecker
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
"sync"
|
||||
@@ -68,7 +68,7 @@ func (s *GrafanaService) checkForUpdates() {
|
||||
s.log.Warn("Failed to close response body", "err", err)
|
||||
}
|
||||
}()
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
s.log.Debug("Update check failed, reading response from github.com", "error", err)
|
||||
return
|
||||
|
||||
@@ -3,7 +3,7 @@ package updatechecker
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
"sync"
|
||||
@@ -99,7 +99,7 @@ func (s *PluginsService) checkForUpdates(ctx context.Context) {
|
||||
}
|
||||
}()
|
||||
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
s.log.Debug("Update check failed, reading response from grafana.com", "error", err.Error())
|
||||
return
|
||||
|
||||
@@ -2,7 +2,7 @@ package updatechecker
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -190,7 +190,7 @@ func (c *fakeHTTPClient) Get(url string) (*http.Response, error) {
|
||||
c.requestURL = url
|
||||
|
||||
resp := &http.Response{
|
||||
Body: ioutil.NopCloser(strings.NewReader(c.fakeResp)),
|
||||
Body: io.NopCloser(strings.NewReader(c.fakeResp)),
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
|
||||
Reference in New Issue
Block a user