Skip to content

Commit

Permalink
fix lint && add docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
halfcrazy committed Mar 28, 2019
1 parent 496e370 commit 44eafc5
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.idea/*
dist/images/kube-ovn
dist/images/kube-ovn-controller
dist/images/kube-ovn-daemon
dist/images/kube-ovn-daemon
dist/images/kube-ovn-gateway
27 changes: 24 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
.PHONY: build-dev-images build-go
GOFILES_NOVENDOR=$(shell find . -type f -name '*.go' -not -path "./vendor/*")
GO_VERSION=1.12

build-dev-images: build-go
.PHONY: build-dev-images build-go build-bin test lint

build-dev-images: build-bin
docker build -t index.alauda.cn/alaudak8s/kube-ovn-node:dev -f dist/images/Dockerfile.node dist/images/
docker push index.alauda.cn/alaudak8s/kube-ovn-node:dev
docker build -t index.alauda.cn/alaudak8s/kube-ovn-controller:dev -f dist/images/Dockerfile.controller dist/images/
Expand All @@ -20,4 +23,22 @@ release: build-go
docker build -t index.alauda.cn/alaudak8s/kube-ovn-controller:`cat VERSION` -f dist/images/Dockerfile.controller dist/images/
docker push index.alauda.cn/alaudak8s/kube-ovn-controller:`cat VERSION`
docker build -t index.alauda.cn/alaudak8s/kube-ovn-cni:`cat VERSION` -f dist/images/Dockerfile.cni dist/images/
docker push index.alauda.cn/alaudak8s/kube-ovn-cni:`cat VERSION`
docker push index.alauda.cn/alaudak8s/kube-ovn-cni:`cat VERSION`

lint:
@gofmt -d ${GOFILES_NOVENDOR}
@gofmt -l ${GOFILES_NOVENDOR} | read && echo "Code differs from gofmt's style" 1>&2 && exit 1 || true
@GOOS=linux go vet ./...

test:
go test -cover -v ./...

build-bin: lint
docker run -e GOOS=linux -e GOCACHE=/tmp \
-u $(shell id -u):$(shell id -g) \
-v $(CURDIR):/go/src/bitbucket.org/mathildetech/kube-ovn:ro \
-v $(CURDIR)/dist:/go/src/bitbucket.org/mathildetech/kube-ovn/dist/ \
golang:$(GO_VERSION) /bin/bash -c '\
cd /go/src/bitbucket.org/mathildetech/kube-ovn && \
make test && \
make build-go '
4 changes: 2 additions & 2 deletions pkg/controller/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,12 @@ func (c *Controller) handleUpdateEndpoint(key string) error {
if port.Protocol == v1.ProtocolTCP {
err = c.ovnClient.CreateLoadBalancerRule(c.config.ClusterTcpLoadBalancer, vip, convertIpToAddress(backends, targetPort))
if err != nil {
klog.Errorf("failed to update vip %s to tcp lb")
klog.Errorf("failed to update vip %s to tcp lb, %v", vip, err)
}
} else {
err = c.ovnClient.CreateLoadBalancerRule(c.config.ClusterUdpLoadBalancer, vip, convertIpToAddress(backends, targetPort))
if err != nil {
klog.Errorf("failed to update vip %s to udp lb")
klog.Errorf("failed to update vip %s to udp lb, %v", vip, err)
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion pkg/controller/handler_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package controller

import (
"github.com/oilbeater/libovsdb"
"testing"

"github.com/oilbeater/libovsdb"
)

func TestListSwitch(t *testing.T) {
t.Skip()
ovs, e := libovsdb.Connect("127.0.0.1", 6641)
if e != nil {
t.Error(e)
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func (c *Controller) handleAddNode(key string) error {
patchPayload := fmt.Sprintf(patchPayloadTemplate, op, raw)
_, err = c.kubeclientset.CoreV1().Nodes().Patch(key, types.JSONPatchType, []byte(patchPayload))
if err != nil {
klog.Errorf("patch node % failed %v", key, err)
klog.Errorf("patch node %s failed %v", key, err)
}
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/nicstobridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func BridgeToNic(bridge string) error {
stdout, err = exec.Command("ovs-vsctl", "--", "--if-exists", "del-port", "br-int",
fmt.Sprintf("k8s-patch-br-int-%s", bridge)).CombinedOutput()
if err != nil {
klog.Errorf("Failed to delete patch port on br-int, %v", string(stdout), err)
klog.Errorf("Failed to delete patch port on br-int, %s %v", string(stdout), err)
return err
}

Expand Down

0 comments on commit 44eafc5

Please sign in to comment.