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:
James Shubin
2024-02-25 15:35:25 -05:00
parent 8db41e7701
commit dd0e67540f
35 changed files with 125 additions and 131 deletions

View File

@@ -19,7 +19,6 @@ package puppet
import (
"fmt"
"io/ioutil"
"os"
"strings"
"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
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 {
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" {
// 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))
tmpdirName, err := ioutil.TempDir("", prefix)
tmpdirName, err := os.MkdirTemp("", prefix)
if err != nil {
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
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 {
return errwrap.Wrapf(err, "can't create temp file")
}