Skip to content

Commit

Permalink
fix linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
aomerk committed Jan 8, 2024
1 parent 22cf78e commit 89579ac
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
23 changes: 7 additions & 16 deletions drivers/r2/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/aws/request"
"github.com/forta-network/disco/interfaces"
"github.com/hashicorp/go-multierror"

dcontext "github.com/distribution/distribution/v3/context"
storagedriver "github.com/distribution/distribution/v3/registry/storage/driver"
Expand Down Expand Up @@ -197,11 +198,6 @@ func FromParameters(parameters map[string]interface{}) (*Driver, error) {
return nil, fmt.Errorf("the skipVerify parameter should be a boolean")
}

keyID := parameters["keyid"]
if keyID == nil {
keyID = ""
}

chunkSize, err := getParameterAsInt64(parameters, "chunksize", defaultChunkSize, minChunkSize, maxChunkSize)
if err != nil {
return nil, err
Expand All @@ -227,11 +223,6 @@ func FromParameters(parameters map[string]interface{}) (*Driver, error) {
rootDirectory = ""
}

userAgent := parameters["useragent"]
if userAgent == nil {
userAgent = ""
}

params := DriverParameters{
AccessKey: fmt.Sprint(accessKey),
SecretKey: fmt.Sprint(secretKey),
Expand Down Expand Up @@ -704,13 +695,14 @@ func (d *driver) Delete(ctx context.Context, path string) error {
if len(resp.Errors) > 0 {
// NOTE: AWS SDK s3.Error does not implement error interface which
// is pretty intensely sad, so we have to do away with this for now.
errs := make([]error, 0, len(resp.Errors))
var errs multierror.Error
for _, err := range resp.Errors {
errs = append(errs, errors.New(*err.Message))
errs.Errors = append(errs.Errors, errors.New(*err.Message))
}

return storagedriver.Error{
DriverName: driverName,
// Errs: errs,
Enclosed: errs.Unwrap(),
}
}
}
Expand Down Expand Up @@ -875,7 +867,6 @@ func (d *driver) doWalk(parentCtx context.Context, objectCount *int64, path, pre
// is file, stop gracefully
return err
}
retError = err
return err
}
}
Expand Down Expand Up @@ -1025,7 +1016,7 @@ func (w *writer) Write(p []byte) (int, error) {
},
})
if err != nil {
w.driver.R2.AbortMultipartUpload(ctx, &s3.AbortMultipartUploadInput{
_, _ = w.driver.R2.AbortMultipartUpload(ctx, &s3.AbortMultipartUploadInput{
Bucket: aws.String(w.driver.Bucket),
Key: aws.String(w.key),
UploadId: aws.String(w.uploadID),
Expand Down Expand Up @@ -1207,7 +1198,7 @@ func (w *writer) Commit() error {
},
})
if err != nil {
w.driver.R2.AbortMultipartUpload(ctx, &s3.AbortMultipartUploadInput{
_, _ = w.driver.R2.AbortMultipartUpload(ctx, &s3.AbortMultipartUploadInput{
Bucket: aws.String(w.driver.Bucket),
Key: aws.String(w.key),
UploadId: aws.String(w.uploadID),
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/s3 v1.47.7
github.com/distribution/distribution/v3 v3.0.0-20210602065436-4f27e1934ccc
github.com/golang/mock v1.6.0
github.com/hashicorp/go-multierror v1.1.1
github.com/ipfs/go-cid v0.0.7
github.com/ipfs/go-ipfs-api v0.2.0
github.com/kelseyhightower/envconfig v1.4.0
Expand Down Expand Up @@ -58,6 +59,7 @@ require (
github.com/gomodule/redigo v1.8.2 // indirect
github.com/gorilla/handlers v1.5.1 // indirect
github.com/gorilla/mux v1.8.0 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/ipfs/go-ipfs-files v0.0.8 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ github.com/gorilla/handlers v1.5.1 h1:9lRY6j8DEeeBT10CvO9hGW0gmky0BprnvDI5vfhUHH
github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q=
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
Expand Down

0 comments on commit 89579ac

Please sign in to comment.