Skip to content

Commit

Permalink
Merge pull request #45 from austinvazquez/remove-ioutil
Browse files Browse the repository at this point in the history
Remove references to io/ioutil package
  • Loading branch information
AkihiroSuda authored Jan 16, 2025
2 parents 4d71bc8 + 7bbea67 commit 8a6b752
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 11 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,25 @@ jobs:
with:
working-directory: src/github.com/containerd/fuse-overlayfs-snapshotter

linters:
name: Linters
permissions:
contents: read # for actions/checkout to fetch code
pull-requests: read # for golangci/golangci-lint-action to fetch pull requests
runs-on: ubuntu-22.04
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
with:
path: src/github.com/containerd/fuse-overlayfs-snapshotter
- uses: actions/setup-go@v5
with:
go-version: 1.21.x
- uses: golangci/golangci-lint-action@v6
with:
version: v1.63.4
working-directory: src/github.com/containerd/fuse-overlayfs-snapshotter

test:
runs-on: ubuntu-22.04
timeout-minutes: 30
Expand Down
25 changes: 25 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
linters:
enable:
- copyloopvar
- depguard
- gofmt
- gosec
- govet
- ineffassign
- misspell
- nolintlint
- staticcheck
- tenv
- unconvert
- unused
disable:
- errcheck
- revive

linters-settings:
depguard:
rules:
main:
deny:
- pkg: "io/ioutil"
desc: use "io" or "os" instead
3 changes: 1 addition & 2 deletions check.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ package fuseoverlayfs

import (
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
Expand All @@ -33,7 +32,7 @@ import (
// supportsReadonlyMultipleLowerDir checks if read-only multiple lowerdirs can be mounted with fuse-overlayfs.
// https://github.com/containers/fuse-overlayfs/pull/133
func supportsReadonlyMultipleLowerDir(d string) error {
td, err := ioutil.TempDir(d, "fuseoverlayfs-check")
td, err := os.MkdirTemp(d, "fuseoverlayfs-check")
if err != nil {
return err
}
Expand Down
3 changes: 1 addition & 2 deletions fuseoverlayfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ package fuseoverlayfs
import (
"context"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -417,7 +416,7 @@ func (o *snapshotter) createSnapshot(ctx context.Context, kind snapshots.Kind, k
}

func (o *snapshotter) prepareDirectory(ctx context.Context, snapshotDir string, kind snapshots.Kind) (string, error) {
td, err := ioutil.TempDir(snapshotDir, "new-")
td, err := os.MkdirTemp(snapshotDir, "new-")
if err != nil {
return "", fmt.Errorf("failed to create temp dir: %w", err)
}
Expand Down
8 changes: 1 addition & 7 deletions fuseoverlayfs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ package fuseoverlayfs
import (
"context"
_ "crypto/sha256"
"io/ioutil"
"os"
"testing"

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

func TestFUSEOverlayFS(t *testing.T) {
testutil.RequiresRoot(t)
td, err := ioutil.TempDir("", "fuseoverlayfs-test")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(td)
td := t.TempDir()
if err := Supported(td); err != nil {
t.Skipf("fuse-overlayfs not supported: %v", err)
}
Expand Down

0 comments on commit 8a6b752

Please sign in to comment.