Skip to content

Commit

Permalink
refactor: replace deprecated ioutil with io and os (#423)
Browse files Browse the repository at this point in the history
Co-authored-by: Patrik <zepatrik@users.noreply.github.com>
  • Loading branch information
alexandear and zepatrik committed Apr 5, 2023
1 parent 87ce1b9 commit 1b74b04
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
3 changes: 1 addition & 2 deletions dockertest.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package dockertest
import (
"fmt"
"io"
"io/ioutil"
"net"
"os"
"path/filepath"
Expand Down Expand Up @@ -340,7 +339,7 @@ func (d *Pool) BuildAndRunWithBuildOptions(buildOpts *BuildOptions, runOpts *Run
err := d.Client.BuildImage(dc.BuildImageOptions{
Name: runOpts.Name,
Dockerfile: buildOpts.Dockerfile,
OutputStream: ioutil.Discard,
OutputStream: io.Discard,
ContextDir: buildOpts.ContextDir,
BuildArgs: buildOpts.BuildArgs,
Platform: buildOpts.Platform,
Expand Down
11 changes: 4 additions & 7 deletions dockertest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"bytes"
"database/sql"
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
Expand Down Expand Up @@ -199,11 +198,10 @@ func TestContainerWithPortBinding(t *testing.T) {

func TestBuildImage(t *testing.T) {
// Create Dockerfile in temp dir
dir, _ := ioutil.TempDir("", "dockertest")
defer os.RemoveAll(dir)
dir := t.TempDir()

dockerfilePath := dir + "/Dockerfile"
ioutil.WriteFile(dockerfilePath,
os.WriteFile(dockerfilePath,
[]byte("FROM postgres:9.5"),
0o644,
)
Expand All @@ -217,11 +215,10 @@ func TestBuildImage(t *testing.T) {

func TestBuildImageWithBuildArg(t *testing.T) {
// Create Dockerfile in temp dir
dir, _ := ioutil.TempDir("", "dockertest")
defer os.RemoveAll(dir)
dir := t.TempDir()

dockerfilePath := dir + "/Dockerfile"
ioutil.WriteFile(dockerfilePath,
os.WriteFile(dockerfilePath,
[]byte((`FROM busybox
ARG foo
RUN echo -n $foo > /build-time-value
Expand Down
4 changes: 2 additions & 2 deletions examples/FakeGoogleCloudStorage.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package main
import (
"context"
"fmt"
"io/ioutil"
"io"
"net/http"
"os"
"strings"
Expand Down Expand Up @@ -198,7 +198,7 @@ func readFile(client *storage.Client, bucketName, fileName string) ([]byte, erro
return nil, err
}
defer reader.Close()
return ioutil.ReadAll(reader)
return io.ReadAll(reader)
}

func deleteFile(client *storage.Client, bucketName, fileName string) error {
Expand Down

0 comments on commit 1b74b04

Please sign in to comment.