Skip to content

Commit

Permalink
Merge branch v1.4 into master
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpollet committed Jan 18, 2022
2 parents 957da2d + a8036b8 commit ef03c40
Show file tree
Hide file tree
Showing 32 changed files with 1,362 additions and 302 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
6 changes: 3 additions & 3 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 @@ -18,10 +18,10 @@ RUN apk --no-cache --no-progress add \
WORKDIR /go/src/github.com/traefik/mesh

# Download goreleaser binary to bin folder in $GOPATH
RUN curl -sfL https://install.goreleaser.com/github.com/goreleaser/goreleaser.sh | sh
RUN curl -sfL https://gist.githubusercontent.com/traefiker/6d7ac019c11d011e4f131bb2cca8900e/raw/goreleaser.sh | sh

# Download golangci-lint binary to bin folder in $GOPATH
RUN curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -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
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
identification within third-party archives.

Copyright 2020 Containous SAS
Copyright 2020 Traefik Labs
Copyright 2020-2022 Traefik Labs

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
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/v2/cmd"
"github.com/traefik/mesh/v2/pkg/cleanup"
Expand All @@ -24,7 +26,8 @@ func NewCmd(config *Configuration, loaders []cli.ResourceLoader) *cli.Command {
}

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

logger, err := cmd.NewLogger(config.LogFormat, config.LogLevel)
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
}
5 changes: 4 additions & 1 deletion cmd/dns/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package dns
import (
"context"
"fmt"
"os/signal"
"syscall"
"time"

"github.com/sirupsen/logrus"
Expand All @@ -29,7 +31,8 @@ func NewCmd(config *Configuration, loaders []cli.ResourceLoader) *cli.Command {
}

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

logger, err := cmd.NewLogger(config.LogFormat, config.LogLevel)
if err != nil {
Expand Down
15 changes: 7 additions & 8 deletions cmd/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,22 @@ func parseLogFormat(format string) (logrus.Formatter, error) {

// NewLogger returns a new field logger with the provided format and level.
func NewLogger(format, level string) (logrus.FieldLogger, error) {
log := logrus.New()

log.SetOutput(os.Stdout)
logger := logrus.New()
logger.SetOutput(os.Stdout)

logLevel, err := parseLogLevel(level)
if err != nil {
return log, err
return logger, err
}

log.SetLevel(logLevel)
logger.SetLevel(logLevel)

logFormat, err := parseLogFormat(format)
if err != nil {
return log, err
return logger, err
}

log.SetFormatter(logFormat)
logger.SetFormatter(logFormat)

return log, nil
return logger, nil
}
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/traefik/mesh/v2/cmd"
Expand Down Expand Up @@ -66,7 +68,8 @@ func main() {
}

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

logger, err := cmd.NewLogger(config.LogFormat, config.LogLevel)
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/v2/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
}
23 changes: 19 additions & 4 deletions docs/content/compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,26 @@

Traefik Mesh supports, [similar to Kubernetes](https://kubernetes.io/docs/setup/release/version-skew-policy/#supported-versions), at least the latest three minor versions of Kubernetes, therefore currently:

* 1.17
* 1.18
* 1.19
* 1.21
* 1.22
* 1.23

General functionality cannot be guaranteed for versions older than that. However, we expect it to work with Kubernetes down to 1.11 currently.
General functionality cannot be guaranted for versions older than that. However, we expect it to work with Kubernetes down to 1.11 currently.

## Compatibility by Features

Some of Traefik Mesh's features are only supported on certain Kubernetes versions.
Please see the table below.

| Features | K8s 1.21 | K8s 1.22 | K8s 1.23 |
|-----------------------|----------|----------|----------|
| General functionality ||||
| Service Topology || - | - |

!!! warning "Service Topology"

In Kubernetes `v1.22`, the experimental Service Topology feature was removed.
Therefore, starting from Traefik Mesh `v1.4.5`, the support of this feature has been removed.

## SMI Specification support

Expand Down
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

0 comments on commit ef03c40

Please sign in to comment.