Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Storage Driver: Minio #962

Merged
merged 38 commits into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
21eb34f
minio
mstgnz Aug 23, 2023
23de4dd
Fix README
mstgnz Aug 23, 2023
580a711
Fix README
mstgnz Aug 23, 2023
bec8bb6
Merge branch 'main' into main
mstgnz Aug 23, 2023
d3d3a58
Added Conn method to return the Minio instance
mstgnz Aug 23, 2023
7f002b3
go mod tidy
mstgnz Aug 23, 2023
244330f
Added to Minio storage
mstgnz Aug 23, 2023
5b49d36
added to minio gosec and depeddabot and drafter
mstgnz Aug 23, 2023
4493457
minio test
mstgnz Aug 23, 2023
68fe393
minio drafter
mstgnz Aug 23, 2023
dab578a
gosec
mstgnz Aug 23, 2023
d62aeb5
Merge branch 'main' into main
mstgnz Aug 23, 2023
b3fe37d
change go version
mstgnz Aug 23, 2023
b2636aa
Merge branch 'main' of github.com:mstgnz/fiber-storage
mstgnz Aug 23, 2023
b597a36
The stretchr/testify package was used for testing
mstgnz Aug 23, 2023
dda7fcf
The Reset flag added to New flag
mstgnz Aug 23, 2023
fd63105
min go version supported added to README
mstgnz Aug 23, 2023
cd33dc9
test fixed
mstgnz Aug 23, 2023
d64fa18
fixed test
mstgnz Aug 23, 2023
4c8f4dc
fix minio test
mstgnz Aug 23, 2023
0ccc5d3
UPDATE README
mstgnz Aug 23, 2023
ca32702
Update README
mstgnz Aug 25, 2023
949c597
definitions added
mstgnz Aug 25, 2023
3d59844
updated test for key not in get requests
mstgnz Aug 25, 2023
c49bca7
change to default bucket name - fiber-bucket
mstgnz Aug 26, 2023
e0523db
update comment for CheckBucket
mstgnz Aug 26, 2023
cb6a705
Update README
mstgnz Aug 26, 2023
cdad223
update comment
mstgnz Aug 26, 2023
67218b0
bucket check control removed and update test
mstgnz Aug 26, 2023
1887a32
update credentials key name
mstgnz Aug 29, 2023
edf7bf2
added yo bytebufferpool
mstgnz Aug 29, 2023
f4a12a2
Merge branch 'main' into main
mstgnz Aug 29, 2023
79fdc2e
fix get
mstgnz Aug 31, 2023
fee5f98
Merge branch 'main' into main
mstgnz Sep 2, 2023
6eba76b
fix bytebufferpool
mstgnz Sep 3, 2023
2e2f6ca
Merge branch 'main' into main
mstgnz Sep 4, 2023
8400db5
Update test-minio.yml
gaby Sep 4, 2023
b6dbad7
Update test-minio.yml
gaby Sep 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion minio/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ module github.com/gofiber/storage/minio
go 1.19

require (
github.com/gofiber/utils v1.1.0
github.com/minio/minio-go/v7 v7.0.62
github.com/stretchr/testify v1.8.4
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
Expand All @@ -17,11 +18,13 @@ require (
github.com/minio/sha256-simd v1.0.1 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rs/xid v1.5.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
golang.org/x/crypto v0.12.0 // indirect
golang.org/x/net v0.14.0 // indirect
golang.org/x/sys v0.11.0 // indirect
golang.org/x/text v0.12.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
9 changes: 5 additions & 4 deletions minio/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/gofiber/utils v1.1.0 h1:vdEBpn7AzIUJRhe+CiTOJdUcTg4Q9RK+pEa0KPbLdrM=
github.com/gofiber/utils v1.1.0/go.mod h1:poZpsnhBykfnY1Mc0KeEa6mSHrS3dV0+oBWyeQmb2e0=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
Expand Down Expand Up @@ -34,8 +32,9 @@ github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk=
golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw=
golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14=
Expand All @@ -46,8 +45,10 @@ golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc=
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
58 changes: 32 additions & 26 deletions minio/minio_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"testing"
"time"

"github.com/gofiber/utils"
"github.com/stretchr/testify/require"
)

var testStore = New(
Expand All @@ -26,25 +26,24 @@ func Test_Get(t *testing.T) {
)

err := testStore.Set(key, val, 0)
utils.AssertEqual(t, nil, err)
require.NoError(t, err)

result, err := testStore.Get(key)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, val, result)
require.NoError(t, err)
require.Equal(t, val, result)

result, err = testStore.Get("doe")
utils.AssertEqual(t, true, len(result) == 0)
gaby marked this conversation as resolved.
Show resolved Hide resolved
utils.AssertEqual(t, true, len(err.Error()) > 0)
require.Error(t, err)
}

