plans/planfile: Don't use deprecated "io/ioutil" package

Everything from ioutil has been moved into other locations in modern Go.
This particular package only used ioutil.ReadAll and ioutil.ReadFile,
which have been replaced by io.ReadAll and os.ReadFile respectively.
testing-renovate
Martin Atkins 2 years ago
parent 6be3ddf9e7
commit ea60ca7d70

@ -7,7 +7,7 @@ import (
"archive/zip"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"path"
"sort"
"strings"
@ -55,7 +55,7 @@ func readConfigSnapshot(z *zip.Reader) (*configload.Snapshot, error) {
if err != nil {
return nil, fmt.Errorf("failed to open module manifest: %s", r)
}
manifestSrc, err = ioutil.ReadAll(r)
manifestSrc, err = io.ReadAll(r)
if err != nil {
return nil, fmt.Errorf("failed to read module manifest: %s", r)
}
@ -77,7 +77,7 @@ func readConfigSnapshot(z *zip.Reader) (*configload.Snapshot, error) {
if err != nil {
return nil, fmt.Errorf("failed to open snapshot of %s from module %q: %s", fileName, moduleKey, err)
}
fileSrc, err := ioutil.ReadAll(r)
fileSrc, err := io.ReadAll(r)
if err != nil {
return nil, fmt.Errorf("failed to read snapshot of %s from module %q: %s", fileName, moduleKey, err)
}

@ -7,7 +7,8 @@ import (
"archive/zip"
"bytes"
"fmt"
"io/ioutil"
"io"
"os"
"github.com/hashicorp/terraform/internal/configs"
"github.com/hashicorp/terraform/internal/configs/configload"
@ -59,7 +60,7 @@ func Open(filename string) (*Reader, error) {
if err != nil {
// To give a better error message, we'll sniff to see if this looks
// like our old plan format from versions prior to 0.12.
if b, sErr := ioutil.ReadFile(filename); sErr == nil {
if b, sErr := os.ReadFile(filename); sErr == nil {
if bytes.HasPrefix(b, []byte("tfplan")) {
return nil, errUnusable(fmt.Errorf("the given plan file was created by an earlier version of Terraform; plan files cannot be shared between different Terraform versions"))
}
@ -236,7 +237,7 @@ func (r *Reader) ReadDependencyLocks() (*depsfile.Locks, tfdiags.Diagnostics) {
))
return nil, diags
}
src, err := ioutil.ReadAll(r)
src, err := io.ReadAll(r)
if err != nil {
diags = diags.Append(tfdiags.Sourceless(
tfdiags.Error,

@ -6,7 +6,6 @@ package planfile
import (
"fmt"
"io"
"io/ioutil"
"time"
"github.com/zclconf/go-cty/cty"
@ -39,7 +38,7 @@ const tfplanFilename = "tfplan"
// a plan file, which is stored in a special file in the archive called
// "tfplan".
func readTfplan(r io.Reader) (*plans.Plan, error) {
src, err := ioutil.ReadAll(r)
src, err := io.ReadAll(r)
if err != nil {
return nil, err
}

Loading…
Cancel
Save