updated linter and fixed deprecated stuff
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
package apiconfig
|
||||
|
||||
import (
|
||||
"gopkg.in/yaml.v2"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
// ClientApiConfig contains configuration parameters for an API server.
|
||||
@@ -26,7 +27,7 @@ func NewClient(configFilePath string) (config ClientConfig, err error) {
|
||||
log.Printf("Loading api client configuration from: %v\n", configFilePath)
|
||||
|
||||
var fileBytes []byte
|
||||
fileBytes, err = ioutil.ReadFile(configFilePath)
|
||||
fileBytes, err = os.ReadFile(configFilePath)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package apiconfig
|
||||
|
||||
import (
|
||||
"gopkg.in/yaml.v2"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
// ClientServerConfig is the full client server configuration.
|
||||
@@ -22,7 +23,7 @@ func NewClientServer(configFilePath string) (config ClientServerConfig, err erro
|
||||
log.Printf("Loading api client server configuration from: %v\n", configFilePath)
|
||||
|
||||
var fileBytes []byte
|
||||
fileBytes, err = ioutil.ReadFile(configFilePath)
|
||||
fileBytes, err = os.ReadFile(configFilePath)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package apiconfig
|
||||
|
||||
import (
|
||||
"gopkg.in/yaml.v2"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
// ServerApiConfig contains configuration parameters for an API server.
|
||||
@@ -28,7 +29,7 @@ func NewServer(configFilePath string) (config ServerConfig, err error) {
|
||||
log.Printf("Loading api server configuration from: %v\n", configFilePath)
|
||||
|
||||
var fileBytes []byte
|
||||
fileBytes, err = ioutil.ReadFile(configFilePath)
|
||||
fileBytes, err = os.ReadFile(configFilePath)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package container
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
@@ -27,7 +26,7 @@ func ListSources() ([]string, error) {
|
||||
}
|
||||
wwlog.Debug("Searching for VNFS Rootfs directories: %s", SourceParentDir())
|
||||
|
||||
sources, err := ioutil.ReadDir(SourceParentDir())
|
||||
sources, err := os.ReadDir(SourceParentDir())
|
||||
if err != nil {
|
||||
return ret, err
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"compress/gzip"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
@@ -51,7 +50,7 @@ func GetKernelVersion(kernelName string) string {
|
||||
wwlog.Error("Kernel Name is not defined")
|
||||
return ""
|
||||
}
|
||||
kernelVersion, err := ioutil.ReadFile(KernelVersionFile(kernelName))
|
||||
kernelVersion, err := os.ReadFile(KernelVersionFile(kernelName))
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
@@ -96,7 +95,7 @@ func ListKernels() ([]string, error) {
|
||||
|
||||
wwlog.Debug("Searching for Kernel image directories: %s", KernelImageTopDir())
|
||||
|
||||
kernels, err := ioutil.ReadDir(KernelImageTopDir())
|
||||
kernels, err := os.ReadDir(KernelImageTopDir())
|
||||
if err != nil {
|
||||
return ret, err
|
||||
}
|
||||
@@ -198,7 +197,7 @@ func Build(kernelVersion, kernelName, root string) (string, error) {
|
||||
driversDestination,
|
||||
[]string{
|
||||
"." + kernelDriversRelative,
|
||||
"./lib/firmware" },
|
||||
"./lib/firmware"},
|
||||
[]string{},
|
||||
// ignore cross-device files
|
||||
true,
|
||||
|
||||
@@ -2,7 +2,7 @@ package node
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"sort"
|
||||
"strings"
|
||||
@@ -48,7 +48,7 @@ func New() (NodeYaml, error) {
|
||||
var ret NodeYaml
|
||||
|
||||
wwlog.Verbose("Opening node configuration file: %s", ConfigFile)
|
||||
data, err := ioutil.ReadFile(ConfigFile)
|
||||
data, err := os.ReadFile(ConfigFile)
|
||||
if err != nil {
|
||||
return ret, err
|
||||
}
|
||||
@@ -79,7 +79,7 @@ func (config *NodeYaml) FindAllNodes() ([]NodeInfo, error) {
|
||||
*/
|
||||
var defConf map[string]*NodeConf
|
||||
wwlog.Verbose("Opening defaults failed %s\n", DefaultConfig)
|
||||
defData, err := ioutil.ReadFile(DefaultConfig)
|
||||
defData, err := os.ReadFile(DefaultConfig)
|
||||
if err != nil {
|
||||
wwlog.Verbose("Couldn't read DefaultConfig :%s\n", err)
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"crypto/sha256"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@@ -139,7 +138,7 @@ func (p *puller) Pull(ctx context.Context, uri, dst string) (err error) {
|
||||
}
|
||||
|
||||
// defaults to $TMPDIR or /tmp
|
||||
tmpDir, err := ioutil.TempDir(p.tmpDirPath, "oci-bundle-")
|
||||
tmpDir, err := os.MkdirTemp(p.tmpDirPath, "oci-bundle-")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package overlay
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
@@ -23,7 +22,7 @@ func templateFileInclude(inc string) string {
|
||||
inc = path.Join(buildconfig.SYSCONFDIR(), "warewulf", inc)
|
||||
}
|
||||
wwlog.Debug("Including file into template: %s", inc)
|
||||
content, err := ioutil.ReadFile(inc)
|
||||
content, err := os.ReadFile(inc)
|
||||
if err != nil {
|
||||
wwlog.Verbose("Could not include file into template: %s", err)
|
||||
}
|
||||
@@ -93,7 +92,7 @@ func templateContainerFileInclude(containername string, filepath string) string
|
||||
return ""
|
||||
}
|
||||
|
||||
content, err := ioutil.ReadFile(path.Join(containerDir, filepath))
|
||||
content, err := os.ReadFile(path.Join(containerDir, filepath))
|
||||
|
||||
if err != nil {
|
||||
wwlog.Error("Template include failed: %s", err)
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
@@ -105,10 +104,9 @@ Get all overlays present in warewulf
|
||||
*/
|
||||
func FindOverlays() ([]string, error) {
|
||||
var ret []string
|
||||
var files []os.FileInfo
|
||||
dotfilecheck, _ := regexp.Compile(`^\..*`)
|
||||
|
||||
files, err := ioutil.ReadDir(OverlaySourceTopDir())
|
||||
files, err := os.ReadDir(OverlaySourceTopDir())
|
||||
if err != nil {
|
||||
return ret, errors.Wrap(err, "could not get list of overlays")
|
||||
}
|
||||
@@ -156,7 +154,7 @@ func BuildOverlay(nodeInfo node.NodeInfo, overlayNames []string) error {
|
||||
|
||||
wwlog.Debug("Created directory for %s: %s", name, overlayImageDir)
|
||||
|
||||
buildDir, err := ioutil.TempDir(os.TempDir(), ".wwctl-overlay-")
|
||||
buildDir, err := os.MkdirTemp(os.TempDir(), ".wwctl-overlay-")
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "Failed to create temporary directory for %s", name)
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ package pidfile
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -47,11 +46,11 @@ func WriteControl(filename string, pid int, overwrite bool) (int, error) {
|
||||
}
|
||||
|
||||
// We're clear to (over)write the file
|
||||
return pid, ioutil.WriteFile(filename, []byte(fmt.Sprintf("%d\n", pid)), 0644)
|
||||
return pid, os.WriteFile(filename, []byte(fmt.Sprintf("%d\n", pid)), 0644)
|
||||
}
|
||||
|
||||
func pidfileContents(filename string) (int, error) {
|
||||
contents, err := ioutil.ReadFile(filename)
|
||||
contents, err := os.ReadFile(filename)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ package warewulfconf
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"os"
|
||||
"path"
|
||||
|
||||
"github.com/brotherpowers/ipsubnet"
|
||||
@@ -43,7 +43,7 @@ func New() (ControllerConf, error) {
|
||||
// Check if cached config is old before re-reading config file
|
||||
if !cachedConf.current {
|
||||
wwlog.Debug("Opening Warewulf configuration file: %s", ConfigFile)
|
||||
data, err := ioutil.ReadFile(ConfigFile)
|
||||
data, err := os.ReadFile(ConfigFile)
|
||||
if err != nil {
|
||||
wwlog.Warn("Error reading Warewulf configuration file")
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package warewulfd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log/syslog"
|
||||
"os"
|
||||
"os/exec"
|
||||
@@ -41,7 +40,7 @@ func DaemonInitLogging() error {
|
||||
if err == nil {
|
||||
wwlog.SetLogLevel(level)
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
wwlog.SetLogLevel(wwlog.SERV)
|
||||
}
|
||||
|
||||
@@ -86,7 +85,7 @@ func DaemonStart() error {
|
||||
logLevel := wwlog.GetLogLevel()
|
||||
if logLevel == wwlog.INFO {
|
||||
os.Setenv("WAREWULFD_LOGLEVEL", strconv.Itoa(wwlog.SERV))
|
||||
}else{
|
||||
} else {
|
||||
os.Setenv("WAREWULFD_LOGLEVEL", strconv.Itoa(logLevel))
|
||||
}
|
||||
|
||||
@@ -124,7 +123,7 @@ func DaemonStatus() error {
|
||||
return errors.New("Warewulf server is not running")
|
||||
}
|
||||
|
||||
dat, err := ioutil.ReadFile(WAREWULFD_PIDFILE)
|
||||
dat, err := os.ReadFile(WAREWULFD_PIDFILE)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "could not read Warewulfd PID file")
|
||||
}
|
||||
@@ -150,7 +149,7 @@ func DaemonReload() error {
|
||||
return errors.New("Warewulf server is not running")
|
||||
}
|
||||
|
||||
dat, err := ioutil.ReadFile(WAREWULFD_PIDFILE)
|
||||
dat, err := os.ReadFile(WAREWULFD_PIDFILE)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "could not read Warewulfd PID file")
|
||||
}
|
||||
@@ -169,7 +168,7 @@ func DaemonReload() error {
|
||||
logLevel := wwlog.GetLogLevel()
|
||||
if logLevel == wwlog.INFO {
|
||||
os.Setenv("WAREWULFD_LOGLEVEL", strconv.Itoa(wwlog.SERV))
|
||||
}else{
|
||||
} else {
|
||||
os.Setenv("WAREWULFD_LOGLEVEL", strconv.Itoa(logLevel))
|
||||
}
|
||||
|
||||
@@ -182,7 +181,7 @@ func DaemonStop() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
dat, err := ioutil.ReadFile(WAREWULFD_PIDFILE)
|
||||
dat, err := os.ReadFile(WAREWULFD_PIDFILE)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user