internal/initwd: deprecate io/ioutil (#343)

Signed-off-by: Lars Lehtonen <lars.lehtonen@gmail.com>
This commit is contained in:
Lars Lehtonen 2023-09-08 01:04:34 -07:00 committed by GitHub
parent 40d6b4bd86
commit 07471df9d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 8 deletions

View File

@ -6,7 +6,6 @@ package initwd
import (
"context"
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
@ -59,7 +58,7 @@ func DirFromModule(ctx context.Context, loader *configload.Loader, rootDir, modu
// The target directory must exist but be empty.
{
entries, err := ioutil.ReadDir(rootDir)
entries, err := os.ReadDir(rootDir)
if err != nil {
if os.IsNotExist(err) {
diags = diags.Append(tfdiags.Sourceless(

View File

@ -8,7 +8,6 @@ import (
"context"
"flag"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
@ -151,12 +150,12 @@ func TestModuleInstaller_packageEscapeError(t *testing.T) {
// %%BASE%% with the temporary directory path.
{
rootFilename := filepath.Join(dir, "package-escape.tf")
template, err := ioutil.ReadFile(rootFilename)
template, err := os.ReadFile(rootFilename)
if err != nil {
t.Fatal(err)
}
final := bytes.ReplaceAll(template, []byte("%%BASE%%"), []byte(filepath.ToSlash(dir)))
err = ioutil.WriteFile(rootFilename, final, 0644)
err = os.WriteFile(rootFilename, final, 0644)
if err != nil {
t.Fatal(err)
}
@ -189,12 +188,12 @@ func TestModuleInstaller_explicitPackageBoundary(t *testing.T) {
// %%BASE%% with the temporary directory path.
{
rootFilename := filepath.Join(dir, "package-prefix.tf")
template, err := ioutil.ReadFile(rootFilename)
template, err := os.ReadFile(rootFilename)
if err != nil {
t.Fatal(err)
}
final := bytes.ReplaceAll(template, []byte("%%BASE%%"), []byte(filepath.ToSlash(dir)))
err = ioutil.WriteFile(rootFilename, final, 0644)
err = os.WriteFile(rootFilename, final, 0644)
if err != nil {
t.Fatal(err)
}
@ -897,7 +896,7 @@ func (h *testInstallHooks) Install(moduleAddr string, version *version.Version,
func tempChdir(t *testing.T, sourceDir string) (string, func()) {
t.Helper()
tmpDir, err := ioutil.TempDir("", "terraform-configload")
tmpDir, err := os.MkdirTemp("", "terraform-configload")
if err != nil {
t.Fatalf("failed to create temporary directory: %s", err)
return "", nil