Skip to content

Commit

Permalink
Update to go1.17
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpollet authored Jan 10, 2022
1 parent af218d8 commit a8036b8
Show file tree
Hide file tree
Showing 29 changed files with 1,281 additions and 255 deletions.
45 changes: 30 additions & 15 deletions .golangci.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,40 +15,55 @@
[linters-settings.gocognit]
min-complexity = 15.0

[linters-settings.maligned]
suggest-new = true

[linters-settings.goconst]
min-len = 3.0
min-occurrences = 3.0

[linters-settings.misspell]
locale = "US"

[linters-settings.stylecheck]
checks = ["all", "-ST1000"]

[linters-settings.gomoddirectives]
replace-allow-list = [
"github.com/abbot/go-http-auth",
"github.com/go-check/check",
"github.com/gorilla/mux",
"github.com/mailgun/minheap",
"github.com/mailgun/multibuf",
]

[linters]
enable-all = true
disable = [
"interfacer", # Deprecated
"golint", # Deprecated
"maligned", # Deprecated
"scopelint", # Deprecated
"cyclop", # Duplicate of gocyclo
"lll", # Long lines are ok.
"dupl",
"prealloc",
"maligned",
"gochecknoinits",
"gochecknoglobals",
"dupl", # Not relevant
"prealloc", # Not relevant
"gochecknoinits", # Too strict
"gochecknoglobals", # Too strict
"gomnd", # Does not allow for any config or time values
"gosec", # Does not allow exec.Command with variable
"scopelint",
"funlen",
"bodyclose", # Too many false positives
"godox",
"goconst", # Too many false positives
"testpackage", # Does not allow testing private funcs
"wrapcheck", # Too strict
"goerr113", # Forces wrapping all errors
"noctx", # Too strict
"exhaustive", # Too strict
"exhaustivestruct", # Too strict
"nlreturn", # Too strict
"wrapcheck",
"exhaustivestruct",
"tparallel",
"ireturn", # Not relevant
"varnamelen", # Not relevant
"nilnil", # Not relevant
"testpackage", # Does not allow testing private funcs
"tparallel", # Not relevant
"paralleltest", # Not relevant
"funlen",
]

[issues]
Expand Down
8 changes: 4 additions & 4 deletions .semaphore/semaphore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ global_job_config:
prologue:
commands:
- curl -sSfL https://raw.githubusercontent.com/ldez/semgo/master/godownloader.sh | sudo sh -s -- -b "/usr/local/bin"
- sudo semgo go1.16
- sudo semgo go1.17
- echo "${DOCKERHUB_PASSWORD}" | docker login -u "${DOCKERHUB_USERNAME}" --password-stdin
- checkout

blocks:
- name: Build
run:
when: "branch =~ '.*' OR pull_request =~'.*'"
when: "branch =~ '.*' OR pull_request =~ '.*'"
task:
jobs:
- name: Cache Go dependencies
Expand All @@ -46,7 +46,7 @@ blocks:

- name: Unit Tests
run:
when: "branch =~ '.*' OR pull_request =~'.*'"
when: "branch =~ '.*' OR pull_request =~ '.*'"
task:
prologue:
commands:
Expand All @@ -58,7 +58,7 @@ blocks:

- name: Integration Tests
run:
when: "branch =~ '.*' OR pull_request =~'.*'"
when: "branch =~ '.*' OR pull_request =~ '.*'"
task:
prologue:
commands:
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.16-alpine AS base-image
FROM golang:1.17-alpine AS base-image

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

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

ENV GO111MODULE on
COPY go.mod go.sum ./
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
</p>


