Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix code errors reported by golangci-lint #57

Merged
merged 2 commits into from
Nov 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ linters-settings:
enable-all: true
# disable:
# - shadow
disable:
- fieldalignment
disable-all: false
unused:
# treat code as a program (not a library) and report unused exported identifiers; default is false.
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.
repos:
- repo: https://github.com/golangci/golangci-lint
rev: v1.32.0
rev: v1.42.1
hooks:
- id: golangci-lint
- repo: https://github.com/pre-commit/mirrors-prettier
Expand Down
8 changes: 4 additions & 4 deletions controllers/modelmesh/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ func (m *Deployment) configureMMDeploymentForEtcdSecret(deployment *appsv1.Deplo
}

volumeMountExists := false
for _, volumeMount := range container.VolumeMounts {
if volumeMount.Name == etcdVolume {
for i := range container.VolumeMounts {
if container.VolumeMounts[i].Name == etcdVolume {
volumeMountExists = true
volumeMount.ReadOnly = true
volumeMount.MountPath = etcdMountPath
container.VolumeMounts[i].ReadOnly = true
container.VolumeMounts[i].MountPath = etcdMountPath
}
}
if !volumeMountExists {
Expand Down
8 changes: 4 additions & 4 deletions pkg/mmesh/etcdrangewatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ func (t KeyEventType) String() string {
}

type KeyEvent struct {
Type KeyEventType
Key string
Value []byte
Type KeyEventType
}

type KeyEventChan chan KeyEvent
Expand All @@ -100,7 +100,7 @@ func (r *EtcdRangeWatcher) Start(ctx context.Context, keysOnly bool, listener Kv
log.Info("EtcdRangeWatcher starting")
go func() {
initSent := false
cache := make(map[string]cacheEntry)
cache := make(map[string]*cacheEntry)
refresh_loop:
for {
client := r.etcdClient
Expand Down Expand Up @@ -134,7 +134,7 @@ func (r *EtcdRangeWatcher) Start(ctx context.Context, keysOnly bool, listener Kv
for _, kv := range gr.Kvs {
k := key(kv, prefixBytes)
if current, ok := cache[k]; !ok || kv.ModRevision > current.kv.ModRevision {
cache[k] = cacheEntry{kv: kv, found: true}
cache[k] = &cacheEntry{kv: kv, found: true}
listener(UPDATE, k, kv.Value)
} else {
current.found = true
Expand Down Expand Up @@ -166,7 +166,7 @@ func (r *EtcdRangeWatcher) Start(ctx context.Context, keysOnly bool, listener Kv
k := key(kv, prefixBytes)
switch event.Type {
case etcd3kv.PUT:
cache[k] = cacheEntry{kv: kv}
cache[k] = &cacheEntry{kv: kv}
listener(UPDATE, k, kv.Value)
case etcd3kv.DELETE:
if prev, ok := cache[k]; ok {
Expand Down