Skip to content

Commit

Permalink
fix golangci-lint
Browse files Browse the repository at this point in the history
Signed-off-by: dongjiang1989 <dongjiang1989@126.com>
  • Loading branch information
dongjiang1989 committed Dec 20, 2023
1 parent fdbbbf4 commit 0e96734
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 16 deletions.
33 changes: 19 additions & 14 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,32 @@ on:
jobs:

build:
name: ubuntu - Go v1.18
name: ubuntu - Go v1.19
runs-on: ubuntu-latest

steps:

- name: Set up Go
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: '1.19'
id: go

- name: Check out code into the Go module directory
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ github.ref }}
path: src/github.com/alibaba/open-local

- name: Install go ci lint
run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.47.3

- name: Run Linter
run: golangci-lint run -v --timeout=10m
working-directory: src/github.com/alibaba/open-local
submodules: true

- name: Cache Go Dependencies
uses: actions/cache@v2
with:
path: .work/pkg
key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-pkg-

# This action uses its own setup-go, which always seems to use the latest
# stable version of Go. We could run 'make lint' to ensure our desired Go
# version, but we prefer this action because it leaves 'annotations' (i.e.
# it comments on PRs to point out linter violations).
- name: Lint
uses: golangci/golangci-lint-action@v3
with:
version: 'v1.49'
7 changes: 7 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
linters:
disable-all: true
enable:
- gosimple
- structcheck
- typecheck
- varcheck
4 changes: 2 additions & 2 deletions pkg/csi/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -817,8 +817,8 @@ func getNodeAddr(node *v1.Node, nodeID string, useNodeHostname bool) (string, er
func GetNodeIP(node *v1.Node, nodeID string) (net.IP, error) {
addresses := node.Status.Addresses
addressMap := make(map[v1.NodeAddressType][]v1.NodeAddress)
for i := range addresses {
addressMap[addresses[i].Type] = append(addressMap[addresses[i].Type], addresses[i])
for _, v := range addresses {
addressMap[v.Type] = append(addressMap[v.Type], v)
}
if addresses, ok := addressMap[v1.NodeInternalIP]; ok {
return net.ParseIP(addresses[0].Address), nil
Expand Down

0 comments on commit 0e96734

Please sign in to comment.