diff --git a/.gitignore b/.gitignore index f6d2d428..a3678b33 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,5 @@ go.work.sum kubeconfig release + +bin/ diff --git a/driver/helpers.go b/driver/helpers.go index bccec8cc..7f090c71 100644 --- a/driver/helpers.go +++ b/driver/helpers.go @@ -1,7 +1,6 @@ package driver import ( - "errors" "fmt" "os" "path/filepath" @@ -112,23 +111,23 @@ func getNewVolumeSize(capacityRange *csi.CapacityRange) (int64, error) { } if requiredSet && limitSet && limitBytes < requiredBytes { - return 0, errors.New("limit size is less than required size") + return 0, errLimitLessThanRequiredBytes } if requiredSet && !limitSet && requiredBytes < MinimalVolumeSizeBytes { - return 0, errors.New("required size is less than the minimun size") + return 0, errRequiredBytesLessThanMinimun } if limitSet && limitBytes < MinimalVolumeSizeBytes { - return 0, errors.New("limit size is less than the minimun size") + return 0, errLimitLessThanMinimum } if requiredSet && requiredBytes > MaximumVolumeSizeBytes { - return 0, errors.New("required size is greater than the maximum size") + return 0, errRequiredBytesGreaterThanMaximun } if !requiredSet && limitSet && limitBytes > MaximumVolumeSizeBytes { - return 0, errors.New("limit size is greater than the maximum size") + return 0, errLimitGreaterThanMaximum } if requiredSet && limitSet && requiredBytes == limitBytes { diff --git a/go.mod b/go.mod index 25807dab..d3d0ba79 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,7 @@ require ( github.com/container-storage-interface/spec v1.8.0 github.com/exoscale/egoscale v0.102.4-0.20240117105256-1ace995a320f github.com/golang/protobuf v1.5.3 + github.com/stretchr/testify v1.8.2 golang.org/x/sys v0.15.0 google.golang.org/grpc v1.58.0 google.golang.org/protobuf v1.31.0 @@ -39,6 +40,7 @@ require ( github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect golang.org/x/crypto v0.17.0 // indirect golang.org/x/net v0.13.0 // indirect golang.org/x/oauth2 v0.10.0 // indirect diff --git a/vendor/modules.txt b/vendor/modules.txt index 2de17323..17280be0 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -96,6 +96,13 @@ github.com/modern-go/reflect2 # github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 ## explicit github.com/munnerz/goautoneg +# github.com/pmezard/go-difflib v1.0.0 +## explicit +github.com/pmezard/go-difflib/difflib +# github.com/stretchr/testify v1.8.2 +## explicit; go 1.13 +github.com/stretchr/testify/assert +github.com/stretchr/testify/require # golang.org/x/crypto v0.17.0 ## explicit; go 1.18 golang.org/x/crypto/sha3