mirror of
https://github.com/akvorado/akvorado.git
synced 2025-12-12 06:24:10 +01:00
build: don't use ioutil
This is deprecated.
This commit is contained in:
@@ -6,7 +6,6 @@ package cmd_test
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
@@ -84,7 +83,7 @@ module1:
|
||||
workers: -5
|
||||
`
|
||||
configFile := filepath.Join(t.TempDir(), "config.yaml")
|
||||
ioutil.WriteFile(configFile, []byte(config), 0o644)
|
||||
os.WriteFile(configFile, []byte(config), 0o644)
|
||||
|
||||
c := cmd.ConfigRelatedOptions{
|
||||
Path: configFile,
|
||||
@@ -117,7 +116,7 @@ module2:
|
||||
- name: second
|
||||
`
|
||||
configFile := filepath.Join(t.TempDir(), "config.yaml")
|
||||
ioutil.WriteFile(configFile, []byte(config), 0o644)
|
||||
os.WriteFile(configFile, []byte(config), 0o644)
|
||||
|
||||
c := cmd.ConfigRelatedOptions{
|
||||
Path: configFile,
|
||||
@@ -198,7 +197,7 @@ module2:
|
||||
interval-value: 20m
|
||||
`
|
||||
configFile := filepath.Join(t.TempDir(), "config.yaml")
|
||||
ioutil.WriteFile(configFile, []byte(config), 0o644)
|
||||
os.WriteFile(configFile, []byte(config), 0o644)
|
||||
|
||||
// Environment
|
||||
clean := func() {
|
||||
@@ -319,7 +318,7 @@ module1:
|
||||
workers: 10
|
||||
`
|
||||
configFile := filepath.Join(t.TempDir(), "config.yaml")
|
||||
ioutil.WriteFile(configFile, []byte(config), 0o644)
|
||||
os.WriteFile(configFile, []byte(config), 0o644)
|
||||
|
||||
c := cmd.ConfigRelatedOptions{Path: configFile}
|
||||
|
||||
@@ -339,7 +338,7 @@ module1:
|
||||
workers: 10
|
||||
`
|
||||
configFile := filepath.Join(t.TempDir(), "config.yaml")
|
||||
ioutil.WriteFile(configFile, []byte(config), 0o644)
|
||||
os.WriteFile(configFile, []byte(config), 0o644)
|
||||
|
||||
c := cmd.ConfigRelatedOptions{Path: configFile}
|
||||
|
||||
@@ -366,7 +365,7 @@ modules:
|
||||
topic: flows2
|
||||
`
|
||||
configFile := filepath.Join(t.TempDir(), "config.yaml")
|
||||
ioutil.WriteFile(configFile, []byte(config), 0o644)
|
||||
os.WriteFile(configFile, []byte(config), 0o644)
|
||||
|
||||
c := cmd.ConfigRelatedOptions{
|
||||
Path: configFile,
|
||||
|
||||
@@ -5,7 +5,7 @@ package cmd
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"strconv"
|
||||
@@ -27,7 +27,7 @@ func TestOrchestratorStart(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestOrchestratorConfig(t *testing.T) {
|
||||
tests, err := ioutil.ReadDir("testdata/configurations")
|
||||
tests, err := os.ReadDir("testdata/configurations")
|
||||
if err != nil {
|
||||
t.Fatalf("ReadDir(%q) error:\n%+v", "testdata/configurations", err)
|
||||
}
|
||||
@@ -36,7 +36,7 @@ func TestOrchestratorConfig(t *testing.T) {
|
||||
continue
|
||||
}
|
||||
t.Run(test.Name(), func(t *testing.T) {
|
||||
expected, err := ioutil.ReadFile(
|
||||
expected, err := os.ReadFile(
|
||||
filepath.Join("testdata/configurations", test.Name(), "expected.yaml"))
|
||||
if err != nil {
|
||||
t.Fatalf("ReadFile() error:\n%+v", err)
|
||||
|
||||
3
common/helpers/cache/persist.go
vendored
3
common/helpers/cache/persist.go
vendored
@@ -7,14 +7,13 @@ import (
|
||||
"bytes"
|
||||
"encoding/gob"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
// Save persists the cache to the specified file
|
||||
func (c *Cache[K, V]) Save(cacheFile string) error {
|
||||
tmpFile, err := ioutil.TempFile(
|
||||
tmpFile, err := os.CreateTemp(
|
||||
filepath.Dir(cacheFile),
|
||||
fmt.Sprintf("%s-*", filepath.Base(cacheFile)))
|
||||
if err != nil {
|
||||
|
||||
@@ -6,7 +6,7 @@ package httpserver
|
||||
import (
|
||||
"bytes"
|
||||
"crypto"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"time"
|
||||
|
||||
cache "github.com/chenyahui/gin-cache"
|
||||
@@ -31,7 +31,7 @@ func (c *Component) CacheByRequestBody(expire time.Duration) gin.HandlerFunc {
|
||||
opts := c.commonCacheOptions()
|
||||
opts = append(opts, cache.WithCacheStrategyByRequest(func(gc *gin.Context) (bool, cache.Strategy) {
|
||||
requestBody, err := gc.GetRawData()
|
||||
gc.Request.Body = ioutil.NopCloser(bytes.NewBuffer(requestBody))
|
||||
gc.Request.Body = io.NopCloser(bytes.NewBuffer(requestBody))
|
||||
if err != nil {
|
||||
return false, cache.Strategy{}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"io/fs"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"strings"
|
||||
@@ -74,7 +73,7 @@ func (c *Component) docsHandlerFunc(gc *gin.Context) {
|
||||
}
|
||||
|
||||
// Markdown rendering to build ToC
|
||||
content, _ := ioutil.ReadAll(f)
|
||||
content, _ := io.ReadAll(f)
|
||||
f.Close()
|
||||
if matches[3] == requestedDocument {
|
||||
// That's the one we need to do final rendering on.
|
||||
|
||||
@@ -5,7 +5,7 @@ package console
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -40,7 +40,7 @@ func TestServeDocs(t *testing.T) {
|
||||
t.Errorf("GET /api/v0/console/docs/%s: got status code %d, not 200",
|
||||
tc.Path, resp.StatusCode)
|
||||
}
|
||||
body, _ := ioutil.ReadAll(resp.Body)
|
||||
body, _ := io.ReadAll(resp.Body)
|
||||
if !strings.Contains(string(body), tc.Expect) {
|
||||
t.Logf("Body:\n%s", string(body))
|
||||
t.Errorf("GET /api/v0/console/docs/%s: does not contain %q",
|
||||
|
||||
@@ -6,8 +6,8 @@ package file
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"gopkg.in/tomb.v2"
|
||||
@@ -50,7 +50,7 @@ func (in *Input) Start() (<-chan []*schema.FlowMessage, error) {
|
||||
in.t.Go(func() error {
|
||||
for idx := 0; true; idx++ {
|
||||
path := in.config.Paths[idx%len(in.config.Paths)]
|
||||
data, err := ioutil.ReadFile(path)
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
in.r.Err(err).Str("path", path).Msg("unable to read path")
|
||||
return err
|
||||
|
||||
@@ -9,8 +9,8 @@ import (
|
||||
"encoding/csv"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
"strconv"
|
||||
"text/template"
|
||||
"time"
|
||||
@@ -103,7 +103,7 @@ func (c *Component) registerHTTPHandlers() error {
|
||||
w.WriteHeader(http.StatusServiceUnavailable)
|
||||
return
|
||||
}
|
||||
file, err := ioutil.ReadFile(v.Source)
|
||||
file, err := os.ReadFile(v.Source)
|
||||
if err != nil {
|
||||
c.r.Err(err).Msg("unable to deliver custom dict csv file")
|
||||
http.Error(w, fmt.Sprintf("unable to deliver custom dict csv file %s", v.Source), http.StatusNotFound)
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"encoding/csv"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/url"
|
||||
"os"
|
||||
"path"
|
||||
@@ -199,7 +198,7 @@ func TestMigration(t *testing.T) {
|
||||
|
||||
var lastRun map[string]string
|
||||
var lastSteps int
|
||||
files, err := ioutil.ReadDir("testdata/states")
|
||||
files, err := os.ReadDir("testdata/states")
|
||||
if err != nil {
|
||||
t.Fatalf("ReadDir(%q) error:\n%+v", "testdata/states", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user