Skip to content

Commit eb90f17

Browse files
committed
chore: Fix lints
1 parent 00dc139 commit eb90f17

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+367
-327
lines changed

.github/workflows/lint.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Lint
2+
3+
on:
4+
workflow_call:
5+
pull_request:
6+
push:
7+
branches:
8+
- main
9+
10+
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Setup golangci-lint
17+
run: |
18+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $HOME/.local/bin v1.64.7
19+
echo "$HOME/.local/bin" >> $GITHUB_PATH
20+
21+
- name: Lint
22+
run: make run-lint

.golangci.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
issues:
2+
exclude-files:
3+
- ".*_test.go"
4+
- "conf_azure.go"
5+
- "core/backend_adlv2.go"
6+
- "core/backend_adlv1.go"
7+
- "core/backend_azblob.go"

.goreleaser.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ builds:
1313
binary: tigrisfs
1414
ldflags:
1515
- -w -extldflags '-static'
16-
- -X 'github.com/yandex-cloud/tigrisfs/main.Version={{.Version}}'
17-
- -X 'github.com/yandex-cloud/tigrisfs/main.Endpoint={{.Env.ENDPOINT}}'
16+
- -X 'github.com/tigrisdata/tigrisfs/main.Version={{.Version}}'
17+
- -X 'github.com/tigrisdata/tigrisfs/main.Endpoint={{.Env.ENDPOINT}}'
1818

1919
archives:
2020
- format_overrides:

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
VERSION=$(shell git describe --tags --always)
22
ENDPOINT ?= "https://fly.storage.tigris.dev"
33

4-
BUILD_PARAM=-ldflags "-X github.com/yandex-cloud/tigrisfs/core/cfg.Version=$(VERSION) -X github.com/yandex-cloud/tigrisfs/core/cfg.DefaultEndpoint=$(ENDPOINT)"
4+
BUILD_PARAM=-ldflags "-X github.com/tigrisdata/tigrisfs/core/cfg.Version=$(VERSION) -X github.com/tigrisdata/tigrisfs/core/cfg.DefaultEndpoint=$(ENDPOINT)"
55

66
run-test: s3proxy.jar build-debug
77
./test/run-tests.sh
@@ -12,6 +12,10 @@ run-xfstests: s3proxy.jar xfstests build-debug
1212
run-cluster-test: s3proxy.jar build-debug
1313
./test/cluster/test_random.sh
1414

