Updated the deprecated ioutil dependency
The ioutil package has been deprecated as of Go v1.16: https://go.dev/doc/go1.16#ioutil This commit replaces ioutil functions with their respective io/os functions.
This commit is contained in:
parent
2a99dd25fe
commit
ae996cd718
@ -3,7 +3,6 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
@ -21,7 +20,7 @@ func configureCi() (bool, *viper.Viper, error) {
|
|||||||
if _, err := os.Stat(ciConfigFile); !os.IsNotExist(err) {
|
if _, err := os.Stat(ciConfigFile); !os.IsNotExist(err) {
|
||||||
fmt.Printf(" Using CI config: %s\n", ciConfigFile)
|
fmt.Printf(" Using CI config: %s\n", ciConfigFile)
|
||||||
|
|
||||||
fileBytes, err := ioutil.ReadFile(ciConfigFile)
|
fileBytes, err := os.ReadFile(ciConfigFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return isCi, nil, err
|
return isCi, nil, err
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
@ -146,7 +146,7 @@ func initLogging() {
|
|||||||
logFileObj, err = os.OpenFile(viper.GetString("log.path"), os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644)
|
logFileObj, err = os.OpenFile(viper.GetString("log.path"), os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644)
|
||||||
log.SetOutput(logFileObj)
|
log.SetOutput(logFileObj)
|
||||||
} else {
|
} else {
|
||||||
log.SetOutput(ioutil.Discard)
|
log.SetOutput(io.Discard)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -198,7 +198,7 @@ func getDefaultCfgFile() string {
|
|||||||
// if not found returns empty string
|
// if not found returns empty string
|
||||||
func findInPath(pathTo string) string {
|
func findInPath(pathTo string) string {
|
||||||
directory := path.Join(pathTo, "dive")
|
directory := path.Join(pathTo, "dive")
|
||||||
files, err := ioutil.ReadDir(directory)
|
files, err := os.ReadDir(directory)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
package docker
|
package docker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
func buildImageFromCli(buildArgs []string) (string, error) {
|
func buildImageFromCli(buildArgs []string) (string, error) {
|
||||||
iidfile, err := ioutil.TempFile("/tmp", "dive.*.iid")
|
iidfile, err := os.CreateTemp("/tmp", "dive.*.iid")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
@ -18,7 +17,7 @@ func buildImageFromCli(buildArgs []string) (string, error) {
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
imageId, err := ioutil.ReadFile(iidfile.Name())
|
imageId, err := os.ReadFile(iidfile.Name())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ import (
|
|||||||
"compress/gzip"
|
"compress/gzip"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
@ -81,7 +80,7 @@ func NewImageArchive(tarFile io.ReadCloser) (*ImageArchive, error) {
|
|||||||
img.layerMap[tree.Name] = tree
|
img.layerMap[tree.Name] = tree
|
||||||
|
|
||||||
} else if strings.HasSuffix(name, ".json") || strings.HasPrefix(name, "sha256:") {
|
} else if strings.HasSuffix(name, ".json") || strings.HasPrefix(name, "sha256:") {
|
||||||
fileBuffer, err := ioutil.ReadAll(tarReader)
|
fileBuffer, err := io.ReadAll(tarReader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return img, err
|
return img, err
|
||||||
}
|
}
|
||||||
|
@ -3,12 +3,11 @@
|
|||||||
package podman
|
package podman
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
func buildImageFromCli(buildArgs []string) (string, error) {
|
func buildImageFromCli(buildArgs []string) (string, error) {
|
||||||
iidfile, err := ioutil.TempFile("/tmp", "dive.*.iid")
|
iidfile, err := os.CreateTemp("/tmp", "dive.*.iid")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
@ -20,7 +19,7 @@ func buildImageFromCli(buildArgs []string) (string, error) {
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
imageId, err := ioutil.ReadFile(iidfile.Name())
|
imageId, err := os.ReadFile(iidfile.Name())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,9 @@ package podman
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"github.com/wagoodman/dive/dive/image"
|
"github.com/wagoodman/dive/dive/image"
|
||||||
"github.com/wagoodman/dive/dive/image/docker"
|
"github.com/wagoodman/dive/dive/image/docker"
|
||||||
"io/ioutil"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type resolver struct{}
|
type resolver struct{}
|
||||||
@ -40,7 +40,7 @@ func (r *resolver) resolveFromDockerArchive(id string) (*image.Image, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
img, err := docker.NewImageArchive(ioutil.NopCloser(reader))
|
img, err := docker.NewImageArchive(io.NopCloser(reader))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"github.com/wagoodman/dive/dive/image/docker"
|
"github.com/wagoodman/dive/dive/image/docker"
|
||||||
"github.com/wagoodman/dive/runtime/ui/format"
|
"github.com/wagoodman/dive/runtime/ui/format"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
@ -31,7 +30,7 @@ func testCaseDataFilePath(name string) string {
|
|||||||
|
|
||||||
func helperLoadBytes(t *testing.T) []byte {
|
func helperLoadBytes(t *testing.T) []byte {
|
||||||
path := testCaseDataFilePath(t.Name())
|
path := testCaseDataFilePath(t.Name())
|
||||||
theBytes, err := ioutil.ReadFile(path)
|
theBytes, err := os.ReadFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to load test data ('%s'): %+v", t.Name(), err)
|
t.Fatalf("unable to load test data ('%s'): %+v", t.Name(), err)
|
||||||
}
|
}
|
||||||
@ -44,7 +43,7 @@ func helperCaptureBytes(t *testing.T, data []byte) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
path := testCaseDataFilePath(t.Name())
|
path := testCaseDataFilePath(t.Name())
|
||||||
err := ioutil.WriteFile(path, data, 0644)
|
err := os.WriteFile(path, data, 0644)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to save test data ('%s'): %+v", t.Name(), err)
|
t.Fatalf("unable to save test data ('%s'): %+v", t.Name(), err)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user