Skip to content

Commit

Permalink
chore: remove refs to deprecated io/ioutil (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
testwill authored Feb 25, 2024
1 parent c41e487 commit a50a4f1
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 19 deletions.
6 changes: 3 additions & 3 deletions appui/disk_usage_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package appui

import (
"io/ioutil"
"os"
"path/filepath"
"testing"
"time"
Expand Down Expand Up @@ -65,9 +65,9 @@ func TestDockerDiskUsageRenderer_Render(t *testing.T) {

golden := filepath.Join("testdata", tt.name+".golden")
if *update {
ioutil.WriteFile(golden, []byte(actual), 0644)
os.WriteFile(golden, []byte(actual), 0644)
}
expected, _ := ioutil.ReadFile(golden)
expected, _ := os.ReadFile(golden)
if string(expected) != actual {
t.Errorf("DockerDiskUsageRenderer.Render(), got: \n%v\nWant: \n%s", actual, expected)
}
Expand Down
6 changes: 3 additions & 3 deletions appui/swarm/service_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package swarm

import (
"flag"
"io/ioutil"
"os"
"path/filepath"
"testing"

Expand Down Expand Up @@ -74,9 +74,9 @@ func Test_serviceInfo(t *testing.T) {

golden := filepath.Join("testdata", tt.name+".golden")
if *updateGoldenFiles {
ioutil.WriteFile(golden, []byte(got), 0644)
os.WriteFile(golden, []byte(got), 0644)
}
expected, _ := ioutil.ReadFile(golden)
expected, _ := os.ReadFile(golden)

if got != string(expected) {
t.Errorf("serviceInfo() = %v, want %v", got, expected)
Expand Down
6 changes: 3 additions & 3 deletions appui/volumes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package appui

import (
"context"
"io/ioutil"
"os"
"path/filepath"
"strings"
"testing"
Expand Down Expand Up @@ -259,9 +259,9 @@ func TestVolumesWidget(t *testing.T) {

golden := filepath.Join("testdata", strings.ReplaceAll(tt.name, " ", "_")+".golden")
if *update {
ioutil.WriteFile(golden, []byte(got), 0644)
os.WriteFile(golden, []byte(got), 0644)
}
want, err := ioutil.ReadFile(golden)
want, err := os.ReadFile(golden)

if got != string(want) {
t.Errorf("NewVolumesWidget() = %v, want %v", got, string(want))
Expand Down
5 changes: 2 additions & 3 deletions docker/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"crypto/tls"
"golang.org/x/crypto/ssh"
"io/ioutil"
"net"
"net/http"
"net/url"
Expand Down Expand Up @@ -180,7 +179,7 @@ func configureSshTransport(host string, user string, pass string) (*ssh.ClientCo
}

if !foundIdentityFile {
pkFilenames, err := ioutil.ReadDir(dirname + "/.ssh/")
pkFilenames, err := os.ReadDir(dirname + "/.ssh/")
if err != nil {
return nil, err
}
Expand All @@ -206,7 +205,7 @@ func configureSshTransport(host string, user string, pass string) (*ssh.ClientCo
}

func readPk(pkFilename string, auth []ssh.AuthMethod, dirname string) ([]ssh.AuthMethod, error) {
pk, err := ioutil.ReadFile(dirname + pkFilename)
pk, err := os.ReadFile(dirname + pkFilename)
if err != nil {
return nil, nil
}
Expand Down
9 changes: 4 additions & 5 deletions docker/stats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"encoding/json"
"errors"
"io"
"io/ioutil"
"strings"
"sync"
"testing"
Expand Down Expand Up @@ -47,7 +46,7 @@ func TestStatsChannel_cancellingContextClosesResources(t *testing.T) {
Os: "Not windows",
},
client: statsClientMock{
statsBody: ioutil.NopCloser(strings.NewReader("")),
statsBody: io.NopCloser(strings.NewReader("")),
}}
ctx, cancel := context.WithCancel(context.Background())
stats := sc.Start(ctx)
Expand Down Expand Up @@ -75,7 +74,7 @@ func TestStatsChannel_statsArePublished(t *testing.T) {
Os: "Not windows",
},
client: statsClientMock{
statsBody: ioutil.NopCloser(strings.NewReader(asJSON(types.StatsJSON{}))),
statsBody: io.NopCloser(strings.NewReader(asJSON(types.StatsJSON{}))),
}}
ctx, cancel := context.WithCancel(context.Background())
stats := sc.Start(ctx)
Expand Down Expand Up @@ -106,7 +105,7 @@ func TestStatsChannel_noErrors_goroutineExitsOnCtxCancel(t *testing.T) {
Os: "Not windows",
},
client: statsClientMock{
statsBody: ioutil.NopCloser(strings.NewReader(asJSON(types.StatsJSON{}))),
statsBody: io.NopCloser(strings.NewReader(asJSON(types.StatsJSON{}))),
}}
ctx, cancel := context.WithCancel(context.Background())
sc.Start(ctx)
Expand All @@ -128,7 +127,7 @@ func TestStatsChannel_errorBuildingStats_goroutineExitsOnCtxCancel(t *testing.T)
},
client: statsClientMock{
//Empty reader results in EOF error
statsBody: ioutil.NopCloser(strings.NewReader("")),
statsBody: io.NopCloser(strings.NewReader("")),
}}
ctx, cancel := context.WithCancel(context.Background())
sc.Start(ctx)
Expand Down
4 changes: 2 additions & 2 deletions tls/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"crypto/tls"
"crypto/x509"
"fmt"
"io/ioutil"
"os"

"github.com/sirupsen/logrus"
)
Expand Down Expand Up @@ -66,7 +66,7 @@ func clientDefault() *tls.Config {
func certPool(caFile string) (*x509.CertPool, error) {
// If we should verify the server, we need to load a trusted ca
certPool := x509.NewCertPool()
pem, err := ioutil.ReadFile(caFile)
pem, err := os.ReadFile(caFile)
if err != nil {
return nil, fmt.Errorf("Could not read CA certificate %q: %v", caFile, err)
}
Expand Down

0 comments on commit a50a4f1

Please sign in to comment.