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
|
|
@ -1,3 +1,4 @@
|
|||
//go:build integration
|
||||
// +build integration
|
||||
|
||||
package boot
|
||||
|
|
@ -5,7 +6,6 @@ package boot
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
|
@ -45,7 +45,7 @@ func newNetworkNamespace() (NetNS, error) {
|
|||
}
|
||||
}
|
||||
|
||||
f, err := ioutil.TempFile(netnsDir, "osbuild-composer-namespace")
|
||||
f, err := os.CreateTemp(netnsDir, "osbuild-composer-namespace")
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("cannot create a tempfile: %v", err)
|
||||
}
|
||||
|
|
@ -90,7 +90,7 @@ func newNetworkNamespace() (NetNS, error) {
|
|||
if err != nil {
|
||||
return "", fmt.Errorf("cannot set up a loopback device in the new namespace: %v", err)
|
||||
}
|
||||
|
||||
|
||||
// There's no potential command injection vector here
|
||||
/* #nosec G204 */
|
||||
cmd = exec.Command("mount", "-o", "bind", "/proc/self/ns/net", f.Name())
|
||||
|
|
@ -134,7 +134,7 @@ func (n NetNS) Path() string {
|
|||
// Delete deletes the namespaces
|
||||
func (n NetNS) Delete() error {
|
||||
// There's no potential command injection vector here
|
||||
/* #nosec G204 */
|
||||
/* #nosec G204 */
|
||||
cmd := exec.Command("umount", n.Path())
|
||||
cmd.Stderr = os.Stderr
|
||||
cmd.Stdout = os.Stdout
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue