From 2ae8b68546baf86de31eb4d08b12e6cdd1a10649 Mon Sep 17 00:00:00 2001 From: Onur Sonmez Date: Wed, 28 Jul 2021 14:43:13 +0300 Subject: [PATCH 1/7] makefile: fix check-fmt target * CI does not fail if go code is not formatted since check-fmt target in makefile is not working properly. Fix check-fmt target and return with status 1 if code is not formatted. --- Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index cd76c7a7f..dce1841f2 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,10 @@ vet: .PHONY: check-fmt check-fmt: - @sh -c 'if [ -n "$(go fmt -mod=vendor ./...)" ]; then echo "Go code is not formatted"; exit 1; fi' + @if go fmt -mod=vendor ./...; then\ + echo "Go code is not formatted";\ + exit 1;\ + fi .PHONY: mock mock: From e847bb11f511ed7792870fa20e8b80e1688c6283 Mon Sep 17 00:00:00 2001 From: Onur Sonmez Date: Wed, 28 Jul 2021 14:47:42 +0300 Subject: [PATCH 2/7] fix indentation --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index dce1841f2..983f3969c 100644 --- a/Makefile +++ b/Makefile @@ -35,7 +35,7 @@ check-fmt: @if go fmt -mod=vendor ./...; then\ echo "Go code is not formatted";\ exit 1;\ - fi + fi .PHONY: mock mock: From ed9d6c914aefffa04c45fada7db3fa4902db06dd Mon Sep 17 00:00:00 2001 From: Onur Sonmez Date: Wed, 28 Jul 2021 14:48:52 +0300 Subject: [PATCH 3/7] fix indentation --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 983f3969c..f8af72053 100644 --- a/Makefile +++ b/Makefile @@ -33,7 +33,7 @@ vet: .PHONY: check-fmt check-fmt: @if go fmt -mod=vendor ./...; then\ - echo "Go code is not formatted";\ + echo "Go code is not formatted";\ exit 1;\ fi From bb9043711d98597f53d2a075088a9a56616b5b4c Mon Sep 17 00:00:00 2001 From: Onur Sonmez Date: Wed, 28 Jul 2021 14:50:18 +0300 Subject: [PATCH 4/7] Format source code --- command/mv.go | 1 - storage/storage.go | 24 ++++++++++++------------ 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/command/mv.go b/command/mv.go index 36c35e0d6..0c9f42cf4 100644 --- a/command/mv.go +++ b/command/mv.go @@ -64,7 +64,6 @@ var moveCommand = &cli.Command{ cacheControl: c.String("cache-control"), expires: c.String("expires"), - storageOpts: NewStorageOpts(c), } diff --git a/storage/storage.go b/storage/storage.go index 5d3f859a5..c7d081c3c 100644 --- a/storage/storage.go +++ b/storage/storage.go @@ -48,13 +48,13 @@ func NewLocalClient(opts Options) *Filesystem { func NewRemoteClient(ctx context.Context, url *url.URL, opts Options) (*S3, error) { newOpts := Options{ - MaxRetries: opts.MaxRetries, - Endpoint: opts.Endpoint, - NoVerifySSL: opts.NoVerifySSL, - DryRun: opts.DryRun, + MaxRetries: opts.MaxRetries, + Endpoint: opts.Endpoint, + NoVerifySSL: opts.NoVerifySSL, + DryRun: opts.DryRun, NoSignRequest: opts.NoSignRequest, - bucket: url.Bucket, - region: opts.region, + bucket: url.Bucket, + region: opts.region, } return newS3Storage(ctx, newOpts) } @@ -68,13 +68,13 @@ func NewClient(ctx context.Context, url *url.URL, opts Options) (Storage, error) // Options stores configuration for storage. type Options struct { - MaxRetries int - Endpoint string - NoVerifySSL bool - DryRun bool + MaxRetries int + Endpoint string + NoVerifySSL bool + DryRun bool NoSignRequest bool - bucket string - region string + bucket string + region string } func (o *Options) SetRegion(region string) { From b1b927cf144c1b25aaf5560267300e4235701f08 Mon Sep 17 00:00:00 2001 From: Onur Sonmez Date: Wed, 28 Jul 2021 15:15:32 +0300 Subject: [PATCH 5/7] Use shell variable for gofmt --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index f8af72053..863505a15 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ vet: .PHONY: check-fmt check-fmt: - @if go fmt -mod=vendor ./...; then\ + @if [ $$(go fmt -mod=vendor ./...) ]; then\ echo "Go code is not formatted";\ exit 1;\ fi From c3db42268c55c95f8bcc631a3bce6b311933ea82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Onur=20S=C3=B6nmez?= Date: Wed, 28 Jul 2021 17:07:33 +0300 Subject: [PATCH 6/7] test linter --- storage/storage.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/storage/storage.go b/storage/storage.go index c7d081c3c..3d91d7d26 100644 --- a/storage/storage.go +++ b/storage/storage.go @@ -14,10 +14,10 @@ import ( var ( // ErrGivenObjectNotFound indicates a specified object is not found. - ErrGivenObjectNotFound = fmt.Errorf("given object not found") +ErrGivenObjectNotFound = fmt.Errorf("given object not found") // ErrNoObjectFound indicates there are no objects found from a given directory. - ErrNoObjectFound = fmt.Errorf("no object found") + ErrNoObjectFound = fmt.Errorf("no object found") ) // Storage is an interface for storage operations that is common From 918b17b7b175323a5f1fe5f78841eb4e9a53721a Mon Sep 17 00:00:00 2001 From: Onur Sonmez Date: Wed, 28 Jul 2021 17:14:05 +0300 Subject: [PATCH 7/7] Revert "test linter" This reverts commit c3db42268c55c95f8bcc631a3bce6b311933ea82. --- storage/storage.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/storage/storage.go b/storage/storage.go index 3d91d7d26..c7d081c3c 100644 --- a/storage/storage.go +++ b/storage/storage.go @@ -14,10 +14,10 @@ import ( var ( // ErrGivenObjectNotFound indicates a specified object is not found. -ErrGivenObjectNotFound = fmt.Errorf("given object not found") + ErrGivenObjectNotFound = fmt.Errorf("given object not found") // ErrNoObjectFound indicates there are no objects found from a given directory. - ErrNoObjectFound = fmt.Errorf("no object found") + ErrNoObjectFound = fmt.Errorf("no object found") ) // Storage is an interface for storage operations that is common