Update deprecated io/ioutil functions
ioutil has been deprecated since go 1.16, this fixes all of the deprecated functions we are using: ioutil.ReadFile -> os.ReadFile ioutil.ReadAll -> io.ReadAll ioutil.WriteFile -> os.WriteFile ioutil.TempFile -> os.CreateTemp ioutil.TempDir -> os.MkdirTemp All of the above are a simple name change, the function arguments and results are exactly the same as before. ioutil.ReadDir -> os.ReadDir now returns a os.DirEntry but the IsDir and Name functions work the same. The difference is that the FileInfo must be retrieved with the Info() function which can also return an error. These were identified by running: golangci-lint run --build-tags=integration ./...
This commit is contained in:
parent
0e4a5b34b2
commit
7a4bb863dd
37 changed files with 113 additions and 126 deletions
|
|
@ -3,6 +3,7 @@
|
|||
// currently run as a "base test". Instead, it's run as a part of the
|
||||
// koji.sh test because it needs a working Koji instance to pass.
|
||||
|
||||
//go:build integration
|
||||
// +build integration
|
||||
|
||||
package main
|
||||
|
|
@ -12,7 +13,6 @@ import (
|
|||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
|
@ -37,14 +37,14 @@ func TestKojiRefund(t *testing.T) {
|
|||
|
||||
// use the self-signed certificate generated by run-koji-container
|
||||
certPool := x509.NewCertPool()
|
||||
cert, err := ioutil.ReadFile(shareDir + "/ca-crt.pem")
|
||||
cert, err := os.ReadFile(shareDir + "/ca-crt.pem")
|
||||
require.NoError(t, err)
|
||||
|
||||
ok := certPool.AppendCertsFromPEM(cert)
|
||||
require.True(t, ok)
|
||||
|
||||
transport.TLSClientConfig = &tls.Config{
|
||||
RootCAs: certPool,
|
||||
RootCAs: certPool,
|
||||
MinVersion: tls.VersionTLS12,
|
||||
}
|
||||
|
||||
|
|
@ -98,14 +98,14 @@ func TestKojiImport(t *testing.T) {
|
|||
|
||||
// use the self-signed certificate generated by run-koji-container
|
||||
certPool := x509.NewCertPool()
|
||||
cert, err := ioutil.ReadFile(shareDir + "/ca-crt.pem")
|
||||
cert, err := os.ReadFile(shareDir + "/ca-crt.pem")
|
||||
require.NoError(t, err)
|
||||
|
||||
ok := certPool.AppendCertsFromPEM(cert)
|
||||
require.True(t, ok)
|
||||
|
||||
transport.TLSClientConfig = &tls.Config{
|
||||
RootCAs: certPool,
|
||||
RootCAs: certPool,
|
||||
MinVersion: tls.VersionTLS12,
|
||||
}
|
||||
|
||||
|
|
@ -125,7 +125,7 @@ func TestKojiImport(t *testing.T) {
|
|||
}()
|
||||
|
||||
// Create a random file
|
||||
f, err := ioutil.TempFile("", "osbuild-koji-test-*.qcow2")
|
||||
f, err := os.CreateTemp("", "osbuild-koji-test-*.qcow2")
|
||||
require.NoError(t, err)
|
||||
defer func() {
|
||||
assert.NoError(t, f.Close())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue