Skip to content

Commit fbe1778

Browse files
committed
add CI and fix code to pass linting
Signed-off-by: Patrik Cyvoct <[email protected]>
1 parent 72862c0 commit fbe1778

File tree

7 files changed

+61
-7
lines changed

7 files changed

+61
-7
lines changed

.golangci.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# taken from https://github.com/kubernetes-sigs/kustomize/blob/master/.golangci.yml
2+
run:
3+
deadline: 5m
4+
5+
linters:
6+
disable-all: true
7+
enable:
8+
- dupl
9+
- goconst
10+
# - gocyclo
11+
- gofmt
12+
- golint
13+
- govet
14+
- ineffassign
15+
# - interfacer
16+
- lll
17+
- misspell
18+
- nakedret
19+
- structcheck
20+
# - unparam
21+
- varcheck
22+
23+
linters-settings:
24+
dupl:
25+
threshold: 400
26+
lll:
27+
line-length: 170
28+
# gocyclo:
29+
# min-complexity: 15
30+
golint:
31+
min-confidence: 0.85

.travis.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
language: go
2+
go:
3+
- 1.13.x
4+
git:
5+
depth: 1
6+
install: true
7+
notifications:
8+
email: false
9+
before_script:
10+
- go install github.com/golangci/golangci-lint/cmd/golangci-lint
11+
script:
12+
- golangci-lint run --skip-files ".*.pb.go"
13+
- go test -v ./... # go test -v -race ./... is failing, should be fixed

cmd/agent/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ func (a *Agent) run(o *GrpcProxyAgentOptions) error {
157157
return nil
158158
}
159159

160-
func (p *Agent) runProxyConnection(o *GrpcProxyAgentOptions) error {
160+
func (a *Agent) runProxyConnection(o *GrpcProxyAgentOptions) error {
161161
agentCert, err := tls.LoadX509KeyPair(o.agentCert, o.agentKey)
162162
if err != nil {
163163
return fmt.Errorf("failed to load X509 key pair %s and %s: %v", o.agentCert, o.agentKey, err)
@@ -190,7 +190,7 @@ func (p *Agent) runProxyConnection(o *GrpcProxyAgentOptions) error {
190190
return nil
191191
}
192192

193-
func (p *Agent) runAdminServer(o *GrpcProxyAgentOptions) error {
193+
func (a *Agent) runAdminServer(o *GrpcProxyAgentOptions) error {
194194
livenessHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
195195
fmt.Fprintf(w, "ok")
196196
})

cmd/proxy/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
"net"
2626
"net/http"
2727
"os"
28-
28+
2929
"github.com/prometheus/client_golang/prometheus"
3030
"github.com/spf13/cobra"
3131
"github.com/spf13/pflag"

pkg/agent/agentclient/client_test.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
)
1616

1717
func TestServeData_HTTP(t *testing.T) {
18+
var err error
1819
var stream agent.AgentService_ConnectClient
1920
client := &AgentClient{
2021
connContext: make(map[int64]*connContext),
@@ -35,7 +36,10 @@ func TestServeData_HTTP(t *testing.T) {
3536

3637
// Stimulate sending KAS DIAL_REQ to AgentClient
3738
dialPacket := newDialPacket("tcp", ts.URL[len("http://"):], 111)
38-
stream.Send(dialPacket)
39+
err = stream.Send(dialPacket)
40+
if err != nil {
41+
t.Error(err.Error())
42+
}
3943

4044
// Expect receiving DIAL_RSP packet from AgentClient
4145
pkg, _ := stream.Recv()
@@ -53,7 +57,10 @@ func TestServeData_HTTP(t *testing.T) {
5357

5458
// Send Data (HTTP Request) via AgentClient to the test http server
5559
dataPacket := newDataPacket(connID, []byte("GET / HTTP/1.1\r\nHost: localhost\r\n\r\n"))
56-
stream.Send(dataPacket)
60+
err = stream.Send(dataPacket)
61+
if err != nil {
62+
t.Error(err.Error())
63+
}
5764

5865
// Expect receiving http response via AgentClient
5966
pkg, _ = stream.Recv()

pkg/agent/agentserver/tunnel.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,10 @@ func (t *Tunnel) ServeHTTP(w http.ResponseWriter, r *http.Request) {
121121
},
122122
},
123123
}
124-
t.Server.Backend.Send(packet)
124+
err = t.Server.Backend.Send(packet)
125+
if err != nil {
126+
klog.Errorf("Error sending packet %v", err)
127+
}
125128
klog.Infof("Forwarding on tunnel, packet %v", string(pkt[:n]))
126129
}
127130

pkg/util/flags.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ import "strings"
2222
// we should always use hyphens instead of underscores when registering component flags
2323
func Normalize(s string) string {
2424
return strings.Replace(s, "_", "-", -1)
25-
}
25+
}

0 commit comments

Comments
 (0)