Skip to content

Commit a8036b8

Browse files
authored
Update to go1.17
1 parent af218d8 commit a8036b8

File tree

29 files changed

+1281
-255
lines changed

29 files changed

+1281
-255
lines changed

.golangci.toml

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,40 +15,55 @@
1515
[linters-settings.gocognit]
1616
min-complexity = 15.0
1717

18-
[linters-settings.maligned]
19-
suggest-new = true
20-
2118
[linters-settings.goconst]
2219
min-len = 3.0
2320
min-occurrences = 3.0
2421

2522
[linters-settings.misspell]
2623
locale = "US"
2724

25+
[linters-settings.stylecheck]
26+
checks = ["all", "-ST1000"]
27+
28+
[linters-settings.gomoddirectives]
29+
replace-allow-list = [
30+
"github.com/abbot/go-http-auth",
31+
"github.com/go-check/check",
32+
"github.com/gorilla/mux",
33+
"github.com/mailgun/minheap",
34+
"github.com/mailgun/multibuf",
35+
]
36+
2837
[linters]
2938
enable-all = true
3039
disable = [
40+
"interfacer", # Deprecated
41+
"golint", # Deprecated
42+
"maligned", # Deprecated
43+
"scopelint", # Deprecated
44+
"cyclop", # Duplicate of gocyclo
3145
"lll", # Long lines are ok.
32-
"dupl",
33-
"prealloc",
34-
"maligned",
35-
"gochecknoinits",
36-
"gochecknoglobals",
46+
"dupl", # Not relevant
47+
"prealloc", # Not relevant
48+
"gochecknoinits", # Too strict
49+
"gochecknoglobals", # Too strict
3750
"gomnd", # Does not allow for any config or time values
3851
"gosec", # Does not allow exec.Command with variable
39-
"scopelint",
40-
"funlen",
4152
"bodyclose", # Too many false positives
42-
"godox",
4353
"goconst", # Too many false positives
44-
"testpackage", # Does not allow testing private funcs
54+
"wrapcheck", # Too strict
4555
"goerr113", # Forces wrapping all errors
4656
"noctx", # Too strict
4757
"exhaustive", # Too strict
58+
"exhaustivestruct", # Too strict
4859
"nlreturn", # Too strict
49-
"wrapcheck",
50-
"exhaustivestruct",
51-
"tparallel",
60+
"ireturn", # Not relevant
61+
"varnamelen", # Not relevant
62+
"nilnil", # Not relevant
63+
"testpackage", # Does not allow testing private funcs
64+
"tparallel", # Not relevant
65+
"paralleltest", # Not relevant
66+
"funlen",
5267
]
5368

5469
[issues]

.semaphore/semaphore.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ global_job_config:
2020
prologue:
2121
commands:
2222
- curl -sSfL https://raw.githubusercontent.com/ldez/semgo/master/godownloader.sh | sudo sh -s -- -b "/usr/local/bin"
23-
- sudo semgo go1.16
23+
- sudo semgo go1.17
2424
- echo "${DOCKERHUB_PASSWORD}" | docker login -u "${DOCKERHUB_USERNAME}" --password-stdin
2525
- checkout
2626

2727
blocks:
2828
- name: Build
2929
run:
30-
when: "branch =~ '.*' OR pull_request =~'.*'"
30+
when: "branch =~ '.*' OR pull_request =~ '.*'"
3131
task:
3232
jobs:
3333
- name: Cache Go dependencies
@@ -46,7 +46,7 @@ blocks:
4646

4747
- name: Unit Tests
4848
run:
49-
when: "branch =~ '.*' OR pull_request =~'.*'"
49+
when: "branch =~ '.*' OR pull_request =~ '.*'"
5050
task:
5151
prologue:
5252
commands:
@@ -58,7 +58,7 @@ blocks:
5858

5959
- name: Integration Tests
6060
run:
61-
when: "branch =~ '.*' OR pull_request =~'.*'"
61+
when: "branch =~ '.*' OR pull_request =~ '.*'"
6262
task:
6363
prologue:
6464
commands:

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.16-alpine AS base-image
1+
FROM golang:1.17-alpine AS base-image
22

33
# Package dependencies
44
RUN apk --no-cache --no-progress add \
@@ -21,7 +21,7 @@ WORKDIR /go/src/github.com/traefik/mesh
2121
RUN curl -sfL https://gist.githubusercontent.com/traefiker/6d7ac019c11d011e4f131bb2cca8900e/raw/goreleaser.sh | sh
2222

2323
# Download golangci-lint binary to bin folder in $GOPATH
24-
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $GOPATH/bin v1.32.0
24+
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $GOPATH/bin v1.43.0
2525

2626
ENV GO111MODULE on
2727
COPY go.mod go.sum ./

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
</p>
44

55

6-
[![Travis CI Build Status](https://travis-ci.com/traefik/mesh.svg?branch=master)](https://travis-ci.com/traefik/mesh)
76
[![Semaphore CI Build Status](https://traefik.semaphoreci.com/badges/mesh/branches/master.svg?style=shields)](https://traefik.semaphoreci.com/projects/mesh)
87
[![Docs](https://img.shields.io/badge/docs-current-brightgreen.svg)](https://doc.traefik.io/traefik-mesh)
98
[![Go Report Card](https://goreportcard.com/badge/github.com/traefik/mesh)](https://goreportcard.com/report/github.com/traefik/mesh)

cmd/cleanup/cleanup.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package cleanup
33
import (
44
"context"
55
"fmt"
6+
"os/signal"
7+
"syscall"
68

79
"github.com/traefik/mesh/cmd"
810
"github.com/traefik/mesh/pkg/cleanup"
@@ -24,7 +26,8 @@ func NewCmd(cConfig *cmd.CleanupConfiguration, loaders []cli.ResourceLoader) *cl
2426
}
2527

2628
func cleanupCommand(cConfig *cmd.CleanupConfiguration) error {
27-
ctx := cmd.ContextWithSignal(context.Background())
29+
ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGTERM, syscall.SIGINT)
30+
defer cancel()
2831

2932
logger, err := cmd.NewLogger(cConfig.LogFormat, cConfig.LogLevel, false)
3033
if err != nil {

cmd/context.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ package cmd
22

33
import (
44
"context"
5-
"os"
6-
"os/signal"
7-
"syscall"
85
)
96

107
// ContextWithStopChan creates a context canceled when the given stopCh receives a message
@@ -23,17 +20,3 @@ func ContextWithStopChan(ctx context.Context, stopCh <-chan struct{}) context.Co
2320

2421
return ctx
2522
}
26-
27-
// ContextWithSignal creates a context canceled when SIGINT or SIGTERM are notified.
28-
func ContextWithSignal(ctx context.Context) context.Context {
29-
newCtx, cancel := context.WithCancel(ctx)
30-
signals := make(chan os.Signal)
31-
signal.Notify(signals, syscall.SIGINT, syscall.SIGTERM)
32-
33-
go func() {
34-
<-signals
35-
cancel()
36-
}()
37-
38-
return newCtx
39-
}

cmd/log.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ func parseLogFormat(format string) (logrus.Formatter, error) {
2727
// NewLogger returns a new field logger with the provided format, level, and debug configurations.
2828
func NewLogger(format, level string, debug bool) (logrus.FieldLogger, error) {
2929
log := logrus.New()
30-
3130
log.SetOutput(os.Stdout)
3231

3332
logLevelStr := level

cmd/mesh/mesh.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import (
77
stdlog "log"
88
"net/http"
99
"os"
10+
"os/signal"
1011
"sync"
12+
"syscall"
1113
"time"
1214

1315
"github.com/sirupsen/logrus"
@@ -67,7 +69,8 @@ func main() {
6769
}
6870

6971
func traefikMeshCommand(config *cmd.TraefikMeshConfiguration) error {
70-
ctx := cmd.ContextWithSignal(context.Background())
72+
ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGTERM, syscall.SIGINT)
73+
defer cancel()
7174

7275
log, err := cmd.NewLogger(config.LogFormat, config.LogLevel, config.Debug)
7376
if err != nil {

cmd/prepare/prepare.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package prepare
33
import (
44
"context"
55
"fmt"
6+
"os/signal"
7+
"syscall"
68

79
"github.com/traefik/mesh/cmd"
810
"github.com/traefik/mesh/pkg/dns"
@@ -25,7 +27,8 @@ func NewCmd(pConfig *cmd.PrepareConfiguration, loaders []cli.ResourceLoader) *cl
2527
}
2628

2729
func prepareCommand(pConfig *cmd.PrepareConfiguration) error {
28-
ctx := cmd.ContextWithSignal(context.Background())
30+
ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGTERM, syscall.SIGINT)
31+
defer cancel()
2932

3033
log, err := cmd.NewLogger(pConfig.LogFormat, pConfig.LogLevel, pConfig.Debug)
3134
if err != nil {

cmd/version/version.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package version
22

33
import (
44
"fmt"
5+
"io"
6+
"os"
57
"runtime"
68

79
"github.com/traefik/mesh/pkg/version"
@@ -24,14 +26,13 @@ func NewCmd() *cli.Command {
2426
Description: `Shows the current Traefik Mesh version.`,
2527
Configuration: nil,
2628
Run: func(_ []string) error {
27-
printVersion()
28-
return nil
29+
return printVersion(os.Stdout)
2930
},
3031
}
3132
}
3233

33-
func printVersion() {
34-
fmt.Printf(
34+
func printVersion(w io.Writer) error {
35+
_, err := io.WriteString(w, fmt.Sprintf(
3536
versionFormat,
3637
version.Version,
3738
version.Commit,
@@ -40,5 +41,7 @@ func printVersion() {
4041
runtime.Compiler,
4142
runtime.GOOS,
4243
runtime.GOARCH,
43-
)
44+
))
45+
46+
return err
4447
}

0 commit comments

Comments
 (0)