Replaced deprecated io/ioutil functions (#768)

Signed-off-by: slab713 <109306207+slab713@users.noreply.github.com>
This commit is contained in:
slab713
2022-09-02 14:56:02 +02:00
committed by GitHub
parent 6ae793eb51
commit 8ffb053cec
36 changed files with 249 additions and 280 deletions
+12 -13
View File
@@ -6,7 +6,6 @@ package lint_test
import (
"context"
"encoding/json"
"io/ioutil"
"net/http"
"os"
"path"
@@ -380,7 +379,7 @@ func TestVerifyMandatoryAnnotationsFunction(t *testing.T) {
}
var index ispec.Index
buf, err := ioutil.ReadFile(path.Join(dir, "zot-test", "index.json"))
buf, err := os.ReadFile(path.Join(dir, "zot-test", "index.json"))
So(err, ShouldBeNil)
err = json.Unmarshal(buf, &index)
So(err, ShouldBeNil)
@@ -388,7 +387,7 @@ func TestVerifyMandatoryAnnotationsFunction(t *testing.T) {
manifestDigest := index.Manifests[0].Digest
var manifest ispec.Manifest
buf, err = ioutil.ReadFile(path.Join(dir, "zot-test", "blobs",
buf, err = os.ReadFile(path.Join(dir, "zot-test", "blobs",
manifestDigest.Algorithm().String(), manifestDigest.Encoded()))
So(err, ShouldBeNil)
err = json.Unmarshal(buf, &manifest)
@@ -408,7 +407,7 @@ func TestVerifyMandatoryAnnotationsFunction(t *testing.T) {
digest := godigest.FromBytes(content)
So(digest, ShouldNotBeNil)
err = ioutil.WriteFile(path.Join(dir, "zot-test", "blobs",
err = os.WriteFile(path.Join(dir, "zot-test", "blobs",
digest.Algorithm().String(), digest.Encoded()), content, 0o600)
So(err, ShouldBeNil)
@@ -444,7 +443,7 @@ func TestVerifyMandatoryAnnotationsFunction(t *testing.T) {
}
var index ispec.Index
buf, err := ioutil.ReadFile(path.Join(dir, "zot-test", "index.json"))
buf, err := os.ReadFile(path.Join(dir, "zot-test", "index.json"))
So(err, ShouldBeNil)
err = json.Unmarshal(buf, &index)
So(err, ShouldBeNil)
@@ -452,7 +451,7 @@ func TestVerifyMandatoryAnnotationsFunction(t *testing.T) {
manifestDigest := index.Manifests[0].Digest
var manifest ispec.Manifest
buf, err = ioutil.ReadFile(path.Join(dir, "zot-test", "blobs",
buf, err = os.ReadFile(path.Join(dir, "zot-test", "blobs",
manifestDigest.Algorithm().String(), manifestDigest.Encoded()))
So(err, ShouldBeNil)
err = json.Unmarshal(buf, &manifest)
@@ -471,7 +470,7 @@ func TestVerifyMandatoryAnnotationsFunction(t *testing.T) {
digest := godigest.FromBytes(content)
So(digest, ShouldNotBeNil)
err = ioutil.WriteFile(path.Join(dir, "zot-test", "blobs",
err = os.WriteFile(path.Join(dir, "zot-test", "blobs",
digest.Algorithm().String(), digest.Encoded()), content, 0o600)
So(err, ShouldBeNil)
@@ -507,7 +506,7 @@ func TestVerifyMandatoryAnnotationsFunction(t *testing.T) {
}
var index ispec.Index
buf, err := ioutil.ReadFile(path.Join(dir, "zot-test", "index.json"))
buf, err := os.ReadFile(path.Join(dir, "zot-test", "index.json"))
So(err, ShouldBeNil)
err = json.Unmarshal(buf, &index)
So(err, ShouldBeNil)
@@ -515,7 +514,7 @@ func TestVerifyMandatoryAnnotationsFunction(t *testing.T) {
manifestDigest := index.Manifests[0].Digest
var manifest ispec.Manifest
buf, err = ioutil.ReadFile(path.Join(dir, "zot-test", "blobs",
buf, err = os.ReadFile(path.Join(dir, "zot-test", "blobs",
manifestDigest.Algorithm().String(), manifestDigest.Encoded()))
So(err, ShouldBeNil)
err = json.Unmarshal(buf, &manifest)
@@ -536,7 +535,7 @@ func TestVerifyMandatoryAnnotationsFunction(t *testing.T) {
digest := godigest.FromBytes(content)
So(digest, ShouldNotBeNil)
err = ioutil.WriteFile(path.Join(dir, "zot-test", "blobs",
err = os.WriteFile(path.Join(dir, "zot-test", "blobs",
digest.Algorithm().String(), digest.Encoded()), content, 0o600)
So(err, ShouldBeNil)
@@ -572,7 +571,7 @@ func TestVerifyMandatoryAnnotationsFunction(t *testing.T) {
}
var index ispec.Index
buf, err := ioutil.ReadFile(path.Join(dir, "zot-test", "index.json"))
buf, err := os.ReadFile(path.Join(dir, "zot-test", "index.json"))
So(err, ShouldBeNil)
err = json.Unmarshal(buf, &index)
So(err, ShouldBeNil)
@@ -580,7 +579,7 @@ func TestVerifyMandatoryAnnotationsFunction(t *testing.T) {
manifestDigest := index.Manifests[0].Digest
var manifest ispec.Manifest
buf, err = ioutil.ReadFile(path.Join(dir, "zot-test", "blobs",
buf, err = os.ReadFile(path.Join(dir, "zot-test", "blobs",
manifestDigest.Algorithm().String(), manifestDigest.Encoded()))
So(err, ShouldBeNil)
err = json.Unmarshal(buf, &manifest)
@@ -600,7 +599,7 @@ func TestVerifyMandatoryAnnotationsFunction(t *testing.T) {
digest := godigest.FromBytes(content)
So(digest, ShouldNotBeNil)
err = ioutil.WriteFile(path.Join(dir, "zot-test", "blobs",
err = os.WriteFile(path.Join(dir, "zot-test", "blobs",
digest.Algorithm().String(), digest.Encoded()), content, 0o600)
So(err, ShouldBeNil)