mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
internal/initwd: deprecate io/ioutil (#343)
Signed-off-by: Lars Lehtonen <lars.lehtonen@gmail.com>
This commit is contained in:
parent
40d6b4bd86
commit
07471df9d3
@ -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(
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user