Skip to content

Commit 1fa243e

Browse files
authored
CI: Add golint-ci (#888)
* add golint-ci * add gofmt * enable linters * uncap count * fix linting/fmt issues
1 parent 7f2cfc7 commit 1fa243e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+525
-475
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.go text eol=lf

.github/workflows/cyclonus-netpol-test.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ on:
66
branches:
77
- main
88
pull_request:
9+
paths:
10+
- 'npm/**'
911
schedule:
1012
# run once a day at midnight
1113
- cron: '0 0 * * *'

.github/workflows/repo-hygiene.yaml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: golangci-lint
2+
on:
3+
workflow_dispatch:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
schedule:
9+
# run once a day at midnight
10+
- cron: '0 0 * * *'
11+
jobs:
12+
golangci:
13+
strategy:
14+
matrix:
15+
go-version: [1.16.x]
16+
os: [ubuntu-latest, windows-latest]
17+
name: Lint
18+
runs-on: ${{ matrix.os }}
19+
steps:
20+
- uses: actions/checkout@v2
21+
- name: golangci-lint
22+
uses: golangci/golangci-lint-action@v2
23+
with:
24+
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
25+
version: v1.40
26+
# Optional: working directory, useful for monorepos
27+
# working-directory: somedir
28+
29+
# Optional: golangci-lint command line arguments.
30+
# args: --issues-exit-code=0
31+
args: --timeout=5m
32+
33+
# Optional: show only new issues if it's a pull request. The default value is `false`.
34+
only-new-issues: true

.golangci.yml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
issues:
2+
max-same-issues: 0
3+
max-issues-per-linter: 0
4+
5+
enable:
6+
- bodyclose
7+
- deadcode
8+
- errcheck
9+
- goconst
10+
- gocritic
11+
- gocyclo
12+
- gofmt
13+
- goimports
14+
- golint
15+
- gomnd
16+
- goprintffuncname
17+
- gosec
18+
- gosimple
19+
- govet
20+
- ineffassign
21+
- interfacer
22+
- lll
23+
- misspell
24+
- nakedret

cni/netconfig.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,4 @@ func GetPoliciesFromNwCfg(kvp []KVPair) []policy.Policy {
131131
func (nwcfg *NetworkConfig) Serialize() []byte {
132132
bytes, _ := json.Marshal(nwcfg)
133133
return bytes
134-
}
134+
}

cni/network/invoker.go

+20-20
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
package network
2-
3-
import (
4-
"net"
5-
6-
"github.com/Azure/azure-container-networking/cni"
7-
cniTypesCurr "github.com/containernetworking/cni/pkg/types/current"
8-
)
9-
10-
// IPAMInvoker is used by the azure-vnet CNI plugin to call different sources for IPAM.
11-
// This interface can be used to call into external binaries, like the azure-vnet-ipam binary,
12-
// or simply act as a client to an external ipam, such as azure-cns.
13-
type IPAMInvoker interface {
14-
15-
//Add returns two results, one IPv4, the other IPv6.
16-
Add(nwCfg *cni.NetworkConfig, subnetPrefix *net.IPNet, options map[string]interface{}) (*cniTypesCurr.Result, *cniTypesCurr.Result, error)
17-
18-
//Delete calls to the invoker source, and returns error. Returning an error here will fail the CNI Delete call.
19-
Delete(address *net.IPNet, nwCfg *cni.NetworkConfig, options map[string]interface{}) error
20-
}
1+
package network
2+
3+
import (
4+
"net"
5+
6+
"github.com/Azure/azure-container-networking/cni"
7+
cniTypesCurr "github.com/containernetworking/cni/pkg/types/current"
8+
)
9+
10+
// IPAMInvoker is used by the azure-vnet CNI plugin to call different sources for IPAM.
11+
// This interface can be used to call into external binaries, like the azure-vnet-ipam binary,
12+
// or simply act as a client to an external ipam, such as azure-cns.
13+
type IPAMInvoker interface {
14+
15+
//Add returns two results, one IPv4, the other IPv6.
16+
Add(nwCfg *cni.NetworkConfig, subnetPrefix *net.IPNet, options map[string]interface{}) (*cniTypesCurr.Result, *cniTypesCurr.Result, error)
17+
18+
//Delete calls to the invoker source, and returns error. Returning an error here will fail the CNI Delete call.
19+
Delete(address *net.IPNet, nwCfg *cni.NetworkConfig, options map[string]interface{}) error
20+
}

0 commit comments

Comments
 (0)