Skip to content

Commit

Permalink
Merge pull request #429 from zachary-walters/update-deprecated-depend…
Browse files Browse the repository at this point in the history
…ency-ioutil

Updated the deprecated ioutil dependency
  • Loading branch information
wagoodman authored Jul 6, 2023
2 parents 67aa2f1 + ae996cd commit 99124ab
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 18 deletions.
3 changes: 1 addition & 2 deletions cmd/ci.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package cmd
import (
"bytes"
"fmt"
"io/ioutil"
"os"
"strconv"

Expand All @@ -21,7 +20,7 @@ func configureCi() (bool, *viper.Viper, error) {
if _, err := os.Stat(ciConfigFile); !os.IsNotExist(err) {
fmt.Printf(" Using CI config: %s\n", ciConfigFile)

fileBytes, err := ioutil.ReadFile(ciConfigFile)
fileBytes, err := os.ReadFile(ciConfigFile)
if err != nil {
return isCi, nil, err
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cmd

import (
"fmt"
"io/ioutil"
"io"
"os"
"path"
"strings"
Expand Down Expand Up @@ -146,7 +146,7 @@ func initLogging() {
logFileObj, err = os.OpenFile(viper.GetString("log.path"), os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644)
log.SetOutput(logFileObj)
} else {
log.SetOutput(ioutil.Discard)
log.SetOutput(io.Discard)
}

if err != nil {
Expand Down Expand Up @@ -198,7 +198,7 @@ func getDefaultCfgFile() string {
// if not found returns empty string
func findInPath(pathTo string) string {
directory := path.Join(pathTo, "dive")
files, err := ioutil.ReadDir(directory)
files, err := os.ReadDir(directory)
if err != nil {
return ""
}
Expand Down
5 changes: 2 additions & 3 deletions dive/image/docker/build.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package docker

import (
"io/ioutil"
"os"
)

func buildImageFromCli(buildArgs []string) (string, error) {
iidfile, err := ioutil.TempFile("/tmp", "dive.*.iid")
iidfile, err := os.CreateTemp("/tmp", "dive.*.iid")
if err != nil {
return "", err
}
Expand All @@ -18,7 +17,7 @@ func buildImageFromCli(buildArgs []string) (string, error) {
return "", err
}

imageId, err := ioutil.ReadFile(iidfile.Name())
imageId, err := os.ReadFile(iidfile.Name())
if err != nil {
return "", err
}
Expand Down
3 changes: 1 addition & 2 deletions dive/image/docker/image_archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"compress/gzip"
"fmt"
"io"
"io/ioutil"
"os"
"path"
"strings"
Expand Down Expand Up @@ -81,7 +80,7 @@ func NewImageArchive(tarFile io.ReadCloser) (*ImageArchive, error) {
img.layerMap[tree.Name] = tree

} else if strings.HasSuffix(name, ".json") || strings.HasPrefix(name, "sha256:") {
fileBuffer, err := ioutil.ReadAll(tarReader)
fileBuffer, err := io.ReadAll(tarReader)
if err != nil {
return img, err
}
Expand Down
5 changes: 2 additions & 3 deletions dive/image/podman/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
package podman

import (
"io/ioutil"
"os"
)

func buildImageFromCli(buildArgs []string) (string, error) {
iidfile, err := ioutil.TempFile("/tmp", "dive.*.iid")
iidfile, err := os.CreateTemp("/tmp", "dive.*.iid")
if err != nil {
return "", err
}
Expand All @@ -20,7 +19,7 @@ func buildImageFromCli(buildArgs []string) (string, error) {
return "", err
}

imageId, err := ioutil.ReadFile(iidfile.Name())
imageId, err := os.ReadFile(iidfile.Name())
if err != nil {
return "", err
}
Expand Down
4 changes: 2 additions & 2 deletions dive/image/podman/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ package podman

import (
"fmt"
"io"
"github.com/wagoodman/dive/dive/image"
"github.com/wagoodman/dive/dive/image/docker"
"io/ioutil"
)

type resolver struct{}
Expand Down Expand Up @@ -40,7 +40,7 @@ func (r *resolver) resolveFromDockerArchive(id string) (*image.Image, error) {
return nil, err
}

img, err := docker.NewImageArchive(ioutil.NopCloser(reader))
img, err := docker.NewImageArchive(io.NopCloser(reader))
if err != nil {
return nil, err
}
Expand Down
5 changes: 2 additions & 3 deletions runtime/ui/viewmodel/filetree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"github.com/wagoodman/dive/dive/image/docker"
"github.com/wagoodman/dive/runtime/ui/format"
"io/ioutil"
"os"
"path/filepath"
"regexp"
Expand All @@ -31,7 +30,7 @@ func testCaseDataFilePath(name string) string {

func helperLoadBytes(t *testing.T) []byte {
path := testCaseDataFilePath(t.Name())
theBytes, err := ioutil.ReadFile(path)
theBytes, err := os.ReadFile(path)
if err != nil {
t.Fatalf("unable to load test data ('%s'): %+v", t.Name(), err)
}
Expand All @@ -44,7 +43,7 @@ func helperCaptureBytes(t *testing.T, data []byte) {
}

path := testCaseDataFilePath(t.Name())
err := ioutil.WriteFile(path, data, 0644)
err := os.WriteFile(path, data, 0644)

if err != nil {
t.Fatalf("unable to save test data ('%s'): %+v", t.Name(), err)
Expand Down

0 comments on commit 99124ab

Please sign in to comment.