Add 'go fmt', golint and 'go vet' in CI

This change introduces go fmt/golint/go vet in CI pipeline to check
the code for each commit. In addition, this change changes code
to pass these checks.
This commit is contained in:
Tomofumi Hayashi 2018-03-28 17:21:52 +09:00
parent 1d2b6a1aee
commit 393d5f47e5
2 changed files with 15 additions and 15 deletions

View File

@ -7,13 +7,14 @@ dist: trusty
before_install:
- sudo apt-get update -qq
#install:
# - go get .
# - go get github.com/golang/lint/golint
install:
- go get github.com/golang/lint/golint
#before_script:
# - go vet .
# - golint . | xargs -r false
before_script:
- golint ./multus/... | grep -v ALL_CAPS | xargs -r false
- go fmt ./multus/...
- go vet ./multus/...
# - gocyclo -over 15 ./multus
script:
- ./build

View File

@ -43,6 +43,7 @@ const defaultCNIDir = "/var/lib/cni/multus"
var masterpluginEnabled bool
var defaultcninetwork bool
// NetConf for cni config file written in json
type NetConf struct {
types.NetConf
CNIDir string `json:"cniDir"`
@ -50,10 +51,6 @@ type NetConf struct {
Kubeconfig string `json:"kubeconfig"`
}
type PodNet struct {
Networkname string `json:"name"`
}
type netplugin struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty" description:"standard object metadata"`
@ -316,7 +313,7 @@ func parsePodNetworkObject(podnetwork string) ([]map[string]interface{}, error)
if len(atItems) == 2 {
m["interfaceRequest"] = atItems[1]
}
podNet = append(podNet,m)
podNet = append(podNet, m)
}
}
@ -345,7 +342,7 @@ func getpluginargs(name string, args string, primary bool, ifname string) (strin
if ifname != "" {
tmpargs = append(tmpargs, fmt.Sprintf(`"ifnameRequest": "%s",`, ifname))
}
tmpargs = append(tmpargs, args[strings.Index(args, "\"") : len(args)-1])
tmpargs = append(tmpargs, args[strings.Index(args, "\""):len(args)-1])
var str bytes.Buffer
@ -439,7 +436,9 @@ func getMultusDelegates(delegate string) ([]map[string]interface{}, error) {
return tmpNetconf.Delegates, nil
}
// NoK8sNetworkError indicates error, no network in kubernetes
type NoK8sNetworkError string
func (e NoK8sNetworkError) Error() string { return string(e) }
func getK8sNetwork(args *skel.CmdArgs, kubeconfig string) ([]map[string]interface{}, error) {