Skip to content

Commit

Permalink
CI: Add golint-ci (Azure#888)
Browse files Browse the repository at this point in the history
* add golint-ci

* add gofmt

* enable linters

* uncap count

* fix linting/fmt issues
  • Loading branch information
matmerr authored Jun 1, 2021
1 parent 7f2cfc7 commit 1fa243e
Show file tree
Hide file tree
Showing 44 changed files with 525 additions and 475 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.go text eol=lf
2 changes: 2 additions & 0 deletions .github/workflows/cyclonus-netpol-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ on:
branches:
- main
pull_request:
paths:
- 'npm/**'
schedule:
# run once a day at midnight
- cron: '0 0 * * *'
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/repo-hygiene.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: golangci-lint
on:
workflow_dispatch:
push:
branches:
- main
pull_request:
schedule:
# run once a day at midnight
- cron: '0 0 * * *'
jobs:
golangci:
strategy:
matrix:
go-version: [1.16.x]
os: [ubuntu-latest, windows-latest]
name: Lint
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.40
# Optional: working directory, useful for monorepos
# working-directory: somedir

# Optional: golangci-lint command line arguments.
# args: --issues-exit-code=0
args: --timeout=5m

# Optional: show only new issues if it's a pull request. The default value is `false`.
only-new-issues: true
24 changes: 24 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
issues:
max-same-issues: 0
max-issues-per-linter: 0

enable:
- bodyclose
- deadcode
- errcheck
- goconst
- gocritic
- gocyclo
- gofmt
- goimports
- golint
- gomnd
- goprintffuncname
- gosec
- gosimple
- govet
- ineffassign
- interfacer
- lll
- misspell
- nakedret
2 changes: 1 addition & 1 deletion cni/netconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,4 @@ func GetPoliciesFromNwCfg(kvp []KVPair) []policy.Policy {
func (nwcfg *NetworkConfig) Serialize() []byte {
bytes, _ := json.Marshal(nwcfg)
return bytes
}
}
40 changes: 20 additions & 20 deletions cni/network/invoker.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
package network

import (
"net"

"github.com/Azure/azure-container-networking/cni"
cniTypesCurr "github.com/containernetworking/cni/pkg/types/current"
)

// IPAMInvoker is used by the azure-vnet CNI plugin to call different sources for IPAM.
// This interface can be used to call into external binaries, like the azure-vnet-ipam binary,
// or simply act as a client to an external ipam, such as azure-cns.
type IPAMInvoker interface {

//Add returns two results, one IPv4, the other IPv6.
Add(nwCfg *cni.NetworkConfig, subnetPrefix *net.IPNet, options map[string]interface{}) (*cniTypesCurr.Result, *cniTypesCurr.Result, error)

//Delete calls to the invoker source, and returns error. Returning an error here will fail the CNI Delete call.
Delete(address *net.IPNet, nwCfg *cni.NetworkConfig, options map[string]interface{}) error
}
package network

import (
"net"

"github.com/Azure/azure-container-networking/cni"
cniTypesCurr "github.com/containernetworking/cni/pkg/types/current"
)

// IPAMInvoker is used by the azure-vnet CNI plugin to call different sources for IPAM.
// This interface can be used to call into external binaries, like the azure-vnet-ipam binary,
// or simply act as a client to an external ipam, such as azure-cns.
type IPAMInvoker interface {

//Add returns two results, one IPv4, the other IPv6.
Add(nwCfg *cni.NetworkConfig, subnetPrefix *net.IPNet, options map[string]interface{}) (*cniTypesCurr.Result, *cniTypesCurr.Result, error)

//Delete calls to the invoker source, and returns error. Returning an error here will fail the CNI Delete call.
Delete(address *net.IPNet, nwCfg *cni.NetworkConfig, options map[string]interface{}) error
}
Loading

0 comments on commit 1fa243e

Please sign in to comment.