all: Remove deprecated io/ioutil package
Porting everything to the newer imports was trivial except for one instance which required a very small refactor.
This commit is contained in:
@@ -19,7 +19,6 @@ package graph
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"sort"
|
"sort"
|
||||||
@@ -161,7 +160,7 @@ func (obj *Engine) ReversalList() (map[string]string, error) {
|
|||||||
result := make(map[string]string) // some key to contents
|
result := make(map[string]string) // some key to contents
|
||||||
|
|
||||||
dir := obj.statePrefix() // loop through this dir...
|
dir := obj.statePrefix() // loop through this dir...
|
||||||
files, err := ioutil.ReadDir(dir)
|
files, err := os.ReadDir(dir)
|
||||||
if err != nil && !os.IsNotExist(err) {
|
if err != nil && !os.IsNotExist(err) {
|
||||||
return nil, errwrap.Wrapf(err, "error reading list of state dirs")
|
return nil, errwrap.Wrapf(err, "error reading list of state dirs")
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
@@ -171,7 +170,7 @@ func (obj *Engine) ReversalList() (map[string]string, error) {
|
|||||||
for _, x := range files {
|
for _, x := range files {
|
||||||
key := x.Name() // some uid for the resource
|
key := x.Name() // some uid for the resource
|
||||||
file := path.Join(dir, key, ReverseFile)
|
file := path.Join(dir, key, ReverseFile)
|
||||||
content, err := ioutil.ReadFile(file)
|
content, err := os.ReadFile(file)
|
||||||
if err != nil && !os.IsNotExist(err) {
|
if err != nil && !os.IsNotExist(err) {
|
||||||
return nil, errwrap.Wrapf(err, "could not read reverse file: %s", file)
|
return nil, errwrap.Wrapf(err, "could not read reverse file: %s", file)
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
@@ -263,7 +262,7 @@ func (obj *State) ReversalWrite(str string, overwrite bool) error {
|
|||||||
}
|
}
|
||||||
file := path.Join(dir, ReverseFile) // return a unique file
|
file := path.Join(dir, ReverseFile) // return a unique file
|
||||||
|
|
||||||
content, err := ioutil.ReadFile(file)
|
content, err := os.ReadFile(file)
|
||||||
if err != nil && !os.IsNotExist(err) {
|
if err != nil && !os.IsNotExist(err) {
|
||||||
return errwrap.Wrapf(err, "could not read reverse file: %s", file)
|
return errwrap.Wrapf(err, "could not read reverse file: %s", file)
|
||||||
}
|
}
|
||||||
@@ -280,7 +279,7 @@ func (obj *State) ReversalWrite(str string, overwrite bool) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ioutil.WriteFile(file, []byte(str), ReversePerm)
|
return os.WriteFile(file, []byte(str), ReversePerm)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReversalDelete removes the reversal state information for this resource.
|
// ReversalDelete removes the reversal state information for this resource.
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"encoding/pem"
|
"encoding/pem"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"regexp"
|
"regexp"
|
||||||
@@ -980,7 +980,7 @@ func (obj *AwsEc2Res) snsGetCert(url string) (*x509.Certificate, error) {
|
|||||||
return nil, errwrap.Wrapf(err, "http get error")
|
return nil, errwrap.Wrapf(err, "http get error")
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
body, err := io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errwrap.Wrapf(err, "error reading post body")
|
return nil, errwrap.Wrapf(err, "error reading post body")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ package resources
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -287,7 +287,7 @@ func (obj *DockerContainerRes) CheckApply(ctx context.Context, apply bool) (bool
|
|||||||
return false, errwrap.Wrapf(err, "error pulling image")
|
return false, errwrap.Wrapf(err, "error pulling image")
|
||||||
}
|
}
|
||||||
// Wait for the image to download, EOF signals that it's done.
|
// Wait for the image to download, EOF signals that it's done.
|
||||||
if _, err := ioutil.ReadAll(p); err != nil {
|
if _, err := io.ReadAll(p); err != nil {
|
||||||
return false, errwrap.Wrapf(err, "error reading image pull result")
|
return false, errwrap.Wrapf(err, "error reading image pull result")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ package resources
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
@@ -155,7 +155,7 @@ func setup() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error pulling image: %s", err)
|
return fmt.Errorf("error pulling image: %s", err)
|
||||||
}
|
}
|
||||||
if _, err := ioutil.ReadAll(p); err != nil {
|
if _, err := io.ReadAll(p); err != nil {
|
||||||
return fmt.Errorf("error reading image pull result: %s", err)
|
return fmt.Errorf("error reading image pull result: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ package resources
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -211,7 +211,7 @@ func (obj *DockerImageRes) CheckApply(ctx context.Context, apply bool) (checkOK
|
|||||||
return false, errwrap.Wrapf(err, "error pulling image")
|
return false, errwrap.Wrapf(err, "error pulling image")
|
||||||
}
|
}
|
||||||
// Wait for the image to download, EOF signals that it's done.
|
// Wait for the image to download, EOF signals that it's done.
|
||||||
if _, err := ioutil.ReadAll(p); err != nil {
|
if _, err := io.ReadAll(p); err != nil {
|
||||||
return false, errwrap.Wrapf(err, "error reading image pull result")
|
return false, errwrap.Wrapf(err, "error reading image pull result")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import (
|
|||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/fs"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@@ -1076,7 +1076,7 @@ func (obj *FileRes) fragmentsCheckApply(ctx context.Context, apply bool) (bool,
|
|||||||
for _, frag := range obj.Fragments {
|
for _, frag := range obj.Fragments {
|
||||||
// It's a single file. Add it to what we're building...
|
// It's a single file. Add it to what we're building...
|
||||||
if isDir := strings.HasSuffix(frag, "/"); !isDir {
|
if isDir := strings.HasSuffix(frag, "/"); !isDir {
|
||||||
out, err := ioutil.ReadFile(frag)
|
out, err := os.ReadFile(frag)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, errwrap.Wrapf(err, "could not read file fragment")
|
return false, errwrap.Wrapf(err, "could not read file fragment")
|
||||||
}
|
}
|
||||||
@@ -1085,7 +1085,7 @@ func (obj *FileRes) fragmentsCheckApply(ctx context.Context, apply bool) (bool,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We're a dir, peer inside...
|
// We're a dir, peer inside...
|
||||||
files, err := ioutil.ReadDir(frag)
|
files, err := os.ReadDir(frag)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, errwrap.Wrapf(err, "could not read fragment directory")
|
return false, errwrap.Wrapf(err, "could not read fragment directory")
|
||||||
}
|
}
|
||||||
@@ -1096,7 +1096,7 @@ func (obj *FileRes) fragmentsCheckApply(ctx context.Context, apply bool) (bool,
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
f := path.Join(frag, file.Name())
|
f := path.Join(frag, file.Name())
|
||||||
out, err := ioutil.ReadFile(f)
|
out, err := os.ReadFile(f)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, errwrap.Wrapf(err, "could not read directory file fragment")
|
return false, errwrap.Wrapf(err, "could not read directory file fragment")
|
||||||
}
|
}
|
||||||
@@ -1571,7 +1571,7 @@ func (obj *FileRes) Reversed() (engine.ReversibleRes, error) {
|
|||||||
// We do this whether we specified content with Content or w/ Fragments.
|
// We do this whether we specified content with Content or w/ Fragments.
|
||||||
// The `res.State != FileStateAbsent` check is an optional optimization.
|
// The `res.State != FileStateAbsent` check is an optional optimization.
|
||||||
if ((obj.Content != nil || len(obj.Fragments) > 0) || obj.State == FileStateAbsent) && res.State != FileStateAbsent {
|
if ((obj.Content != nil || len(obj.Fragments) > 0) || obj.State == FileStateAbsent) && res.State != FileStateAbsent {
|
||||||
content, err := ioutil.ReadFile(obj.getPath())
|
content, err := os.ReadFile(obj.getPath())
|
||||||
if err != nil && !os.IsNotExist(err) {
|
if err != nil && !os.IsNotExist(err) {
|
||||||
return nil, errwrap.Wrapf(err, "could not read file for reversal storage")
|
return nil, errwrap.Wrapf(err, "could not read file for reversal storage")
|
||||||
}
|
}
|
||||||
@@ -1598,8 +1598,8 @@ func (obj *FileRes) Reversed() (engine.ReversibleRes, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// There is a race if the operating system is adding/changing/removing
|
// There is a race if the operating system is adding/changing/removing
|
||||||
// the file between the ioutil.Readfile at the top and here. If there is
|
// the file between the os.ReadFile at the top and here. If there is a
|
||||||
// a discrepancy between the two, then you might get an unexpected
|
// discrepancy between the two, then you might get an unexpected
|
||||||
// reverse, but in reality, your perspective is pretty absurd. This is a
|
// reverse, but in reality, your perspective is pretty absurd. This is a
|
||||||
// user error, and not an issue we actually care about, afaict.
|
// user error, and not an issue we actually care about, afaict.
|
||||||
fileInfo, err := os.Stat(obj.getPath())
|
fileInfo, err := os.Stat(obj.getPath())
|
||||||
@@ -1647,9 +1647,9 @@ func (obj *FileRes) GraphQueryAllowed(opts ...engine.GraphQueryableOption) error
|
|||||||
}
|
}
|
||||||
|
|
||||||
// smartPath adds a trailing slash to the path if it is a directory.
|
// smartPath adds a trailing slash to the path if it is a directory.
|
||||||
func smartPath(fileInfo os.FileInfo) string {
|
func smartPath(dirEntry fs.DirEntry) string {
|
||||||
smartPath := fileInfo.Name() // absolute path
|
smartPath := dirEntry.Name() // absolute path
|
||||||
if fileInfo.IsDir() {
|
if dirEntry.IsDir() {
|
||||||
smartPath += "/" // add a trailing slash for dirs
|
smartPath += "/" // add a trailing slash for dirs
|
||||||
}
|
}
|
||||||
return smartPath
|
return smartPath
|
||||||
@@ -1670,24 +1670,30 @@ func ReadDir(path string) ([]FileInfo, error) {
|
|||||||
return nil, fmt.Errorf("path must be a directory")
|
return nil, fmt.Errorf("path must be a directory")
|
||||||
}
|
}
|
||||||
output := []FileInfo{} // my file info
|
output := []FileInfo{} // my file info
|
||||||
fileInfos, err := ioutil.ReadDir(path)
|
files, err := os.ReadDir(path)
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
return output, err // return empty list
|
return output, err // return empty list
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
for _, fi := range fileInfos {
|
for _, file := range files {
|
||||||
abs := path + smartPath(fi)
|
abs := path + smartPath(file)
|
||||||
rel, err := filepath.Rel(path, abs) // NOTE: calls Clean()
|
rel, err := filepath.Rel(path, abs) // NOTE: calls Clean()
|
||||||
if err != nil { // shouldn't happen
|
if err != nil { // shouldn't happen
|
||||||
return nil, errwrap.Wrapf(err, "unhandled error in ReadDir")
|
return nil, errwrap.Wrapf(err, "unhandled error in ReadDir")
|
||||||
}
|
}
|
||||||
if fi.IsDir() {
|
if file.IsDir() {
|
||||||
rel += "/" // add a trailing slash for dirs
|
rel += "/" // add a trailing slash for dirs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fileInfo, err := file.Info()
|
||||||
|
if err != nil {
|
||||||
|
return nil, errwrap.Wrapf(err, "unhandled error in FileInfo")
|
||||||
|
}
|
||||||
|
|
||||||
x := FileInfo{
|
x := FileInfo{
|
||||||
FileInfo: fi,
|
FileInfo: fileInfo,
|
||||||
AbsPath: abs,
|
AbsPath: abs,
|
||||||
RelPath: rel,
|
RelPath: rel,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ package resources
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"os/user"
|
"os/user"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -210,7 +210,7 @@ func (obj *GroupRes) CheckApply(ctx context.Context, apply bool) (bool, error) {
|
|||||||
return false, errwrap.Wrapf(err, "cmd failed to start")
|
return false, errwrap.Wrapf(err, "cmd failed to start")
|
||||||
}
|
}
|
||||||
// capture any error messages
|
// capture any error messages
|
||||||
slurp, err := ioutil.ReadAll(stderr)
|
slurp, err := io.ReadAll(stderr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, errwrap.Wrapf(err, "error slurping error message")
|
return false, errwrap.Wrapf(err, "error slurping error message")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -148,7 +147,7 @@ func (obj *MountRes) Validate() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate type
|
// validate type
|
||||||
fs, err := ioutil.ReadFile(procFilesystems)
|
fs, err := os.ReadFile(procFilesystems)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errwrap.Wrapf(err, "error reading %s", procFilesystems)
|
return errwrap.Wrapf(err, "error reading %s", procFilesystems)
|
||||||
}
|
}
|
||||||
@@ -517,7 +516,7 @@ func (obj *MountRes) fstabWrite(file string, mounts fstab.Mounts) error {
|
|||||||
contents := fmt.Sprintf("# Generated by %s at %d", obj.init.Program, time.Now().UnixNano()) + "\n"
|
contents := fmt.Sprintf("# Generated by %s at %d", obj.init.Program, time.Now().UnixNano()) + "\n"
|
||||||
contents = contents + mounts.String() + "\n"
|
contents = contents + mounts.String() + "\n"
|
||||||
// write the file
|
// write the file
|
||||||
if err := ioutil.WriteFile(file, []byte(contents), fstabUmask); err != nil {
|
if err := os.WriteFile(file, []byte(contents), fstabUmask); err != nil {
|
||||||
return errwrap.Wrapf(err, "error writing fstab file: %s", file)
|
return errwrap.Wrapf(err, "error writing fstab file: %s", file)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -20,7 +20,6 @@
|
|||||||
package resources
|
package resources
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@@ -49,18 +48,18 @@ func TestMountExists(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
file, err := ioutil.TempFile("", "proc")
|
file, err := os.CreateTemp("", "proc")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("error creating temp file: %v", err)
|
t.Errorf("error creating temp file: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer os.Remove(file.Name())
|
defer os.Remove(file.Name())
|
||||||
for _, test := range mountExistsTests {
|
for _, test := range mountExistsTests {
|
||||||
if err := ioutil.WriteFile(file.Name(), test.procMock, 0664); err != nil {
|
if err := os.WriteFile(file.Name(), test.procMock, 0664); err != nil {
|
||||||
t.Errorf("error writing proc file: %s: %v", file.Name(), err)
|
t.Errorf("error writing proc file: %s: %v", file.Name(), err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := ioutil.WriteFile(test.in.Spec, []byte{}, 0664); err != nil {
|
if err := os.WriteFile(test.in.Spec, []byte{}, 0664); err != nil {
|
||||||
t.Errorf("error writing fstab file: %s: %v", file.Name(), err)
|
t.Errorf("error writing fstab file: %s: %v", file.Name(), err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,6 @@
|
|||||||
package resources
|
package resources
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@@ -65,7 +64,7 @@ var fstabWriteTests = []struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (obj *MountRes) TestFstabWrite(t *testing.T) {
|
func (obj *MountRes) TestFstabWrite(t *testing.T) {
|
||||||
file, err := ioutil.TempFile("", "fstab")
|
file, err := os.CreateTemp("", "fstab")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("error creating temp file: %v", err)
|
t.Errorf("error creating temp file: %v", err)
|
||||||
return
|
return
|
||||||
@@ -117,7 +116,7 @@ var fstabEntryAddTests = []struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (obj *MountRes) TestFstabEntryAdd(t *testing.T) {
|
func (obj *MountRes) TestFstabEntryAdd(t *testing.T) {
|
||||||
file, err := ioutil.TempFile("", "fstab")
|
file, err := os.CreateTemp("", "fstab")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("error creating temp file: %v", err)
|
t.Errorf("error creating temp file: %v", err)
|
||||||
return
|
return
|
||||||
@@ -125,7 +124,7 @@ func (obj *MountRes) TestFstabEntryAdd(t *testing.T) {
|
|||||||
defer os.Remove(file.Name())
|
defer os.Remove(file.Name())
|
||||||
|
|
||||||
for _, test := range fstabEntryAddTests {
|
for _, test := range fstabEntryAddTests {
|
||||||
if err := ioutil.WriteFile(file.Name(), test.fstabMock, 0644); err != nil {
|
if err := os.WriteFile(file.Name(), test.fstabMock, 0644); err != nil {
|
||||||
t.Errorf("error writing fstab file: %s: %v", file.Name(), err)
|
t.Errorf("error writing fstab file: %s: %v", file.Name(), err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -163,7 +162,7 @@ var fstabEntryRemoveTests = []struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (obj *MountRes) TestFstabEntryRemove(t *testing.T) {
|
func (obj *MountRes) TestFstabEntryRemove(t *testing.T) {
|
||||||
file, err := ioutil.TempFile("", "fstab")
|
file, err := os.CreateTemp("", "fstab")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("error creating temp file: %v", err)
|
t.Errorf("error creating temp file: %v", err)
|
||||||
return
|
return
|
||||||
@@ -171,7 +170,7 @@ func (obj *MountRes) TestFstabEntryRemove(t *testing.T) {
|
|||||||
defer os.Remove(file.Name())
|
defer os.Remove(file.Name())
|
||||||
|
|
||||||
for _, test := range fstabEntryRemoveTests {
|
for _, test := range fstabEntryRemoveTests {
|
||||||
if err := ioutil.WriteFile(file.Name(), test.fstabMock, 0644); err != nil {
|
if err := os.WriteFile(file.Name(), test.fstabMock, 0644); err != nil {
|
||||||
t.Errorf("error writing fstab file: %s: %v", file.Name(), err)
|
t.Errorf("error writing fstab file: %s: %v", file.Name(), err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -258,7 +257,7 @@ var fstabEntryExistsTests = []struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestFstabEntryExists(t *testing.T) {
|
func TestFstabEntryExists(t *testing.T) {
|
||||||
file, err := ioutil.TempFile("", "fstab")
|
file, err := os.CreateTemp("", "fstab")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("error creating temp file: %v", err)
|
t.Errorf("error creating temp file: %v", err)
|
||||||
return
|
return
|
||||||
@@ -266,7 +265,7 @@ func TestFstabEntryExists(t *testing.T) {
|
|||||||
defer os.Remove(file.Name())
|
defer os.Remove(file.Name())
|
||||||
|
|
||||||
for _, test := range fstabEntryExistsTests {
|
for _, test := range fstabEntryExistsTests {
|
||||||
if err := ioutil.WriteFile(file.Name(), test.fstabMock, 0644); err != nil {
|
if err := os.WriteFile(file.Name(), test.fstabMock, 0644); err != nil {
|
||||||
t.Errorf("error writing fstab file: %s: %v", file.Name(), err)
|
t.Errorf("error writing fstab file: %s: %v", file.Name(), err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
@@ -509,7 +508,7 @@ func (obj *NetRes) fileCheckApply(ctx context.Context, apply bool) (bool, error)
|
|||||||
fileContents := []byte{}
|
fileContents := []byte{}
|
||||||
if exists {
|
if exists {
|
||||||
// check the file contents
|
// check the file contents
|
||||||
byt, err := ioutil.ReadFile(obj.unitFilePath)
|
byt, err := os.ReadFile(obj.unitFilePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, errwrap.Wrapf(err, "error reading file")
|
return false, errwrap.Wrapf(err, "error reading file")
|
||||||
}
|
}
|
||||||
@@ -535,7 +534,7 @@ func (obj *NetRes) fileCheckApply(ctx context.Context, apply bool) (bool, error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// all other situations, we write the file
|
// all other situations, we write the file
|
||||||
if err := ioutil.WriteFile(obj.unitFilePath, contents, networkdUnitFileUmask); err != nil {
|
if err := os.WriteFile(obj.unitFilePath, contents, networkdUnitFileUmask); err != nil {
|
||||||
return false, errwrap.Wrapf(err, "error writing configuration file")
|
return false, errwrap.Wrapf(err, "error writing configuration file")
|
||||||
}
|
}
|
||||||
return false, nil
|
return false, nil
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"math/big"
|
"math/big"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
@@ -109,7 +109,7 @@ func (obj *PasswordRes) read() (string, error) {
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
data, err := ioutil.ReadAll(file)
|
data, err := io.ReadAll(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", errwrap.Wrapf(err, "could not read from file")
|
return "", errwrap.Wrapf(err, "could not read from file")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ package resources
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/user"
|
"os/user"
|
||||||
"path"
|
"path"
|
||||||
@@ -166,7 +165,7 @@ func FileExpect(p, s string) Step { // path & string
|
|||||||
return &manualStep{
|
return &manualStep{
|
||||||
action: func() error { return nil },
|
action: func() error { return nil },
|
||||||
expect: func() error {
|
expect: func() error {
|
||||||
content, err := ioutil.ReadFile(p)
|
content, err := os.ReadFile(p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -207,7 +206,7 @@ func FileWrite(p, s string) Step { // path & string
|
|||||||
action: func() error {
|
action: func() error {
|
||||||
// TODO: apparently using 0666 is equivalent to respecting the current umask
|
// TODO: apparently using 0666 is equivalent to respecting the current umask
|
||||||
const umask = 0666
|
const umask = 0666
|
||||||
return ioutil.WriteFile(p, []byte(s), umask)
|
return os.WriteFile(p, []byte(s), umask)
|
||||||
},
|
},
|
||||||
expect: func() error { return nil },
|
expect: func() error { return nil },
|
||||||
}
|
}
|
||||||
@@ -318,7 +317,7 @@ func TestResources1(t *testing.T) {
|
|||||||
timeline: timeline,
|
timeline: timeline,
|
||||||
expect: func() error { return nil },
|
expect: func() error { return nil },
|
||||||
// build file for inotifywait
|
// build file for inotifywait
|
||||||
startup: func() error { return ioutil.WriteFile(f, []byte("starting...\n"), 0666) },
|
startup: func() error { return os.WriteFile(f, []byte("starting...\n"), 0666) },
|
||||||
cleanup: func() error { return os.Remove(f) },
|
cleanup: func() error { return os.Remove(f) },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -354,7 +353,7 @@ func TestResources1(t *testing.T) {
|
|||||||
timeline: timeline,
|
timeline: timeline,
|
||||||
expect: func() error { return nil },
|
expect: func() error { return nil },
|
||||||
// build file for inotifywait
|
// build file for inotifywait
|
||||||
startup: func() error { return ioutil.WriteFile(f, []byte("starting...\n"), 0666) },
|
startup: func() error { return os.WriteFile(f, []byte("starting...\n"), 0666) },
|
||||||
cleanup: func() error { return os.Remove(f) },
|
cleanup: func() error { return os.Remove(f) },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -402,7 +401,7 @@ func TestResources1(t *testing.T) {
|
|||||||
fail: false,
|
fail: false,
|
||||||
timeline: timeline,
|
timeline: timeline,
|
||||||
expect: func() error { return nil },
|
expect: func() error { return nil },
|
||||||
startup: func() error { return ioutil.WriteFile(p, []byte(content), 0666) },
|
startup: func() error { return os.WriteFile(p, []byte(content), 0666) },
|
||||||
cleanup: func() error { return os.Remove(p) },
|
cleanup: func() error { return os.Remove(p) },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -429,7 +428,7 @@ func TestResources1(t *testing.T) {
|
|||||||
fail: false,
|
fail: false,
|
||||||
timeline: timeline,
|
timeline: timeline,
|
||||||
expect: func() error { return nil },
|
expect: func() error { return nil },
|
||||||
startup: func() error { return ioutil.WriteFile(p, []byte(content), 0666) },
|
startup: func() error { return os.WriteFile(p, []byte(content), 0666) },
|
||||||
cleanup: func() error { return os.Remove(p) },
|
cleanup: func() error { return os.Remove(p) },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -841,13 +840,13 @@ func TestResources2(t *testing.T) {
|
|||||||
fileWrite := func(p, s string) func() error {
|
fileWrite := func(p, s string) func() error {
|
||||||
// write the file to path
|
// write the file to path
|
||||||
return func() error {
|
return func() error {
|
||||||
return ioutil.WriteFile(p, []byte(s), 0666)
|
return os.WriteFile(p, []byte(s), 0666)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fileExpect := func(p, s string) func() error {
|
fileExpect := func(p, s string) func() error {
|
||||||
// check the contents at the path match the string we expect
|
// check the contents at the path match the string we expect
|
||||||
return func() error {
|
return func() error {
|
||||||
content, err := ioutil.ReadFile(p)
|
content, err := os.ReadFile(p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ package resources
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"os/user"
|
"os/user"
|
||||||
"sort"
|
"sort"
|
||||||
@@ -276,7 +276,7 @@ func (obj *UserRes) CheckApply(ctx context.Context, apply bool) (bool, error) {
|
|||||||
return false, errwrap.Wrapf(err, "cmd failed to start")
|
return false, errwrap.Wrapf(err, "cmd failed to start")
|
||||||
}
|
}
|
||||||
// capture any error messages
|
// capture any error messages
|
||||||
slurp, err := ioutil.ReadAll(stderr)
|
slurp, err := io.ReadAll(stderr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, errwrap.Wrapf(err, "error slurping error message")
|
return false, errwrap.Wrapf(err, "error slurping error message")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -46,7 +46,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
log.Printf("Event received: %+v", result)
|
log.Printf("Event received: %+v", result)
|
||||||
|
|
||||||
s, err := ioutil.ReadAll(result.Body) // TODO: apparently we can stream
|
s, err := io.ReadAll(result.Body) // TODO: apparently we can stream
|
||||||
result.Body.Close()
|
result.Body.Close()
|
||||||
log.Printf("Response: %+v", string(s))
|
log.Printf("Response: %+v", string(s))
|
||||||
log.Printf("Error: %+v", err)
|
log.Printf("Error: %+v", err)
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
package gapi
|
package gapi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"os"
|
||||||
|
|
||||||
"github.com/purpleidea/mgmt/engine"
|
"github.com/purpleidea/mgmt/engine"
|
||||||
"github.com/purpleidea/mgmt/util"
|
"github.com/purpleidea/mgmt/util"
|
||||||
@@ -31,7 +31,7 @@ const Umask = 0666
|
|||||||
|
|
||||||
// CopyFileToFs copies a file from src path on the local fs to a dst path on fs.
|
// CopyFileToFs copies a file from src path on the local fs to a dst path on fs.
|
||||||
func CopyFileToFs(fs engine.WriteableFS, src, dst string) error {
|
func CopyFileToFs(fs engine.WriteableFS, src, dst string) error {
|
||||||
data, err := ioutil.ReadFile(src)
|
data, err := os.ReadFile(src)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errwrap.Wrapf(err, "can't read from file `%s`", src)
|
return errwrap.Wrapf(err, "can't read from file `%s`", src)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ package integration
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"sort"
|
"sort"
|
||||||
@@ -136,7 +135,7 @@ func TestInstance1(t *testing.T) {
|
|||||||
sort.Strings(files) // loop in a deterministic order
|
sort.Strings(files) // loop in a deterministic order
|
||||||
for _, f := range files {
|
for _, f := range files {
|
||||||
filename := path.Join(d, RootDirectory, f)
|
filename := path.Join(d, RootDirectory, f)
|
||||||
b, err := ioutil.ReadFile(filename)
|
b, err := os.ReadFile(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("could not read file: `%s`", filename)
|
t.Errorf("could not read file: `%s`", filename)
|
||||||
continue
|
continue
|
||||||
@@ -274,7 +273,7 @@ func TestCluster1(t *testing.T) {
|
|||||||
sort.Strings(files) // loop in a deterministic order
|
sort.Strings(files) // loop in a deterministic order
|
||||||
for _, f := range files {
|
for _, f := range files {
|
||||||
filename := path.Join(d, RootDirectory, f)
|
filename := path.Join(d, RootDirectory, f)
|
||||||
b, err := ioutil.ReadFile(filename)
|
b, err := os.ReadFile(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("could not read file: `%s`", filename)
|
t.Errorf("could not read file: `%s`", filename)
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ package integration
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path"
|
"path"
|
||||||
@@ -68,7 +67,7 @@ func (obj *Cluster) Init() error {
|
|||||||
|
|
||||||
// create temporary directory to use during testing
|
// create temporary directory to use during testing
|
||||||
if obj.dir == "" {
|
if obj.dir == "" {
|
||||||
obj.dir, err = ioutil.TempDir("", "mgmt-integration-cluster-")
|
obj.dir, err = os.MkdirTemp("", "mgmt-integration-cluster-")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errwrap.Wrapf(err, "can't create temporary directory")
|
return errwrap.Wrapf(err, "can't create temporary directory")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ package integration
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path"
|
"path"
|
||||||
@@ -117,7 +116,7 @@ func (obj *Instance) Init() error {
|
|||||||
// create temporary directory to use during testing
|
// create temporary directory to use during testing
|
||||||
if obj.dir == "" {
|
if obj.dir == "" {
|
||||||
var err error
|
var err error
|
||||||
obj.dir, err = ioutil.TempDir("", fmt.Sprintf("mgmt-integration-%s-", obj.Hostname))
|
obj.dir, err = os.MkdirTemp("", fmt.Sprintf("mgmt-integration-%s-", obj.Hostname))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errwrap.Wrapf(err, "can't create temporary directory")
|
return errwrap.Wrapf(err, "can't create temporary directory")
|
||||||
}
|
}
|
||||||
@@ -379,7 +378,7 @@ func (obj *Instance) Wait(ctx context.Context) error {
|
|||||||
return ctx.Err()
|
return ctx.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
contents, err := ioutil.ReadFile(obj.convergedStatusFile)
|
contents, err := os.ReadFile(obj.convergedStatusFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continue // file might not exist yet, wait for an event
|
continue // file might not exist yet, wait for an event
|
||||||
}
|
}
|
||||||
@@ -418,7 +417,7 @@ func (obj *Instance) DeployLang(code string) error {
|
|||||||
|
|
||||||
filename := path.Join(obj.dir, "deploy.mcl")
|
filename := path.Join(obj.dir, "deploy.mcl")
|
||||||
data := []byte(code)
|
data := []byte(code)
|
||||||
if err := ioutil.WriteFile(filename, data, fileMode); err != nil {
|
if err := os.WriteFile(filename, data, fileMode); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -451,7 +450,7 @@ func (obj *Instance) Dir() string {
|
|||||||
|
|
||||||
// CombinedOutput returns the logged output from the instance.
|
// CombinedOutput returns the logged output from the instance.
|
||||||
func (obj *Instance) CombinedOutput() (string, error) {
|
func (obj *Instance) CombinedOutput() (string, error) {
|
||||||
contents, err := ioutil.ReadFile(path.Join(obj.dir, StdoutStderrFile))
|
contents, err := os.ReadFile(path.Join(obj.dir, StdoutStderrFile))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ package core
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
"sync"
|
"sync"
|
||||||
@@ -489,7 +488,7 @@ func TestLiveFuncExec0(t *testing.T) {
|
|||||||
funcname: "os.readfile",
|
funcname: "os.readfile",
|
||||||
timeline: timeline,
|
timeline: timeline,
|
||||||
expect: func() error { return nil },
|
expect: func() error { return nil },
|
||||||
startup: func() error { return ioutil.WriteFile(p, []byte(content), 0666) },
|
startup: func() error { return os.WriteFile(p, []byte(content), 0666) },
|
||||||
cleanup: func() error { return os.Remove(p) },
|
cleanup: func() error { return os.Remove(p) },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ package coreos
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"os"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/purpleidea/mgmt/lang/funcs"
|
"github.com/purpleidea/mgmt/lang/funcs"
|
||||||
@@ -203,7 +203,7 @@ func (obj *ReadFileFunc) Stream(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// read file...
|
// read file...
|
||||||
content, err := ioutil.ReadFile(*obj.filename)
|
content, err := os.ReadFile(*obj.filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errwrap.Wrapf(err, "error reading file")
|
return errwrap.Wrapf(err, "error reading file")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ package coresys
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"io/ioutil"
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -173,7 +173,7 @@ func (obj CPUCountFact) Stream(ctx context.Context) error {
|
|||||||
|
|
||||||
// getCPUCount looks in sysfs to get the number of CPUs that are online.
|
// getCPUCount looks in sysfs to get the number of CPUs that are online.
|
||||||
func getCPUCount() (int64, error) {
|
func getCPUCount() (int64, error) {
|
||||||
dat, err := ioutil.ReadFile("/sys/devices/system/cpu/online")
|
dat, err := os.ReadFile("/sys/devices/system/cpu/online")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@@ -72,7 +71,7 @@ func parseFuncs(c config, f functions, path, templates string) error {
|
|||||||
func generateTemplate(c config, f functions, path, templateFile, finalName string) error {
|
func generateTemplate(c config, f functions, path, templateFile, finalName string) error {
|
||||||
log.Printf("Reading: %s", templateFile)
|
log.Printf("Reading: %s", templateFile)
|
||||||
basename := filepath.Base(templateFile)
|
basename := filepath.Base(templateFile)
|
||||||
tplFile, err := ioutil.ReadFile(templateFile)
|
tplFile, err := os.ReadFile(templateFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ func testRenderFuncsWithFixture(t *testing.T, fixture string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
funcs := &functions{}
|
funcs := &functions{}
|
||||||
fixtures, err := ioutil.ReadFile(fmt.Sprintf("fixtures/func_%s.yaml", fixture))
|
fixtures, err := os.ReadFile(fmt.Sprintf("fixtures/func_%s.yaml", fixture))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Fixtures (yaml) unreadable!\n%v", err)
|
t.Fatalf("Fixtures (yaml) unreadable!\n%v", err)
|
||||||
}
|
}
|
||||||
@@ -46,7 +46,7 @@ func testRenderFuncsWithFixture(t *testing.T, fixture string) {
|
|||||||
t.Fatalf("Fixtures (yaml) unreadable!\n%v", err)
|
t.Fatalf("Fixtures (yaml) unreadable!\n%v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
golangFixtures, err := ioutil.ReadFile(fmt.Sprintf("fixtures/func_%s.tpl", fixture))
|
golangFixtures, err := os.ReadFile(fmt.Sprintf("fixtures/func_%s.tpl", fixture))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Fixtures (tpl) unreadable!\n%v", err)
|
t.Fatalf("Fixtures (tpl) unreadable!\n%v", err)
|
||||||
}
|
}
|
||||||
@@ -60,7 +60,7 @@ func testRenderFuncsWithFixture(t *testing.T, fixture string) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Not generating template!\n%v", err)
|
t.Fatalf("Not generating template!\n%v", err)
|
||||||
}
|
}
|
||||||
result, err := ioutil.ReadFile(fmt.Sprintf("fixtures/%s", dstFileName))
|
result, err := os.ReadFile(fmt.Sprintf("fixtures/%s", dstFileName))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Result unreadable!\n%v", err)
|
t.Fatalf("Result unreadable!\n%v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
@@ -55,7 +55,7 @@ func parsePkg(path, filename, templates string) error {
|
|||||||
var c config
|
var c config
|
||||||
filePath := filepath.Join(path, filename)
|
filePath := filepath.Join(path, filename)
|
||||||
log.Printf("Data: %s", filePath)
|
log.Printf("Data: %s", filePath)
|
||||||
cfgFile, err := ioutil.ReadFile(filePath)
|
cfgFile, err := os.ReadFile(filePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ func testParseFuncsWithFixture(t *testing.T, fixture string) {
|
|||||||
Exclude: []string{"ToLower"},
|
Exclude: []string{"ToLower"},
|
||||||
}
|
}
|
||||||
|
|
||||||
signatures, err := ioutil.ReadFile(fmt.Sprintf("fixtures/func_%s.txt", fixture))
|
signatures, err := os.ReadFile(fmt.Sprintf("fixtures/func_%s.txt", fixture))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Fixtures (txt) unreadable!\n%v", err)
|
t.Fatalf("Fixtures (txt) unreadable!\n%v", err)
|
||||||
}
|
}
|
||||||
@@ -46,7 +46,7 @@ func testParseFuncsWithFixture(t *testing.T, fixture string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
expected := &functions{}
|
expected := &functions{}
|
||||||
fixtures, err := ioutil.ReadFile(fmt.Sprintf("fixtures/func_%s.yaml", fixture))
|
fixtures, err := os.ReadFile(fmt.Sprintf("fixtures/func_%s.yaml", fixture))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Fixtures (yaml) unreadable!\n%v", err)
|
t.Fatalf("Fixtures (yaml) unreadable!\n%v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ package inputs
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -162,7 +162,7 @@ func inputStdin(s string, fs engine.Fs) (*ParsedInput, error) {
|
|||||||
// TODO: yes, we could pass a reader directly, but we'd
|
// TODO: yes, we could pass a reader directly, but we'd
|
||||||
// need to have a convention for it to get closed after
|
// need to have a convention for it to get closed after
|
||||||
// and we need to save it to disk for deploys to use it
|
// and we need to save it to disk for deploys to use it
|
||||||
b, err := ioutil.ReadAll(os.Stdin) // doesn't need fs
|
b, err := io.ReadAll(os.Stdin) // doesn't need fs
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errwrap.Wrapf(err, "can't read in stdin")
|
return nil, errwrap.Wrapf(err, "can't read in stdin")
|
||||||
}
|
}
|
||||||
@@ -203,7 +203,7 @@ func inputMetadata(s string, fs engine.Fs) (*ParsedInput, error) {
|
|||||||
return nil, errwrap.Wrapf(err, "can't read from file: `%s`", m)
|
return nil, errwrap.Wrapf(err, "can't read from file: `%s`", m)
|
||||||
}
|
}
|
||||||
defer fm.Close() // we're done reading by the time this runs
|
defer fm.Close() // we're done reading by the time this runs
|
||||||
b, err := ioutil.ReadAll(fm) // doesn't need fs
|
b, err := io.ReadAll(fm) // doesn't need fs
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errwrap.Wrapf(err, "can't read in file: `%s`", m)
|
return nil, errwrap.Wrapf(err, "can't read in file: `%s`", m)
|
||||||
}
|
}
|
||||||
@@ -252,7 +252,7 @@ func inputMcl(s string, fs engine.Fs) (*ParsedInput, error) {
|
|||||||
return nil, errwrap.Wrapf(err, "can't read from file: `%s`", s)
|
return nil, errwrap.Wrapf(err, "can't read from file: `%s`", s)
|
||||||
}
|
}
|
||||||
defer fm.Close() // we're done reading by the time this runs
|
defer fm.Close() // we're done reading by the time this runs
|
||||||
b, err := ioutil.ReadAll(fm) // doesn't need fs
|
b, err := io.ReadAll(fm) // doesn't need fs
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errwrap.Wrapf(err, "can't read in file: `%s`", s)
|
return nil, errwrap.Wrapf(err, "can't read in file: `%s`", s)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ package interfaces
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/purpleidea/mgmt/util/errwrap"
|
"github.com/purpleidea/mgmt/util/errwrap"
|
||||||
@@ -196,7 +195,7 @@ func ParseMetadata(reader io.Reader) (*Metadata, error) {
|
|||||||
//if err := decoder.Decode(metadata); err != nil {
|
//if err := decoder.Decode(metadata); err != nil {
|
||||||
// return nil, errwrap.Wrapf(err, "can't parse metadata")
|
// return nil, errwrap.Wrapf(err, "can't parse metadata")
|
||||||
//}
|
//}
|
||||||
b, err := ioutil.ReadAll(reader)
|
b, err := io.ReadAll(reader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errwrap.Wrapf(err, "can't read metadata")
|
return nil, errwrap.Wrapf(err, "can't read metadata")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
@@ -123,7 +122,7 @@ func TestAstFunc1(t *testing.T) {
|
|||||||
testCases := []test{}
|
testCases := []test{}
|
||||||
|
|
||||||
// build test array automatically from reading the dir
|
// build test array automatically from reading the dir
|
||||||
files, err := ioutil.ReadDir(dir)
|
files, err := os.ReadDir(dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("could not read through tests directory: %+v", err)
|
t.Errorf("could not read through tests directory: %+v", err)
|
||||||
return
|
return
|
||||||
@@ -207,7 +206,7 @@ func TestAstFunc1(t *testing.T) {
|
|||||||
t.Errorf("err making dir(%s): %+v", dir, err)
|
t.Errorf("err making dir(%s): %+v", dir, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := ioutil.WriteFile(name, file.Data, 0660); err != nil {
|
if err := os.WriteFile(name, file.Data, 0660); err != nil {
|
||||||
t.Errorf("err writing file(%s): %+v", name, err)
|
t.Errorf("err writing file(%s): %+v", name, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -289,7 +288,7 @@ func TestAstFunc1(t *testing.T) {
|
|||||||
t.Logf(fmt.Sprintf("test #%d", index)+": "+format, v...)
|
t.Logf(fmt.Sprintf("test #%d", index)+": "+format, v...)
|
||||||
}
|
}
|
||||||
mmFs := afero.NewMemMapFs()
|
mmFs := afero.NewMemMapFs()
|
||||||
afs := &afero.Afero{Fs: mmFs} // wrap so that we're implementing ioutil
|
afs := &afero.Afero{Fs: mmFs} // wrap to implement the fs API's
|
||||||
fs := &util.AferoFs{Afero: afs}
|
fs := &util.AferoFs{Afero: afs}
|
||||||
|
|
||||||
// use this variant, so that we don't copy the dir name
|
// use this variant, so that we don't copy the dir name
|
||||||
@@ -603,7 +602,7 @@ func TestAstFunc2(t *testing.T) {
|
|||||||
testCases := []test{}
|
testCases := []test{}
|
||||||
|
|
||||||
// build test array automatically from reading the dir
|
// build test array automatically from reading the dir
|
||||||
files, err := ioutil.ReadDir(dir)
|
files, err := os.ReadDir(dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("could not read through tests directory: %+v", err)
|
t.Errorf("could not read through tests directory: %+v", err)
|
||||||
return
|
return
|
||||||
@@ -690,7 +689,7 @@ func TestAstFunc2(t *testing.T) {
|
|||||||
t.Errorf("err making dir(%s): %+v", dir, err)
|
t.Errorf("err making dir(%s): %+v", dir, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := ioutil.WriteFile(name, file.Data, 0660); err != nil {
|
if err := os.WriteFile(name, file.Data, 0660); err != nil {
|
||||||
t.Errorf("err writing file(%s): %+v", name, err)
|
t.Errorf("err writing file(%s): %+v", name, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -796,7 +795,7 @@ func TestAstFunc2(t *testing.T) {
|
|||||||
t.Logf(fmt.Sprintf("test #%d", index)+": "+format, v...)
|
t.Logf(fmt.Sprintf("test #%d", index)+": "+format, v...)
|
||||||
}
|
}
|
||||||
mmFs := afero.NewMemMapFs()
|
mmFs := afero.NewMemMapFs()
|
||||||
afs := &afero.Afero{Fs: mmFs} // wrap so that we're implementing ioutil
|
afs := &afero.Afero{Fs: mmFs} // wrap to implement the fs API's
|
||||||
fs := &util.AferoFs{Afero: afs}
|
fs := &util.AferoFs{Afero: afs}
|
||||||
|
|
||||||
// implementation of the Local API (we only expect just this single one)
|
// implementation of the Local API (we only expect just this single one)
|
||||||
@@ -1411,7 +1410,7 @@ func TestAstFunc3(t *testing.T) {
|
|||||||
testCases := []test{}
|
testCases := []test{}
|
||||||
|
|
||||||
// build test array automatically from reading the dir
|
// build test array automatically from reading the dir
|
||||||
files, err := ioutil.ReadDir(dir)
|
files, err := os.ReadDir(dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("could not read through tests directory: %+v", err)
|
t.Errorf("could not read through tests directory: %+v", err)
|
||||||
return
|
return
|
||||||
@@ -1498,7 +1497,7 @@ func TestAstFunc3(t *testing.T) {
|
|||||||
t.Errorf("err making dir(%s): %+v", dir, err)
|
t.Errorf("err making dir(%s): %+v", dir, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := ioutil.WriteFile(name, file.Data, 0660); err != nil {
|
if err := os.WriteFile(name, file.Data, 0660); err != nil {
|
||||||
t.Errorf("err writing file(%s): %+v", name, err)
|
t.Errorf("err writing file(%s): %+v", name, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -1598,7 +1597,7 @@ func TestAstFunc3(t *testing.T) {
|
|||||||
t.Logf(fmt.Sprintf("test #%d", index)+": "+format, v...)
|
t.Logf(fmt.Sprintf("test #%d", index)+": "+format, v...)
|
||||||
}
|
}
|
||||||
mmFs := afero.NewMemMapFs()
|
mmFs := afero.NewMemMapFs()
|
||||||
afs := &afero.Afero{Fs: mmFs} // wrap so that we're implementing ioutil
|
afs := &afero.Afero{Fs: mmFs} // wrap to implement the fs API's
|
||||||
fs := &util.AferoFs{Afero: afs}
|
fs := &util.AferoFs{Afero: afs}
|
||||||
|
|
||||||
// implementation of the Local API (we only expect just this single one)
|
// implementation of the Local API (we only expect just this single one)
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ package lib
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/user"
|
"os/user"
|
||||||
@@ -258,7 +257,7 @@ func (obj *Main) Run() error {
|
|||||||
if obj.TmpPrefix || os.MkdirAll(prefix, 0770) != nil {
|
if obj.TmpPrefix || os.MkdirAll(prefix, 0770) != nil {
|
||||||
if obj.TmpPrefix || obj.AllowTmpPrefix {
|
if obj.TmpPrefix || obj.AllowTmpPrefix {
|
||||||
var err error
|
var err error
|
||||||
if prefix, err = ioutil.TempDir("", obj.Program+"-"+hostname+"-"); err != nil {
|
if prefix, err = os.MkdirTemp("", obj.Program+"-"+hostname+"-"); err != nil {
|
||||||
return fmt.Errorf("can't create temporary prefix")
|
return fmt.Errorf("can't create temporary prefix")
|
||||||
}
|
}
|
||||||
Logf("warning: working prefix directory is temporary!")
|
Logf("warning: working prefix directory is temporary!")
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"crypto"
|
"crypto"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -155,7 +155,7 @@ func (obj *PGP) Encrypt(to *openpgp.Entity, msg string) (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// encode to base64
|
// encode to base64
|
||||||
bytes, err := ioutil.ReadAll(buf)
|
bytes, err := io.ReadAll(buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", errwrap.Wrapf(err, "can't read unverified body")
|
return "", errwrap.Wrapf(err, "can't read unverified body")
|
||||||
}
|
}
|
||||||
@@ -199,7 +199,7 @@ func (obj *PGP) Decrypt(encString string) (string, error) {
|
|||||||
return "", errwrap.Wrapf(err, "can't read message")
|
return "", errwrap.Wrapf(err, "can't read message")
|
||||||
}
|
}
|
||||||
|
|
||||||
bytes, err := ioutil.ReadAll(md.UnverifiedBody)
|
bytes, err := io.ReadAll(md.UnverifiedBody)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", errwrap.Wrapf(err, "can't read unverified body")
|
return "", errwrap.Wrapf(err, "can't read unverified body")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ package pgraph // TODO: this should be a subpackage
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"html"
|
"html"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"sort"
|
"sort"
|
||||||
@@ -168,7 +167,7 @@ func (obj *Graphviz) Exec() error {
|
|||||||
uid, err1 := strconv.Atoi(os.Getenv("SUDO_UID"))
|
uid, err1 := strconv.Atoi(os.Getenv("SUDO_UID"))
|
||||||
gid, err2 := strconv.Atoi(os.Getenv("SUDO_GID"))
|
gid, err2 := strconv.Atoi(os.Getenv("SUDO_GID"))
|
||||||
|
|
||||||
if err := ioutil.WriteFile(filename, []byte(obj.Text()), 0644); err != nil {
|
if err := os.WriteFile(filename, []byte(obj.Text()), 0644); err != nil {
|
||||||
return errwrap.Wrapf(err, "error writing to filename")
|
return errwrap.Wrapf(err, "error writing to filename")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ package puppet
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@@ -202,7 +201,7 @@ func (obj *GAPI) Init(data *gapi.Data) error {
|
|||||||
|
|
||||||
// store the puppet file on disk for other binaries to see and use
|
// store the puppet file on disk for other binaries to see and use
|
||||||
prefix := fmt.Sprintf("%s-%s-%s", data.Program, data.Hostname, strings.Replace(PuppetFile, "/", "", -1))
|
prefix := fmt.Sprintf("%s-%s-%s", data.Program, data.Hostname, strings.Replace(PuppetFile, "/", "", -1))
|
||||||
tmpfile, err := ioutil.TempFile("", prefix)
|
tmpfile, err := os.CreateTemp("", prefix)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errwrap.Wrapf(err, "can't create temp file")
|
return errwrap.Wrapf(err, "can't create temp file")
|
||||||
}
|
}
|
||||||
@@ -222,7 +221,7 @@ func (obj *GAPI) Init(data *gapi.Data) error {
|
|||||||
} else if obj.Mode == "dir" {
|
} else if obj.Mode == "dir" {
|
||||||
// store the puppet files on disk for other binaries to see and use
|
// store the puppet files on disk for other binaries to see and use
|
||||||
prefix := fmt.Sprintf("%s-%s-%s", data.Program, data.Hostname, strings.Replace(PuppetSite, "/", "", -1))
|
prefix := fmt.Sprintf("%s-%s-%s", data.Program, data.Hostname, strings.Replace(PuppetSite, "/", "", -1))
|
||||||
tmpdirName, err := ioutil.TempDir("", prefix)
|
tmpdirName, err := os.MkdirTemp("", prefix)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errwrap.Wrapf(err, "can't create temp dir")
|
return errwrap.Wrapf(err, "can't create temp dir")
|
||||||
}
|
}
|
||||||
@@ -244,7 +243,7 @@ func (obj *GAPI) Init(data *gapi.Data) error {
|
|||||||
|
|
||||||
// store the puppet conf on disk for other binaries to see and use
|
// store the puppet conf on disk for other binaries to see and use
|
||||||
prefix := fmt.Sprintf("%s-%s-%s", data.Program, data.Hostname, strings.Replace(PuppetConf, "/", "", -1))
|
prefix := fmt.Sprintf("%s-%s-%s", data.Program, data.Hostname, strings.Replace(PuppetConf, "/", "", -1))
|
||||||
tmpfile, err := ioutil.TempFile("", prefix)
|
tmpfile, err := os.CreateTemp("", prefix)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errwrap.Wrapf(err, "can't create temp file")
|
return errwrap.Wrapf(err, "can't create temp file")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,6 +94,11 @@ function consistent-imports() {
|
|||||||
if grep '"golang.org/x/net/context"' "$1"; then # use built-in context
|
if grep '"golang.org/x/net/context"' "$1"; then # use built-in context
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# deprecated import
|
||||||
|
if grep $'\t"io/ioutil"' "$1"; then # use the documented replacements
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function reflowed-comments() {
|
function reflowed-comments() {
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ package util
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
@@ -125,7 +124,7 @@ func TestCopyDiskToFs1(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
t.Logf("tests directory is: %s", dir)
|
t.Logf("tests directory is: %s", dir)
|
||||||
files, err := ioutil.ReadDir(dir)
|
files, err := os.ReadDir(dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("could not read through tests directory: %+v", err)
|
t.Errorf("could not read through tests directory: %+v", err)
|
||||||
return
|
return
|
||||||
@@ -146,7 +145,7 @@ func TestCopyDiskToFs1(t *testing.T) {
|
|||||||
//t.Logf("skipping: %s -> %+v", treeFile, err)
|
//t.Logf("skipping: %s -> %+v", treeFile, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
content, err := ioutil.ReadFile(treeFileFull)
|
content, err := os.ReadFile(treeFileFull)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("could not read tree file: %+v", err)
|
t.Errorf("could not read tree file: %+v", err)
|
||||||
return
|
return
|
||||||
@@ -156,7 +155,7 @@ func TestCopyDiskToFs1(t *testing.T) {
|
|||||||
t.Logf("testing: %s", treeFile)
|
t.Logf("testing: %s", treeFile)
|
||||||
|
|
||||||
mmFs := afero.NewMemMapFs()
|
mmFs := afero.NewMemMapFs()
|
||||||
afs := &afero.Afero{Fs: mmFs} // wrap so that we're implementing ioutil
|
afs := &afero.Afero{Fs: mmFs} // wrap to implement the fs API's
|
||||||
fs := &AferoFs{Afero: afs}
|
fs := &AferoFs{Afero: afs}
|
||||||
|
|
||||||
if err := CopyDiskToFs(fs, dir+f+"/", "/", false); err != nil {
|
if err := CopyDiskToFs(fs, dir+f+"/", "/", false); err != nil {
|
||||||
@@ -186,7 +185,7 @@ func TestCopyDiskToFs2(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
t.Logf("tests directory is: %s", dir)
|
t.Logf("tests directory is: %s", dir)
|
||||||
files, err := ioutil.ReadDir(dir)
|
files, err := os.ReadDir(dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("could not read through tests directory: %+v", err)
|
t.Errorf("could not read through tests directory: %+v", err)
|
||||||
return
|
return
|
||||||
@@ -207,7 +206,7 @@ func TestCopyDiskToFs2(t *testing.T) {
|
|||||||
//t.Logf("skipping: %s -> %+v", treeFile, err)
|
//t.Logf("skipping: %s -> %+v", treeFile, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
content, err := ioutil.ReadFile(treeFileFull)
|
content, err := os.ReadFile(treeFileFull)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("could not read tree file: %+v", err)
|
t.Errorf("could not read tree file: %+v", err)
|
||||||
return
|
return
|
||||||
@@ -217,7 +216,7 @@ func TestCopyDiskToFs2(t *testing.T) {
|
|||||||
t.Logf("testing: %s", treeFile)
|
t.Logf("testing: %s", treeFile)
|
||||||
|
|
||||||
mmFs := afero.NewMemMapFs()
|
mmFs := afero.NewMemMapFs()
|
||||||
afs := &afero.Afero{Fs: mmFs} // wrap so that we're implementing ioutil
|
afs := &afero.Afero{Fs: mmFs} // wrap to implement the fs API's
|
||||||
fs := &AferoFs{Afero: afs}
|
fs := &AferoFs{Afero: afs}
|
||||||
|
|
||||||
src := dir + f + "/"
|
src := dir + f + "/"
|
||||||
@@ -250,7 +249,7 @@ func TestCopyDiskContentsToFs1(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
t.Logf("tests directory is: %s", dir)
|
t.Logf("tests directory is: %s", dir)
|
||||||
files, err := ioutil.ReadDir(dir)
|
files, err := os.ReadDir(dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("could not read through tests directory: %+v", err)
|
t.Errorf("could not read through tests directory: %+v", err)
|
||||||
return
|
return
|
||||||
@@ -271,7 +270,7 @@ func TestCopyDiskContentsToFs1(t *testing.T) {
|
|||||||
//t.Logf("skipping: %s -> %+v", treeFile, err)
|
//t.Logf("skipping: %s -> %+v", treeFile, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
content, err := ioutil.ReadFile(treeFileFull)
|
content, err := os.ReadFile(treeFileFull)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("could not read tree file: %+v", err)
|
t.Errorf("could not read tree file: %+v", err)
|
||||||
return
|
return
|
||||||
@@ -281,7 +280,7 @@ func TestCopyDiskContentsToFs1(t *testing.T) {
|
|||||||
t.Logf("testing: %s", treeFile)
|
t.Logf("testing: %s", treeFile)
|
||||||
|
|
||||||
mmFs := afero.NewMemMapFs()
|
mmFs := afero.NewMemMapFs()
|
||||||
afs := &afero.Afero{Fs: mmFs} // wrap so that we're implementing ioutil
|
afs := &afero.Afero{Fs: mmFs} // wrap to implement the fs API's
|
||||||
fs := &AferoFs{Afero: afs}
|
fs := &AferoFs{Afero: afs}
|
||||||
|
|
||||||
if err := CopyDiskContentsToFs(fs, dir+f+"/", "/", false); err != nil {
|
if err := CopyDiskContentsToFs(fs, dir+f+"/", "/", false); err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user