mirror of
https://github.com/project-zot/zot.git
synced 2026-06-16 12:28:01 +08:00
Replaced deprecated io/ioutil functions (#768)
Signed-off-by: slab713 <109306207+slab713@users.noreply.github.com>
This commit is contained in:
+5
-6
@@ -7,7 +7,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"math/big"
|
||||
"net/http"
|
||||
@@ -67,14 +66,14 @@ func MakeHtpasswdFile() string {
|
||||
}
|
||||
|
||||
func MakeHtpasswdFileFromString(fileContent string) string {
|
||||
htpasswdFile, err := ioutil.TempFile("", "htpasswd-")
|
||||
htpasswdFile, err := os.CreateTemp("", "htpasswd-")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// bcrypt(username="test", passwd="test")
|
||||
content := []byte(fileContent)
|
||||
if err := ioutil.WriteFile(htpasswdFile.Name(), content, 0o600); err != nil { //nolint:gomnd
|
||||
if err := os.WriteFile(htpasswdFile.Name(), content, 0o600); err != nil { //nolint:gomnd
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@@ -109,9 +108,9 @@ func CopyFiles(sourceDir, destDir string) error {
|
||||
return fmt.Errorf("CopyFiles os.MkdirAll failed: %w", err)
|
||||
}
|
||||
|
||||
files, err := ioutil.ReadDir(sourceDir)
|
||||
files, err := os.ReadDir(sourceDir)
|
||||
if err != nil {
|
||||
return fmt.Errorf("CopyFiles ioutil.ReadDir failed: %w", err)
|
||||
return fmt.Errorf("CopyFiles os.ReadDir failed: %w", err)
|
||||
}
|
||||
|
||||
for _, file := range files {
|
||||
@@ -258,7 +257,7 @@ func GetOciLayoutDigests(imagePath string) (godigest.Digest, godigest.Digest, go
|
||||
panic(err)
|
||||
}
|
||||
|
||||
manifestBuf, err := ioutil.ReadAll(manifestBlob)
|
||||
manifestBuf, err := io.ReadAll(manifestBlob)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ package test_test
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"testing"
|
||||
@@ -58,7 +57,7 @@ func TestCopyFiles(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
|
||||
filePath := path.Join(dir, "file.txt")
|
||||
err := ioutil.WriteFile(filePath, []byte("some dummy file content"), 0o644) //nolint: gosec
|
||||
err := os.WriteFile(filePath, []byte("some dummy file content"), 0o644) //nolint: gosec
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -103,7 +102,7 @@ func TestGetOciLayoutDigests(t *testing.T) {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
buf, err := ioutil.ReadFile(path.Join(dir, "test-manifest", "index.json"))
|
||||
buf, err := os.ReadFile(path.Join(dir, "test-manifest", "index.json"))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package mocks
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -58,7 +57,7 @@ func (s *StorageDriverMock) Reader(ctx context.Context, path string, offset int6
|
||||
return s.ReaderFn(ctx, path, offset)
|
||||
}
|
||||
|
||||
return ioutil.NopCloser(strings.NewReader("")), nil
|
||||
return io.NopCloser(strings.NewReader("")), nil
|
||||
}
|
||||
|
||||
func (s *StorageDriverMock) Writer(ctx context.Context, path string, isAppend bool) (driver.FileWriter, error) {
|
||||
|
||||
Reference in New Issue
Block a user