From ff17a79101fc3854e86b150fe1bcb5ef67dbde6c Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 25 May 2023 22:45:21 +0200 Subject: [PATCH 1/3] gofmt code Signed-off-by: Sebastiaan van Stijn --- zfs.go | 9 +++------ zfs_test.go | 4 ++-- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/zfs.go b/zfs.go index bd26aa2..e48b956 100644 --- a/zfs.go +++ b/zfs.go @@ -75,11 +75,9 @@ func NewSnapshotter(root string) (snapshots.Snapshotter, error) { return b, nil } -var ( - zfsCreateProperties = map[string]string{ - "mountpoint": "legacy", - } -) +var zfsCreateProperties = map[string]string{ + "mountpoint": "legacy", +} // createFilesystem creates but not mount. func createFilesystem(datasetName string) (*zfs.Dataset, error) { @@ -138,7 +136,6 @@ func (z *snapshotter) usage(ctx context.Context, key string) (snapshots.Usage, e if info.Kind == snapshots.KindActive { activeName := filepath.Join(z.dataset.Name, id) sDataset, err := zfs.GetDataset(activeName) - if err != nil { return snapshots.Usage{}, err } diff --git a/zfs_test.go b/zfs_test.go index b97326c..a58f6d8 100644 --- a/zfs_test.go +++ b/zfs_test.go @@ -142,7 +142,7 @@ func TestZFSUsage(t *testing.T) { ) // Create a child layer with a 1MB file - baseApplier := fstest.Apply(fstest.CreateRandomFile("/a", 12345679, oneMB, 0777)) + baseApplier := fstest.Apply(fstest.CreateRandomFile("/a", 12345679, oneMB, 0o777)) target = filepath.Join(root, "prepare-2") mounts, err := z.Prepare(ctx, target, filepath.Join(root, "layer-1")) @@ -172,7 +172,7 @@ func TestZFSUsage(t *testing.T) { } // Create another child layer with a 2MB file - baseApplier = fstest.Apply(fstest.CreateRandomFile("/b", 12345679, twoMB, 0777)) + baseApplier = fstest.Apply(fstest.CreateRandomFile("/b", 12345679, twoMB, 0o777)) target = filepath.Join(root, "prepare-3") mounts, err = z.Prepare(ctx, target, filepath.Join(root, "layer-2")) From 6e9c675d5fb46bfef3450b97dc66705b9b1c1257 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 25 May 2023 22:52:24 +0200 Subject: [PATCH 2/3] README: update badges - update badge for GHA (re-generated link) - add badge for documentation - add badge for GoreportCard Signed-off-by: Sebastiaan van Stijn --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3618fb6..b747037 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # [containerd](https://github.com/containerd/containerd) ZFS snapshotter plugin -[![Build Status](https://github.com/containerd/zfs/workflows/CI/badge.svg)](https://github.com/containerd/zfs/actions?query=workflow%3ACI) +[![PkgGoDev](https://pkg.go.dev/badge/github.com/containerd/zfs)](https://pkg.go.dev/github.com/containerd/zfs) +[![Build Status](https://github.com/containerd/zfs/actions/workflows/ci.yml/badge.svg)](https://github.com/containerd/zfs/actions/workflows/ci.yml) +[![Go Report Card](https://goreportcard.com/badge/github.com/containerd/zfs)](https://goreportcard.com/report/github.com/containerd/zfs) [![codecov](https://codecov.io/gh/containerd/zfs/branch/main/graph/badge.svg)](https://codecov.io/gh/containerd/zfs) ZFS snapshotter plugin for containerd. From 5e3457b5e3b8e586e7b634da7bb1d05bafa7af97 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 25 May 2023 23:00:20 +0200 Subject: [PATCH 3/3] TestZFSUsage: use t.TempDir() Signed-off-by: Sebastiaan van Stijn --- zfs_test.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/zfs_test.go b/zfs_test.go index a58f6d8..991fc62 100644 --- a/zfs_test.go +++ b/zfs_test.go @@ -101,11 +101,7 @@ func TestZFSUsage(t *testing.T) { ctx := context.Background() // Create temporary directory - root, err := os.MkdirTemp("", "TestZFSUsage-") - if err != nil { - t.Error(err) - } - defer os.RemoveAll(root) + root := t.TempDir() // Create the snapshotter z, closer, err := newSnapshotter()(ctx, root)