15+
run-lint:
16+
shellcheck scripts/*
17+
golangci-lint --timeout=5m run --fix
18+
1519
xfstests:
1620
git clone --depth=1 https://github.com/kdave/xfstests
1721
cd xfstests && patch -p1 -l < ../test/xfstests.diff

bench/Dockerfile.azure

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ RUN git clone --depth 1 https://github.com/Azure/azure-storage-fuse.git && \
2828
# ideally I want to clear out all the go deps too but there's no
2929
# way to do that with ADD
3030
ENV PATH=$PATH:/root/go/bin
31-
ADD . /root/go/src/github.com/yandex-cloud/tigrisfs
32-
WORKDIR /root/go/src/github.com/yandex-cloud/tigrisfs
31+
ADD . /root/go/src/github.com/tigrisdata/tigrisfs
32+
WORKDIR /root/go/src/github.com/tigrisdata/tigrisfs
3333
RUN go get . && make install
3434

35-
ENTRYPOINT ["/root/go/src/github.com/yandex-cloud/tigrisfs/bench/run_bench.sh"]
35+
ENTRYPOINT ["/root/go/src/github.com/tigrisdata/tigrisfs/bench/run_bench.sh"]

core/aws_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
package core
1717

1818
import (
19-
"github.com/tigrisdata/tigrisfs/core/cfg"
20-
. "gopkg.in/check.v1"
21-
2219
"fmt"
2320
"sync"
2421
"syscall"
2522
"time"
23+
24+
"github.com/tigrisdata/tigrisfs/core/cfg"
25+
. "gopkg.in/check.v1"
2626
)
2727

2828
type AwsTest struct {

core/backend.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -222,22 +222,19 @@ type MultipartBlobAbortOutput struct {
222222
RequestId string
223223
}
224224

225-
type MultipartExpireInput struct {
226-
}
225+
type MultipartExpireInput struct{}
227226

228227
type MultipartExpireOutput struct {
229228
RequestId string
230229
}
231230

232-
type RemoveBucketInput struct {
233-
}
231+
type RemoveBucketInput struct{}
234232

235233
type RemoveBucketOutput struct {
236234
RequestId string
237235
}
238236

239-
type MakeBucketInput struct {
240-
}
237+
type MakeBucketInput struct{}
241238

242239
type MakeBucketOutput struct {
243240
RequestId string
@@ -486,7 +483,7 @@ func (e StorageBackendInitError) ListBlobs(param *ListBlobsInput) (*ListBlobsOut
486483
if param.Prefix == nil || *param.Prefix == "" {
487484
return &ListBlobsOutput{
488485
Items: []BlobItemOutput{
489-
BlobItemOutput{
486+
{
490487
Key: PString(INIT_ERR_BLOB),
491488
Size: uint64(len(e.Error())),
492489
LastModified: PTime(time.Now()),

core/backend_adlv1.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@
1717
package core
1818

1919
import (
20-
"github.com/rs/zerolog"
21-
"github.com/tigrisdata/tigrisfs/core/cfg"
22-
"github.com/tigrisdata/tigrisfs/log"
23-
2420
"bytes"
2521
"context"
2622
"encoding/json"
@@ -31,6 +27,10 @@ import (
3127
"syscall"
3228
"time"
3329

30+
"github.com/rs/zerolog"
31+
"github.com/tigrisdata/tigrisfs/core/cfg"
32+
"github.com/tigrisdata/tigrisfs/log"
33+
3434
adl "github.com/Azure/azure-sdk-for-go/services/datalake/store/2016-11-01/filesystem"
3535
"github.com/Azure/go-autorest/autorest"
3636
uuid "github.com/gofrs/uuid"
@@ -75,7 +75,7 @@ type ADLv1MultipartBlobCommitInput struct {
7575

7676
func IsADLv1Endpoint(endpoint string) bool {
7777
return strings.HasPrefix(endpoint, "adl://")
78-
//return strings.HasSuffix(endpoint, ".azuredatalakestore.net")
78+
// return strings.HasSuffix(endpoint, ".azuredatalakestore.net")
7979
}
8080

8181
func adlLogResp(level zerolog.Level, r *http.Response) {
@@ -149,7 +149,7 @@ func NewADLv1(bucket string, flags *cfg.FlagStorage, config *cfg.ADLv1Config) (*
149149
account: parts[0],
150150
bucket: bucket,
151151
cap: Capabilities{
152-
//NoParallelMultipart: true,
152+
// NoParallelMultipart: true,
153153
DirBlob: true,
154154
Name: "adl",
155155
// ADLv1 fails with 404 if we upload data
@@ -261,12 +261,11 @@ func (b *ADLv1) HeadBlob(param *HeadBlobInput) (*HeadBlobOutput, error) {
261261
BlobItemOutput: adlv1FileStatus2BlobItem(res.FileStatus, &param.Key),
262262
IsDirBlob: res.FileStatus.Type == "DIRECTORY",
263263
}, nil
264-
265264
}
266265

267266
func (b *ADLv1) appendToListResults(path string, recursive bool, startAfter string,
268-
maxKeys *uint32, prefixes []BlobPrefixOutput, items []BlobItemOutput) (adl.FileStatusesResult, []BlobPrefixOutput, []BlobItemOutput, error) {
269-
267+
maxKeys *uint32, prefixes []BlobPrefixOutput, items []BlobItemOutput,
268+
) (adl.FileStatusesResult, []BlobPrefixOutput, []BlobItemOutput, error) {
270269
res, err := b.client.ListFileStatus(context.TODO(), b.account, b.path(path),
271270
nil, "", "", nil)
272271
err = mapADLv1Error(res.Response.Response, err, false)

core/backend_adlv2.go

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@
1818
package core
1919

2020
import (
21-
"github.com/rs/zerolog"
22-
"github.com/tigrisdata/tigrisfs/core/cfg"
23-
"github.com/tigrisdata/tigrisfs/log"
24-
2521
"context"
2622
"encoding/base64"
2723
"encoding/json"
@@ -39,6 +35,9 @@ import (
3935
"github.com/Azure/go-autorest/autorest"
4036
"github.com/Azure/go-autorest/autorest/azure"
4137
"github.com/google/uuid"
38+
"github.com/rs/zerolog"
39+
"github.com/tigrisdata/tigrisfs/core/cfg"
40+
"github.com/tigrisdata/tigrisfs/log"
4241
)
4342

4443
type ADLv2 struct {
@@ -51,8 +50,10 @@ type ADLv2 struct {
5150
bucket string
5251
}
5352

54-
const ADL2_CLIENT_REQUEST_ID = "X-Ms-Client-Request-Id"
55-
const ADL2_REQUEST_ID = "X-Ms-Request-Id"
53+
const (
54+
ADL2_CLIENT_REQUEST_ID = "X-Ms-Client-Request-Id"
55+
ADL2_REQUEST_ID = "X-Ms-Request-Id"
56+
)
5657

5758
var adl2Log = log.GetLogger("adlv2")
5859

@@ -230,7 +231,7 @@ func adlv2ErrLogHeaders(errCode string, resp *http.Response) {
230231
switch errCode {
231232
case "MissingRequiredHeader", "UnsupportedHeader":
232233
var s strings.Builder
233-
for k, _ := range resp.Request.Header {
234+
for k := range resp.Request.Header {
234235
s.WriteString(k)
235236
s.WriteString(" ")
236237
}
@@ -252,7 +253,6 @@ func adlv2ErrLogHeaders(errCode string, resp *http.Response) {
252253
}
253254

254255
func mapADLv2Error(resp *http.Response, err error, rawError bool) error {
255-
256256
if resp == nil {
257257
if err != nil {
258258
if detailedError, ok := err.(autorest.DetailedError); ok {
@@ -624,7 +624,7 @@ func (b *ADLv2) toADLProperties(metadata map[string]*string) string {
624624
buf.WriteString(base64.StdEncoding.EncodeToString([]byte(*v)))
625625
buf.WriteString(",")
626626
}
627-
var s = buf.String()
627+
s := buf.String()
628628
if len(s) != 0 {
629629
// remove trailing comma
630630
s = s[:len(s)-1]
@@ -633,7 +633,8 @@ func (b *ADLv2) toADLProperties(metadata map[string]*string) string {
633633
}
634634

635635
func (b *ADLv2) create(key string, pathType adl2.PathResourceType, contentType *string,
636-
metadata map[string]*string, leaseId string) (resp autorest.Response, err error) {
636+
metadata map[string]*string, leaseId string,
637+
) (resp autorest.Response, err error) {
637638
resp, err = b.client.Create(context.TODO(), b.bucket, key,
638639
pathType, "", "", "", "", "", "", "", NilStr(contentType),
639640
"", "", "", "", leaseId, "", b.toADLProperties(metadata), "", "", "", "", "", "",
@@ -645,7 +646,8 @@ func (b *ADLv2) create(key string, pathType adl2.PathResourceType, contentType *
645646
}
646647

647648
func (b *ADLv2) append(key string, offset int64, size int64, body io.ReadSeeker,
648-
leaseId string) (resp autorest.Response, err error) {
649+
leaseId string,
650+
) (resp autorest.Response, err error) {
649651
resp, err = b.client.Update(context.TODO(), adl2.Append, b.bucket,
650652
key, &offset, nil, nil, &size, "", leaseId, "",
651653
"", "", "", "", "", "", "", "", "", "",
@@ -789,7 +791,8 @@ func (b *ADLv2) MultipartBlobBegin(param *MultipartBlobBeginInput) (*MultipartBl
789791
}
790792

791793
func (b *ADLv2) lease(action adl2.PathLeaseAction, key string, leaseId string, durationSec int32,
792-
ifMatch string) error {
794+
ifMatch string,
795+
) error {
793796
var proposeLeaseId string
794797
var prevLeaseId string
795798
if action == adl2.Acquire {
@@ -884,7 +887,7 @@ func (b *ADLv2) MultipartExpire(param *MultipartExpireInput) (*MultipartExpireOu
884887
}
885888

886889
func (b *ADLv2) RemoveBucket(param *RemoveBucketInput) (*RemoveBucketOutput, error) {
887-
fs := adl2.FilesystemClient{b.client.BaseClient}
890+
fs := adl2.FilesystemClient{BaseClient: b.client.BaseClient}
888891
res, err := fs.Delete(context.TODO(), b.bucket, "", "", uuid.New().String(), nil, "")
889892
if err != nil {
890893
return nil, mapADLv2Error(res.Response, err, false)
@@ -893,7 +896,7 @@ func (b *ADLv2) RemoveBucket(param *RemoveBucketInput) (*RemoveBucketOutput, err
893896
}
894897

895898
func (b *ADLv2) MakeBucket(param *MakeBucketInput) (*MakeBucketOutput, error) {
896-
fs := adl2.FilesystemClient{b.client.BaseClient}
899+
fs := adl2.FilesystemClient{BaseClient: b.client.BaseClient}
897900
res, err := fs.Create(context.TODO(), b.bucket, "", uuid.New().String(), nil, "")
898901
if err != nil {
899902
return nil, mapADLv2Error(res.Response, err, false)
@@ -1761,7 +1764,6 @@ func (client adl2PathClient) UpdatePreparer(ctx context.Context, action adl2.Pat
17611764
// UpdateSender sends the Update request. The method will close the
17621765
// http.Response Body if it receives an error.
17631766
func (client adl2PathClient) UpdateSender(req *http.Request) (*http.Response, error) {
1764-
17651767
sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
17661768
return autorest.SendWithSender(client, req, sd...)
17671769
}

core/backend_azblob.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"context"
2222
"encoding/base64"
2323
"fmt"
24-
"github.com/tigrisdata/tigrisfs/log"
2524
"net/http"
2625
"net/url"
2726
"sort"
@@ -30,6 +29,8 @@ import (
3029
"syscall"
3130
"time"
3231

32+
"github.com/tigrisdata/tigrisfs/log"
33+
3334
"github.com/rs/zerolog"
3435

3536
"github.com/Azure/azure-pipeline-go/pipeline"
@@ -38,9 +39,11 @@ import (
3839
"github.com/tigrisdata/tigrisfs/core/cfg"
3940
)
4041

41-
const AzuriteEndpoint = "http://127.0.0.1:8080/devstoreaccount1/"
42-
const AzureDirBlobMetadataKey = "hdi_isfolder"
43-
const AzureBlobMetaDataHeaderPrefix = "x-ms-meta-"
42+
const (
43+
AzuriteEndpoint = "http://127.0.0.1:8080/devstoreaccount1/"
44+
AzureDirBlobMetadataKey = "hdi_isfolder"
45+
AzureBlobMetaDataHeaderPrefix = "x-ms-meta-"
46+
)
4447

4548
// Azure Blob Store API does not not treat headers as case insensitive.
4649
// This is particularly a problem with `AzureDirBlobMetadataKey` header.
@@ -504,15 +507,15 @@ func (b *AZBlob) ListBlobs(param *ListBlobsInput) (*ListBlobsOutput, error) {
504507
if param.Delimiter != nil {
505508
resp, err := c.ListBlobsHierarchySegment(context.TODO(),
506509
azblob.Marker{
507-
param.ContinuationToken,
510+
Val: param.ContinuationToken,
508511
},
509512
NilStr(param.Delimiter),
510513
options)
511514
if err != nil {
512515
return nil, mapAZBError(err)
513516
}
514517

515-
for i, _ := range resp.Segment.BlobPrefixes {
518+
for i := range resp.Segment.BlobPrefixes {
516519
p := resp.Segment.BlobPrefixes[i]
517520
prefixes = append(prefixes, BlobPrefixOutput{Prefix: &p.Name})
518521
}
@@ -528,7 +531,7 @@ func (b *AZBlob) ListBlobs(param *ListBlobsInput) (*ListBlobsOutput, error) {
528531
} else {
529532
resp, err := c.ListBlobsFlatSegment(context.TODO(),
530533
azblob.Marker{
531-
param.ContinuationToken,
534+
Val: param.ContinuationToken,
532535
},
533536
options)
534537
if err != nil {
@@ -555,7 +558,7 @@ func (b *AZBlob) ListBlobs(param *ListBlobsInput) (*ListBlobsOutput, error) {
555558
}
556559
var sortItems bool
557560

558-
for idx, _ := range blobItems {
561+
for idx := range blobItems {
559562
i := &blobItems[idx]
560563
p := &i.Properties
561564

0 commit comments

Comments
 (0)