func Test_Get_Empty_Key(t *testing.T) {
var (
key = ""
)

result, err := testStore.Get(key)
utils.AssertEqual(t, true, len(result) == 0)
utils.AssertEqual(t, "the key value is required", err.Error())
_, err := testStore.Get(key)
require.Error(t, err)
require.EqualError(t, err, "the key value is required")

}

Expand All @@ -56,9 +55,9 @@ func Test_Get_Not_Exists_Bucket(t *testing.T) {
// random bucket name
testStore.cfg.Bucket = strconv.FormatInt(time.Now().UnixMicro(), 10)

result, err := testStore.Get(key)
utils.AssertEqual(t, true, len(result) == 0)
utils.AssertEqual(t, "the specified bucket does not exist", err.Error())
_, err := testStore.Get(key)
gaby marked this conversation as resolved.
Show resolved Hide resolved
require.Error(t, err)
require.EqualError(t, err, "the specified bucket does not exist")

testStore.cfg.Bucket = "test-bucket"

Expand All @@ -71,7 +70,7 @@ func Test_Set(t *testing.T) {
)

err := testStore.Set(key, val, 0)
utils.AssertEqual(t, nil, err)
require.NoError(t, err)
}

func Test_Set_Empty_Key(t *testing.T) {
Expand All @@ -81,7 +80,9 @@ func Test_Set_Empty_Key(t *testing.T) {
)

err := testStore.Set(key, val, 0)
utils.AssertEqual(t, "the key value is required", err.Error())

require.Error(t, err)
require.EqualError(t, err, "the key value is required")

}

Expand All @@ -95,15 +96,15 @@ func Test_Set_Not_Exists_Bucket(t *testing.T) {
testStore.cfg.Bucket = strconv.FormatInt(time.Now().UnixMicro(), 10)

err := testStore.Set(key, val, 0)
utils.AssertEqual(t, nil, err)
require.NoError(t, err)

// remove object
err = testStore.Delete(key)
utils.AssertEqual(t, nil, err)
require.NoError(t, err)

// remove bucket
err = testStore.RemoveBucket()
utils.AssertEqual(t, nil, err)
require.NoError(t, err)

testStore.cfg.Bucket = "test-bucket"
}
Expand All @@ -115,10 +116,10 @@ func Test_Delete(t *testing.T) {
)

err := testStore.Set(key, val, 0)
utils.AssertEqual(t, nil, err)
require.NoError(t, err)

err = testStore.Delete(key)
utils.AssertEqual(t, nil, err)
require.NoError(t, err)

}

Expand All @@ -129,7 +130,9 @@ func Test_Delete_Empty_Key(t *testing.T) {
)

err := testStore.Set(key, val, 0)
utils.AssertEqual(t, "the key value is required", err.Error())

require.Error(t, err)
require.EqualError(t, err, "the key value is required")

}

Expand All @@ -142,7 +145,9 @@ func Test_Delete_Not_Exists_Bucket(t *testing.T) {
testStore.cfg.Bucket = strconv.FormatInt(time.Now().UnixMicro(), 10)

err := testStore.Delete(key)
utils.AssertEqual(t, "the specified bucket does not exist", err.Error())

require.Error(t, err)
require.EqualError(t, err, "the specified bucket does not exist")

testStore.cfg.Bucket = "test-bucket"

Expand All @@ -154,19 +159,20 @@ func Test_Reset(t *testing.T) {
)

err := testStore.Set("john1", val, 0)
utils.AssertEqual(t, nil, err)
require.NoError(t, err)

err = testStore.Set("john2", val, 0)
utils.AssertEqual(t, nil, err)
require.NoError(t, err)

err = testStore.Reset()
utils.AssertEqual(t, nil, err)
require.NoError(t, err)

result, err := testStore.Get("john1")
utils.AssertEqual(t, true, len(result) == 0)
require.Error(t, err)
require.True(t, len(result) == 0)
gaby marked this conversation as resolved.
Show resolved Hide resolved

}

func Test_Close(t *testing.T) {
utils.AssertEqual(t, nil, testStore.Close())
require.NoError(t, testStore.Close())
}