Move away from deprecated go funcs (#1123)

This commit is contained in:
6543 2022-08-25 08:39:19 +02:00 committed by GitHub
parent d3eea72663
commit f21d854114
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 7 additions and 11 deletions

View file

@ -18,7 +18,6 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"io" "io"
"io/ioutil"
"runtime" "runtime"
"strconv" "strconv"
"sync" "sync"
@ -211,7 +210,7 @@ func (r *Runner) Run(ctx context.Context) error {
} }
// TODO should be configurable // TODO should be configurable
limitedPart = io.LimitReader(part, maxFileUpload) limitedPart = io.LimitReader(part, maxFileUpload)
data, err = ioutil.ReadAll(limitedPart) data, err = io.ReadAll(limitedPart)
if err != nil { if err != nil {
loglogger.Err(err).Msg("could not read limited part") loglogger.Err(err).Msg("could not read limited part")
} }

View file

@ -4,7 +4,6 @@ import (
"context" "context"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"os" "os"
"path" "path"
"path/filepath" "path/filepath"
@ -72,7 +71,7 @@ func execFile(c *cli.Context, file string) error {
} }
func runExec(c *cli.Context, file, repoPath string) error { func runExec(c *cli.Context, file, repoPath string) error {
dat, err := ioutil.ReadFile(file) dat, err := os.ReadFile(file)
if err != nil { if err != nil {
return err return err
} }

View file

@ -4,7 +4,6 @@ import (
"context" "context"
"encoding/base64" "encoding/base64"
"io" "io"
"io/ioutil"
"os" "os"
"os/exec" "os/exec"
"strings" "strings"
@ -36,7 +35,7 @@ func (e *local) IsAvailable() bool {
} }
func (e *local) Load() error { func (e *local) Load() error {
dir, err := ioutil.TempDir("", "woodpecker-local-*") dir, err := os.MkdirTemp("", "woodpecker-local-*")
e.workingdir = dir e.workingdir = dir
return err return err
} }

View file

@ -16,7 +16,7 @@ package datastore
import ( import (
"bytes" "bytes"
"io/ioutil" "io"
"testing" "testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
@ -71,7 +71,7 @@ func TestFileFind(t *testing.T) {
t.Error(err) t.Error(err)
return return
} }
out, _ := ioutil.ReadAll(rc) out, _ := io.ReadAll(rc)
if got, want := string(out), "hello world"; got != want { if got, want := string(out), "hello world"; got != want {
t.Errorf("Want file data %s, got %s", want, got) t.Errorf("Want file data %s, got %s", want, got)
} }

View file

@ -17,7 +17,6 @@ package datastore
import ( import (
"bytes" "bytes"
"io" "io"
"io/ioutil"
"github.com/woodpecker-ci/woodpecker/server/model" "github.com/woodpecker-ci/woodpecker/server/model"
) )
@ -30,11 +29,11 @@ func (s storage) LogFind(proc *model.Proc) (io.ReadCloser, error) {
return nil, err return nil, err
} }
buf := bytes.NewBuffer(logs.Data) buf := bytes.NewBuffer(logs.Data)
return ioutil.NopCloser(buf), nil return io.NopCloser(buf), nil
} }
func (s storage) LogSave(proc *model.Proc, reader io.Reader) error { func (s storage) LogSave(proc *model.Proc, reader io.Reader) error {
data, _ := ioutil.ReadAll(reader) data, _ := io.ReadAll(reader)
sess := s.engine.NewSession() sess := s.engine.NewSession()
defer sess.Close() defer sess.Close()