Move from io/ioutil to os package (#524)

Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2021-12-26 03:59:05 +01:00
committed by GitHub
parent 35d1322a7b
commit 82d056d3ab
4 changed files with 7 additions and 9 deletions

View File

@@ -1,7 +1,7 @@
package file
import (
"io/ioutil"
"os"
"path/filepath"
"strings"
@@ -21,7 +21,7 @@ func (c *Client) listFileImage() []model.Image {
for _, file := range files {
var items []model.Image
bytes, err := ioutil.ReadFile(file)
bytes, err := os.ReadFile(file)
if err != nil {
c.logger.Error().Err(err).Msgf("Unable to read config file %s", file)
continue
@@ -77,7 +77,7 @@ func (c *Client) getFiles() []string {
switch {
case len(c.config.Directory) > 0:
fileList, err := ioutil.ReadDir(c.config.Directory)
fileList, err := os.ReadDir(c.config.Directory)
if err != nil {
c.logger.Error().Err(err).Msgf("Unable to read directory %s", c.config.Directory)
return files

View File

@@ -2,7 +2,7 @@ package dockerfile
import (
"bytes"
"io/ioutil"
"os"
"github.com/moby/buildkit/frontend/dockerfile/instructions"
"github.com/moby/buildkit/frontend/dockerfile/parser"
@@ -25,7 +25,7 @@ type Options struct {
// New initializes a new dockerfile client
func New(opts Options) (*Client, error) {
b, err := ioutil.ReadFile(opts.Filename)
b, err := os.ReadFile(opts.Filename)
if err != nil {
return nil, errors.Wrapf(err, "Cannot read Dockerfile %s", opts.Filename)
}

View File

@@ -2,7 +2,6 @@ package k8s
import (
"context"
"io/ioutil"
"os"
"github.com/crazy-max/diun/v4/pkg/utl"
@@ -105,7 +104,7 @@ func newExternalClusterClient(opts Options) (*kubernetes.Clientset, error) {
}
if opts.CertAuthFilePath != "" {
caData, err := ioutil.ReadFile(opts.CertAuthFilePath)
caData, err := os.ReadFile(opts.CertAuthFilePath)
if err != nil {
return nil, errors.Wrap(err, "Failed to read CA file")
}

View File

@@ -1,7 +1,6 @@
package utl
import (
"io/ioutil"
"os"
"regexp"
"time"
@@ -59,7 +58,7 @@ func GetSecret(plaintext, filename string) (string, error) {
if plaintext != "" {
return plaintext, nil
} else if filename != "" {
b, err := ioutil.ReadFile(filename)
b, err := os.ReadFile(filename)
if err != nil {
return "", err
}