[![Travis CI Build Status](https://travis-ci.com/traefik/mesh.svg?branch=master)](https://travis-ci.com/traefik/mesh)
[![Semaphore CI Build Status](https://traefik.semaphoreci.com/badges/mesh/branches/master.svg?style=shields)](https://traefik.semaphoreci.com/projects/mesh)
[![Docs](https://img.shields.io/badge/docs-current-brightgreen.svg)](https://doc.traefik.io/traefik-mesh)
[![Go Report Card](https://goreportcard.com/badge/github.com/traefik/mesh)](https://goreportcard.com/report/github.com/traefik/mesh)
Expand Down
5 changes: 4 additions & 1 deletion cmd/cleanup/cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package cleanup
import (
"context"
"fmt"
"os/signal"
"syscall"

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

func cleanupCommand(cConfig *cmd.CleanupConfiguration) error {
ctx := cmd.ContextWithSignal(context.Background())
ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGTERM, syscall.SIGINT)
defer cancel()

logger, err := cmd.NewLogger(cConfig.LogFormat, cConfig.LogLevel, false)
if err != nil {
Expand Down
17 changes: 0 additions & 17 deletions cmd/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ package cmd

import (
"context"
"os"
"os/signal"
"syscall"
)

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

return ctx
}

// ContextWithSignal creates a context canceled when SIGINT or SIGTERM are notified.
func ContextWithSignal(ctx context.Context) context.Context {
newCtx, cancel := context.WithCancel(ctx)
signals := make(chan os.Signal)
signal.Notify(signals, syscall.SIGINT, syscall.SIGTERM)

go func() {
<-signals
cancel()
}()

return newCtx
}
1 change: 0 additions & 1 deletion cmd/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ func parseLogFormat(format string) (logrus.Formatter, error) {
// NewLogger returns a new field logger with the provided format, level, and debug configurations.
func NewLogger(format, level string, debug bool) (logrus.FieldLogger, error) {
log := logrus.New()

log.SetOutput(os.Stdout)

logLevelStr := level
Expand Down
5 changes: 4 additions & 1 deletion cmd/mesh/mesh.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import (
stdlog "log"
"net/http"
"os"
"os/signal"
"sync"
"syscall"
"time"

"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -67,7 +69,8 @@ func main() {
}

func traefikMeshCommand(config *cmd.TraefikMeshConfiguration) error {
ctx := cmd.ContextWithSignal(context.Background())
ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGTERM, syscall.SIGINT)
defer cancel()

log, err := cmd.NewLogger(config.LogFormat, config.LogLevel, config.Debug)
if err != nil {
Expand Down
5 changes: 4 additions & 1 deletion cmd/prepare/prepare.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package prepare
import (
"context"
"fmt"
"os/signal"
"syscall"

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

func prepareCommand(pConfig *cmd.PrepareConfiguration) error {
ctx := cmd.ContextWithSignal(context.Background())
ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGTERM, syscall.SIGINT)
defer cancel()

log, err := cmd.NewLogger(pConfig.LogFormat, pConfig.LogLevel, pConfig.Debug)
if err != nil {
Expand Down
13 changes: 8 additions & 5 deletions cmd/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package version

import (
"fmt"
"io"
"os"
"runtime"

"github.com/traefik/mesh/pkg/version"
Expand All @@ -24,14 +26,13 @@ func NewCmd() *cli.Command {
Description: `Shows the current Traefik Mesh version.`,
Configuration: nil,
Run: func(_ []string) error {
printVersion()
return nil
return printVersion(os.Stdout)
},
}
}

func printVersion() {
fmt.Printf(
func printVersion(w io.Writer) error {
_, err := io.WriteString(w, fmt.Sprintf(
versionFormat,
version.Version,
version.Commit,
Expand All @@ -40,5 +41,7 @@ func printVersion() {
runtime.Compiler,
runtime.GOOS,
runtime.GOARCH,
)
))

return err
}
12 changes: 6 additions & 6 deletions docs/content/contributing/building-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ $ make
Successfully tagged traefik/mesh:latest
docker run --name=build -t "traefik/mesh:latest" version
version:
version : b417901
commit : b417901
build date : 2020-09-01_09:27:55AM
go version : go1.15
version : d6947526
commit : d6947526
build date : 2021-12-28_03:19:22PM
go version : go1.17.5
go compiler : gc
platform : linux/amd64
#[...]
Expand All @@ -37,7 +37,7 @@ traefik-mesh

Requirements:

- `Go` v1.14+
- `Go` v1.17+
- Environment variable `GO111MODULE=on`

One your Go environment is set up, you can build Traefik Mesh from the sources by using the `go build` command.
Expand All @@ -50,7 +50,7 @@ version:
version : dev
commit : I don't remember exactly
build date : I don't remember exactly
go version : go1.15
go version : go1.17.5
go compiler : gc
platform : linux/amd64
```
Expand Down
60 changes: 53 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,25 +1,71 @@
module github.com/traefik/mesh

go 1.16
go 1.17

require (
github.com/cenkalti/backoff/v4 v4.1.0
github.com/cenkalti/backoff/v4 v4.1.1
github.com/go-check/check v0.0.0-20180628173108-788fd7840127
github.com/google/uuid v1.1.2
github.com/gorilla/mux v1.7.3
github.com/google/uuid v1.2.0
github.com/gorilla/mux v1.8.0
github.com/hashicorp/go-version v1.3.0
github.com/servicemeshinterface/smi-sdk-go v0.4.1
github.com/sirupsen/logrus v1.7.0
github.com/sirupsen/logrus v1.8.1
github.com/stretchr/testify v1.7.0
github.com/traefik/paerser v0.1.4
github.com/traefik/traefik/v2 v2.4.13
github.com/traefik/traefik/v2 v2.5.6
github.com/vdemeester/shakers v0.1.0
k8s.io/api v0.22.5
k8s.io/apimachinery v0.22.5
k8s.io/client-go v0.22.5
)

replace github.com/docker/docker => github.com/docker/engine v1.4.2-0.20200204220554-5f6d6f3f2203
require (
github.com/BurntSushi/toml v0.3.1 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.1.1 // indirect
github.com/Masterminds/sprig/v3 v3.2.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/evanphx/json-patch v4.11.0+incompatible // indirect
github.com/go-acme/lego/v4 v4.5.3 // indirect
github.com/go-logr/logr v0.4.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-cmp v0.5.5 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/googleapis/gnostic v0.5.5 // indirect
github.com/gorilla/context v1.1.1 // indirect
github.com/huandu/xstrings v1.3.1 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/json-iterator/go v1.1.11 // indirect
github.com/mitchellh/copystructure v1.0.0 // indirect
github.com/mitchellh/reflectwalk v1.0.1 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/patrickmn/go-cache v2.1.0+incompatible // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/shopspring/decimal v1.2.0 // indirect
github.com/spf13/cast v1.3.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e // indirect
golang.org/x/net v0.0.0-20211209124913-491a49abca63 // indirect
golang.org/x/oauth2 v0.0.0-20210402161424-2e8d93401602 // indirect
golang.org/x/sys v0.0.0-20210817190340-bfb29a6856f2 // indirect
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d // indirect
golang.org/x/text v0.3.6 // indirect
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/square/go-jose.v2 v2.6.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
k8s.io/klog/v2 v2.9.0 // indirect
k8s.io/kube-openapi v0.0.0-20211109043538-20434351676c // indirect
k8s.io/utils v0.0.0-20210819203725-bdf08cb9a70a // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.1.2 // indirect
sigs.k8s.io/yaml v1.2.0 // indirect
)

// Containous forks
replace (
Expand Down
Loading

0 comments on commit a8036b8

Please sign in to comment.