mirror of
https://github.com/hashicorp/packer.git
synced 2025-12-18 23:16:06 -05:00
chore: remove refs to deprecated io/ioutil
Signed-off-by: guoguangwu <guoguangwu@magic-shield.com>
This commit is contained in:
parent
324e628b86
commit
7eb6a45cd4
37 changed files with 112 additions and 135 deletions
|
|
@ -8,7 +8,7 @@ package plugin
|
|||
import (
|
||||
_ "embed"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"os"
|
||||
"os/exec"
|
||||
"testing"
|
||||
|
|
@ -54,7 +54,7 @@ func TestAccInitAndBuildBasicAmazonAmiDatasource(t *testing.T) {
|
|||
}
|
||||
defer logs.Close()
|
||||
|
||||
logsBytes, err := ioutil.ReadAll(logs)
|
||||
logsBytes, err := io.ReadAll(logs)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Unable to read %s", logfile)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ package plugin
|
|||
import (
|
||||
_ "embed"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
|
|
@ -58,7 +58,7 @@ func TestAccInitAndBuildBasicAmazonEbs(t *testing.T) {
|
|||
}
|
||||
defer logs.Close()
|
||||
|
||||
logsBytes, err := ioutil.ReadAll(logs)
|
||||
logsBytes, err := io.ReadAll(logs)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Unable to read %s", logfile)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ package acctest
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
|
|
@ -182,8 +182,8 @@ func Test(t TestT, c TestCase) {
|
|||
log.Printf("[DEBUG] Running 'test' build")
|
||||
ui := &packersdk.BasicUi{
|
||||
Reader: os.Stdin,
|
||||
Writer: ioutil.Discard,
|
||||
ErrorWriter: ioutil.Discard,
|
||||
Writer: io.Discard,
|
||||
ErrorWriter: io.Discard,
|
||||
PB: &packersdk.NoopProgressTracker{},
|
||||
}
|
||||
artifacts, err := build.Run(context.Background(), ui)
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
|
|
@ -77,7 +76,7 @@ func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook)
|
|||
} else {
|
||||
// We're going to write Contents; if it's empty we'll just create an
|
||||
// empty file.
|
||||
err := ioutil.WriteFile(b.config.Target, []byte(b.config.Content), 0600)
|
||||
err := os.WriteFile(b.config.Target, []byte(b.config.Content), 0600)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ package file
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
|
||||
|
|
@ -33,7 +33,7 @@ func TestBuilderFileAcc_copy(t *testing.T) {
|
|||
}
|
||||
|
||||
func checkContent(artifacts []packersdk.Artifact) error {
|
||||
content, err := ioutil.ReadFile("contentTest.txt")
|
||||
content, err := os.ReadFile("contentTest.txt")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -45,7 +45,7 @@ func checkContent(artifacts []packersdk.Artifact) error {
|
|||
}
|
||||
|
||||
func checkCopy(artifacts []packersdk.Artifact) error {
|
||||
content, err := ioutil.ReadFile("copyTest.txt")
|
||||
content, err := os.ReadFile("copyTest.txt")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ package main
|
|||
|
||||
import (
|
||||
"flag"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"os/user"
|
||||
|
|
@ -74,12 +73,12 @@ func main() {
|
|||
log.Fatalf("%s already exists.", cla.Filename)
|
||||
}
|
||||
log.Printf("Saving private key to %s", cla.Filename)
|
||||
if err := ioutil.WriteFile(cla.Filename, keypair.Private, 0600); err != nil {
|
||||
if err := os.WriteFile(cla.Filename, keypair.Private, 0600); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
publicFilename := cla.Filename + ".pub"
|
||||
log.Printf("Saving public key to %s", publicFilename)
|
||||
if err := ioutil.WriteFile(publicFilename, keypair.Public, 0644); err != nil {
|
||||
if err := os.WriteFile(publicFilename, keypair.Public, 0644); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ package command
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
|
@ -1009,9 +1008,9 @@ func (fc fileCheck) verify(t *testing.T, dir string) {
|
|||
}
|
||||
}
|
||||
for file, expectedContent := range fc.expectedContent {
|
||||
content, err := ioutil.ReadFile(filepath.Join(dir, file))
|
||||
content, err := os.ReadFile(filepath.Join(dir, file))
|
||||
if err != nil {
|
||||
t.Fatalf("ioutil.ReadFile: %v", err)
|
||||
t.Fatalf("os.ReadFile: %v", err)
|
||||
}
|
||||
if diff := cmp.Diff(expectedContent, string(content)); diff != "" {
|
||||
t.Errorf("content of %s differs: %s", file, diff)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ package command
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
|
|
@ -27,7 +27,7 @@ func fatalCommand(t *testing.T, m Meta) {
|
|||
|
||||
func testFixtureContent(n ...string) string {
|
||||
path := filepath.Join(append([]string{fixturesDir}, n...)...)
|
||||
b, err := ioutil.ReadFile(path)
|
||||
b, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ package command
|
|||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
|
@ -128,7 +127,7 @@ func TestFmt_Recursive(t *testing.T) {
|
|||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
tempDirectory := mustString(ioutil.TempDir(testDir, "test-dir-*"))
|
||||
tempDirectory := mustString(os.MkdirTemp(testDir, "test-dir-*"))
|
||||
defer os.RemoveAll(tempDirectory)
|
||||
|
||||
createFiles(tempDirectory, tt.alreadyPresentContent)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
package command
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
|
@ -64,8 +63,8 @@ func Test_hcl2_upgrade(t *testing.T) {
|
|||
if tc.exitEarly {
|
||||
return
|
||||
}
|
||||
expected := string(mustBytes(ioutil.ReadFile(expectedPath)))
|
||||
actual := string(mustBytes(ioutil.ReadFile(outputPath)))
|
||||
expected := string(mustBytes(os.ReadFile(expectedPath)))
|
||||
actual := string(mustBytes(os.ReadFile(outputPath)))
|
||||
|
||||
if diff := cmp.Diff(expected, actual); diff != "" {
|
||||
t.Fatalf("unexpected output: %s", diff)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
package command
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
|
@ -23,7 +22,7 @@ func createFiles(dir string, content map[string]string) {
|
|||
if err := os.MkdirAll(filepath.Dir(contentPath), 0777); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := ioutil.WriteFile(contentPath, []byte(content), 0666); err != nil {
|
||||
if err := os.WriteFile(contentPath, []byte(content), 0666); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
log.Printf("created tmp file: %s", contentPath)
|
||||
|
|
@ -39,7 +38,7 @@ func (c *configDirSingleton) dir(key string) string {
|
|||
if v, exists := c.dirs[key]; exists {
|
||||
return v
|
||||
}
|
||||
c.dirs[key] = mustString(ioutil.TempDir("", "pkr-test-cfg-dir-"+key))
|
||||
c.dirs[key] = mustString(os.MkdirTemp("", "pkr-test-cfg-dir-"+key))
|
||||
return c.dirs[key]
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ package main
|
|||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
|
|
@ -122,7 +121,7 @@ func TestLoadExternalComponentsFromConfig_onlyProvisioner(t *testing.T) {
|
|||
func TestLoadSingleComponent(t *testing.T) {
|
||||
|
||||
// .exe will work everyone for testing purpose, but mostly here to help Window's test runs.
|
||||
tmpFile, err := ioutil.TempFile(".", "packer-builder-*.exe")
|
||||
tmpFile, err := os.CreateTemp(".", "packer-builder-*.exe")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create test file with error: %s", err)
|
||||
}
|
||||
|
|
@ -160,7 +159,7 @@ func TestLoadSingleComponent(t *testing.T) {
|
|||
}
|
||||
|
||||
func generateFakePlugins(dirname string, pluginNames []string) (string, []string, func(), error) {
|
||||
dir, err := ioutil.TempDir("", dirname)
|
||||
dir, err := os.MkdirTemp("", dirname)
|
||||
if err != nil {
|
||||
return "", nil, nil, fmt.Errorf("failed to create temporary test directory: %v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ package http
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"mime"
|
||||
"net/http"
|
||||
"regexp"
|
||||
|
|
@ -137,7 +137,7 @@ func (d *Datasource) Execute() (cty.Value, error) {
|
|||
fmt.Println("If the content is binary data, Packer may not properly handle the contents of the response.")
|
||||
}
|
||||
|
||||
bytes, err := ioutil.ReadAll(resp.Body)
|
||||
bytes, err := io.ReadAll(resp.Body)
|
||||
// TODO: How to make test case for this?
|
||||
if err != nil {
|
||||
fmt.Println("Error processing response body of call")
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ package http
|
|||
import (
|
||||
_ "embed"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"os"
|
||||
"os/exec"
|
||||
"regexp"
|
||||
|
|
@ -84,7 +84,7 @@ func TestHttpDataSource(t *testing.T) {
|
|||
}
|
||||
defer logs.Close()
|
||||
|
||||
logsBytes, err := ioutil.ReadAll(logs)
|
||||
logsBytes, err := io.ReadAll(logs)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Unable to read %s", logfile)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import (
|
|||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
|
|
@ -76,7 +75,7 @@ func (f *HCL2Formatter) Format(path string) (int, hcl.Diagnostics) {
|
|||
return f.formatFile(path, diags, bytesModified)
|
||||
}
|
||||
|
||||
fileInfos, err := ioutil.ReadDir(path)
|
||||
fileInfos, err := os.ReadDir(path)
|
||||
if err != nil {
|
||||
diag := &hcl.Diagnostic{
|
||||
Severity: hcl.DiagError,
|
||||
|
|
@ -129,7 +128,7 @@ func (f *HCL2Formatter) processFile(filename string) ([]byte, error) {
|
|||
}
|
||||
}
|
||||
|
||||
inSrc, err := ioutil.ReadAll(in)
|
||||
inSrc, err := io.ReadAll(in)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to read %s: %s", filename, err)
|
||||
}
|
||||
|
|
@ -158,7 +157,7 @@ func (f *HCL2Formatter) processFile(filename string) ([]byte, error) {
|
|||
if filename == "-" {
|
||||
_, _ = f.Output.Write(outSrc)
|
||||
} else {
|
||||
if err := ioutil.WriteFile(filename, outSrc, 0644); err != nil {
|
||||
if err := os.WriteFile(filename, outSrc, 0644); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
|
@ -178,14 +177,14 @@ func (f *HCL2Formatter) processFile(filename string) ([]byte, error) {
|
|||
// bytesDiff returns the unified diff of b1 and b2
|
||||
// Shamelessly copied from Terraform's fmt command.
|
||||
func bytesDiff(b1, b2 []byte, path string) (data []byte, err error) {
|
||||
f1, err := ioutil.TempFile("", "")
|
||||
f1, err := os.CreateTemp("", "")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
defer os.Remove(f1.Name())
|
||||
defer f1.Close()
|
||||
|
||||
f2, err := ioutil.TempFile("", "")
|
||||
f2, err := os.CreateTemp("", "")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ package hcl2template
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
|
@ -48,12 +47,12 @@ func TestHCL2Formatter_Format_Write(t *testing.T) {
|
|||
f.Output = &buf
|
||||
f.Write = true
|
||||
|
||||
unformattedData, err := ioutil.ReadFile("testdata/format/unformatted.pkr.hcl")
|
||||
unformattedData, err := os.ReadFile("testdata/format/unformatted.pkr.hcl")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to open the unformatted fixture %s", err)
|
||||
}
|
||||
|
||||
tf, err := ioutil.TempFile("", "*.pkr.hcl")
|
||||
tf, err := os.CreateTemp("", "*.pkr.hcl")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create tempfile for test %s", err)
|
||||
}
|
||||
|
|
@ -68,12 +67,12 @@ func TestHCL2Formatter_Format_Write(t *testing.T) {
|
|||
}
|
||||
|
||||
//lets re-read the tempfile which should now be formatted
|
||||
data, err := ioutil.ReadFile(tf.Name())
|
||||
data, err := os.ReadFile(tf.Name())
|
||||
if err != nil {
|
||||
t.Fatalf("failed to open the newly formatted fixture %s", err)
|
||||
}
|
||||
|
||||
formattedData, err := ioutil.ReadFile("testdata/format/formatted.pkr.hcl")
|
||||
formattedData, err := os.ReadFile("testdata/format/formatted.pkr.hcl")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to open the formatted fixture %s", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ package hcl2template
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
|
@ -74,7 +73,7 @@ func GetHCL2Files(filename, hclSuffix, jsonSuffix string) (hclFiles, jsonFiles [
|
|||
return nil, nil, diags
|
||||
}
|
||||
|
||||
fileInfos, err := ioutil.ReadDir(filename)
|
||||
fileInfos, err := os.ReadDir(filename)
|
||||
if err != nil {
|
||||
diag := &hcl.Diagnostic{
|
||||
Severity: hcl.DiagError,
|
||||
|
|
|
|||
5
main.go
5
main.go
|
|
@ -9,7 +9,6 @@ package main
|
|||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"math/rand"
|
||||
"os"
|
||||
|
|
@ -65,13 +64,13 @@ func realMain() int {
|
|||
return 1
|
||||
}
|
||||
if logWriter == nil {
|
||||
logWriter = ioutil.Discard
|
||||
logWriter = io.Discard
|
||||
}
|
||||
|
||||
packersdk.LogSecretFilter.SetOutput(logWriter)
|
||||
|
||||
// Disable logging here
|
||||
log.SetOutput(ioutil.Discard)
|
||||
log.SetOutput(io.Discard)
|
||||
|
||||
// We always send logs to a temporary file that we use in case
|
||||
// there is a panic. Otherwise, we delete it.
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ package packer
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
|
@ -102,7 +101,7 @@ func TestClient_Stderr(t *testing.T) {
|
|||
|
||||
func TestClient_Stdin(t *testing.T) {
|
||||
// Overwrite stdin for this test with a temporary file
|
||||
tf, err := ioutil.TempFile("", "packer")
|
||||
tf, err := os.CreateTemp("", "packer")
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
|
|
@ -71,7 +70,7 @@ func transformChecksumStream() func(in io.ReadCloser) (io.ReadCloser, error) {
|
|||
}
|
||||
}
|
||||
_, _ = buffer.WriteString("]")
|
||||
return ioutil.NopCloser(buffer), nil
|
||||
return io.NopCloser(buffer), nil
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -103,7 +102,7 @@ func transformVersionStream(in io.ReadCloser) (io.ReadCloser, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
return ioutil.NopCloser(buf), nil
|
||||
return io.NopCloser(buf), nil
|
||||
}
|
||||
|
||||
// HostSpecificTokenAuthTransport makes sure the http roundtripper only sets an
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
|
@ -714,7 +713,7 @@ func (pr *Requirement) InstallLatest(opts InstallOptions) (*Installation, error)
|
|||
log.Printf("[WARNING] %v, ignoring", err)
|
||||
}
|
||||
|
||||
if err := ioutil.WriteFile(outputFileName+checksum.Checksummer.FileExt(), []byte(hex.EncodeToString(cs)), 0555); err != nil {
|
||||
if err := os.WriteFile(outputFileName+checksum.Checksummer.FileExt(), []byte(hex.EncodeToString(cs)), 0555); err != nil {
|
||||
err := fmt.Errorf("failed to write local binary checksum file: %s", err)
|
||||
errs = multierror.Append(errs, err)
|
||||
log.Printf("[WARNING] %v, ignoring", err)
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
|
@ -754,7 +753,7 @@ func (g *mockPluginGetter) Get(what string, options GetOptions) (io.ReadCloser,
|
|||
panic(err)
|
||||
}
|
||||
}()
|
||||
return ioutil.NopCloser(read), nil
|
||||
return io.NopCloser(read), nil
|
||||
}
|
||||
|
||||
func zipFile(content map[string]string) io.ReadCloser {
|
||||
|
|
@ -778,7 +777,7 @@ func zipFile(content map[string]string) io.ReadCloser {
|
|||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return ioutil.NopCloser(buff)
|
||||
return io.NopCloser(buff)
|
||||
}
|
||||
|
||||
var _ Getter = &mockPluginGetter{}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net"
|
||||
"os"
|
||||
|
|
@ -114,7 +113,7 @@ func NewClient(config *PluginClientConfig) (c *PluginClient) {
|
|||
}
|
||||
|
||||
if config.Stderr == nil {
|
||||
config.Stderr = ioutil.Discard
|
||||
config.Stderr = io.Discard
|
||||
}
|
||||
|
||||
c = &PluginClient{config: config}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ package packer
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
"golang.org/x/sync/errgroup"
|
||||
|
|
@ -16,10 +16,10 @@ import (
|
|||
func TestProgressTracking_open_close(t *testing.T) {
|
||||
var bar *UiProgressBar
|
||||
|
||||
tracker := bar.TrackProgress("1,", 1, 42, ioutil.NopCloser(nil))
|
||||
tracker := bar.TrackProgress("1,", 1, 42, io.NopCloser(nil))
|
||||
tracker.Close()
|
||||
|
||||
tracker = bar.TrackProgress("2,", 1, 42, ioutil.NopCloser(nil))
|
||||
tracker = bar.TrackProgress("2,", 1, 42, io.NopCloser(nil))
|
||||
tracker.Close()
|
||||
}
|
||||
|
||||
|
|
@ -29,7 +29,7 @@ func TestProgressTracking_multi_open_close(t *testing.T) {
|
|||
|
||||
for i := 0; i < 100; i++ {
|
||||
g.Go(func() error {
|
||||
tracker := bar.TrackProgress("file,", 1, 42, ioutil.NopCloser(nil))
|
||||
tracker := bar.TrackProgress("file,", 1, 42, io.NopCloser(nil))
|
||||
return tracker.Close()
|
||||
})
|
||||
}
|
||||
|
|
@ -46,7 +46,7 @@ func TestProgressTracking_races(t *testing.T) {
|
|||
g.Go(func() error {
|
||||
txt := []byte("foobarbaz dolores")
|
||||
b := bytes.NewReader(txt)
|
||||
tracker := bar.TrackProgress("file,", 1, 42, ioutil.NopCloser(b))
|
||||
tracker := bar.TrackProgress("file,", 1, 42, io.NopCloser(b))
|
||||
|
||||
for i := 0; i < 42; i++ {
|
||||
tracker.Read([]byte("i"))
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ package packer
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
|
||||
|
|
@ -40,8 +40,8 @@ func TestUi(t *testing.T) packersdk.Ui {
|
|||
var buf bytes.Buffer
|
||||
return &packersdk.BasicUi{
|
||||
Reader: &buf,
|
||||
Writer: ioutil.Discard,
|
||||
ErrorWriter: ioutil.Discard,
|
||||
Writer: io.Discard,
|
||||
ErrorWriter: io.Discard,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import (
|
|||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
|
@ -38,7 +38,7 @@ func TestChecksumSHA1(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Errorf("Unable to read checksum file: %s", err)
|
||||
}
|
||||
if buf, _ := ioutil.ReadAll(f); !bytes.Equal(buf, []byte("d3486ae9136e7856bc42212385ea797094475802\tpackage.txt\n")) {
|
||||
if buf, _ := io.ReadAll(f); !bytes.Equal(buf, []byte("d3486ae9136e7856bc42212385ea797094475802\tpackage.txt\n")) {
|
||||
t.Errorf("Failed to compute checksum: %s\n%s", buf, "d3486ae9136e7856bc42212385ea797094475802 package.txt")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import (
|
|||
"compress/gzip"
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
|
@ -84,7 +84,7 @@ func TestCompressOptions(t *testing.T) {
|
|||
filename := "package.gz"
|
||||
archive, _ := os.Open(filename)
|
||||
gzipReader, _ := gzip.NewReader(archive)
|
||||
data, _ := ioutil.ReadAll(gzipReader)
|
||||
data, _ := io.ReadAll(gzipReader)
|
||||
|
||||
if string(data) != expectedFileContents {
|
||||
t.Errorf("Expected:\n%s\nFound:\n%s\n", expectedFileContents, data)
|
||||
|
|
@ -115,7 +115,7 @@ func TestCompressInterpolation(t *testing.T) {
|
|||
}
|
||||
|
||||
gzipReader, _ := gzip.NewReader(archive)
|
||||
data, _ := ioutil.ReadAll(gzipReader)
|
||||
data, _ := io.ReadAll(gzipReader)
|
||||
|
||||
if string(data) != expectedFileContents {
|
||||
t.Errorf("Expected:\n%s\nFound:\n%s\n", expectedFileContents, data)
|
||||
|
|
@ -194,7 +194,7 @@ func TestArchive(t *testing.T) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ioutil.ReadAll(bzipReader)
|
||||
return io.ReadAll(bzipReader)
|
||||
},
|
||||
"zip": func(archive *os.File) ([]byte, error) {
|
||||
fi, _ := archive.Stat()
|
||||
|
|
@ -206,7 +206,7 @@ func TestArchive(t *testing.T) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ioutil.ReadAll(ctt)
|
||||
return io.ReadAll(ctt)
|
||||
},
|
||||
"tar": func(archive *os.File) ([]byte, error) {
|
||||
tarReader := tar.NewReader(archive)
|
||||
|
|
@ -214,7 +214,7 @@ func TestArchive(t *testing.T) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ioutil.ReadAll(tarReader)
|
||||
return io.ReadAll(tarReader)
|
||||
},
|
||||
"tar.gz": func(archive *os.File) ([]byte, error) {
|
||||
gzipReader, err := gzip.NewReader(archive)
|
||||
|
|
@ -226,15 +226,15 @@ func TestArchive(t *testing.T) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ioutil.ReadAll(tarReader)
|
||||
return io.ReadAll(tarReader)
|
||||
},
|
||||
"gz": func(archive *os.File) ([]byte, error) {
|
||||
gzipReader, _ := gzip.NewReader(archive)
|
||||
return ioutil.ReadAll(gzipReader)
|
||||
return io.ReadAll(gzipReader)
|
||||
},
|
||||
"lz4": func(archive *os.File) ([]byte, error) {
|
||||
lz4Reader := lz4.NewReader(archive)
|
||||
return ioutil.ReadAll(lz4Reader)
|
||||
return io.ReadAll(lz4Reader)
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import (
|
|||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
|
@ -143,7 +142,7 @@ func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, source
|
|||
|
||||
// Read the current manifest file from disk
|
||||
contents := []byte{}
|
||||
if contents, err = ioutil.ReadFile(p.config.OutputPath); err != nil && !os.IsNotExist(err) {
|
||||
if contents, err = os.ReadFile(p.config.OutputPath); err != nil && !os.IsNotExist(err) {
|
||||
return source, true, true, fmt.Errorf("Unable to open %s for reading: %s", p.config.OutputPath, err)
|
||||
}
|
||||
|
||||
|
|
@ -167,7 +166,7 @@ func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, source
|
|||
|
||||
// Write JSON to disk
|
||||
if out, err := json.MarshalIndent(manifestFile, "", " "); err == nil {
|
||||
if err = ioutil.WriteFile(p.config.OutputPath, out, 0664); err != nil {
|
||||
if err = os.WriteFile(p.config.OutputPath, out, 0664); err != nil {
|
||||
return source, true, true, fmt.Errorf("Unable to write %s: %s", p.config.OutputPath, err)
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
package shell_local
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"runtime"
|
||||
"testing"
|
||||
|
|
@ -95,7 +94,7 @@ func TestPostProcessorPrepare_Script(t *testing.T) {
|
|||
}
|
||||
|
||||
// Test with a good one
|
||||
tf, err := ioutil.TempFile("", "packer")
|
||||
tf, err := os.CreateTemp("", "packer")
|
||||
if err != nil {
|
||||
t.Fatalf("error tempfile: %s", err)
|
||||
}
|
||||
|
|
@ -163,7 +162,7 @@ func TestPostProcessorPrepare_ScriptAndInline(t *testing.T) {
|
|||
}
|
||||
|
||||
// Test with both
|
||||
tf, err := ioutil.TempFile("", "packer")
|
||||
tf, err := os.CreateTemp("", "packer")
|
||||
if err != nil {
|
||||
t.Fatalf("error tempfile: %s", err)
|
||||
}
|
||||
|
|
@ -182,7 +181,7 @@ func TestPostProcessorPrepare_ScriptAndScripts(t *testing.T) {
|
|||
raws := testConfig()
|
||||
|
||||
// Test with both
|
||||
tf, err := ioutil.TempFile("", "packer")
|
||||
tf, err := os.CreateTemp("", "packer")
|
||||
if err != nil {
|
||||
t.Fatalf("error tempfile: %s", err)
|
||||
}
|
||||
|
|
@ -208,7 +207,7 @@ func TestPostProcessorPrepare_Scripts(t *testing.T) {
|
|||
}
|
||||
|
||||
// Test with a good one
|
||||
tf, err := ioutil.TempFile("", "packer")
|
||||
tf, err := os.CreateTemp("", "packer")
|
||||
if err != nil {
|
||||
t.Fatalf("error tempfile: %s", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ package file
|
|||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
|
|
@ -62,7 +61,7 @@ func TestProvisionerPrepare_InvalidSource(t *testing.T) {
|
|||
func TestProvisionerPrepare_ValidSource(t *testing.T) {
|
||||
var p Provisioner
|
||||
|
||||
tf, err := ioutil.TempFile("", "packer")
|
||||
tf, err := os.CreateTemp("", "packer")
|
||||
if err != nil {
|
||||
t.Fatalf("error tempfile: %s", err)
|
||||
}
|
||||
|
|
@ -107,7 +106,7 @@ func TestProvisionerPrepare_EmptyDestination(t *testing.T) {
|
|||
|
||||
func TestProvisionerProvision_SendsFile(t *testing.T) {
|
||||
var p Provisioner
|
||||
tf, err := ioutil.TempFile("", "packer")
|
||||
tf, err := os.CreateTemp("", "packer")
|
||||
if err != nil {
|
||||
t.Fatalf("error tempfile: %s", err)
|
||||
}
|
||||
|
|
@ -195,7 +194,7 @@ func TestProvisionerProvision_SendsContent(t *testing.T) {
|
|||
|
||||
func TestProvisionerProvision_SendsFileMultipleFiles(t *testing.T) {
|
||||
var p Provisioner
|
||||
tf1, err := ioutil.TempFile("", "packer")
|
||||
tf1, err := os.CreateTemp("", "packer")
|
||||
if err != nil {
|
||||
t.Fatalf("error tempfile: %s", err)
|
||||
}
|
||||
|
|
@ -205,7 +204,7 @@ func TestProvisionerProvision_SendsFileMultipleFiles(t *testing.T) {
|
|||
t.Fatalf("error writing tempfile: %s", err)
|
||||
}
|
||||
|
||||
tf2, err := ioutil.TempFile("", "packer")
|
||||
tf2, err := os.CreateTemp("", "packer")
|
||||
if err != nil {
|
||||
t.Fatalf("error tempfile: %s", err)
|
||||
}
|
||||
|
|
@ -248,13 +247,13 @@ func TestProvisionerProvision_SendsFileMultipleDirs(t *testing.T) {
|
|||
var p Provisioner
|
||||
|
||||
// Prepare the first directory
|
||||
td1, err := ioutil.TempDir("", "packerdir")
|
||||
td1, err := os.MkdirTemp("", "packerdir")
|
||||
if err != nil {
|
||||
t.Fatalf("error temp folder 1: %s", err)
|
||||
}
|
||||
defer os.Remove(td1)
|
||||
|
||||
tf1, err := ioutil.TempFile(td1, "packer")
|
||||
tf1, err := os.CreateTemp(td1, "packer")
|
||||
if err != nil {
|
||||
t.Fatalf("error tempfile: %s", err)
|
||||
}
|
||||
|
|
@ -264,13 +263,13 @@ func TestProvisionerProvision_SendsFileMultipleDirs(t *testing.T) {
|
|||
}
|
||||
|
||||
// Prepare the second directory
|
||||
td2, err := ioutil.TempDir("", "packerdir")
|
||||
td2, err := os.MkdirTemp("", "packerdir")
|
||||
if err != nil {
|
||||
t.Fatalf("error temp folder 1: %s", err)
|
||||
}
|
||||
defer os.Remove(td2)
|
||||
|
||||
tf2, err := ioutil.TempFile(td2, "packer")
|
||||
tf2, err := os.CreateTemp(td2, "packer")
|
||||
if err != nil {
|
||||
t.Fatalf("error tempfile: %s", err)
|
||||
}
|
||||
|
|
@ -317,7 +316,7 @@ func TestProvisionerProvision_SendsFileMultipleDirs(t *testing.T) {
|
|||
func TestProvisionerProvision_DownloadsMultipleFilesToFolder(t *testing.T) {
|
||||
var p Provisioner
|
||||
|
||||
tf1, err := ioutil.TempFile("", "packer")
|
||||
tf1, err := os.CreateTemp("", "packer")
|
||||
if err != nil {
|
||||
t.Fatalf("error tempfile: %s", err)
|
||||
}
|
||||
|
|
@ -327,7 +326,7 @@ func TestProvisionerProvision_DownloadsMultipleFilesToFolder(t *testing.T) {
|
|||
t.Fatalf("error writing tempfile: %s", err)
|
||||
}
|
||||
|
||||
tf2, err := ioutil.TempFile("", "packer")
|
||||
tf2, err := os.CreateTemp("", "packer")
|
||||
if err != nil {
|
||||
t.Fatalf("error tempfile: %s", err)
|
||||
}
|
||||
|
|
@ -388,7 +387,7 @@ func TestProvisionerProvision_DownloadsMultipleFilesToFolder(t *testing.T) {
|
|||
func TestProvisionerProvision_SendsFileMultipleFilesToFolder(t *testing.T) {
|
||||
var p Provisioner
|
||||
|
||||
tf1, err := ioutil.TempFile("", "packer")
|
||||
tf1, err := os.CreateTemp("", "packer")
|
||||
if err != nil {
|
||||
t.Fatalf("error tempfile: %s", err)
|
||||
}
|
||||
|
|
@ -398,7 +397,7 @@ func TestProvisionerProvision_SendsFileMultipleFilesToFolder(t *testing.T) {
|
|||
t.Fatalf("error writing tempfile: %s", err)
|
||||
}
|
||||
|
||||
tf2, err := ioutil.TempFile("", "packer")
|
||||
tf2, err := os.CreateTemp("", "packer")
|
||||
if err != nil {
|
||||
t.Fatalf("error tempfile: %s", err)
|
||||
}
|
||||
|
|
@ -454,12 +453,12 @@ func TestProvisionDownloadMkdirAll(t *testing.T) {
|
|||
{"path/to/dir"},
|
||||
{"path/to/dir/"},
|
||||
}
|
||||
tmpDir, err := ioutil.TempDir("", "packer-file")
|
||||
tmpDir, err := os.MkdirTemp("", "packer-file")
|
||||
if err != nil {
|
||||
t.Fatalf("error tempdir: %s", err)
|
||||
}
|
||||
defer os.RemoveAll(tmpDir)
|
||||
tf, err := ioutil.TempFile(tmpDir, "packer")
|
||||
tf, err := os.CreateTemp(tmpDir, "packer")
|
||||
if err != nil {
|
||||
t.Fatalf("error tempfile: %s", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ package powershell_test
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
|
|
@ -35,7 +35,7 @@ func LoadProvisionerFragment(templateFragmentPath string) (string, error) {
|
|||
}
|
||||
defer fragmentFile.Close()
|
||||
|
||||
fragmentString, err := ioutil.ReadAll(fragmentFile)
|
||||
fragmentString, err := io.ReadAll(fragmentFile)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("Unable to read %s", fragmentAbsPath)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import (
|
|||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
|
@ -35,7 +34,7 @@ func TestProvisionerPrepare_extractScript(t *testing.T) {
|
|||
}
|
||||
|
||||
// File contents should contain 2 lines concatenated by newlines: foo\nbar
|
||||
readFile, err := ioutil.ReadFile(file)
|
||||
readFile, err := os.ReadFile(file)
|
||||
expectedContents := "foo\nbar\n"
|
||||
if err != nil {
|
||||
t.Fatalf("Should not be error: %s", err)
|
||||
|
|
@ -187,7 +186,7 @@ func TestProvisionerPrepare_Script(t *testing.T) {
|
|||
}
|
||||
|
||||
// Test with a good one
|
||||
tf, err := ioutil.TempFile("", "packer")
|
||||
tf, err := os.CreateTemp("", "packer")
|
||||
if err != nil {
|
||||
t.Fatalf("error tempfile: %s", err)
|
||||
}
|
||||
|
|
@ -214,7 +213,7 @@ func TestProvisionerPrepare_ScriptAndInline(t *testing.T) {
|
|||
}
|
||||
|
||||
// Test with both
|
||||
tf, err := ioutil.TempFile("", "packer")
|
||||
tf, err := os.CreateTemp("", "packer")
|
||||
if err != nil {
|
||||
t.Fatalf("error tempfile: %s", err)
|
||||
}
|
||||
|
|
@ -234,7 +233,7 @@ func TestProvisionerPrepare_ScriptAndScripts(t *testing.T) {
|
|||
config := testConfig()
|
||||
|
||||
// Test with both
|
||||
tf, err := ioutil.TempFile("", "packer")
|
||||
tf, err := os.CreateTemp("", "packer")
|
||||
if err != nil {
|
||||
t.Fatalf("error tempfile: %s", err)
|
||||
}
|
||||
|
|
@ -261,7 +260,7 @@ func TestProvisionerPrepare_Scripts(t *testing.T) {
|
|||
}
|
||||
|
||||
// Test with a good one
|
||||
tf, err := ioutil.TempFile("", "packer")
|
||||
tf, err := os.CreateTemp("", "packer")
|
||||
if err != nil {
|
||||
t.Fatalf("error tempfile: %s", err)
|
||||
}
|
||||
|
|
@ -512,7 +511,7 @@ func TestProvisionerProvision_Inline(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestProvisionerProvision_Scripts(t *testing.T) {
|
||||
tempFile, _ := ioutil.TempFile("", "packer")
|
||||
tempFile, _ := os.CreateTemp("", "packer")
|
||||
defer os.Remove(tempFile.Name())
|
||||
defer tempFile.Close()
|
||||
|
||||
|
|
@ -542,7 +541,7 @@ func TestProvisionerProvision_Scripts(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestProvisionerProvision_ScriptsWithEnvVars(t *testing.T) {
|
||||
tempFile, _ := ioutil.TempFile("", "packer")
|
||||
tempFile, _ := os.CreateTemp("", "packer")
|
||||
ui := testUi()
|
||||
defer os.Remove(tempFile.Name())
|
||||
defer tempFile.Close()
|
||||
|
|
@ -579,7 +578,7 @@ func TestProvisionerProvision_ScriptsWithEnvVars(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestProvisionerProvision_SkipClean(t *testing.T) {
|
||||
tempFile, _ := ioutil.TempFile("", "packer")
|
||||
tempFile, _ := os.CreateTemp("", "packer")
|
||||
defer func() {
|
||||
tempFile.Close()
|
||||
os.Remove(tempFile.Name())
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ package shell_test
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
|
|
@ -31,7 +31,7 @@ func loadFile(templateFragmentPath string) (string, error) {
|
|||
}
|
||||
defer fragmentFile.Close()
|
||||
|
||||
fragmentString, err := ioutil.ReadAll(fragmentFile)
|
||||
fragmentString, err := io.ReadAll(fragmentFile)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("Unable to read %s", fragmentAbsPath)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ package shell_test
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
|
|
@ -31,7 +31,7 @@ func loadFile(templateFragmentPath string) (string, error) {
|
|||
}
|
||||
defer fragmentFile.Close()
|
||||
|
||||
fragmentString, err := ioutil.ReadAll(fragmentFile)
|
||||
fragmentString, err := io.ReadAll(fragmentFile)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("Unable to read %s", fragmentAbsPath)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
package shell
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
|
@ -123,7 +122,7 @@ func TestProvisionerPrepare_Script(t *testing.T) {
|
|||
}
|
||||
|
||||
// Test with a good one
|
||||
tf, err := ioutil.TempFile("", "packer")
|
||||
tf, err := os.CreateTemp("", "packer")
|
||||
if err != nil {
|
||||
t.Fatalf("error tempfile: %s", err)
|
||||
}
|
||||
|
|
@ -149,7 +148,7 @@ func TestProvisionerPrepare_ScriptAndInline(t *testing.T) {
|
|||
}
|
||||
|
||||
// Test with both
|
||||
tf, err := ioutil.TempFile("", "packer")
|
||||
tf, err := os.CreateTemp("", "packer")
|
||||
if err != nil {
|
||||
t.Fatalf("error tempfile: %s", err)
|
||||
}
|
||||
|
|
@ -168,7 +167,7 @@ func TestProvisionerPrepare_ScriptAndScripts(t *testing.T) {
|
|||
config := testConfig()
|
||||
|
||||
// Test with both
|
||||
tf, err := ioutil.TempFile("", "packer")
|
||||
tf, err := os.CreateTemp("", "packer")
|
||||
if err != nil {
|
||||
t.Fatalf("error tempfile: %s", err)
|
||||
}
|
||||
|
|
@ -194,7 +193,7 @@ func TestProvisionerPrepare_Scripts(t *testing.T) {
|
|||
}
|
||||
|
||||
// Test with a good one
|
||||
tf, err := ioutil.TempFile("", "packer")
|
||||
tf, err := os.CreateTemp("", "packer")
|
||||
if err != nil {
|
||||
t.Fatalf("error tempfile: %s", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ package shell
|
|||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
|
|
@ -37,7 +36,7 @@ func TestProvisionerPrepare_extractScript(t *testing.T) {
|
|||
}
|
||||
|
||||
// File contents should contain 2 lines concatenated by newlines: foo\nbar
|
||||
readFile, err := ioutil.ReadFile(file)
|
||||
readFile, err := os.ReadFile(file)
|
||||
if err != nil {
|
||||
t.Fatalf("Should not be error: %s", err)
|
||||
}
|
||||
|
|
@ -102,7 +101,7 @@ func TestProvisionerPrepare_Script(t *testing.T) {
|
|||
}
|
||||
|
||||
// Test with a good one
|
||||
tf, err := ioutil.TempFile("", "packer")
|
||||
tf, err := os.CreateTemp("", "packer")
|
||||
if err != nil {
|
||||
t.Fatalf("error tempfile: %s", err)
|
||||
}
|
||||
|
|
@ -129,7 +128,7 @@ func TestProvisionerPrepare_ScriptAndInline(t *testing.T) {
|
|||
}
|
||||
|
||||
// Test with both
|
||||
tf, err := ioutil.TempFile("", "packer")
|
||||
tf, err := os.CreateTemp("", "packer")
|
||||
if err != nil {
|
||||
t.Fatalf("error tempfile: %s", err)
|
||||
}
|
||||
|
|
@ -149,7 +148,7 @@ func TestProvisionerPrepare_ScriptAndScripts(t *testing.T) {
|
|||
config := testConfig()
|
||||
|
||||
// Test with both
|
||||
tf, err := ioutil.TempFile("", "packer")
|
||||
tf, err := os.CreateTemp("", "packer")
|
||||
if err != nil {
|
||||
t.Fatalf("error tempfile: %s", err)
|
||||
}
|
||||
|
|
@ -176,7 +175,7 @@ func TestProvisionerPrepare_Scripts(t *testing.T) {
|
|||
}
|
||||
|
||||
// Test with a good one
|
||||
tf, err := ioutil.TempFile("", "packer")
|
||||
tf, err := os.CreateTemp("", "packer")
|
||||
if err != nil {
|
||||
t.Fatalf("error tempfile: %s", err)
|
||||
}
|
||||
|
|
@ -325,7 +324,7 @@ func TestProvisionerProvision_Inline(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestProvisionerProvision_Scripts(t *testing.T) {
|
||||
tf, err := ioutil.TempFile("", "packer")
|
||||
tf, err := os.CreateTemp("", "packer")
|
||||
if err != nil {
|
||||
t.Fatalf("error tempfile: %s", err)
|
||||
}
|
||||
|
|
@ -357,7 +356,7 @@ func TestProvisionerProvision_Scripts(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestProvisionerProvision_ScriptsWithEnvVars(t *testing.T) {
|
||||
tf, err := ioutil.TempFile("", "packer")
|
||||
tf, err := os.CreateTemp("", "packer")
|
||||
if err != nil {
|
||||
t.Fatalf("error tempfile: %s", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ import (
|
|||
"go/ast"
|
||||
"go/parser"
|
||||
"go/token"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
|
@ -142,7 +141,7 @@ func makeImports(builders, provisioners, postProcessors, Datasources []plugin) s
|
|||
// listDirectories recursively lists directories under the specified path
|
||||
func listDirectories(path string) ([]string, error) {
|
||||
names := []string{}
|
||||
items, err := ioutil.ReadDir(path)
|
||||
items, err := os.ReadDir(path)
|
||||
if err != nil {
|
||||
return names, err
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue