Skip to content

Commit

Permalink
fix: Fix code errors reported by golangci-lint (#57)
Browse files Browse the repository at this point in the history
* fix code error reported by golangci-lint

* upgrade golangci and disable fieldalignment
  • Loading branch information
pugangxa authored Nov 10, 2021
1 parent 0095faa commit 80f6603
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
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

0 comments on commit 80f6603

Please sign in to comment.