mirror of
https://github.com/zrepl/zrepl.git
synced 2024-11-21 16:03:32 +01:00
chore: io/ioutil has been deprecated
This commit is contained in:
parent
48c5b60024
commit
740ab4b1b2
@ -2,7 +2,6 @@ package config
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"log/syslog"
|
"log/syslog"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
@ -671,7 +670,7 @@ func ParseConfig(path string) (i *Config, err error) {
|
|||||||
|
|
||||||
var bytes []byte
|
var bytes []byte
|
||||||
|
|
||||||
if bytes, err = ioutil.ReadFile(path); err != nil {
|
if bytes, err = os.ReadFile(path); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
@ -64,7 +63,7 @@ func (o *FSOp) Run(ctx context.Context, e Execer) error {
|
|||||||
if o.Encrypted {
|
if o.Encrypted {
|
||||||
const passphraseFilePath = "/tmp/zreplplatformtest.encryption.passphrase"
|
const passphraseFilePath = "/tmp/zreplplatformtest.encryption.passphrase"
|
||||||
const passphrase = "foobar2342"
|
const passphrase = "foobar2342"
|
||||||
err := ioutil.WriteFile(passphraseFilePath, []byte(passphrase), 0600)
|
err := os.WriteFile(passphraseFilePath, []byte(passphrase), 0600)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ import (
|
|||||||
"go/format"
|
"go/format"
|
||||||
"go/parser"
|
"go/parser"
|
||||||
"go/token"
|
"go/token"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
@ -132,7 +131,7 @@ var Cases = []Case {
|
|||||||
formatted, err := format.Source(buf.Bytes())
|
formatted, err := format.Source(buf.Bytes())
|
||||||
check(err)
|
check(err)
|
||||||
|
|
||||||
err = ioutil.WriteFile("generated_cases.go", formatted, 0664)
|
err = os.WriteFile("generated_cases.go", formatted, 0664)
|
||||||
check(err)
|
check(err)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package tests
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path"
|
"path"
|
||||||
@ -102,7 +101,7 @@ func SendStreamCloseAfterEOFRead(ctx *platformtest.Context) {
|
|||||||
|
|
||||||
sendStream := sendStreamTest(ctx)
|
sendStream := sendStreamTest(ctx)
|
||||||
|
|
||||||
_, err := io.Copy(ioutil.Discard, sendStream)
|
_, err := io.Copy(io.Discard, sendStream)
|
||||||
require.NoError(ctx, err)
|
require.NoError(ctx, err)
|
||||||
|
|
||||||
var buf [128]byte
|
var buf [128]byte
|
||||||
@ -122,7 +121,7 @@ func SendStreamMultipleCloseAfterEOF(ctx *platformtest.Context) {
|
|||||||
|
|
||||||
sendStream := sendStreamTest(ctx)
|
sendStream := sendStreamTest(ctx)
|
||||||
|
|
||||||
_, err := io.Copy(ioutil.Discard, sendStream)
|
_, err := io.Copy(io.Discard, sendStream)
|
||||||
require.NoError(ctx, err)
|
require.NoError(ctx, err)
|
||||||
|
|
||||||
var buf [128]byte
|
var buf [128]byte
|
||||||
|
@ -5,7 +5,6 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"net"
|
"net"
|
||||||
"sync"
|
"sync"
|
||||||
"syscall"
|
"syscall"
|
||||||
@ -354,7 +353,7 @@ func (c *Conn) Shutdown(deadline time.Time) error {
|
|||||||
// TODO DoS mitigation by reading limited number of bytes
|
// TODO DoS mitigation by reading limited number of bytes
|
||||||
// see discussion above why this is non-trivial
|
// see discussion above why this is non-trivial
|
||||||
defer prometheus.NewTimer(prom.ShutdownDrainSeconds).ObserveDuration()
|
defer prometheus.NewTimer(prom.ShutdownDrainSeconds).ObserveDuration()
|
||||||
n, _ := io.Copy(ioutil.Discard, c.nc)
|
n, _ := io.Copy(io.Discard, c.nc)
|
||||||
prom.ShutdownDrainBytesRead.Observe(float64(n))
|
prom.ShutdownDrainBytesRead.Observe(float64(n))
|
||||||
|
|
||||||
return closeWire("close")
|
return closeWire("close")
|
||||||
|
@ -5,7 +5,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
|
||||||
@ -47,7 +46,7 @@ func main() {
|
|||||||
flag.StringVar(&args.testCase, "testcase", "", "")
|
flag.StringVar(&args.testCase, "testcase", "", "")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
bytes, err := ioutil.ReadFile(args.configPath)
|
bytes, err := os.ReadFile(args.configPath)
|
||||||
noerror(err)
|
noerror(err)
|
||||||
err = yaml.UnmarshalStrict(bytes, &conf)
|
err = yaml.UnmarshalStrict(bytes, &conf)
|
||||||
noerror(err)
|
noerror(err)
|
||||||
|
@ -3,7 +3,6 @@ package main
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/zrepl/zrepl/transport"
|
"github.com/zrepl/zrepl/transport"
|
||||||
@ -83,7 +82,7 @@ func (CloseWrite) receiver(wire transport.Wire) {
|
|||||||
// consume half the test data, then detect an error, send it and CloseWrite
|
// consume half the test data, then detect an error, send it and CloseWrite
|
||||||
|
|
||||||
r := io.LimitReader(wire, int64(5*len(closeWriteTestSendData)/3))
|
r := io.LimitReader(wire, int64(5*len(closeWriteTestSendData)/3))
|
||||||
_, err := io.Copy(ioutil.Discard, r)
|
_, err := io.Copy(io.Discard, r)
|
||||||
noerror(err)
|
noerror(err)
|
||||||
|
|
||||||
var errBuf bytes.Buffer
|
var errBuf bytes.Buffer
|
||||||
@ -95,7 +94,7 @@ func (CloseWrite) receiver(wire transport.Wire) {
|
|||||||
noerror(err)
|
noerror(err)
|
||||||
|
|
||||||
// drain wire, as documented in transport.Wire, this is the only way we know the client closed the conn
|
// drain wire, as documented in transport.Wire, this is the only way we know the client closed the conn
|
||||||
_, err = io.Copy(ioutil.Discard, wire)
|
_, err = io.Copy(io.Discard, wire)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// io.Copy masks io.EOF to nil, and we expect io.EOF from the client's Close() call
|
// io.Copy masks io.EOF to nil, and we expect io.EOF from the client's Close() call
|
||||||
log.Panicf("unexpected error returned from reading conn: %s", err)
|
log.Panicf("unexpected error returned from reading conn: %s", err)
|
||||||
|
@ -6,7 +6,6 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
@ -14,7 +13,7 @@ import (
|
|||||||
|
|
||||||
func ParseCAFile(certfile string) (*x509.CertPool, error) {
|
func ParseCAFile(certfile string) (*x509.CertPool, error) {
|
||||||
pool := x509.NewCertPool()
|
pool := x509.NewCertPool()
|
||||||
pem, err := ioutil.ReadFile(certfile)
|
pem, err := os.ReadFile(certfile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package zfs
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -20,7 +19,7 @@ func getPipeCapacityHint(envvar string) int {
|
|||||||
// https://github.com/zrepl/zrepl/issues/424#issuecomment-800370928
|
// https://github.com/zrepl/zrepl/issues/424#issuecomment-800370928
|
||||||
// https://bugzilla.kernel.org/show_bug.cgi?id=212295
|
// https://bugzilla.kernel.org/show_bug.cgi?id=212295
|
||||||
if _, err := os.Stat("/proc/sys/fs/pipe-max-size"); err == nil {
|
if _, err := os.Stat("/proc/sys/fs/pipe-max-size"); err == nil {
|
||||||
if dat, err := ioutil.ReadFile("/proc/sys/fs/pipe-max-size"); err == nil {
|
if dat, err := os.ReadFile("/proc/sys/fs/pipe-max-size"); err == nil {
|
||||||
if capacity, err = strconv.ParseInt(strings.TrimSpace(string(dat)), 10, 64); err != nil {
|
if capacity, err = strconv.ParseInt(strings.TrimSpace(string(dat)), 10, 64); err != nil {
|
||||||
capacity = 1 << 25
|
capacity = 1 << 25
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user