mirror of
https://github.com/crazy-max/diun.git
synced 2025-04-14 07:08:32 +00:00
Move from io/ioutil to os package (#524)
Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
35d1322a7b
commit
82d056d3ab
4 changed files with 7 additions and 9 deletions
|
@ -1,7 +1,7 @@
|
||||||
package file
|
package file
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ func (c *Client) listFileImage() []model.Image {
|
||||||
|
|
||||||
for _, file := range files {
|
for _, file := range files {
|
||||||
var items []model.Image
|
var items []model.Image
|
||||||
bytes, err := ioutil.ReadFile(file)
|
bytes, err := os.ReadFile(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.logger.Error().Err(err).Msgf("Unable to read config file %s", file)
|
c.logger.Error().Err(err).Msgf("Unable to read config file %s", file)
|
||||||
continue
|
continue
|
||||||
|
@ -77,7 +77,7 @@ func (c *Client) getFiles() []string {
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case len(c.config.Directory) > 0:
|
case len(c.config.Directory) > 0:
|
||||||
fileList, err := ioutil.ReadDir(c.config.Directory)
|
fileList, err := os.ReadDir(c.config.Directory)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.logger.Error().Err(err).Msgf("Unable to read directory %s", c.config.Directory)
|
c.logger.Error().Err(err).Msgf("Unable to read directory %s", c.config.Directory)
|
||||||
return files
|
return files
|
||||||
|
|
|
@ -2,7 +2,7 @@ package dockerfile
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"io/ioutil"
|
"os"
|
||||||
|
|
||||||
"github.com/moby/buildkit/frontend/dockerfile/instructions"
|
"github.com/moby/buildkit/frontend/dockerfile/instructions"
|
||||||
"github.com/moby/buildkit/frontend/dockerfile/parser"
|
"github.com/moby/buildkit/frontend/dockerfile/parser"
|
||||||
|
@ -25,7 +25,7 @@ type Options struct {
|
||||||
|
|
||||||
// New initializes a new dockerfile client
|
// New initializes a new dockerfile client
|
||||||
func New(opts Options) (*Client, error) {
|
func New(opts Options) (*Client, error) {
|
||||||
b, err := ioutil.ReadFile(opts.Filename)
|
b, err := os.ReadFile(opts.Filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrapf(err, "Cannot read Dockerfile %s", opts.Filename)
|
return nil, errors.Wrapf(err, "Cannot read Dockerfile %s", opts.Filename)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package k8s
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/crazy-max/diun/v4/pkg/utl"
|
"github.com/crazy-max/diun/v4/pkg/utl"
|
||||||
|
@ -105,7 +104,7 @@ func newExternalClusterClient(opts Options) (*kubernetes.Clientset, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if opts.CertAuthFilePath != "" {
|
if opts.CertAuthFilePath != "" {
|
||||||
caData, err := ioutil.ReadFile(opts.CertAuthFilePath)
|
caData, err := os.ReadFile(opts.CertAuthFilePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "Failed to read CA file")
|
return nil, errors.Wrap(err, "Failed to read CA file")
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package utl
|
package utl
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
"time"
|
"time"
|
||||||
|
@ -59,7 +58,7 @@ func GetSecret(plaintext, filename string) (string, error) {
|
||||||
if plaintext != "" {
|
if plaintext != "" {
|
||||||
return plaintext, nil
|
return plaintext, nil
|
||||||
} else if filename != "" {
|
} else if filename != "" {
|
||||||
b, err := ioutil.ReadFile(filename)
|
b, err := os.ReadFile(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue