Skip to content

Commit

Permalink
ci: build with 1.13 and 1.12, lint with golangci-lint
Browse files Browse the repository at this point in the history
  • Loading branch information
dmke committed Sep 19, 2019
1 parent 2810035 commit dcfa228
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 27 deletions.
10 changes: 0 additions & 10 deletions .circleci/check-gofmt

This file was deleted.

26 changes: 15 additions & 11 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
# Check https://circleci.com/docs/2.0/language-go/ for more details
version: 2
jobs:
build:
build-1.13: &build-defaults
docker:
- image: circleci/golang:1.12
- image: circleci/golang:1.13
steps:
- checkout

Expand All @@ -16,22 +16,26 @@ jobs:
# build binary
- run: go install github.com/digineo/http-over-ssh

checks:
build-1.12:
<<: *build-defaults
docker:
- image: circleci/golang:1.12

lint:
docker:
- image: circleci/golang:1.13
environment:
GOLANGCI_LINT_VERSION: v1.18.0
steps:
- checkout

# check goftm
- run: .circleci/check-gofmt

# check misspell
- run: go get github.com/client9/misspell/cmd/misspell
- run: misspell -error *.go *.md
- run: curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s "$GOLANGCI_LINT_VERSION"
- run: ./bin/golangci-lint run

workflows:
version: 2
workflow:
jobs:
- checks
- build
- lint
- build-1.13
- build-1.12
13 changes: 13 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
linters:
enable-all: true
disable:
- gochecknoglobals

issues:
exclude-rules:
- path: _test\.go
linters:
- errcheck
- interfacer
- maligned
- funlen
1 change: 1 addition & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,4 @@ changelog:
exclude:
- '^docs:'
- '^test:'
- '^ci:'
1 change: 1 addition & 0 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ func TestInvalidRequestURI(t *testing.T) {

res := w.Result()
body, err := ioutil.ReadAll(res.Body)
res.Body.Close()

assert.NoError(err)
assert.Equal(400, res.StatusCode)
Expand Down
2 changes: 1 addition & 1 deletion http.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (proxy *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// copy response header and body
copyHeader(w.Header(), res.Header)
w.WriteHeader(res.StatusCode)
io.Copy(w, res.Body)
_, _ = io.Copy(w, res.Body)
res.Body.Close()
}

Expand Down
9 changes: 5 additions & 4 deletions metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ func (e *prometheusExporter) Describe(c chan<- *prometheus.Desc) {

// Collect implements (part of the) prometheus.Collector interface.
func (e prometheusExporter) Collect(c chan<- prometheus.Metric) {
c <- prometheus.MustNewConstMetric(sshConnectionsDesc, prometheus.CounterValue, float64(e.connections.established), "established")
c <- prometheus.MustNewConstMetric(sshConnectionsDesc, prometheus.CounterValue, float64(e.connections.failed), "failed")
c <- prometheus.MustNewConstMetric(sshForwardingsDesc, prometheus.CounterValue, float64(e.forwardings.established), "established")
c <- prometheus.MustNewConstMetric(sshForwardingsDesc, prometheus.CounterValue, float64(e.forwardings.failed), "failed")
const C = prometheus.CounterValue
c <- prometheus.MustNewConstMetric(sshConnectionsDesc, C, float64(e.connections.established), "established")
c <- prometheus.MustNewConstMetric(sshConnectionsDesc, C, float64(e.connections.failed), "failed")
c <- prometheus.MustNewConstMetric(sshForwardingsDesc, C, float64(e.forwardings.established), "established")
c <- prometheus.MustNewConstMetric(sshForwardingsDesc, C, float64(e.forwardings.failed), "failed")

proxy.mtx.Lock()
for key, client := range proxy.clients {
Expand Down
2 changes: 1 addition & 1 deletion proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (proxy *Proxy) getClient(key clientKey) *client {
defer proxy.mtx.Unlock()

// connection established?
pClient, _ := proxy.clients[key]
pClient := proxy.clients[key]
if pClient != nil {
return pClient
}
Expand Down

0 comments on commit dcfa228

Please sign in to comment.