Skip to content

Commit 8a6b752

Browse files
authored
Merge pull request #45 from austinvazquez/remove-ioutil
Remove references to io/ioutil package
2 parents 4d71bc8 + 7bbea67 commit 8a6b752

File tree

5 files changed

+47
-11
lines changed

5 files changed

+47
-11
lines changed

.github/workflows/main.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,25 @@ jobs:
2222
with:
2323
working-directory: src/github.com/containerd/fuse-overlayfs-snapshotter
2424

25+
linters:
26+
name: Linters
27+
permissions:
28+
contents: read # for actions/checkout to fetch code
29+
pull-requests: read # for golangci/golangci-lint-action to fetch pull requests
30+
runs-on: ubuntu-22.04
31+
timeout-minutes: 10
32+
steps:
33+
- uses: actions/checkout@v4
34+
with:
35+
path: src/github.com/containerd/fuse-overlayfs-snapshotter
36+
- uses: actions/setup-go@v5
37+
with:
38+
go-version: 1.21.x
39+
- uses: golangci/golangci-lint-action@v6
40+
with:
41+
version: v1.63.4
42+
working-directory: src/github.com/containerd/fuse-overlayfs-snapshotter
43+
2544
test:
2645
runs-on: ubuntu-22.04
2746
timeout-minutes: 30

.golangci.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
linters:
2+
enable:
3+
- copyloopvar
4+
- depguard
5+
- gofmt
6+
- gosec
7+
- govet
8+
- ineffassign
9+
- misspell
10+
- nolintlint
11+
- staticcheck
12+
- tenv
13+
- unconvert
14+
- unused
15+
disable:
16+
- errcheck
17+
- revive
18+
19+
linters-settings:
20+
depguard:
21+
rules:
22+
main:
23+
deny:
24+
- pkg: "io/ioutil"
25+
desc: use "io" or "os" instead

check.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ package fuseoverlayfs
2121

2222
import (
2323
"fmt"
24-
"io/ioutil"
2524
"os"
2625
"os/exec"
2726
"path/filepath"
@@ -33,7 +32,7 @@ import (
3332
// supportsReadonlyMultipleLowerDir checks if read-only multiple lowerdirs can be mounted with fuse-overlayfs.
3433
// https://github.com/containers/fuse-overlayfs/pull/133
3534
func supportsReadonlyMultipleLowerDir(d string) error {
36-
td, err := ioutil.TempDir(d, "fuseoverlayfs-check")
35+
td, err := os.MkdirTemp(d, "fuseoverlayfs-check")
3736
if err != nil {
3837
return err
3938
}

fuseoverlayfs.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ package fuseoverlayfs
2222
import (
2323
"context"
2424
"fmt"
25-
"io/ioutil"
2625
"os"
2726
"path/filepath"
2827
"strings"
@@ -417,7 +416,7 @@ func (o *snapshotter) createSnapshot(ctx context.Context, kind snapshots.Kind, k
417416
}
418417

419418
func (o *snapshotter) prepareDirectory(ctx context.Context, snapshotDir string, kind snapshots.Kind) (string, error) {
420-
td, err := ioutil.TempDir(snapshotDir, "new-")
419+
td, err := os.MkdirTemp(snapshotDir, "new-")
421420
if err != nil {
422421
return "", fmt.Errorf("failed to create temp dir: %w", err)
423422
}

fuseoverlayfs_test.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ package fuseoverlayfs
2222
import (
2323
"context"
2424
_ "crypto/sha256"
25-
"io/ioutil"
26-
"os"
2725
"testing"
2826

2927
"github.com/containerd/containerd/v2/core/snapshots"
@@ -42,11 +40,7 @@ func newSnapshotter(ctx context.Context, root string) (snapshots.Snapshotter, fu
4240

4341
func TestFUSEOverlayFS(t *testing.T) {
4442
testutil.RequiresRoot(t)
45-
td, err := ioutil.TempDir("", "fuseoverlayfs-test")
46-
if err != nil {
47-
t.Fatal(err)
48-
}
49-
defer os.RemoveAll(td)
43+
td := t.TempDir()
5044
if err := Supported(td); err != nil {
5145
t.Skipf("fuse-overlayfs not supported: %v", err)
5246
}

0 commit comments

Comments
 (0)