Skip to content

Commit 537ae54

Browse files
committed
the last pile of fixes
1 parent 9ac7acc commit 537ae54

File tree

31 files changed

+215
-77
lines changed

31 files changed

+215
-77
lines changed

.golangci.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ linters:
1919
# Such cases aren't reported by default.
2020
# Default: false
2121
check-blank: true
22+
exclusions:
23+
rules:
24+
# Exclude staticcheck deprecation warnings in generated proto files
25+
- linters:
26+
- staticcheck
27+
path: "gen/go/proto/.*\\.pb\\.go$"
28+
# Exclude staticcheck deprecation warnings for proto imports
29+
- linters:
30+
- staticcheck
31+
text: "SA1019.*github.com/golang/protobuf/proto.*is deprecated"
2232
formatters:
2333
enable:
2434
- gofmt # Format Go code

build-index/cmd/cmd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ func Run(flags *Flags, opts ...Option) {
209209
log.Fatalf("Error creating write-back manager: %s", err)
210210
}
211211

212-
tagStore := tagstore.New(config.TagStore, stats, ss, backends, writeBackManager)
212+
tagStore := tagstore.New(config.TagStore, ss, backends, writeBackManager)
213213

214214
depResolver, err := tagtype.NewMap(config.TagTypes, originClient)
215215
if err != nil {

build-index/tagstore/store.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ import (
3030
"github.com/uber/kraken/lib/store/metadata"
3131
"github.com/uber/kraken/utils/closers"
3232
"github.com/uber/kraken/utils/log"
33-
34-
"github.com/uber-go/tally"
3533
)
3634

3735
// Store errors.
@@ -69,15 +67,10 @@ type tagStore struct {
6967
// New creates a new Store.
7068
func New(
7169
config Config,
72-
stats tally.Scope,
7370
fs FileStore,
7471
backends *backend.Manager,
7572
writeBackManager persistedretry.Manager,
7673
) Store {
77-
stats = stats.Tagged(map[string]string{
78-
"module": "tagstore",
79-
})
80-
8174
s := &tagStore{
8275
config: config,
8376
fs: fs,

build-index/tagstore/store_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import (
3131

3232
"github.com/golang/mock/gomock"
3333
"github.com/stretchr/testify/require"
34-
"github.com/uber-go/tally"
3534
)
3635

3736
const _testNamespace = ".*"
@@ -64,7 +63,7 @@ func newStoreMocks(t *testing.T) (*storeMocks, func()) {
6463
}
6564

6665
func (m *storeMocks) new(config Config) Store {
67-
return New(config, tally.NoopScope, m.ss, m.backends, m.writeBackManager)
66+
return New(config, m.ss, m.backends, m.writeBackManager)
6867
}
6968

7069
func TestPutAndGetFromDisk(t *testing.T) {

core/peer_id.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ package core
1515

1616
import (
1717
"bytes"
18+
"crypto/rand"
1819
"crypto/sha1"
1920
"encoding/hex"
2021
"errors"
2122
"fmt"
2223
"io"
23-
"math/rand"
2424
)
2525

2626
// PeerIDFactory defines the method used to generate a peer id.

lib/backend/throttle.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func (c *ThrottledClient) Upload(namespace, name string, src io.Reader) error {
5454

5555
// Download downloads name into dst.
5656
func (c *ThrottledClient) Download(namespace, name string, dst io.Writer) error {
57-
info, err := c.Client.Stat(namespace, name)
57+
info, err := c.Stat(namespace, name)
5858
if err != nil {
5959
return err
6060
}

lib/containerruntime/dockerdaemon/cli.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,22 +78,26 @@ func parseHost(host string) (*http.Client, string, string, error) {
7878
transport := new(http.Transport)
7979

8080
protocol, addr := strs[0], strs[1]
81-
if protocol == "tcp" {
81+
switch protocol {
82+
case "tcp":
8283
parsed, err := url.Parse("tcp://" + addr)
8384
if err != nil {
8485
return nil, "", "", err
8586
}
8687
addr = parsed.Host
8788
basePath = parsed.Path
88-
} else if protocol == "unix" {
89+
case "unix":
8990
if len(addr) > len(syscall.RawSockaddrUnix{}.Path) {
9091
return nil, "", "", fmt.Errorf("unix socket path %q is too long", addr)
9192
}
9293
transport.DisableCompression = true
93-
transport.Dial = func(_, _ string) (net.Conn, error) {
94-
return net.DialTimeout(protocol, addr, _defaultTimeout)
94+
transport.DialContext = func(ctx context.Context, _, _ string) (net.Conn, error) {
95+
d := &net.Dialer{
96+
Timeout: _defaultTimeout,
97+
}
98+
return d.DialContext(ctx, protocol, addr)
9599
}
96-
} else {
100+
default:
97101
return nil, "", "", fmt.Errorf("protocol %s not supported", protocol)
98102
}
99103

lib/dockerregistry/storage_driver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ func (d *KrakenStorageDriver) Delete(ctx context.Context, path string) error {
360360
// URLFor returns url for path
361361
func (d *KrakenStorageDriver) URLFor(ctx context.Context, path string, options map[string]interface{}) (string, error) {
362362
log.Debugf("(*KrakenStorageDriver).URLFor %s", path)
363-
return "", fmt.Errorf("Not implemented")
363+
return "", fmt.Errorf("not implemented")
364364
}
365365

366366
// Walk is not implemented.

lib/dockerregistry/testutils_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,10 @@ func genManifestListPath(repo string) string {
151151
return fmt.Sprintf("/docker/registry/v2/repositories/%s/_manifests/tags", repo)
152152
}
153153

154+
type contextKey string
155+
156+
const varsNameKey contextKey = "vars.name"
157+
154158
func contextFixture() context.Context {
155-
return context.WithValue(context.Background(), "vars.name", "dummy")
159+
return context.WithValue(context.Background(), varsNameKey, "dummy")
156160
}

lib/store/base/file_entry.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ func (entry *localFileEntry) SetMetadataAt(
533533
if _, err := f.ReadAt(prev, offset); err != nil {
534534
return false, err
535535
}
536-
if bytes.Compare(prev, b) == 0 {
536+
if bytes.Equal(prev, b) {
537537
return false, nil
538538
}
539539
if _, err := f.WriteAt(b, offset); err != nil {

0 commit comments

Comments
 (0)