Skip to content

Commit 7dd8af7

Browse files
committed
feat: make lint happy
1 parent bcc25bd commit 7dd8af7

File tree

7 files changed

+24
-26
lines changed

7 files changed

+24
-26
lines changed

block/factory/build.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ func BuildBlockAdapter(ctx context.Context, c params.AdapterConfig) (block.Adapt
7676
}
7777

7878
func buildIpfsAdapter(_ context.Context, params params.Ipfs) (*ipfs.Adapter, error) {
79-
adapter, err := ipfs.NewAdapter(params.Url)
79+
adapter, err := ipfs.NewAdapter(params.URL)
8080
if err != nil {
81-
return nil, fmt.Errorf("got error opening a local block adapter with path %s: %w", params.Url, err)
81+
return nil, fmt.Errorf("got error opening a local block adapter with path %s: %w", params.URL, err)
8282
}
8383
log.With(
8484
"type", "local",
85-
"url", params.Url,
85+
"url", params.URL,
8686
).Info("initialized blockstore adapter")
8787
return adapter, nil
8888
}

block/ipfs/adapter.go

+7-8
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func (qk QualifiedKey) GetKey() string {
6565
}
6666

6767
func NewAdapter(url string, opts ...func(a *Adapter)) (*Adapter, error) {
68-
addr, err := ma.NewMultiaddr(strings.TrimSpace(string(url)))
68+
addr, err := ma.NewMultiaddr(strings.TrimSpace(url))
6969
if err != nil {
7070
return nil, err
7171
}
@@ -282,7 +282,7 @@ func (l *Adapter) GetRange(ctx context.Context, obj block.ObjectPointer, start i
282282
return rc, nil
283283
}
284284

285-
func (l *Adapter) GetProperties(_ context.Context, obj block.ObjectPointer) (block.Properties, error) {
285+
func (l *Adapter) GetProperties(_ context.Context, _ block.ObjectPointer) (block.Properties, error) {
286286
return block.Properties{}, nil
287287
}
288288

@@ -317,26 +317,25 @@ func (l *Adapter) UploadPart(ctx context.Context, obj block.ObjectPointer, _ int
317317
}, err
318318
}
319319

320-
func (l *Adapter) AbortMultiPartUpload(_ context.Context, obj block.ObjectPointer, uploadID string) error {
320+
func (l *Adapter) AbortMultiPartUpload(_ context.Context, _ block.ObjectPointer, uploadID string) error {
321321
if err := isValidUploadID(uploadID); err != nil {
322322
return err
323323
}
324324

325325
panic("todo")
326326
}
327327

328-
func (l *Adapter) CompleteMultiPartUpload(ctx context.Context, obj block.ObjectPointer, uploadID string, multipartList *block.MultipartUploadCompletion) (*block.CompleteMultiPartUploadResponse, error) {
328+
func (l *Adapter) CompleteMultiPartUpload(_ context.Context, obj block.ObjectPointer, uploadID string, multipartList *block.MultipartUploadCompletion) (*block.CompleteMultiPartUploadResponse, error) {
329329
if err := isValidUploadID(uploadID); err != nil {
330330
return nil, err
331331
}
332-
etag := computeETag(multipartList.Part) + "-" + strconv.Itoa(len(multipartList.Part))
333332

334333
size, err := l.unitePartFiles(obj, uploadID)
335334
if err != nil {
336335
return nil, fmt.Errorf("multipart upload unite for %s: %w", uploadID, err)
337336
}
338337
return &block.CompleteMultiPartUploadResponse{
339-
ETag: etag,
338+
ETag: computeETag(multipartList.Part) + "-" + strconv.Itoa(len(multipartList.Part)),
340339
ContentLength: size,
341340
}, nil
342341
}
@@ -354,11 +353,11 @@ func computeETag(parts []block.MultipartPart) string {
354353
return csm
355354
}
356355

357-
func (l *Adapter) unitePartFiles(identifier block.ObjectPointer, uploadID string) (int64, error) {
356+
func (l *Adapter) unitePartFiles(_ block.ObjectPointer, _ string) (int64, error) {
358357
panic("not impl")
359358
}
360359

361-
func (l *Adapter) removePartFiles(ctx context.Context, files []string) error {
360+
func (l *Adapter) removePartFiles(ctx context.Context, files []string) error { //nolint
362361
var firstErr error
363362
for _, name := range files {
364363
// If removal fails prefer to skip the error: "only" wasted space.

block/ipfs/walker.go

+4-7
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,17 @@ package ipfs
33
import (
44
"context"
55
"fmt"
6-
"github.com/modern-go/reflect2"
6+
77
"net/url"
88
"sort"
99
"strings"
1010

11-
iface "github.com/ipfs/kubo/core/coreiface"
12-
13-
"github.com/ipfs/kubo/core/coreiface/options"
14-
1511
"github.com/ipfs/boxo/path"
16-
1712
"github.com/ipfs/kubo/client/rpc"
13+
iface "github.com/ipfs/kubo/core/coreiface"
14+
"github.com/ipfs/kubo/core/coreiface/options"
1815
"github.com/jiaozifs/jiaozifs/block"
16+
"github.com/modern-go/reflect2"
1917
)
2018

2119
type Walker struct {
@@ -31,7 +29,6 @@ func NewIPFSWalker(client *rpc.HttpApi) *Walker {
3129
}
3230

3331
func (s *Walker) Walk(ctx context.Context, storageURI *url.URL, op block.WalkOptions, walkFn func(e block.ObjectStoreEntry) error) error {
34-
const maxKeys = 1000
3532
prefix := strings.TrimLeft(storageURI.Path, "/")
3633

3734
curPath, err := path.NewPath(prefix)

block/params/block.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type AdapterConfig interface {
1717
type Mem struct{}
1818

1919
type Ipfs struct {
20-
Url string
20+
URL string
2121
}
2222

2323
type Local struct {

config/blockstore.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type BlockStoreConfig struct {
1919
AllowedExternalPrefixes []string `mapstructure:"allowed_external_prefixes" json:"allowed_external_prefixes"`
2020
} `mapstructure:"local" json:"local"`
2121
Ipfs *struct {
22-
Url string `mapstructure:"url" json:"url"`
22+
URL string `mapstructure:"url" json:"url"`
2323
} `mapstructure:"ipfs" json:"ipfs"`
2424
S3 *struct {
2525
S3AuthInfo `mapstructure:",squash"`
@@ -67,7 +67,7 @@ func (c *BlockStoreConfig) BlockstoreType() string {
6767

6868
func (c *BlockStoreConfig) BlockstoreIpfsParams() (params.Ipfs, error) {
6969
return params.Ipfs{
70-
Url: c.Ipfs.Url,
70+
URL: c.Ipfs.URL,
7171
}, nil
7272
}
7373

integrationtest/repo_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -447,31 +447,31 @@ func RepoSpec(ctx context.Context, urlStr string) func(c convey.C) {
447447
c.Convey("no auth", func() {
448448
re := client.RequestEditors
449449
client.RequestEditors = nil
450-
resp, err := client.DeleteRepository(ctx, userName, repoName)
450+
resp, err := client.DeleteRepository(ctx, userName, repoName, &api.DeleteRepositoryParams{})
451451
client.RequestEditors = re
452452
convey.So(err, convey.ShouldBeNil)
453453
convey.So(resp.StatusCode, convey.ShouldEqual, http.StatusUnauthorized)
454454
})
455455
c.Convey("delete repository in not exit repo", func() {
456-
resp, err := client.DeleteRepository(ctx, userName, "happyrunfake")
456+
resp, err := client.DeleteRepository(ctx, userName, "happyrunfake", &api.DeleteRepositoryParams{})
457457
convey.So(err, convey.ShouldBeNil)
458458
convey.So(resp.StatusCode, convey.ShouldEqual, http.StatusNotFound)
459459
})
460460

461461
c.Convey("delete repository in non exit user", func() {
462-
resp, err := client.DeleteRepository(ctx, "telo", repoName)
462+
resp, err := client.DeleteRepository(ctx, "telo", repoName, &api.DeleteRepositoryParams{})
463463
convey.So(err, convey.ShouldBeNil)
464464
convey.So(resp.StatusCode, convey.ShouldEqual, http.StatusNotFound)
465465
})
466466

467467
c.Convey("delete repository in other's repo", func() {
468-
resp, err := client.DeleteRepository(ctx, "admin", repoName)
468+
resp, err := client.DeleteRepository(ctx, "admin", repoName, &api.DeleteRepositoryParams{})
469469
convey.So(err, convey.ShouldBeNil)
470470
convey.So(resp.StatusCode, convey.ShouldEqual, http.StatusForbidden)
471471
})
472472

473473
c.Convey("delete repository successful", func() {
474-
resp, err := client.DeleteRepository(ctx, userName, repoName)
474+
resp, err := client.DeleteRepository(ctx, userName, repoName, &api.DeleteRepositoryParams{})
475475
convey.So(err, convey.ShouldBeNil)
476476
convey.So(resp.StatusCode, convey.ShouldEqual, http.StatusOK)
477477

makefile

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ SWAGGER_ARG=
2323
swagger-srv:
2424
swagger serve $(SWAGGER_ARG) -F swagger ./api/swagger.yml
2525

26+
lint:
27+
golang-lint run ./...
2628
test: gen-api
2729
go test -timeout=30m -parallel=4 -v ./...
2830
build:gen-api

0 commit comments

Comments
 (0)