mirror of
https://github.com/outbackdingo/debos.git
synced 2026-01-27 10:18:47 +00:00
fix: Using a deprecated function, variable, constant or field (SA1019)
Reported by staticcheck Signed-off-by: Loïc Minier <loic.minier@oss.qualcomm.com>
This commit is contained in:
@@ -31,7 +31,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path"
|
||||
@@ -93,7 +92,7 @@ func (fd *FilesystemDeployAction) setupKernelCmdline(context *debos.DebosContext
|
||||
return fmt.Errorf("couldn't create etc/kernel in image: %v", err)
|
||||
}
|
||||
path := path.Join(context.Rootdir, "etc/kernel/cmdline")
|
||||
current, _ := ioutil.ReadFile(path)
|
||||
current, _ := os.ReadFile(path)
|
||||
f, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE, 0755)
|
||||
defer f.Close()
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ package actions
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io/fs"
|
||||
"os"
|
||||
"path"
|
||||
|
||||
@@ -95,12 +95,12 @@ func (d *PacstrapAction) Run(context *debos.DebosContext) error {
|
||||
return err
|
||||
}
|
||||
|
||||
read, err := ioutil.ReadFile(src)
|
||||
read, err := os.ReadFile(src)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err = ioutil.WriteFile(dest, read, 0644); err != nil {
|
||||
if err = os.WriteFile(dest, read, fs.FileMode(0644)); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,6 @@ package actions
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path"
|
||||
@@ -92,7 +91,7 @@ func (raw *RawAction) Run(context *debos.DebosContext) error {
|
||||
return fmt.Errorf("origin `%s` doesn't exist", raw.Origin)
|
||||
}
|
||||
s := path.Join(origin, raw.Source)
|
||||
content, err := ioutil.ReadFile(s)
|
||||
content, err := os.ReadFile(s)
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to read %s", s)
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"github.com/go-debos/debos"
|
||||
"github.com/go-debos/debos/actions"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -153,7 +152,7 @@ actions:
|
||||
}
|
||||
|
||||
func runTest(t *testing.T, test testRecipe, templateVars ...map[string]string) actions.Recipe {
|
||||
file, err := ioutil.TempFile(os.TempDir(), "recipe")
|
||||
file, err := os.CreateTemp(os.TempDir(), "recipe")
|
||||
assert.Empty(t, err)
|
||||
defer os.Remove(file.Name())
|
||||
|
||||
@@ -308,11 +307,11 @@ actions:
|
||||
|
||||
func runTestWithSubRecipes(t *testing.T, test testSubRecipe, templateVars ...map[string]string) actions.Recipe {
|
||||
context := debos.DebosContext{&debos.CommonContext{}, "", "", 512}
|
||||
dir, err := ioutil.TempDir("", "go-debos")
|
||||
dir, err := os.MkdirTemp("", "go-debos")
|
||||
assert.Empty(t, err)
|
||||
defer os.RemoveAll(dir)
|
||||
|
||||
file, err := ioutil.TempFile(dir, "recipe")
|
||||
file, err := os.CreateTemp(dir, "recipe")
|
||||
assert.Empty(t, err)
|
||||
defer os.Remove(file.Name())
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path"
|
||||
@@ -224,7 +223,7 @@ func main() {
|
||||
if !runInFakeMachine && !fakemachine.InMachine() {
|
||||
log.Printf("fakemachine not supported, running on the host!")
|
||||
cwd, _ := os.Getwd()
|
||||
context.Scratchdir, err = ioutil.TempDir(cwd, ".debos-")
|
||||
context.Scratchdir, err = os.MkdirTemp(cwd, ".debos-")
|
||||
defer os.RemoveAll(context.Scratchdir)
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"crypto/sha256"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
@@ -136,7 +135,7 @@ func (cmd *Command) saveResolvConf() (*[sha256.Size]byte, error) {
|
||||
}
|
||||
|
||||
/* Expect a relatively small file here */
|
||||
data, err := ioutil.ReadFile(hostconf)
|
||||
data, err := os.ReadFile(hostconf)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -145,7 +144,7 @@ func (cmd *Command) saveResolvConf() (*[sha256.Size]byte, error) {
|
||||
|
||||
sum = sha256.Sum256(out)
|
||||
|
||||
err = ioutil.WriteFile(chrootedconf, out, 0644)
|
||||
err = os.WriteFile(chrootedconf, out, 0644)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -177,7 +176,7 @@ func (cmd *Command) restoreResolvConf(sum *[sha256.Size]byte) error {
|
||||
switch {
|
||||
case mode.IsRegular():
|
||||
// Try to calculate checksum
|
||||
data, err := ioutil.ReadFile(chrootedconf)
|
||||
data, err := os.ReadFile(chrootedconf)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package debos
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
@@ -29,7 +28,7 @@ func CopyFile(src, dst string, mode os.FileMode) error {
|
||||
return err
|
||||
}
|
||||
defer in.Close()
|
||||
tmp, err := ioutil.TempFile(filepath.Dir(dst), "")
|
||||
tmp, err := os.CreateTemp(filepath.Dir(dst), "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user