Merge pull request #790 from austinvazquez/remove-ioutil-references

Remove references to io/ioutil package
This commit is contained in:
Casey Callendrello
2023-01-16 10:45:56 +01:00
committed by GitHub
23 changed files with 80 additions and 99 deletions

View File

@ -16,7 +16,7 @@ package ip
import (
"bytes"
"io/ioutil"
"os"
current "github.com/containernetworking/cni/pkg/types/100"
)
@ -53,10 +53,10 @@ func EnableForward(ips []*current.IPConfig) error {
}
func echo1(f string) error {
if content, err := ioutil.ReadFile(f); err == nil {
if content, err := os.ReadFile(f); err == nil {
if bytes.Equal(bytes.TrimSpace(content), []byte("1")) {
return nil
}
}
return ioutil.WriteFile(f, []byte("1"), 0644)
return os.WriteFile(f, []byte("1"), 0644)
}

View File

@ -1,7 +1,6 @@
package ip
import (
"io/ioutil"
"os"
"time"
@ -11,7 +10,7 @@ import (
var _ = Describe("IpforwardLinux", func() {
It("echo1 must not write the file if content is 1", func() {
file, err := ioutil.TempFile(os.TempDir(), "containernetworking")
file, err := os.CreateTemp("", "containernetworking")
Expect(err).NotTo(HaveOccurred())
defer os.Remove(file.Name())
err = echo1(file.Name())