Skip to content

Commit

Permalink
chore: update dependencies (#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbarrosop authored Oct 3, 2022
1 parent 7500dd4 commit 2eb2eb7
Show file tree
Hide file tree
Showing 407 changed files with 23,638 additions and 8,384 deletions.
26 changes: 14 additions & 12 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,22 @@
linters:
enable-all: true
disable:
# - gochecknoglobals
# - gochecknoinits
# - lll
# - gomnd
# - gofumpt
# - paralleltest
# - testpackage
# - forbidigo
- varnamelen
- gomoddirectives
- nlreturn
- wsl
- exhaustivestruct
- maligned # deprecated
- scopelint # deprecated
- interfacer # deprecated
- golint # deprecated
- maligned # deprecated
- scopelint # deprecated
- interfacer # deprecated
- golint # deprecated
- varcheck # deprecated
- ifshort # deprecated
- deadcode # deprecated
- nosnakecase # deprecated
- structcheck # deprecated
- usestdlibvars # needs to be fixed
- exhaustruct # needs to be fixed

issues:
exclude-rules:
Expand All @@ -36,3 +35,6 @@ issues:
linters:
- funlen
- ireturn
- path: image/image.go
linters:
- nosnakecase
5 changes: 0 additions & 5 deletions build/dev/jwt-gen/build.sh

This file was deleted.

2 changes: 1 addition & 1 deletion build/dev/jwt-gen/get-jwt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ cd $(dirname $0)

JWT_SECRET=$(docker exec hasura-storage-graphql bash -c 'echo "$HASURA_GRAPHQL_JWT_SECRET"')

./jwt-gen.`uname`.`uname -m` -jwt-secret "$JWT_SECRET"
go run main.go -jwt-secret "$JWT_SECRET"
Binary file removed build/dev/jwt-gen/jwt-gen.Darwin.arm64
Binary file not shown.
Binary file removed build/dev/jwt-gen/jwt-gen.Darwin.x86_64
Binary file not shown.
Binary file removed build/dev/jwt-gen/jwt-gen.Linux.aarch64
Binary file not shown.
Binary file removed build/dev/jwt-gen/jwt-gen.Linux.x86_64
Binary file not shown.
2 changes: 1 addition & 1 deletion build/dev/jwt-gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func main() {

now := time.Now()
iat := now.Unix()
exp := now.Add(15 * time.Minute).Unix()
exp := now.Add(24 * 365 * 10 * time.Hour).Unix()

// Create the Claims
claims := &jwt.MapClaims{
Expand Down
6 changes: 2 additions & 4 deletions client/get_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"mime"
"net/http"

Expand All @@ -19,7 +18,7 @@ type FileInformationHeaderWithReader struct {
}

func unmarshalGetFileError(resp *http.Response) error {
b, err := ioutil.ReadAll(resp.Body)
b, err := io.ReadAll(resp.Body)
if err != nil {
return fmt.Errorf("got an error but failed to read the body: %w", err)
}
Expand Down Expand Up @@ -47,8 +46,7 @@ func parseFilename(resp *http.Response) (string, error) {
return filename, nil
}

// nolint: cyclop
func (c *Client) GetFile(
func (c *Client) GetFile( //nolint: cyclop
ctx context.Context, fileID string, opts ...GetFileInformationOpt,
) (*FileInformationHeaderWithReader, error) {
req, err := http.NewRequestWithContext(ctx, "GET", c.baseURL+"/files/"+fileID, nil)
Expand Down
2 changes: 1 addition & 1 deletion cmd/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "github.com/sirupsen/logrus"

func getLogger() *logrus.Logger {
logger := logrus.New()
logger.SetFormatter(&logrus.TextFormatter{ // nolint:exhaustivestruct
logger.SetFormatter(&logrus.TextFormatter{ //nolint:exhaustivestruct
FullTimestamp: true,
})

Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var (

// Execute executes the root command.
func Execute() error {
return rootCmd.Execute() // nolint: wrapcheck
return rootCmd.Execute() //nolint: wrapcheck
}

func init() {
Expand Down
8 changes: 4 additions & 4 deletions cmd/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ const (
trustedProxiesFlag = "trusted-proxies"
hasuraEndpointFlag = "hasura-endpoint"
hasuraMetadataFlag = "hasura-metadata"
hasuraAdminSecretFlag = "hasura-graphql-admin-secret" // nolint: gosec
hasuraAdminSecretFlag = "hasura-graphql-admin-secret" //nolint: gosec
s3EndpointFlag = "s3-endpoint"
s3AccessKeyFlag = "s3-access-key"
s3SecretKeyFlag = "s3-secret-key" // nolint: gosec
s3SecretKeyFlag = "s3-secret-key" //nolint: gosec
s3RegionFlag = "s3-region"
s3BucketFlag = "s3-bucket"
s3RootFolderFlag = "s3-root-folder"
Expand Down Expand Up @@ -98,7 +98,7 @@ func getGin(
middlewares = append(middlewares, fastly.New(fastlyService, viper.GetString(fastlyKeyFlag), logger))
}

return ctrl.SetupRouter(trustedProxies, apiRootPrefix, middlewares...) // nolint: wrapcheck
return ctrl.SetupRouter(trustedProxies, apiRootPrefix, middlewares...) //nolint: wrapcheck
}

func getMetadataStorage(endpoint string) *metadata.Hasura {
Expand All @@ -108,7 +108,7 @@ func getMetadataStorage(endpoint string) *metadata.Hasura {
func getContentStorage(
s3Endpoint, region, s3AccessKey, s3SecretKey, bucket, rootFolder string, logger *logrus.Logger,
) *storage.S3 {
config := &aws.Config{ // nolint: exhaustivestruct
config := &aws.Config{ //nolint: exhaustivestruct
Credentials: credentials.NewStaticCredentials(s3AccessKey, s3SecretKey, ""),
Endpoint: aws.String(s3Endpoint),
Region: aws.String(region),
Expand Down
8 changes: 4 additions & 4 deletions controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type FileMetadataWithBucket struct {
Bucket BucketMetadata
}

//go:generate mockgen --build_flags=--mod=mod -destination mock_controller/metadata_storage.go -package mock_controller . MetadataStorage
//go:generate mockgen --build_flags=--mod=mod -destination mock/metadata_storage.go -package mock . MetadataStorage
type MetadataStorage interface {
GetBucketByID(ctx context.Context, id string, headers http.Header) (BucketMetadata, *APIError)
GetFileByID(ctx context.Context, id string, headers http.Header) (FileMetadata, *APIError)
Expand All @@ -64,7 +64,7 @@ type MetadataStorage interface {
ListFiles(ctx context.Context, headers http.Header) ([]FileSummary, *APIError)
}

//go:generate mockgen --build_flags=--mod=mod -destination mock_controller/content_storage.go -package mock_controller . ContentStorage
//go:generate mockgen --build_flags=--mod=mod -destination mock/content_storage.go -package mock . ContentStorage
type ContentStorage interface {
PutFile(content io.ReadSeeker, filepath, contentType string) (string, *APIError)
GetFile(filepath string, headers http.Header) (*File, *APIError)
Expand Down Expand Up @@ -114,7 +114,7 @@ func (ctrl *Controller) SetupRouter(
return nil, fmt.Errorf("problem setting trusted proxies: %w", err)
}

router.MaxMultipartMemory = 1000 << 20 // nolint:gomnd // 1GB
router.MaxMultipartMemory = 1000 << 20 //nolint:gomnd // 1GB
router.Use(gin.Recovery())

for _, mw := range middleware {
Expand All @@ -132,7 +132,7 @@ func (ctrl *Controller) SetupRouter(
ExposeHeaders: []string{
"Content-Length", "Content-Type", "Cache-Control", "ETag", "Last-Modified", "X-Error",
},
MaxAge: 12 * time.Hour, // nolint: gomnd
MaxAge: 12 * time.Hour, //nolint: gomnd
}))

router.GET("/healthz", ctrl.Health)
Expand Down
6 changes: 3 additions & 3 deletions controller/delete_broken_metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

"github.com/golang/mock/gomock"
"github.com/nhost/hasura-storage/controller"
"github.com/nhost/hasura-storage/controller/mock_controller"
"github.com/nhost/hasura-storage/controller/mock"
"github.com/sirupsen/logrus"
)

Expand Down Expand Up @@ -54,8 +54,8 @@ func TestDeleteBrokenMetadata(t *testing.T) {
c := gomock.NewController(t)
defer c.Finish()

metadataStorage := mock_controller.NewMockMetadataStorage(c)
contentStorage := mock_controller.NewMockContentStorage(c)
metadataStorage := mock.NewMockMetadataStorage(c)
contentStorage := mock.NewMockContentStorage(c)

metadataStorage.EXPECT().ListFiles(
gomock.Any(), gomock.Any(),
Expand Down
6 changes: 3 additions & 3 deletions controller/delete_file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/golang/mock/gomock"
"github.com/nhost/hasura-storage/controller"
"github.com/nhost/hasura-storage/controller/mock_controller"
"github.com/nhost/hasura-storage/controller/mock"
"github.com/sirupsen/logrus"
)

Expand Down Expand Up @@ -38,8 +38,8 @@ func TestDeleteFile(t *testing.T) {
c := gomock.NewController(t)
defer c.Finish()

metadataStorage := mock_controller.NewMockMetadataStorage(c)
contentStorage := mock_controller.NewMockContentStorage(c)
metadataStorage := mock.NewMockMetadataStorage(c)
contentStorage := mock.NewMockContentStorage(c)

metadataStorage.EXPECT().DeleteFileByID(
gomock.Any(), "55af1e60-0f28-454e-885e-ea6aab2bb288", gomock.Any(),
Expand Down
6 changes: 3 additions & 3 deletions controller/delete_orphans_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

"github.com/golang/mock/gomock"
"github.com/nhost/hasura-storage/controller"
"github.com/nhost/hasura-storage/controller/mock_controller"
"github.com/nhost/hasura-storage/controller/mock"
"github.com/sirupsen/logrus"
)

Expand Down Expand Up @@ -41,8 +41,8 @@ func TestDeleteOrphans(t *testing.T) {
c := gomock.NewController(t)
defer c.Finish()

metadataStorage := mock_controller.NewMockMetadataStorage(c)
contentStorage := mock_controller.NewMockContentStorage(c)
metadataStorage := mock.NewMockMetadataStorage(c)
contentStorage := mock.NewMockContentStorage(c)

metadataStorage.EXPECT().ListFiles(
gomock.Any(), gomock.Any(),
Expand Down
20 changes: 10 additions & 10 deletions controller/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,43 +10,43 @@ var (
ErrMultipartFormFileNotFound = &APIError{
http.StatusBadRequest,
"file[] not found in Multipart form",
errors.New("file[] not found in Multipart form"), // nolint
errors.New("file[] not found in Multipart form"), //nolint
nil,
}
ErrMultipartFileWrong = &APIError{
http.StatusBadRequest,
"wrong file data in multipart form, one needs to be specified",
errors.New("wrong file data in multipart form, one needs to be specified"), // nolint
errors.New("wrong file data in multipart form, one needs to be specified"), //nolint
nil,
}
ErrWrongDate = &APIError{
http.StatusBadRequest,
"couldn't parse date",
errors.New("couldn't parse date"), // nolint
errors.New("couldn't parse date"), //nolint
nil,
}
ErrMetadataLength = &APIError{
http.StatusBadRequest,
"file metadata length doesn't match number of files in request",
errors.New("file metadata length doesn't match number of files in request"), // nolint
errors.New("file metadata length doesn't match number of files in request"), //nolint
nil,
}
ErrBucketNotFound = &APIError{
http.StatusNotFound,
"bucket not found",
errors.New("bucket not found"), // nolint
errors.New("bucket not found"), //nolint
nil,
}
ErrFileNotFound = &APIError{
http.StatusNotFound,
"file not found",
errors.New("file not found"), // nolint
errors.New("file not found"), //nolint
nil,
}
ErrFileNotUploaded = &APIError{
http.StatusForbidden,
"file not uploaded",
errors.New("file not uploaded"), // nolint
errors.New("file not uploaded"), //nolint
nil,
}
)
Expand Down Expand Up @@ -95,7 +95,7 @@ func FileTooBigError(filename string, size, maxSize int) *APIError {
return &APIError{
statusCode: http.StatusBadRequest,
publicMessage: "file too big",
err: fmt.Errorf("file %s too big: %d > %d", filename, size, maxSize), // nolint
err: fmt.Errorf("file %s too big: %d > %d", filename, size, maxSize), //nolint
data: map[string]interface{}{
"filename": filename,
"size": size,
Expand All @@ -108,7 +108,7 @@ func FileTooSmallError(filename string, size, minSize int) *APIError {
return &APIError{
statusCode: http.StatusBadRequest,
publicMessage: "file too small",
err: fmt.Errorf("file %s too big: %d < %d", filename, size, minSize), // nolint
err: fmt.Errorf("file %s too big: %d < %d", filename, size, minSize), //nolint
data: map[string]interface{}{
"filename": filename,
"size": size,
Expand Down Expand Up @@ -161,6 +161,6 @@ func (a *APIError) Error() string {
}

func (a *APIError) ExtendError(msg string) *APIError {
a.err = fmt.Errorf(fmt.Sprintf("%s: %s", msg, a.err.Error())) // nolint
a.err = fmt.Errorf(fmt.Sprintf("%s: %s", msg, a.err.Error())) //nolint
return a
}
6 changes: 3 additions & 3 deletions controller/get_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func getQueryFloat(ctx *gin.Context, param string) (float64, *APIError) {
if !ok {
return 0, nil
}
x, err := strconv.ParseFloat(s, 32) // nolint: gomnd
x, err := strconv.ParseFloat(s, 32) //nolint: gomnd
if err != nil {
return 0, BadDataError(err, fmt.Sprintf("query parameter %s must be an int", param))
}
Expand Down Expand Up @@ -80,7 +80,7 @@ func getImageManipulationOptions(ctx *gin.Context, mimeType string) (image.Optio
opts.Format = image.ImageTypeJPEG
default:
return image.Options{}, BadDataError(
fmt.Errorf("image manipulation features are not supported for '%s'", mimeType), // nolint: goerr113
fmt.Errorf("image manipulation features are not supported for '%s'", mimeType), //nolint: goerr113
fmt.Sprintf("image manipulation features are not supported for '%s'", mimeType),
)
}
Expand Down Expand Up @@ -127,7 +127,7 @@ func (ctrl *Controller) manipulateImage(

type getFileFunc func() (*File, *APIError)

func (ctrl *Controller) processFileToDownload(
func (ctrl *Controller) processFileToDownload( //nolint: funlen
ctx *gin.Context,
downloadFunc getFileFunc,
fileMetadata FileMetadata,
Expand Down
2 changes: 1 addition & 1 deletion controller/get_file_information.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func modifiedSince(updatedAt string, modifiedSince string) (bool, *APIError) {
return modtime.After(wants), nil
}

func checkConditionals( // nolint: cyclop
func checkConditionals( //nolint: cyclop
etag string,
updatedAt string,
headers *getFileInformationHeaders,
Expand Down
16 changes: 12 additions & 4 deletions controller/get_file_information_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/golang/mock/gomock"
"github.com/nhost/hasura-storage/controller"
"github.com/nhost/hasura-storage/controller/mock_controller"
"github.com/nhost/hasura-storage/controller/mock"
"github.com/nhost/hasura-storage/image"
"github.com/sirupsen/logrus"
)
Expand Down Expand Up @@ -105,8 +105,8 @@ func TestGetFileInfo(t *testing.T) {
c := gomock.NewController(t)
defer c.Finish()

metadataStorage := mock_controller.NewMockMetadataStorage(c)
contentStorage := mock_controller.NewMockContentStorage(c)
metadataStorage := mock.NewMockMetadataStorage(c)
contentStorage := mock.NewMockContentStorage(c)

metadataStorage.EXPECT().GetFileByID(
gomock.Any(), "55af1e60-0f28-454e-885e-ea6aab2bb288", gomock.Any(),
Expand Down Expand Up @@ -136,7 +136,15 @@ func TestGetFileInfo(t *testing.T) {
CacheControl: "max-age=3600",
}, nil)

ctrl := controller.New("http://asd", "/v1", "asdasd", metadataStorage, contentStorage, image.NewTransformer(), logger)
ctrl := controller.New(
"http://asd",
"/v1",
"asdasd",
metadataStorage,
contentStorage,
image.NewTransformer(),
logger,
)

router, _ := ctrl.SetupRouter(nil, "/v1", ginLogger(logger))

Expand Down
2 changes: 1 addition & 1 deletion controller/get_file_presigned_url.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (ctrl *Controller) getFilePresignedURL(ctx *gin.Context) (GetFilePresignedU
}

if !bucketMetadata.PresignedURLsEnabled {
err := errors.New("presigned URLs are not enabled on the bucket where this file is located in") // nolint: goerr113
err := errors.New("presigned URLs are not enabled on the bucket where this file is located in") //nolint: goerr113
return GetFilePresignedURLResponse{}, ForbiddenError(err, err.Error())
}

Expand Down
Loading

0 comments on commit 2eb2eb7

Please sign in to comment.