Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

os instead of ioutil #502

Merged
merged 1 commit into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions netboot/netconf.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package netboot
import (
"errors"
"fmt"
"io/ioutil"
"net"
"os"
"strings"
Expand Down Expand Up @@ -211,7 +210,7 @@ func ConfigureInterface(ifname string, netconf *NetConf) (err error) {
if len(netconf.DNSSearchList) > 0 {
resolvconf += fmt.Sprintf("search %s\n", strings.Join(netconf.DNSSearchList, " "))
}
if err = ioutil.WriteFile("/etc/resolv.conf", []byte(resolvconf), 0644); err != nil {
if err = os.WriteFile("/etc/resolv.conf", []byte(resolvconf), 0644); err != nil {
return fmt.Errorf("could not write resolv.conf file %v", err)
}

Expand Down
6 changes: 3 additions & 3 deletions netboot/netconf_integ_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ package netboot

import (
"fmt"
"io/ioutil"
"log"
"net"
"os"
"testing"
"time"

Expand Down Expand Up @@ -34,7 +34,7 @@ func TestConfigureInterface(t *testing.T) {
// `NetConf.DNSServers` is set. In this test we make a backup of resolv.conf
// and subsequently restore it. This is really ugly, and not safe if
// multiple tests do the same.
resolvconf, err := ioutil.ReadFile("/etc/resolv.conf")
resolvconf, err := os.ReadFile("/etc/resolv.conf")
if err != nil {
panic(fmt.Sprintf("Failed to read /etc/resolv.conf: %v", err))
}
Expand Down Expand Up @@ -69,7 +69,7 @@ func TestConfigureInterface(t *testing.T) {

// after the test, restore the content of /etc/resolv.conf . The permissions
// are used only if it didn't exist.
if err = ioutil.WriteFile("/etc/resolv.conf", resolvconf, 0644); err != nil {
if err = os.WriteFile("/etc/resolv.conf", resolvconf, 0644); err != nil {
panic(fmt.Sprintf("Failed to restore /etc/resolv.conf: %v", err))
}
log.Printf("Restored /etc/resolv.conf")
Expand Down
Loading