Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2021-09-20 17:23:49 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2021-09-20 17:23:49 +0300
commitd54f7f25a1c8d3eba3ac66f62c56d599ca36986b (patch)
tree8fd85e37bd9e36f485f22eabe9000cb74da9f1cf
parentaf5cd856461519c3f6c1d508eabb40aced2ff384 (diff)
global: Replace deprecated usage of `ioutil.WriteFile()`
With Go 1.16, the ioutil package was deprecated. Replace our usage of `ioutil.WriteFile()` with `os.WriteFile()` to adapt accordingly.
-rw-r--r--cmd/gitaly-hooks/hooks_test.go3
-rw-r--r--internal/backup/backup_test.go5
-rw-r--r--internal/backup/filesystem_sink_test.go7
-rw-r--r--internal/backup/locator_test.go5
-rw-r--r--internal/bootstrap/bootstrap_test.go3
-rw-r--r--internal/cache/walker_test.go5
-rw-r--r--internal/git/dirs_test.go3
-rw-r--r--internal/git/gittest/hooks.go3
-rw-r--r--internal/git/gittest/http_server.go4
-rw-r--r--internal/git/housekeeping/housekeeping_test.go3
-rw-r--r--internal/git/localrepo/objects_test.go3
-rw-r--r--internal/git/localrepo/remote_test.go3
-rw-r--r--internal/git/objectpool/link_test.go3
-rw-r--r--internal/git/objectpool/pool_test.go3
-rw-r--r--internal/git/quarantine/quarantine_test.go13
-rw-r--r--internal/git/ssh.go5
-rw-r--r--internal/gitaly/config/config_test.go5
-rw-r--r--internal/gitaly/hook/custom_test.go3
-rw-r--r--internal/gitaly/maintenance/randomwalker_test.go3
-rw-r--r--internal/gitaly/service/conflicts/list_conflict_files_test.go4
-rw-r--r--internal/gitaly/service/conflicts/resolve_conflicts_test.go4
-rw-r--r--internal/gitaly/service/objectpool/alternates_test.go5
-rw-r--r--internal/gitaly/service/objectpool/fetch_into_object_pool_test.go5
-rw-r--r--internal/gitaly/service/objectpool/get_test.go3
-rw-r--r--internal/gitaly/service/objectpool/link_test.go3
-rw-r--r--internal/gitaly/service/operations/squash_test.go7
-rw-r--r--internal/gitaly/service/operations/tags_test.go5
-rw-r--r--internal/gitaly/service/remote/fetch_internal_remote_test.go3
-rw-r--r--internal/gitaly/service/repository/apply_gitattributes_test.go3
-rw-r--r--internal/gitaly/service/repository/backup_custom_hooks_test.go3
-rw-r--r--internal/gitaly/service/repository/create_from_url_test.go3
-rw-r--r--internal/gitaly/service/repository/fork_test.go5
-rw-r--r--internal/gitaly/service/repository/gc_test.go7
-rw-r--r--internal/gitaly/service/repository/info_attributes_test.go3
-rw-r--r--internal/gitaly/service/repository/midx_test.go3
-rw-r--r--internal/gitaly/service/repository/replicate_test.go3
-rw-r--r--internal/gitaly/service/repository/search_files_test.go4
-rw-r--r--internal/gitaly/service/repository/snapshot_test.go13
-rw-r--r--internal/gitaly/service/server/info.go3
-rw-r--r--internal/gitaly/service/smarthttp/inforefs_test.go3
-rw-r--r--internal/gitaly/service/smarthttp/receive_pack_test.go5
-rw-r--r--internal/gitaly/service/ssh/receive_pack_test.go5
-rw-r--r--internal/gitaly/transaction/voting_test.go4
-rw-r--r--internal/gitlab/test_server.go3
-rw-r--r--internal/safe/file_writer_test.go2
-rw-r--r--internal/safe/locking_file_writer_test.go21
-rw-r--r--internal/streamcache/filestore_test.go3
-rw-r--r--internal/tempdir/clean_test.go2
-rw-r--r--internal/tempdir/tempdir_test.go4
-rw-r--r--internal/testhelper/testcfg/gitaly_builder.go3
-rw-r--r--internal/testhelper/testhelper.go3
51 files changed, 95 insertions, 134 deletions
diff --git a/cmd/gitaly-hooks/hooks_test.go b/cmd/gitaly-hooks/hooks_test.go
index c71daf429..93d980bdd 100644
--- a/cmd/gitaly-hooks/hooks_test.go
+++ b/cmd/gitaly-hooks/hooks_test.go
@@ -5,7 +5,6 @@ import (
"context"
"encoding/json"
"fmt"
- "io/ioutil"
"os"
"os/exec"
"path"
@@ -786,7 +785,7 @@ func writeTemporaryGitalyConfigFile(t testing.TB, tempDir, gitlabURL, user, pass
password = %q
`, gitlabURL, secretFile, user, password)
- require.NoError(t, ioutil.WriteFile(path, []byte(contents), 0o644))
+ require.NoError(t, os.WriteFile(path, []byte(contents), 0o644))
return path, func() {
require.NoError(t, os.RemoveAll(path))
}
diff --git a/internal/backup/backup_test.go b/internal/backup/backup_test.go
index 425656435..fd1dd04d8 100644
--- a/internal/backup/backup_test.go
+++ b/internal/backup/backup_test.go
@@ -4,7 +4,6 @@ import (
"context"
"errors"
"fmt"
- "io/ioutil"
"os"
"os/exec"
"path/filepath"
@@ -39,7 +38,7 @@ func TestManager_Create(t *testing.T) {
RelativePath: "hooks",
})
require.NoError(t, os.Mkdir(filepath.Join(hooksRepoPath, "custom_hooks"), os.ModePerm))
- require.NoError(t, ioutil.WriteFile(filepath.Join(hooksRepoPath, "custom_hooks/pre-commit.sample"), []byte("Some hooks"), os.ModePerm))
+ require.NoError(t, os.WriteFile(filepath.Join(hooksRepoPath, "custom_hooks/pre-commit.sample"), []byte("Some hooks"), os.ModePerm))
noHooksRepo, _ := gittest.CloneRepo(t, cfg, cfg.Storages[0], gittest.CloneRepoOpts{
RelativePath: "no-hooks",
@@ -336,7 +335,7 @@ func TestResolveSink(t *testing.T) {
tmpDir := testhelper.TempDir(t)
gsCreds := filepath.Join(tmpDir, "gs.creds")
- require.NoError(t, ioutil.WriteFile(gsCreds, []byte(`
+ require.NoError(t, os.WriteFile(gsCreds, []byte(`
{
"type": "service_account",
"project_id": "hostfactory-179005",
diff --git a/internal/backup/filesystem_sink_test.go b/internal/backup/filesystem_sink_test.go
index 84457e41d..f2f257c26 100644
--- a/internal/backup/filesystem_sink_test.go
+++ b/internal/backup/filesystem_sink_test.go
@@ -3,7 +3,6 @@ package backup
import (
"fmt"
"io"
- "io/ioutil"
"os"
"path/filepath"
"strings"
@@ -20,7 +19,7 @@ func TestFilesystemSink_GetReader(t *testing.T) {
dir := testhelper.TempDir(t)
const relativePath = "test.dat"
- require.NoError(t, ioutil.WriteFile(filepath.Join(dir, relativePath), []byte("test"), 0o644))
+ require.NoError(t, os.WriteFile(filepath.Join(dir, relativePath), []byte("test"), 0o644))
fsSink := NewFilesystemSink(dir)
reader, err := fsSink.GetReader(ctx, relativePath)
@@ -86,7 +85,7 @@ func TestFilesystemSink_Write(t *testing.T) {
fullPath := filepath.Join(dir, relativePath)
require.NoError(t, os.MkdirAll(filepath.Dir(fullPath), 0o755))
- require.NoError(t, ioutil.WriteFile(fullPath, []byte("initial"), 0o655))
+ require.NoError(t, os.WriteFile(fullPath, []byte("initial"), 0o655))
fsSink := NewFilesystemSink(dir)
require.NoError(t, fsSink.Write(ctx, relativePath, strings.NewReader("test")))
@@ -103,7 +102,7 @@ func TestFilesystemSink_Write(t *testing.T) {
dir := testhelper.TempDir(t)
const relativePath = "nested/test.dat"
- require.NoError(t, ioutil.WriteFile(filepath.Join(dir, "nested"), []byte("lock"), os.ModePerm))
+ require.NoError(t, os.WriteFile(filepath.Join(dir, "nested"), []byte("lock"), os.ModePerm))
fsSink := NewFilesystemSink(dir)
err := fsSink.Write(ctx, relativePath, strings.NewReader("test"))
diff --git a/internal/backup/locator_test.go b/internal/backup/locator_test.go
index 64146b35e..f8e97a2e5 100644
--- a/internal/backup/locator_test.go
+++ b/internal/backup/locator_test.go
@@ -1,7 +1,6 @@
package backup
import (
- "io/ioutil"
"os"
"path/filepath"
"testing"
@@ -92,7 +91,7 @@ func TestPointerLocator(t *testing.T) {
require.ErrorIs(t, err, ErrDoesntExist)
require.NoError(t, os.MkdirAll(filepath.Join(backupPath, repo.RelativePath), 0o755))
- require.NoError(t, ioutil.WriteFile(filepath.Join(backupPath, repo.RelativePath, "LATEST"), []byte(backupID), 0o644))
+ require.NoError(t, os.WriteFile(filepath.Join(backupPath, repo.RelativePath, "LATEST"), []byte(backupID), 0o644))
expected := &Full{
BundlePath: filepath.Join(repo.RelativePath, backupID, "full.bundle"),
RefPath: filepath.Join(repo.RelativePath, backupID, "full.refs"),
@@ -125,7 +124,7 @@ func TestPointerLocator(t *testing.T) {
require.Equal(t, expectedFallback, fallbackFull)
require.NoError(t, os.MkdirAll(filepath.Join(backupPath, repo.RelativePath), 0o755))
- require.NoError(t, ioutil.WriteFile(filepath.Join(backupPath, repo.RelativePath, "LATEST"), []byte(backupID), 0o644))
+ require.NoError(t, os.WriteFile(filepath.Join(backupPath, repo.RelativePath, "LATEST"), []byte(backupID), 0o644))
expected := &Full{
BundlePath: filepath.Join(repo.RelativePath, backupID, "full.bundle"),
RefPath: filepath.Join(repo.RelativePath, backupID, "full.refs"),
diff --git a/internal/bootstrap/bootstrap_test.go b/internal/bootstrap/bootstrap_test.go
index a809f46f0..8b870395c 100644
--- a/internal/bootstrap/bootstrap_test.go
+++ b/internal/bootstrap/bootstrap_test.go
@@ -4,7 +4,6 @@ import (
"context"
"errors"
"fmt"
- "io/ioutil"
"net"
"net/http"
"os"
@@ -69,7 +68,7 @@ func TestCreateUnixListener(t *testing.T) {
}
// simulate a dangling socket
- require.NoError(t, ioutil.WriteFile(socketPath, nil, 0o755))
+ require.NoError(t, os.WriteFile(socketPath, nil, 0o755))
listen := func(network, addr string) (net.Listener, error) {
require.Equal(t, "unix", network)
diff --git a/internal/cache/walker_test.go b/internal/cache/walker_test.go
index 823e1edb2..87e02d8fa 100644
--- a/internal/cache/walker_test.go
+++ b/internal/cache/walker_test.go
@@ -1,7 +1,6 @@
package cache
import (
- "io/ioutil"
"os"
"os/exec"
"path/filepath"
@@ -75,7 +74,7 @@ func TestDiskCacheInitialClear(t *testing.T) {
canary := filepath.Join(cacheDir, "canary.txt")
require.NoError(t, os.MkdirAll(filepath.Dir(canary), 0o755))
- require.NoError(t, ioutil.WriteFile(canary, []byte("chirp chirp"), 0o755))
+ require.NoError(t, os.WriteFile(canary, []byte("chirp chirp"), 0o755))
cache := New(cfg, locator, withDisabledWalker())
require.NoError(t, cache.StartWalkers())
@@ -132,7 +131,7 @@ func TestCleanWalkEmptyDirs(t *testing.T) {
if strings.HasSuffix(tt.path, "/") {
require.NoError(t, os.MkdirAll(p, 0o755))
} else {
- require.NoError(t, ioutil.WriteFile(p, nil, 0o655))
+ require.NoError(t, os.WriteFile(p, nil, 0o655))
if tt.stale {
require.NoError(t, os.Chtimes(p, time.Now(), time.Now().Add(-time.Hour)))
}
diff --git a/internal/git/dirs_test.go b/internal/git/dirs_test.go
index 14599a89b..05d0f04e7 100644
--- a/internal/git/dirs_test.go
+++ b/internal/git/dirs_test.go
@@ -1,7 +1,6 @@
package git
import (
- "io/ioutil"
"os"
"path/filepath"
"testing"
@@ -76,7 +75,7 @@ func TestObjectDirsOutsideStorage(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
- require.NoError(t, ioutil.WriteFile(alternatesFile, []byte(tc.alternates), 0o600))
+ require.NoError(t, os.WriteFile(alternatesFile, []byte(tc.alternates), 0o600))
out, err := ObjectDirectories(ctx, storageRoot, repoPath)
require.Equal(t, expectedErr, err)
require.Nil(t, out)
diff --git a/internal/git/gittest/hooks.go b/internal/git/gittest/hooks.go
index 2df6450c0..e2867648a 100644
--- a/internal/git/gittest/hooks.go
+++ b/internal/git/gittest/hooks.go
@@ -2,7 +2,6 @@ package gittest
import (
"fmt"
- "io/ioutil"
"os"
"path/filepath"
"testing"
@@ -61,7 +60,7 @@ func CaptureHookEnv(t testing.TB) (string, func()) {
#!/bin/sh
env | grep -e ^GIT -e ^GL_ > ` + hookOutputFile + "\n")
- require.NoError(t, ioutil.WriteFile(filepath.Join(hooks.Override, "update"), script, 0o755))
+ require.NoError(t, os.WriteFile(filepath.Join(hooks.Override, "update"), script, 0o755))
return hookOutputFile, func() {
hooks.Override = oldOverride
diff --git a/internal/git/gittest/http_server.go b/internal/git/gittest/http_server.go
index 11bf4cf4b..bb09276b2 100644
--- a/internal/git/gittest/http_server.go
+++ b/internal/git/gittest/http_server.go
@@ -4,11 +4,11 @@ import (
"compress/gzip"
"context"
"fmt"
- "io/ioutil"
"net"
"net/http"
"net/http/cgi"
"net/http/httptest"
+ "os"
"os/exec"
"path/filepath"
"testing"
@@ -67,7 +67,7 @@ func RemoteUploadPackServer(ctx context.Context, t *testing.T, gitPath, repoName
// repository is prepared such that git-http-backend(1) will serve it by
// creating the "git-daemon-export-ok" magic file.
func GitServer(t testing.TB, cfg config.Cfg, repoPath string, middleware func(http.ResponseWriter, *http.Request, http.Handler)) (int, func() error) {
- require.NoError(t, ioutil.WriteFile(filepath.Join(repoPath, "git-daemon-export-ok"), nil, 0o644))
+ require.NoError(t, os.WriteFile(filepath.Join(repoPath, "git-daemon-export-ok"), nil, 0o644))
listener, err := net.Listen("tcp", "127.0.0.1:0")
require.NoError(t, err)
diff --git a/internal/git/housekeeping/housekeeping_test.go b/internal/git/housekeeping/housekeeping_test.go
index 7c871affb..09b46599d 100644
--- a/internal/git/housekeeping/housekeeping_test.go
+++ b/internal/git/housekeeping/housekeeping_test.go
@@ -4,7 +4,6 @@ import (
"bytes"
"context"
"fmt"
- "io/ioutil"
"os"
"path/filepath"
"strings"
@@ -303,7 +302,7 @@ func TestPerform_references(t *testing.T) {
path := filepath.Join(repoPath, ref.name)
require.NoError(t, os.MkdirAll(filepath.Dir(path), 0o755))
- require.NoError(t, ioutil.WriteFile(path, bytes.Repeat([]byte{0}, ref.size), 0o644))
+ require.NoError(t, os.WriteFile(path, bytes.Repeat([]byte{0}, ref.size), 0o644))
filetime := time.Now().Add(-ref.age)
require.NoError(t, os.Chtimes(path, filetime, filetime))
}
diff --git a/internal/git/localrepo/objects_test.go b/internal/git/localrepo/objects_test.go
index c6410f6d5..d1d797955 100644
--- a/internal/git/localrepo/objects_test.go
+++ b/internal/git/localrepo/objects_test.go
@@ -3,7 +3,6 @@ package localrepo
import (
"fmt"
"io"
- "io/ioutil"
"os"
"path/filepath"
"strings"
@@ -91,7 +90,7 @@ func TestRepo_WriteBlob(t *testing.T) {
} {
t.Run(tc.desc, func(t *testing.T) {
require.NoError(t,
- ioutil.WriteFile(filepath.Join(repoPath, "info", "attributes"), []byte(tc.attributes), os.ModePerm),
+ os.WriteFile(filepath.Join(repoPath, "info", "attributes"), []byte(tc.attributes), os.ModePerm),
)
sha, err := repo.WriteBlob(ctx, "file-path", tc.input)
diff --git a/internal/git/localrepo/remote_test.go b/internal/git/localrepo/remote_test.go
index 0e4313ff6..4f1a8276a 100644
--- a/internal/git/localrepo/remote_test.go
+++ b/internal/git/localrepo/remote_test.go
@@ -4,7 +4,6 @@ import (
"bytes"
"errors"
"fmt"
- "io/ioutil"
"os"
"os/exec"
"path/filepath"
@@ -449,7 +448,7 @@ func captureGitSSHCommand(t testing.TB, gitBinaryPath string) (string, string) {
gitPath := filepath.Join(tmpDir, "git-hook")
envPath := filepath.Join(tmpDir, "GIT_SSH_PATH")
- require.NoError(t, ioutil.WriteFile(
+ require.NoError(t, os.WriteFile(
gitPath,
[]byte(fmt.Sprintf(
`#!/usr/bin/env bash
diff --git a/internal/git/objectpool/link_test.go b/internal/git/objectpool/link_test.go
index 97a7d5d6d..46ec094d7 100644
--- a/internal/git/objectpool/link_test.go
+++ b/internal/git/objectpool/link_test.go
@@ -3,6 +3,7 @@ package objectpool
import (
"context"
"io/ioutil"
+ "os"
"path/filepath"
"strings"
"testing"
@@ -161,7 +162,7 @@ func TestLinkAbsoluteLinkExists(t *testing.T) {
fullPath := filepath.Join(pool.FullPath(), "objects")
- require.NoError(t, ioutil.WriteFile(altPath, []byte(fullPath), 0o644))
+ require.NoError(t, os.WriteFile(altPath, []byte(fullPath), 0o644))
require.NoError(t, pool.Link(ctx, testRepo), "we expect this call to change the absolute link to a relative link")
diff --git a/internal/git/objectpool/pool_test.go b/internal/git/objectpool/pool_test.go
index 68729ff1b..94756ee0c 100644
--- a/internal/git/objectpool/pool_test.go
+++ b/internal/git/objectpool/pool_test.go
@@ -1,7 +1,6 @@
package objectpool
import (
- "io/ioutil"
"os"
"path/filepath"
"strings"
@@ -80,7 +79,7 @@ func TestNewFromRepoNoObjectPool(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) {
alternateFilePath := filepath.Join(testRepoPath, "objects", "info", "alternates")
- require.NoError(t, ioutil.WriteFile(alternateFilePath, tc.fileContent, 0o644))
+ require.NoError(t, os.WriteFile(alternateFilePath, tc.fileContent, 0o644))
poolFromRepo, err := FromRepo(pool.cfg, pool.locator, pool.gitCmdFactory, nil, nil, testRepo)
require.Equal(t, tc.expectedErr, err)
require.Nil(t, poolFromRepo)
diff --git a/internal/git/quarantine/quarantine_test.go b/internal/git/quarantine/quarantine_test.go
index f12f92bc6..5896d73f6 100644
--- a/internal/git/quarantine/quarantine_test.go
+++ b/internal/git/quarantine/quarantine_test.go
@@ -1,7 +1,6 @@
package quarantine
import (
- "io/ioutil"
"os"
"path/filepath"
"strings"
@@ -33,7 +32,7 @@ func (e entry) create(t *testing.T, root string) {
child.create(t, filepath.Join(root, name))
}
} else {
- require.NoError(t, ioutil.WriteFile(root, []byte(e.contents), 0o666))
+ require.NoError(t, os.WriteFile(root, []byte(e.contents), 0o666))
}
}
@@ -113,7 +112,7 @@ func TestQuarantine_Migrate(t *testing.T) {
quarantine, err := New(ctx, repo, locator)
require.NoError(t, err)
- require.NoError(t, ioutil.WriteFile(filepath.Join(quarantine.dir.Path(), "file"), []byte("foobar"), 0o666))
+ require.NoError(t, os.WriteFile(filepath.Join(quarantine.dir.Path(), "file"), []byte("foobar"), 0o666))
require.NoError(t, quarantine.Migrate())
newContents := listEntries(t, repoPath)
@@ -323,7 +322,7 @@ func TestFinalizeObjectFile(t *testing.T) {
source := filepath.Join(dir, "a")
target := filepath.Join(dir, "b")
- require.NoError(t, ioutil.WriteFile(source, []byte("a"), 0o777))
+ require.NoError(t, os.WriteFile(source, []byte("a"), 0o777))
require.NoError(t, finalizeObjectFile(source, target))
require.NoFileExists(t, source)
@@ -336,7 +335,7 @@ func TestFinalizeObjectFile(t *testing.T) {
source := filepath.Join(sourceDir, "a")
target := filepath.Join(targetDir, "a")
- require.NoError(t, ioutil.WriteFile(source, []byte("a"), 0o777))
+ require.NoError(t, os.WriteFile(source, []byte("a"), 0o777))
require.NoError(t, finalizeObjectFile(source, target))
require.NoFileExists(t, source)
@@ -347,10 +346,10 @@ func TestFinalizeObjectFile(t *testing.T) {
dir := testhelper.TempDir(t)
source := filepath.Join(dir, "a")
- require.NoError(t, ioutil.WriteFile(source, []byte("a"), 0o777))
+ require.NoError(t, os.WriteFile(source, []byte("a"), 0o777))
target := filepath.Join(dir, "b")
- require.NoError(t, ioutil.WriteFile(target, []byte("b"), 0o777))
+ require.NoError(t, os.WriteFile(target, []byte("b"), 0o777))
// We do not expect an error in case the target file exists: given that objects and
// packs are content addressable, a file with the same name should have the same
diff --git a/internal/git/ssh.go b/internal/git/ssh.go
index 93870136b..be411576f 100644
--- a/internal/git/ssh.go
+++ b/internal/git/ssh.go
@@ -3,7 +3,6 @@ package git
import (
"context"
"fmt"
- "io/ioutil"
"os"
"path/filepath"
"strings"
@@ -33,7 +32,7 @@ func BuildSSHInvocation(ctx context.Context, sshKey, knownHosts string) (string,
args := []string{sshCommand}
if sshKey != "" {
sshKeyFile := filepath.Join(tmpDir, "ssh-key")
- if err := ioutil.WriteFile(sshKeyFile, []byte(sshKey), 0o400); err != nil {
+ if err := os.WriteFile(sshKeyFile, []byte(sshKey), 0o400); err != nil {
cleanup()
return "", nil, fmt.Errorf("create ssh key file: %w", err)
}
@@ -43,7 +42,7 @@ func BuildSSHInvocation(ctx context.Context, sshKey, knownHosts string) (string,
if knownHosts != "" {
knownHostsFile := filepath.Join(tmpDir, "known-hosts")
- if err := ioutil.WriteFile(knownHostsFile, []byte(knownHosts), 0o400); err != nil {
+ if err := os.WriteFile(knownHostsFile, []byte(knownHosts), 0o400); err != nil {
cleanup()
return "", nil, fmt.Errorf("create known hosts file: %w", err)
}
diff --git a/internal/gitaly/config/config_test.go b/internal/gitaly/config/config_test.go
index 08093edeb..27aaa0c76 100644
--- a/internal/gitaly/config/config_test.go
+++ b/internal/gitaly/config/config_test.go
@@ -4,7 +4,6 @@ import (
"bytes"
"errors"
"fmt"
- "io/ioutil"
"os"
"os/exec"
"path/filepath"
@@ -347,7 +346,7 @@ func setupTempHookDirs(t *testing.T, m map[string]hookFileMode) (string, func())
path := filepath.Join(tempDir, hookName)
require.NoError(t, os.MkdirAll(filepath.Dir(path), 0o755))
- require.NoError(t, ioutil.WriteFile(filepath.Join(tempDir, hookName), nil, 0o644))
+ require.NoError(t, os.WriteFile(filepath.Join(tempDir, hookName), nil, 0o644))
if mode&hookFileExecutable > 0 {
require.NoError(t, os.Chmod(filepath.Join(tempDir, hookName), 0o755))
@@ -616,7 +615,7 @@ func TestConfigureRuby(t *testing.T) {
defer func() { require.NoError(t, os.RemoveAll(tmpDir)) }()
tmpFile := filepath.Join(tmpDir, "file")
- require.NoError(t, ioutil.WriteFile(tmpFile, nil, 0o644))
+ require.NoError(t, os.WriteFile(tmpFile, nil, 0o644))
testCases := []struct {
desc string
diff --git a/internal/gitaly/hook/custom_test.go b/internal/gitaly/hook/custom_test.go
index cd9872c92..9f99fa6b7 100644
--- a/internal/gitaly/hook/custom_test.go
+++ b/internal/gitaly/hook/custom_test.go
@@ -4,7 +4,6 @@ import (
"bufio"
"bytes"
"fmt"
- "io/ioutil"
"os"
"path/filepath"
"strings"
@@ -425,7 +424,7 @@ type customHookResults struct {
func writeCustomHook(t *testing.T, hookName, dir string, content []byte) func() {
require.NoError(t, os.MkdirAll(dir, 0o755))
- require.NoError(t, ioutil.WriteFile(filepath.Join(dir, hookName), content, 0o755))
+ require.NoError(t, os.WriteFile(filepath.Join(dir, hookName), content, 0o755))
return func() {
require.NoError(t, os.RemoveAll(dir))
diff --git a/internal/gitaly/maintenance/randomwalker_test.go b/internal/gitaly/maintenance/randomwalker_test.go
index 66676f372..5db523dc3 100644
--- a/internal/gitaly/maintenance/randomwalker_test.go
+++ b/internal/gitaly/maintenance/randomwalker_test.go
@@ -1,7 +1,6 @@
package maintenance
import (
- "io/ioutil"
"math/rand"
"os"
"path/filepath"
@@ -154,7 +153,7 @@ func TestRandomWalk(t *testing.T) {
}
for _, file := range tc.files {
- require.NoError(t, ioutil.WriteFile(filepath.Join(root, file), []byte{}, 0o777))
+ require.NoError(t, os.WriteFile(filepath.Join(root, file), []byte{}, 0o777))
}
walker := newRandomWalker(root, rand.New(rand.NewSource(1)))
diff --git a/internal/gitaly/service/conflicts/list_conflict_files_test.go b/internal/gitaly/service/conflicts/list_conflict_files_test.go
index 2fc7b4346..f5b68c777 100644
--- a/internal/gitaly/service/conflicts/list_conflict_files_test.go
+++ b/internal/gitaly/service/conflicts/list_conflict_files_test.go
@@ -4,7 +4,7 @@ import (
"bytes"
"context"
"io"
- "io/ioutil"
+ "os"
"path/filepath"
"testing"
@@ -185,7 +185,7 @@ func buildCommit(t *testing.T, ctx context.Context, cfg config.Cfg, repo *gitaly
for file, contents := range files {
filePath := filepath.Join(repoPath, file)
- require.NoError(t, ioutil.WriteFile(filePath, contents, 0o666))
+ require.NoError(t, os.WriteFile(filePath, contents, 0o666))
gittest.Exec(t, cfg, "-C", repoPath, "add", filePath)
}
diff --git a/internal/gitaly/service/conflicts/resolve_conflicts_test.go b/internal/gitaly/service/conflicts/resolve_conflicts_test.go
index cce440526..9bc790d89 100644
--- a/internal/gitaly/service/conflicts/resolve_conflicts_test.go
+++ b/internal/gitaly/service/conflicts/resolve_conflicts_test.go
@@ -6,7 +6,7 @@ import (
"encoding/json"
"fmt"
"io"
- "io/ioutil"
+ "os"
"os/exec"
"path/filepath"
"regexp"
@@ -448,7 +448,7 @@ func TestResolveConflictsIdenticalContent(t *testing.T) {
} {
contents := gittest.Exec(t, cfg, "-C", repoPath, "cat-file", "-p", rev+":files/ruby/popen.rb")
path := filepath.Join(tempDir, rev)
- require.NoError(t, ioutil.WriteFile(path, contents, 0o644))
+ require.NoError(t, os.WriteFile(path, contents, 0o644))
conflictingPaths = append(conflictingPaths, path)
}
diff --git a/internal/gitaly/service/objectpool/alternates_test.go b/internal/gitaly/service/objectpool/alternates_test.go
index 350973d8a..383120a19 100644
--- a/internal/gitaly/service/objectpool/alternates_test.go
+++ b/internal/gitaly/service/objectpool/alternates_test.go
@@ -2,7 +2,6 @@ package objectpool
import (
"fmt"
- "io/ioutil"
"os"
"testing"
@@ -91,7 +90,7 @@ func TestDisconnectGitAlternatesUnexpectedAlternates(t *testing.T) {
altPath, err := locator.InfoAlternatesPath(repo)
require.NoError(t, err, "find info/alternates")
- require.NoError(t, ioutil.WriteFile(altPath, []byte(tc.altContent), 0o644))
+ require.NoError(t, os.WriteFile(altPath, []byte(tc.altContent), 0o644))
_, err = client.DisconnectGitAlternates(ctx, &gitalypb.DisconnectGitAlternatesRequest{Repository: repo})
require.Error(t, err, "call DisconnectGitAlternates on repository with unexpected objects/info/alternates")
@@ -111,7 +110,7 @@ func TestRemoveAlternatesIfOk(t *testing.T) {
altPath, err := locator.InfoAlternatesPath(repo)
require.NoError(t, err, "find info/alternates")
altContent := "/var/empty\n"
- require.NoError(t, ioutil.WriteFile(altPath, []byte(altContent), 0o644), "write alternates file")
+ require.NoError(t, os.WriteFile(altPath, []byte(altContent), 0o644), "write alternates file")
// Intentionally break the repository, so that 'git fsck' will fail later.
testhelper.MustRunCommand(t, nil, "sh", "-c", fmt.Sprintf("rm %s/objects/pack/*.pack", repoPath))
diff --git a/internal/gitaly/service/objectpool/fetch_into_object_pool_test.go b/internal/gitaly/service/objectpool/fetch_into_object_pool_test.go
index c3e14761d..9b68557e1 100644
--- a/internal/gitaly/service/objectpool/fetch_into_object_pool_test.go
+++ b/internal/gitaly/service/objectpool/fetch_into_object_pool_test.go
@@ -3,7 +3,6 @@ package objectpool
import (
"bytes"
"encoding/json"
- "io/ioutil"
"os"
"path/filepath"
"strings"
@@ -71,7 +70,7 @@ func TestFetchIntoObjectPool_Success(t *testing.T) {
require.NoError(t, err)
brokenRef := filepath.Join(poolPath, "refs", "heads", "broken")
require.NoError(t, os.MkdirAll(filepath.Dir(brokenRef), 0o755))
- require.NoError(t, ioutil.WriteFile(brokenRef, []byte{}, 0o777))
+ require.NoError(t, os.WriteFile(brokenRef, []byte{}, 0o777))
oldTime := time.Now().Add(-25 * time.Hour)
require.NoError(t, os.Chtimes(brokenRef, oldTime, oldTime))
@@ -100,7 +99,7 @@ func TestFetchIntoObjectPool_hooks(t *testing.T) {
// Set up a custom reference-transaction hook which simply exits failure. This asserts that
// the RPC doesn't invoke any reference-transaction.
- require.NoError(t, ioutil.WriteFile(filepath.Join(hookDir, "reference-transaction"), []byte("#!/bin/sh\nexit 1\n"), 0o777))
+ require.NoError(t, os.WriteFile(filepath.Join(hookDir, "reference-transaction"), []byte("#!/bin/sh\nexit 1\n"), 0o777))
req := &gitalypb.FetchIntoObjectPoolRequest{
ObjectPool: pool.ToProto(),
diff --git a/internal/gitaly/service/objectpool/get_test.go b/internal/gitaly/service/objectpool/get_test.go
index 562a93273..ecc9a2343 100644
--- a/internal/gitaly/service/objectpool/get_test.go
+++ b/internal/gitaly/service/objectpool/get_test.go
@@ -1,7 +1,6 @@
package objectpool
import (
- "io/ioutil"
"os"
"path/filepath"
"testing"
@@ -55,7 +54,7 @@ func TestGetObjectPoolBadFile(t *testing.T) {
alternatesFilePath := filepath.Join(repoPath, "objects", "info", "alternates")
require.NoError(t, os.MkdirAll(filepath.Dir(alternatesFilePath), 0o755))
- require.NoError(t, ioutil.WriteFile(alternatesFilePath, []byte("not-a-directory"), 0o644))
+ require.NoError(t, os.WriteFile(alternatesFilePath, []byte("not-a-directory"), 0o644))
ctx, cancel := testhelper.Context()
defer cancel()
diff --git a/internal/gitaly/service/objectpool/link_test.go b/internal/gitaly/service/objectpool/link_test.go
index 148a0889d..5ae22a8b5 100644
--- a/internal/gitaly/service/objectpool/link_test.go
+++ b/internal/gitaly/service/objectpool/link_test.go
@@ -1,7 +1,6 @@
package objectpool
import (
- "io/ioutil"
"os"
"path/filepath"
"testing"
@@ -120,7 +119,7 @@ func TestLinkNoClobber(t *testing.T) {
require.NoFileExists(t, alternatesFile)
contentBefore := "mock/objects\n"
- require.NoError(t, ioutil.WriteFile(alternatesFile, []byte(contentBefore), 0o644))
+ require.NoError(t, os.WriteFile(alternatesFile, []byte(contentBefore), 0o644))
request := &gitalypb.LinkRepositoryToObjectPoolRequest{
Repository: repo,
diff --git a/internal/gitaly/service/operations/squash_test.go b/internal/gitaly/service/operations/squash_test.go
index 5bbdec94d..02e833c5a 100644
--- a/internal/gitaly/service/operations/squash_test.go
+++ b/internal/gitaly/service/operations/squash_test.go
@@ -3,6 +3,7 @@ package operations
import (
"fmt"
"io/ioutil"
+ "os"
"path/filepath"
"strings"
"testing"
@@ -229,7 +230,7 @@ func TestUserSquash_renames(t *testing.T) {
renamedFilename := "renamed-file.txt"
gittest.Exec(t, cfg, "-C", repoPath, "checkout", "-b", "squash-rename-test", "master")
- require.NoError(t, ioutil.WriteFile(filepath.Join(repoPath, originalFilename), []byte("This is a test"), 0o644))
+ require.NoError(t, os.WriteFile(filepath.Join(repoPath, originalFilename), []byte("This is a test"), 0o644))
gittest.Exec(t, cfg, "-C", repoPath, "add", ".")
gittest.Exec(t, cfg, "-C", repoPath, "commit", "-m", "test file")
@@ -240,10 +241,10 @@ func TestUserSquash_renames(t *testing.T) {
// Modify the original file in another branch
gittest.Exec(t, cfg, "-C", repoPath, "checkout", "-b", "squash-rename-branch", startCommitID)
- require.NoError(t, ioutil.WriteFile(filepath.Join(repoPath, originalFilename), []byte("This is a change"), 0o644))
+ require.NoError(t, os.WriteFile(filepath.Join(repoPath, originalFilename), []byte("This is a change"), 0o644))
gittest.Exec(t, cfg, "-C", repoPath, "commit", "-a", "-m", "test")
- require.NoError(t, ioutil.WriteFile(filepath.Join(repoPath, originalFilename), []byte("This is another change"), 0o644))
+ require.NoError(t, os.WriteFile(filepath.Join(repoPath, originalFilename), []byte("This is another change"), 0o644))
gittest.Exec(t, cfg, "-C", repoPath, "commit", "-a", "-m", "test")
endCommitID := text.ChompBytes(gittest.Exec(t, cfg, "-C", repoPath, "rev-parse", "HEAD"))
diff --git a/internal/gitaly/service/operations/tags_test.go b/internal/gitaly/service/operations/tags_test.go
index 7fd6f4137..b5d2db68d 100644
--- a/internal/gitaly/service/operations/tags_test.go
+++ b/internal/gitaly/service/operations/tags_test.go
@@ -2,7 +2,6 @@ package operations
import (
"fmt"
- "io/ioutil"
"os"
"path/filepath"
"testing"
@@ -117,7 +116,7 @@ end`, cfg.Git.BinPath)
dir := testhelper.TempDir(t)
hookPath := filepath.Join(dir, "pre-receive")
- require.NoError(t, ioutil.WriteFile(hookPath, []byte(hook), 0o755))
+ require.NoError(t, os.WriteFile(hookPath, []byte(hook), 0o755))
return hookPath
}
@@ -150,7 +149,7 @@ end`, cfg.Git.BinPath)
dir := testhelper.TempDir(t)
hookPath := filepath.Join(dir, "pre-receive")
- require.NoError(t, ioutil.WriteFile(hookPath, []byte(hook), 0o755))
+ require.NoError(t, os.WriteFile(hookPath, []byte(hook), 0o755))
return hookPath
}
diff --git a/internal/gitaly/service/remote/fetch_internal_remote_test.go b/internal/gitaly/service/remote/fetch_internal_remote_test.go
index 0472f0948..334f1612f 100644
--- a/internal/gitaly/service/remote/fetch_internal_remote_test.go
+++ b/internal/gitaly/service/remote/fetch_internal_remote_test.go
@@ -4,7 +4,6 @@ import (
"context"
"fmt"
"io"
- "io/ioutil"
"os"
"path/filepath"
"strconv"
@@ -83,7 +82,7 @@ func listenGitalySSHCalls(t *testing.T, conf config.Cfg) func() []GitalySSHParam
exit $?`,
tmpDir, envPrefix, argsPrefix, updatedPath)
- require.NoError(t, ioutil.WriteFile(initialPath, []byte(script), 0o755))
+ require.NoError(t, os.WriteFile(initialPath, []byte(script), 0o755))
getSSHParams := func() []GitalySSHParams {
var gitalySSHParams []GitalySSHParams
diff --git a/internal/gitaly/service/repository/apply_gitattributes_test.go b/internal/gitaly/service/repository/apply_gitattributes_test.go
index ba75d865c..51aaf9270 100644
--- a/internal/gitaly/service/repository/apply_gitattributes_test.go
+++ b/internal/gitaly/service/repository/apply_gitattributes_test.go
@@ -5,7 +5,6 @@ import (
"context"
"errors"
"fmt"
- "io/ioutil"
"os"
"path/filepath"
"testing"
@@ -75,7 +74,7 @@ func testApplyGitattributesSuccess(t *testing.T, ctx context.Context) {
// Test when a git attributes file already exists
require.NoError(t, os.MkdirAll(infoPath, 0o755))
- require.NoError(t, ioutil.WriteFile(attributesPath, []byte("*.docx diff=word"), 0o644))
+ require.NoError(t, os.WriteFile(attributesPath, []byte("*.docx diff=word"), 0o644))
assertGitattributesApplied(t, ctx, client, repo, attributesPath, test.revision, test.contents)
})
}
diff --git a/internal/gitaly/service/repository/backup_custom_hooks_test.go b/internal/gitaly/service/repository/backup_custom_hooks_test.go
index 9c154d1f4..ef0b69b3b 100644
--- a/internal/gitaly/service/repository/backup_custom_hooks_test.go
+++ b/internal/gitaly/service/repository/backup_custom_hooks_test.go
@@ -5,7 +5,6 @@ import (
"bytes"
"fmt"
"io"
- "io/ioutil"
"os"
"path/filepath"
"testing"
@@ -31,7 +30,7 @@ func TestSuccessfullBackupCustomHooksRequest(t *testing.T) {
}
require.NoError(t, os.Mkdir(filepath.Join(repoPath, "custom_hooks"), 0o700), "Could not create custom_hooks dir")
for _, fileName := range expectedTarResponse[1:] {
- require.NoError(t, ioutil.WriteFile(filepath.Join(repoPath, fileName), []byte("Some hooks"), 0o700), fmt.Sprintf("Could not create %s", fileName))
+ require.NoError(t, os.WriteFile(filepath.Join(repoPath, fileName), []byte("Some hooks"), 0o700), fmt.Sprintf("Could not create %s", fileName))
}
backupRequest := &gitalypb.BackupCustomHooksRequest{Repository: repo}
diff --git a/internal/gitaly/service/repository/create_from_url_test.go b/internal/gitaly/service/repository/create_from_url_test.go
index 9aae68ca7..527ccea07 100644
--- a/internal/gitaly/service/repository/create_from_url_test.go
+++ b/internal/gitaly/service/repository/create_from_url_test.go
@@ -3,7 +3,6 @@ package repository
import (
"encoding/base64"
"fmt"
- "io/ioutil"
"net/http"
"os"
"path/filepath"
@@ -118,7 +117,7 @@ func TestFailedCreateRepositoryFromURLRequestDueToExistingTarget(t *testing.T) {
if testCase.isDir {
require.NoError(t, os.MkdirAll(importedRepoPath, 0o770))
} else {
- require.NoError(t, ioutil.WriteFile(importedRepoPath, nil, 0o644))
+ require.NoError(t, os.WriteFile(importedRepoPath, nil, 0o644))
}
t.Cleanup(func() { require.NoError(t, os.RemoveAll(importedRepoPath)) })
diff --git a/internal/gitaly/service/repository/fork_test.go b/internal/gitaly/service/repository/fork_test.go
index 7ec027588..dba63ffa2 100644
--- a/internal/gitaly/service/repository/fork_test.go
+++ b/internal/gitaly/service/repository/fork_test.go
@@ -3,7 +3,6 @@ package repository
import (
"crypto/tls"
"crypto/x509"
- "io/ioutil"
"os"
"path/filepath"
"testing"
@@ -174,13 +173,13 @@ func TestFailedCreateForkRequestDueToExistingTarget(t *testing.T) {
if testCase.isDir {
require.NoError(t, os.MkdirAll(forkedRepoPath, 0o770))
- require.NoError(t, ioutil.WriteFile(
+ require.NoError(t, os.WriteFile(
filepath.Join(forkedRepoPath, "config"),
nil,
0o644,
))
} else {
- require.NoError(t, ioutil.WriteFile(forkedRepoPath, nil, 0o644))
+ require.NoError(t, os.WriteFile(forkedRepoPath, nil, 0o644))
}
defer func() { require.NoError(t, os.RemoveAll(forkedRepoPath)) }()
diff --git a/internal/gitaly/service/repository/gc_test.go b/internal/gitaly/service/repository/gc_test.go
index 4ab776502..35727167c 100644
--- a/internal/gitaly/service/repository/gc_test.go
+++ b/internal/gitaly/service/repository/gc_test.go
@@ -3,7 +3,6 @@ package repository
import (
"bytes"
"fmt"
- "io/ioutil"
"os"
"path/filepath"
"testing"
@@ -434,11 +433,11 @@ func TestCleanupInvalidKeepAroundRefs(t *testing.T) {
// Create an invalid ref that should should be removed with the testcase
bogusSha := "b3f5e4adf6277b571b7943a4f0405a6dd7ee7e15"
bogusPath := filepath.Join(repoPath, fmt.Sprintf("refs/keep-around/%s", bogusSha))
- require.NoError(t, ioutil.WriteFile(bogusPath, []byte(bogusSha), 0o644))
+ require.NoError(t, os.WriteFile(bogusPath, []byte(bogusSha), 0o644))
// Creating the keeparound without using git so we can create invalid ones in testcases
refPath := filepath.Join(repoPath, fmt.Sprintf("refs/keep-around/%s", testcase.refName))
- require.NoError(t, ioutil.WriteFile(refPath, []byte(testcase.refContent), 0o644))
+ require.NoError(t, os.WriteFile(refPath, []byte(testcase.refContent), 0o644))
// Perform the request
req := &gitalypb.GarbageCollectRequest{Repository: repo}
@@ -467,7 +466,7 @@ func mustCreateFileWithTimes(t testing.TB, path string, mTime time.Time) {
t.Helper()
require.NoError(t, os.MkdirAll(filepath.Dir(path), 0o755))
- require.NoError(t, ioutil.WriteFile(path, nil, 0o644))
+ require.NoError(t, os.WriteFile(path, nil, 0o644))
require.NoError(t, os.Chtimes(path, mTime, mTime))
}
diff --git a/internal/gitaly/service/repository/info_attributes_test.go b/internal/gitaly/service/repository/info_attributes_test.go
index 23f4e915a..05aece572 100644
--- a/internal/gitaly/service/repository/info_attributes_test.go
+++ b/internal/gitaly/service/repository/info_attributes_test.go
@@ -3,7 +3,6 @@ package repository
import (
"bytes"
"io"
- "io/ioutil"
"os"
"path/filepath"
"testing"
@@ -24,7 +23,7 @@ func TestGetInfoAttributesExisting(t *testing.T) {
buffSize := streamio.WriteBufferSize + 1
data := bytes.Repeat([]byte("*.pbxproj binary\n"), buffSize)
attrsPath := filepath.Join(infoPath, "attributes")
- err := ioutil.WriteFile(attrsPath, data, 0o644)
+ err := os.WriteFile(attrsPath, data, 0o644)
require.NoError(t, err)
request := &gitalypb.GetInfoAttributesRequest{Repository: repo}
diff --git a/internal/gitaly/service/repository/midx_test.go b/internal/gitaly/service/repository/midx_test.go
index da01b2f3c..76b655f33 100644
--- a/internal/gitaly/service/repository/midx_test.go
+++ b/internal/gitaly/service/repository/midx_test.go
@@ -3,7 +3,6 @@ package repository
import (
"context"
"fmt"
- "io/ioutil"
"os"
"path/filepath"
"testing"
@@ -66,7 +65,7 @@ func TestMidxRewrite(t *testing.T) {
// Create an invalid multi-pack-index file
// with mtime update being the basis for comparison
- require.NoError(t, ioutil.WriteFile(midxPath, nil, 0o644))
+ require.NoError(t, os.WriteFile(midxPath, nil, 0o644))
require.NoError(t, os.Chtimes(midxPath, time.Time{}, time.Time{}))
info, err := os.Stat(midxPath)
require.NoError(t, err)
diff --git a/internal/gitaly/service/repository/replicate_test.go b/internal/gitaly/service/repository/replicate_test.go
index 742dcf753..a62456a8b 100644
--- a/internal/gitaly/service/repository/replicate_test.go
+++ b/internal/gitaly/service/repository/replicate_test.go
@@ -3,7 +3,6 @@ package repository
import (
"bytes"
"context"
- "io/ioutil"
"os"
"path/filepath"
"testing"
@@ -50,7 +49,7 @@ func TestReplicateRepository(t *testing.T) {
// write info attributes
attrFilePath := filepath.Join(repoPath, "info", "attributes")
attrData := []byte("*.pbxproj binary\n")
- require.NoError(t, ioutil.WriteFile(attrFilePath, attrData, 0o644))
+ require.NoError(t, os.WriteFile(attrFilePath, attrData, 0o644))
// Write a modified gitconfig
gittest.Exec(t, cfg, "-C", repoPath, "config", "please.replicate", "me")
diff --git a/internal/gitaly/service/repository/search_files_test.go b/internal/gitaly/service/repository/search_files_test.go
index d3716ee07..096485610 100644
--- a/internal/gitaly/service/repository/search_files_test.go
+++ b/internal/gitaly/service/repository/search_files_test.go
@@ -4,7 +4,7 @@ import (
"bytes"
"fmt"
"io"
- "io/ioutil"
+ "os"
"path/filepath"
"strings"
"testing"
@@ -181,7 +181,7 @@ func TestSearchFilesByContentLargeFile(t *testing.T) {
for _, largeFile := range largeFiles {
t.Run(largeFile.filename, func(t *testing.T) {
- require.NoError(t, ioutil.WriteFile(filepath.Join(repoPath, largeFile.filename), bytes.Repeat([]byte(largeFile.line), largeFile.repeated), 0o644))
+ require.NoError(t, os.WriteFile(filepath.Join(repoPath, largeFile.filename), bytes.Repeat([]byte(largeFile.line), largeFile.repeated), 0o644))
gittest.Exec(t, cfg, "-C", repoPath, "add", ".")
gittest.Exec(t, cfg, "-C", repoPath,
"-c", fmt.Sprintf("user.name=%s", committerName),
diff --git a/internal/gitaly/service/repository/snapshot_test.go b/internal/gitaly/service/repository/snapshot_test.go
index a6e2be7a7..973eb93b6 100644
--- a/internal/gitaly/service/repository/snapshot_test.go
+++ b/internal/gitaly/service/repository/snapshot_test.go
@@ -4,7 +4,6 @@ import (
"bytes"
"fmt"
"io"
- "io/ioutil"
"net/http/httptest"
"os"
"os/exec"
@@ -49,7 +48,7 @@ func getSnapshot(client gitalypb.RepositoryServiceClient, req *gitalypb.GetSnaps
func touch(t *testing.T, format string, args ...interface{}) {
path := fmt.Sprintf(format, args...)
- require.NoError(t, ioutil.WriteFile(path, nil, 0o644))
+ require.NoError(t, os.WriteFile(path, nil, 0o644))
}
func TestGetSnapshotSuccess(t *testing.T) {
@@ -144,7 +143,7 @@ func TestGetSnapshotWithDedupe(t *testing.T) {
// write alternates file to point to alt objects folder
alternatesPath, err := locator.InfoAlternatesPath(repoProto)
require.NoError(t, err)
- require.NoError(t, ioutil.WriteFile(alternatesPath, []byte(filepath.Join(repoPath, ".git", fmt.Sprintf("%s\n", alternateObjDir))), 0o644))
+ require.NoError(t, os.WriteFile(alternatesPath, []byte(filepath.Join(repoPath, ".git", fmt.Sprintf("%s\n", alternateObjDir))), 0o644))
// write another commit and ensure we can find it
cmd = exec.Command(cfg.Git.BinPath, "-C", repoPath,
@@ -182,7 +181,7 @@ func TestGetSnapshotWithDedupeSoftFailures(t *testing.T) {
alternateObjPath := filepath.Join(repoPath, ".git", alternateObjDir)
alternatesPath, err := locator.InfoAlternatesPath(testRepo)
require.NoError(t, err)
- require.NoError(t, ioutil.WriteFile(alternatesPath, []byte(fmt.Sprintf("%s\n", alternateObjPath)), 0o644))
+ require.NoError(t, os.WriteFile(alternatesPath, []byte(fmt.Sprintf("%s\n", alternateObjPath)), 0o644))
req := &gitalypb.GetSnapshotRequest{Repository: testRepo}
_, err = getSnapshot(client, req)
@@ -192,14 +191,14 @@ func TestGetSnapshotWithDedupeSoftFailures(t *testing.T) {
// write alternates file to point outside storage root
storageRoot, err := locator.GetStorageByName(testRepo.GetStorageName())
require.NoError(t, err)
- require.NoError(t, ioutil.WriteFile(alternatesPath, []byte(filepath.Join(storageRoot, "..")), 0o600))
+ require.NoError(t, os.WriteFile(alternatesPath, []byte(filepath.Join(storageRoot, "..")), 0o600))
_, err = getSnapshot(client, &gitalypb.GetSnapshotRequest{Repository: testRepo})
assert.NoError(t, err)
require.NoError(t, os.Remove(alternatesPath))
// write alternates file with bad permissions
- require.NoError(t, ioutil.WriteFile(alternatesPath, []byte(fmt.Sprintf("%s\n", alternateObjPath)), 0o000))
+ require.NoError(t, os.WriteFile(alternatesPath, []byte(fmt.Sprintf("%s\n", alternateObjPath)), 0o000))
_, err = getSnapshot(client, req)
assert.NoError(t, err)
require.NoError(t, os.Remove(alternatesPath))
@@ -216,7 +215,7 @@ func TestGetSnapshotWithDedupeSoftFailures(t *testing.T) {
commitSha := gittest.CreateCommitInAlternateObjectDirectory(t, cfg.Git.BinPath, repoPath, alternateObjDir, cmd)
originalAlternatesCommit := string(commitSha)
- require.NoError(t, ioutil.WriteFile(alternatesPath, []byte(alternateObjPath), 0o644))
+ require.NoError(t, os.WriteFile(alternatesPath, []byte(alternateObjPath), 0o644))
_, repoCopyPath := copyRepoUsingSnapshot(t, cfg, client, testRepo)
diff --git a/internal/gitaly/service/server/info.go b/internal/gitaly/service/server/info.go
index 509e9e70a..11ade3b35 100644
--- a/internal/gitaly/service/server/info.go
+++ b/internal/gitaly/service/server/info.go
@@ -2,7 +2,6 @@ package server
import (
"context"
- "io/ioutil"
"os"
"path/filepath"
@@ -57,7 +56,7 @@ func shardCheck(shardPath string) (readable bool, writeable bool) {
testPath := filepath.Join(shardPath, "+testWrite")
content := []byte("testWrite")
- if err := ioutil.WriteFile(testPath, content, 0o644); err == nil {
+ if err := os.WriteFile(testPath, content, 0o644); err == nil {
writeable = true
}
_ = os.Remove(testPath)
diff --git a/internal/gitaly/service/smarthttp/inforefs_test.go b/internal/gitaly/service/smarthttp/inforefs_test.go
index c06b5274d..1746aca5d 100644
--- a/internal/gitaly/service/smarthttp/inforefs_test.go
+++ b/internal/gitaly/service/smarthttp/inforefs_test.go
@@ -6,7 +6,6 @@ import (
"errors"
"fmt"
"io"
- "io/ioutil"
"os"
"path/filepath"
"strings"
@@ -400,7 +399,7 @@ func createInvalidRepo(t testing.TB, repoDir string) func() {
func replaceCachedResponse(t testing.TB, ctx context.Context, cache *cache.DiskCache, req *gitalypb.InfoRefsRequest, newContents string) {
path := pathToCachedResponse(t, ctx, cache, req)
- require.NoError(t, ioutil.WriteFile(path, []byte(newContents), 0o644))
+ require.NoError(t, os.WriteFile(path, []byte(newContents), 0o644))
}
func setInfoRefsUploadPackMethod(ctx context.Context) context.Context {
diff --git a/internal/gitaly/service/smarthttp/receive_pack_test.go b/internal/gitaly/service/smarthttp/receive_pack_test.go
index 8de40ac40..94198e6db 100644
--- a/internal/gitaly/service/smarthttp/receive_pack_test.go
+++ b/internal/gitaly/service/smarthttp/receive_pack_test.go
@@ -5,7 +5,6 @@ import (
"context"
"fmt"
"io"
- "io/ioutil"
"os"
"path/filepath"
"strings"
@@ -214,7 +213,7 @@ func TestFailedReceivePackRequestDueToHooksFailure(t *testing.T) {
require.NoError(t, os.MkdirAll(hooks.Path(cfg), 0o755))
hookContent := []byte("#!/bin/sh\nexit 1")
- require.NoError(t, ioutil.WriteFile(filepath.Join(hooks.Path(cfg), "pre-receive"), hookContent, 0o755))
+ require.NoError(t, os.WriteFile(filepath.Join(hooks.Path(cfg), "pre-receive"), hookContent, 0o755))
serverSocketPath := runSmartHTTPServer(t, cfg)
@@ -306,7 +305,7 @@ func createCommit(t *testing.T, cfg config.Cfg, repoPath string, fileContents []
oldHead = text.ChompBytes(gittest.Exec(t, cfg, "-C", repoPath, "rev-parse", "master"))
changedFile := "README.md"
- require.NoError(t, ioutil.WriteFile(filepath.Join(repoPath, changedFile), fileContents, 0o644))
+ require.NoError(t, os.WriteFile(filepath.Join(repoPath, changedFile), fileContents, 0o644))
gittest.Exec(t, cfg, "-C", repoPath, "add", changedFile)
gittest.Exec(t, cfg, "-C", repoPath,
diff --git a/internal/gitaly/service/ssh/receive_pack_test.go b/internal/gitaly/service/ssh/receive_pack_test.go
index a778d047c..d13dfa69a 100644
--- a/internal/gitaly/service/ssh/receive_pack_test.go
+++ b/internal/gitaly/service/ssh/receive_pack_test.go
@@ -5,7 +5,6 @@ import (
"context"
"fmt"
"io"
- "io/ioutil"
"os"
"os/exec"
"path/filepath"
@@ -197,7 +196,7 @@ func TestReceivePackPushHookFailure(t *testing.T) {
require.NoError(t, os.MkdirAll(hooks.Path(cfg), 0o755))
hookContent := []byte("#!/bin/sh\nexit 1")
- require.NoError(t, ioutil.WriteFile(filepath.Join(hooks.Path(cfg), "pre-receive"), hookContent, 0o755))
+ require.NoError(t, os.WriteFile(filepath.Join(hooks.Path(cfg), "pre-receive"), hookContent, 0o755))
_, _, err := testCloneAndPush(t, cfg, cfg.Storages[0].Path, serverSocketPath, repo, pushParams{storageName: cfg.Storages[0].Name, glID: "1"})
require.Error(t, err)
@@ -617,7 +616,7 @@ func makeCommit(t *testing.T, cfg config.Cfg, localRepoPath string) ([]byte, []b
newFilePath := localRepoPath + "/foo.txt"
// Create a tiny file and add it to the index
- require.NoError(t, ioutil.WriteFile(newFilePath, []byte("foo bar"), 0o644))
+ require.NoError(t, os.WriteFile(newFilePath, []byte("foo bar"), 0o644))
gittest.Exec(t, cfg, "-C", localRepoPath, "add", ".")
// The latest commit ID on the remote repo
diff --git a/internal/gitaly/transaction/voting_test.go b/internal/gitaly/transaction/voting_test.go
index 8912a3032..434c9374e 100644
--- a/internal/gitaly/transaction/voting_test.go
+++ b/internal/gitaly/transaction/voting_test.go
@@ -3,7 +3,7 @@ package transaction
import (
"context"
"fmt"
- "io/ioutil"
+ "os"
"path/filepath"
"testing"
@@ -198,7 +198,7 @@ func TestCommitLockedFile(t *testing.T) {
VoteFn: func(context.Context, txinfo.Transaction, voting.Vote) error {
// This shouldn't typically happen given that the file is locked,
// but we concurrently update the file after our first vote.
- require.NoError(t, ioutil.WriteFile(file, []byte("something"),
+ require.NoError(t, os.WriteFile(file, []byte("something"),
0o666))
return nil
},
diff --git a/internal/gitlab/test_server.go b/internal/gitlab/test_server.go
index 5e43f7556..7de3fc7ae 100644
--- a/internal/gitlab/test_server.go
+++ b/internal/gitlab/test_server.go
@@ -6,7 +6,6 @@ import (
"encoding/base64"
"encoding/json"
"fmt"
- "io/ioutil"
"net"
"net/http"
"net/http/httptest"
@@ -31,7 +30,7 @@ func WriteShellSecretFile(t testing.TB, dir, secretToken string) string {
require.NoError(t, os.MkdirAll(dir, os.ModeDir))
filePath := filepath.Join(dir, ".gitlab_shell_secret")
- require.NoError(t, ioutil.WriteFile(filePath, []byte(secretToken), 0o644))
+ require.NoError(t, os.WriteFile(filePath, []byte(secretToken), 0o644))
return filePath
}
diff --git a/internal/safe/file_writer_test.go b/internal/safe/file_writer_test.go
index d6c83ab03..1f2e6cd60 100644
--- a/internal/safe/file_writer_test.go
+++ b/internal/safe/file_writer_test.go
@@ -49,7 +49,7 @@ func TestFileWriter_mode(t *testing.T) {
dir := testhelper.TempDir(t)
target := filepath.Join(dir, "file")
- require.NoError(t, ioutil.WriteFile(target, []byte("contents"), 0o600))
+ require.NoError(t, os.WriteFile(target, []byte("contents"), 0o600))
writer, err := safe.NewFileWriter(target, safe.FileWriterConfig{
FileMode: 0o060,
diff --git a/internal/safe/locking_file_writer_test.go b/internal/safe/locking_file_writer_test.go
index bf813a2d3..152c63d94 100644
--- a/internal/safe/locking_file_writer_test.go
+++ b/internal/safe/locking_file_writer_test.go
@@ -2,7 +2,6 @@ package safe_test
import (
"fmt"
- "io/ioutil"
"os"
"path/filepath"
"testing"
@@ -148,7 +147,7 @@ func TestLockingFileWriter_seedingWithExistingTarget(t *testing.T) {
t.Parallel()
target := filepath.Join(testhelper.TempDir(t), "file")
- require.NoError(t, ioutil.WriteFile(target, []byte("seed"), 0o644))
+ require.NoError(t, os.WriteFile(target, []byte("seed"), 0o644))
writer, err := safe.NewLockingFileWriter(target, safe.LockingFileWriterConfig{
SeedContents: true,
@@ -166,7 +165,7 @@ func TestLockingFileWriter_modifiesExistingFiles(t *testing.T) {
t.Parallel()
target := filepath.Join(testhelper.TempDir(t), "file")
- require.NoError(t, ioutil.WriteFile(target, []byte("preexisting"), 0o644))
+ require.NoError(t, os.WriteFile(target, []byte("preexisting"), 0o644))
writer, err := safe.NewLockingFileWriter(target)
require.NoError(t, err)
@@ -182,7 +181,7 @@ func TestLockingFileWriter_modifiesExistingFilesWithMode(t *testing.T) {
t.Parallel()
target := filepath.Join(testhelper.TempDir(t), "file")
- require.NoError(t, ioutil.WriteFile(target, []byte("preexisting"), 0o644))
+ require.NoError(t, os.WriteFile(target, []byte("preexisting"), 0o644))
writer, err := safe.NewLockingFileWriter(target, safe.LockingFileWriterConfig{
FileWriterConfig: safe.FileWriterConfig{FileMode: 0o060},
@@ -205,7 +204,7 @@ func TestLockingFileWriter_concurrentCreation(t *testing.T) {
require.NoError(t, err)
// Create file concurrently.
- require.NoError(t, ioutil.WriteFile(target, []byte("concurrent"), 0o644))
+ require.NoError(t, os.WriteFile(target, []byte("concurrent"), 0o644))
require.Equal(t, fmt.Errorf("file concurrently created"), writer.Lock())
@@ -217,7 +216,7 @@ func TestLockingFileWriter_concurrentDeletion(t *testing.T) {
target := filepath.Join(testhelper.TempDir(t), "file")
- require.NoError(t, ioutil.WriteFile(target, []byte("base"), 0o644))
+ require.NoError(t, os.WriteFile(target, []byte("base"), 0o644))
writer, err := safe.NewLockingFileWriter(target)
require.NoError(t, err)
@@ -234,12 +233,12 @@ func TestLockingFileWriter_concurrentModification(t *testing.T) {
target := filepath.Join(testhelper.TempDir(t), "file")
- require.NoError(t, ioutil.WriteFile(target, []byte("base"), 0o644))
+ require.NoError(t, os.WriteFile(target, []byte("base"), 0o644))
writer, err := safe.NewLockingFileWriter(target)
require.NoError(t, err)
// Concurrently modify the file.
- require.NoError(t, ioutil.WriteFile(target, []byte("concurrent"), 0o644))
+ require.NoError(t, os.WriteFile(target, []byte("concurrent"), 0o644))
require.Equal(t, fmt.Errorf("file concurrently modified"), writer.Lock())
@@ -272,13 +271,13 @@ func TestLockingFileWriter_locked(t *testing.T) {
t.Parallel()
target := filepath.Join(testhelper.TempDir(t), "file")
- require.NoError(t, ioutil.WriteFile(target, []byte("base"), 0o644))
+ require.NoError(t, os.WriteFile(target, []byte("base"), 0o644))
writer, err := safe.NewLockingFileWriter(target)
require.NoError(t, err)
// Concurrently lock the file.
- require.NoError(t, ioutil.WriteFile(target+".lock", nil, 0o644))
+ require.NoError(t, os.WriteFile(target+".lock", nil, 0o644))
require.Equal(t, fmt.Errorf("file already locked"), writer.Lock())
@@ -291,7 +290,7 @@ func TestLockingFileWriter_externalProcess(t *testing.T) {
cfg := testcfg.Build(t)
target := filepath.Join(testhelper.TempDir(t), "file")
- require.NoError(t, ioutil.WriteFile(target, []byte("base"), 0o644))
+ require.NoError(t, os.WriteFile(target, []byte("base"), 0o644))
writer, err := safe.NewLockingFileWriter(target)
require.NoError(t, err)
diff --git a/internal/streamcache/filestore_test.go b/internal/streamcache/filestore_test.go
index f9ff5826a..b5c1f055e 100644
--- a/internal/streamcache/filestore_test.go
+++ b/internal/streamcache/filestore_test.go
@@ -2,7 +2,6 @@ package streamcache
import (
"fmt"
- "io/ioutil"
"os"
"path/filepath"
"regexp"
@@ -110,7 +109,7 @@ func TestFilestoreCleanwalk(t *testing.T) {
file := filepath.Join(dir2, "file")
require.NoError(t, os.Mkdir(dir1, 0o755))
require.NoError(t, os.Mkdir(dir2, 0o755))
- require.NoError(t, ioutil.WriteFile(file, nil, 0o644))
+ require.NoError(t, os.WriteFile(file, nil, 0o644))
require.NoError(t, os.Chmod(dir2, 0), "create dir with pathological permissions")
require.NoError(t, fs.cleanWalk(time.Now().Add(time.Hour)))
diff --git a/internal/tempdir/clean_test.go b/internal/tempdir/clean_test.go
index 98bf9936c..46bf58a6d 100644
--- a/internal/tempdir/clean_test.go
+++ b/internal/tempdir/clean_test.go
@@ -139,7 +139,7 @@ func makeFile(t *testing.T, locator storage.Locator, storage config.Storage, fil
require.NoError(t, err)
fullPath := filepath.Join(root, filePath)
- require.NoError(t, ioutil.WriteFile(fullPath, nil, 0o644))
+ require.NoError(t, os.WriteFile(fullPath, nil, 0o644))
require.NoError(t, os.Chtimes(fullPath, mtime, mtime))
}
diff --git a/internal/tempdir/tempdir_test.go b/internal/tempdir/tempdir_test.go
index 7db046a29..c474bee4f 100644
--- a/internal/tempdir/tempdir_test.go
+++ b/internal/tempdir/tempdir_test.go
@@ -1,7 +1,7 @@
package tempdir
import (
- "io/ioutil"
+ "os"
"path/filepath"
"testing"
@@ -27,7 +27,7 @@ func TestNewRepositorySuccess(t *testing.T) {
require.NoError(t, err)
require.Equal(t, tempDir.Path(), calculatedPath)
- require.NoError(t, ioutil.WriteFile(filepath.Join(tempDir.Path(), "test"), []byte("hello"), 0o644))
+ require.NoError(t, os.WriteFile(filepath.Join(tempDir.Path(), "test"), []byte("hello"), 0o644))
require.DirExists(t, tempDir.Path())
diff --git a/internal/testhelper/testcfg/gitaly_builder.go b/internal/testhelper/testcfg/gitaly_builder.go
index 6d65556a2..2dc48643c 100644
--- a/internal/testhelper/testcfg/gitaly_builder.go
+++ b/internal/testhelper/testcfg/gitaly_builder.go
@@ -1,7 +1,6 @@
package testcfg
import (
- "io/ioutil"
"os"
"path/filepath"
"testing"
@@ -125,7 +124,7 @@ func (gc *GitalyCfgBuilder) Build(t testing.TB) config.Cfg {
if cfg.Ruby.LinguistLanguagesPath == "" {
// set a stub to prevent a long ruby process to run where it is not needed
cfg.Ruby.LinguistLanguagesPath = filepath.Join(root, "linguist_languages.json")
- require.NoError(t, ioutil.WriteFile(cfg.Ruby.LinguistLanguagesPath, []byte(`{}`), 0o655))
+ require.NoError(t, os.WriteFile(cfg.Ruby.LinguistLanguagesPath, []byte(`{}`), 0o655))
}
}
diff --git a/internal/testhelper/testhelper.go b/internal/testhelper/testhelper.go
index 53b89f043..1c452e85a 100644
--- a/internal/testhelper/testhelper.go
+++ b/internal/testhelper/testhelper.go
@@ -12,7 +12,6 @@ import (
"encoding/pem"
"fmt"
"io"
- "io/ioutil"
"math/big"
"net"
"os"
@@ -275,7 +274,7 @@ func WriteExecutable(t testing.TB, path string, content []byte) {
dir := filepath.Dir(path)
require.NoError(t, os.MkdirAll(dir, 0o755))
- require.NoError(t, ioutil.WriteFile(path, content, 0o755))
+ require.NoError(t, os.WriteFile(path, content, 0o755))
t.Cleanup(func() {
assert.NoError(t, os.RemoveAll(dir))