Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez authored and traefiker committed Jul 3, 2018
1 parent bb14ec7 commit 17ad515
Show file tree
Hide file tree
Showing 38 changed files with 93 additions and 182 deletions.
10 changes: 5 additions & 5 deletions cluster/datastore.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func (d *Datastore) Begin() (Transaction, Object, error) {
operation := func() error {
meta := d.get()
if meta.Lock != id {
return fmt.Errorf("Object lock value: expected %s, got %s", id, meta.Lock)
return fmt.Errorf("object lock value: expected %s, got %s", id, meta.Lock)
}
return nil
}
Expand All @@ -167,7 +167,7 @@ func (d *Datastore) Begin() (Transaction, Object, error) {
ebo.MaxElapsedTime = 60 * time.Second
err = backoff.RetryNotify(safe.OperationWithRecover(operation), ebo, notify)
if err != nil {
return nil, nil, fmt.Errorf("Datastore cannot sync: %v", err)
return nil, nil, fmt.Errorf("datastore cannot sync: %v", err)
}

// we synced with KV store, we can now return Setter
Expand Down Expand Up @@ -224,12 +224,12 @@ func (s *datastoreTransaction) Commit(object Object) error {
s.localLock.Lock()
defer s.localLock.Unlock()
if s.dirty {
return fmt.Errorf("Transaction already used, please begin a new one")
return fmt.Errorf("transaction already used, please begin a new one")
}
s.Datastore.meta.object = object
err := s.Datastore.meta.Marshall()
if err != nil {
return fmt.Errorf("Marshall error: %s", err)
return fmt.Errorf("marshall error: %s", err)
}
err = s.kv.StoreConfig(s.Datastore.meta)
if err != nil {
Expand All @@ -238,7 +238,7 @@ func (s *datastoreTransaction) Commit(object Object) error {

err = s.remoteLock.Unlock()
if err != nil {
return fmt.Errorf("Unlock error: %s", err)
return fmt.Errorf("unlock error: %s", err)
}

s.dirty = true
Expand Down
2 changes: 1 addition & 1 deletion cmd/bug/bug.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Add more configuration information here.
// NewCmd builds a new Bug command
func NewCmd(traefikConfiguration *cmd.TraefikConfiguration, traefikPointersConfiguration *cmd.TraefikConfiguration) *flaeg.Command {

//version Command init
// version Command init
return &flaeg.Command{
Name: "bug",
Description: `Report an issue on Traefik bugtracker`,
Expand Down
2 changes: 1 addition & 1 deletion configuration/router/internal_router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ func TestWithMiddleware(t *testing.T) {
request := httptest.NewRequest(http.MethodGet, "/test", nil)
internalMuxRouter.ServeHTTP(recorder, request)

obtained := string(recorder.Body.Bytes())
obtained := recorder.Body.String()

assert.Equal(t, "before middleware1|before middleware2|router|after middleware2|after middleware1", obtained)
}
Expand Down
2 changes: 1 addition & 1 deletion docs/configuration/backends/file.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Træfik can be configured with a file.
trustForwardHeader = true
authResponseHeaders = ["X-Auth-User"]
[frontends.frontend1.auth.forward.tls]
ca = [ "path/to/local.crt"]
ca = "path/to/local.crt"
caOptional = true
cert = "path/to/foo.cert"
key = "path/to/foo.key"
Expand Down
4 changes: 2 additions & 2 deletions docs/configuration/entrypoints.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
trustForwardHeader = true
authResponseHeaders = ["X-Auth-User"]
[entryPoints.http.auth.forward.tls]
ca = [ "path/to/local.crt"]
ca = "path/to/local.crt"
caOptional = true
cert = "path/to/foo.cert"
key = "path/to/foo.key"
Expand Down Expand Up @@ -347,7 +347,7 @@ Otherwise, the response from the authentication server is returned.
# Optional
#
[entryPoints.http.auth.forward.tls]
ca = [ "path/to/local.crt"]
ca = "path/to/local.crt"
caOptional = true
cert = "path/to/foo.cert"
key = "path/to/foo.key"
Expand Down
8 changes: 5 additions & 3 deletions h2c/h2c.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ func init() {
// to provide an http.Server.
type Server struct {
*http.Server
originalHandler http.Handler
}

// Serve Put a middleware around the original handler to handle h2c
Expand Down Expand Up @@ -101,6 +100,9 @@ func initH2CWithPriorKnowledge(w http.ResponseWriter) (net.Conn, error) {

buf := make([]byte, len(expectedBody))
n, err := io.ReadFull(rw, buf)
if err != nil {
return nil, fmt.Errorf("fail to read body: %v", err)
}

if bytes.Equal(buf[0:n], []byte(expectedBody)) {
c := &rwConn{
Expand Down Expand Up @@ -132,7 +134,7 @@ func drainClientPreface(r io.Reader) error {
return err
}
if n != prefaceLen || buf.String() != http2.ClientPreface {
return fmt.Errorf("Client never sent: %s", http2.ClientPreface)
return fmt.Errorf("client never sent: %s", http2.ClientPreface)
}
return nil
}
Expand Down Expand Up @@ -363,7 +365,7 @@ func getH2Settings(h http.Header) ([]http2.Setting, error) {
}
settings, err := decodeSettings(vals[0])
if err != nil {
return nil, fmt.Errorf("Invalid HTTP2-Settings: %q", vals[0])
return nil, fmt.Errorf("invalid HTTP2-Settings: %q", vals[0])
}
return settings, nil
}
Expand Down
8 changes: 4 additions & 4 deletions integration/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func (s *SimpleSuite) TestInvalidConfigShouldFail(c *check.C) {
actual := output.String()

if !strings.Contains(actual, expected) {
return fmt.Errorf("Got %s, wanted %s", actual, expected)
return fmt.Errorf("got %s, wanted %s", actual, expected)
}

return nil
Expand Down Expand Up @@ -72,7 +72,7 @@ func (s *SimpleSuite) TestDefaultEntryPoints(c *check.C) {
actual := output.String()

if !strings.Contains(actual, expected) {
return fmt.Errorf("Got %s, wanted %s", actual, expected)
return fmt.Errorf("got %s, wanted %s", actual, expected)
}

return nil
Expand All @@ -93,10 +93,10 @@ func (s *SimpleSuite) TestPrintHelp(c *check.C) {
actual := output.String()

if strings.Contains(actual, notExpected) {
return fmt.Errorf("Got %s", actual)
return fmt.Errorf("got %s", actual)
}
if !strings.Contains(actual, expected) {
return fmt.Errorf("Got %s, wanted %s", actual, expected)
return fmt.Errorf("got %s, wanted %s", actual, expected)
}

return nil
Expand Down
4 changes: 2 additions & 2 deletions integration/consul_catalog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ func (s *ConsulCatalogSuite) TestRefreshConfigPortChange(c *check.C) {
}

func (s *ConsulCatalogSuite) TestRetryWithConsulServer(c *check.C) {
//Scale consul to 0 to be able to start traefik before and test retry
// Scale consul to 0 to be able to start traefik before and test retry
s.composeProject.Scale(c, "consul", 0)

cmd, display := s.traefikCmd(
Expand Down Expand Up @@ -547,7 +547,7 @@ func (s *ConsulCatalogSuite) TestRetryWithConsulServer(c *check.C) {
}

func (s *ConsulCatalogSuite) TestServiceWithMultipleHealthCheck(c *check.C) {
//Scale consul to 0 to be able to start traefik before and test retry
// Scale consul to 0 to be able to start traefik before and test retry
s.composeProject.Scale(c, "consul", 0)

cmd, display := s.traefikCmd(
Expand Down
4 changes: 2 additions & 2 deletions integration/consul_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ func (s *ConsulSuite) TestGlobalConfiguration(c *check.C) {
err = try.GetRequest("http://127.0.0.1:8080/api/providers", 60*time.Second, try.BodyContains("Path:/test"))
c.Assert(err, checker.IsNil)

//check
// check
req, err := http.NewRequest(http.MethodGet, "http://127.0.0.1:8001/", nil)
c.Assert(err, checker.IsNil)
req.Host = "test.localhost"
Expand Down Expand Up @@ -469,7 +469,7 @@ func datastoreContains(datastore *cluster.Datastore, expectedValue string) func(
return func() error {
kvStruct := datastore.Get().(*TestStruct)
if kvStruct.String != expectedValue {
return fmt.Errorf("Got %s, wanted %s", kvStruct.String, expectedValue)
return fmt.Errorf("got %s, wanted %s", kvStruct.String, expectedValue)
}
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion integration/docker_compose_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (s *DockerComposeSuite) TestComposeScale(c *check.C) {

s.composeProject.Scale(c, composeService, serviceCount)

file := s.adaptFileForHost(c, "fixtures/docker/simple.toml")
file := s.adaptFileForHost(c, "fixtures/docker/minimal.toml")
defer os.Remove(file)

cmd, display := s.traefikCmd(withConfigFile(file))
Expand Down
2 changes: 1 addition & 1 deletion integration/error_pages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (s *ErrorPagesSuite) TestSimpleConfiguration(c *check.C) {

func (s *ErrorPagesSuite) TestErrorPage(c *check.C) {

//error.toml contains a mis-configuration of the backend host
// error.toml contains a mis-configuration of the backend host
file := s.adaptFile(c, "fixtures/error_pages/error.toml", struct {
Server1 string
Server2 string
Expand Down
8 changes: 4 additions & 4 deletions integration/etcd3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ func (s *Etcd3Suite) TestGlobalConfiguration(c *check.C) {
err = try.GetRequest("http://127.0.0.1:8080/api/providers", 60*time.Second, try.BodyContains("Path:/test"))
c.Assert(err, checker.IsNil)

//check
// check
req, err := http.NewRequest(http.MethodGet, "http://127.0.0.1:8001/", nil)
c.Assert(err, checker.IsNil)
req.Host = "test.localhost"
Expand All @@ -298,7 +298,7 @@ func (s *Etcd3Suite) TestCertificatesContentWithSNIConfigHandshake(c *check.C) {
"--etcd.useAPIV3=true")
defer display(c)

//Copy the contents of the certificate files into ETCD
// Copy the contents of the certificate files into ETCD
snitestComCert, err := ioutil.ReadFile("fixtures/https/snitest.com.cert")
c.Assert(err, checker.IsNil)
snitestComKey, err := ioutil.ReadFile("fixtures/https/snitest.com.key")
Expand Down Expand Up @@ -376,7 +376,7 @@ func (s *Etcd3Suite) TestCertificatesContentWithSNIConfigHandshake(c *check.C) {
err = try.GetRequest("http://127.0.0.1:8080/api/providers", 60*time.Second, try.BodyContains("Host:snitest.org"))
c.Assert(err, checker.IsNil)

//check
// check
tlsConfig := &tls.Config{
InsecureSkipVerify: true,
ServerName: "snitest.com",
Expand Down Expand Up @@ -406,7 +406,7 @@ func (s *Etcd3Suite) TestCommandStoreConfig(c *check.C) {
// wait for traefik finish without error
cmd.Wait()

//CHECK
// CHECK
checkmap := map[string]string{
"/traefik/loglevel": "DEBUG",
"/traefik/defaultentrypoints/0": "http",
Expand Down
14 changes: 14 additions & 0 deletions integration/fixtures/docker/minimal.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
defaultEntryPoints = ["http"]

logLevel = "DEBUG"

[entryPoints]
[entryPoints.http]
address = ":8000"

[api]

[docker]
endpoint = "{{.DockerHost}}"
domain = "docker.localhost"
exposedByDefault = false
3 changes: 0 additions & 3 deletions integration/fixtures/docker/simple.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ logLevel = "DEBUG"
[api]

[docker]

# It's dynamagic !
endpoint = "{{.DockerHost}}"

domain = "docker.localhost"
exposedByDefault = true
2 changes: 1 addition & 1 deletion integration/healthcheck_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func (s *HealthCheckSuite) TestPortOverload(c *check.C) {
c.Assert(err, checker.IsNil)
frontendHealthReq.Host = "test.localhost"

//We test bad gateway because we use an invalid port for the backend
// We test bad gateway because we use an invalid port for the backend
err = try.Request(frontendHealthReq, 500*time.Millisecond, try.StatusCodeIs(http.StatusBadGateway))
c.Assert(err, checker.IsNil)

Expand Down
2 changes: 1 addition & 1 deletion integration/log_rotation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (s *LogRotationSuite) TestTraefikLogRotation(c *check.C) {
// If more log entries are output on startup
c.Assert(lineCount, checker.GreaterOrEqualThan, 5)

//Verify traefik.log output as expected
// Verify traefik.log output as expected
lineCount = verifyLogLines(c, traefikTestLogFile, lineCount, false)
c.Assert(lineCount, checker.GreaterOrEqualThan, 7)
}
Expand Down
2 changes: 1 addition & 1 deletion integration/marathon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/containous/traefik/integration/try"
"github.com/containous/traefik/provider/label"
marathon "github.com/gambol99/go-marathon"
"github.com/gambol99/go-marathon"
"github.com/go-check/check"
checker "github.com/vdemeester/shakers"
)
Expand Down
1 change: 1 addition & 0 deletions integration/resources/compose/minimal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ whoami1:
image: emilevauge/whoami
labels:
- traefik.frontend.rule=PathPrefix:/whoami
- traefik.enable=true
2 changes: 1 addition & 1 deletion integration/try/condition.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func HasBody() ResponseCondition {
}

if len(body) == 0 {
return errors.New("Response doesn't have body content")
return errors.New("response doesn't have body content")
}
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions integration/websocket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ func (s *WebsocketSuite) TestSSLTermination(c *check.C) {
err = try.GetRequest("http://127.0.0.1:8080/api/providers", 10*time.Second, try.BodyContains("127.0.0.1"))
c.Assert(err, checker.IsNil)

//Add client self-signed cert
// Add client self-signed cert
roots := x509.NewCertPool()
certContent, err := ioutil.ReadFile("./resources/tls/local.cert")
c.Assert(err, checker.IsNil)
Expand Down Expand Up @@ -487,7 +487,7 @@ func (s *WebsocketSuite) TestSSLhttp2(c *check.C) {
err = try.GetRequest("http://127.0.0.1:8080/api/providers", 10*time.Second, try.BodyContains("127.0.0.1"))
c.Assert(err, checker.IsNil)

//Add client self-signed cert
// Add client self-signed cert
roots := x509.NewCertPool()
certContent, err := ioutil.ReadFile("./resources/tls/local.cert")
c.Assert(err, checker.IsNil)
Expand Down
13 changes: 6 additions & 7 deletions metrics/influxdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,16 @@ func (w *influxDBWriter) Write(bp influxdb.BatchPoints) error {
return nil
}

func (w *influxDBWriter) initWriteClient() (c influxdb.Client, err error) {
func (w *influxDBWriter) initWriteClient() (influxdb.Client, error) {
if w.config.Protocol == "http" {
c, err = influxdb.NewHTTPClient(influxdb.HTTPConfig{
Addr: w.config.Address,
})
} else {
c, err = influxdb.NewUDPClient(influxdb.UDPConfig{
return influxdb.NewHTTPClient(influxdb.HTTPConfig{
Addr: w.config.Address,
})
}
return

return influxdb.NewUDPClient(influxdb.UDPConfig{
Addr: w.config.Address,
})
}

func (w *influxDBWriter) handleWriteError(c influxdb.Client, writeErr error) error {
Expand Down
25 changes: 13 additions & 12 deletions metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
type Registry interface {
// IsEnabled shows whether metrics instrumentation is enabled.
IsEnabled() bool

// server metrics
ConfigReloadsCounter() metrics.Counter
ConfigReloadsFailureCounter() metrics.Counter
Expand Down Expand Up @@ -38,18 +39,18 @@ func NewVoidRegistry() Registry {
// It handles the case when a registry hasn't registered some metric and returns nil.
// This allows for feature imparity between the different metric implementations.
func NewMultiRegistry(registries []Registry) Registry {
configReloadsCounter := []metrics.Counter{}
configReloadsFailureCounter := []metrics.Counter{}
lastConfigReloadSuccessGauge := []metrics.Gauge{}
lastConfigReloadFailureGauge := []metrics.Gauge{}
entrypointReqsCounter := []metrics.Counter{}
entrypointReqDurationHistogram := []metrics.Histogram{}
entrypointOpenConnsGauge := []metrics.Gauge{}
backendReqsCounter := []metrics.Counter{}
backendReqDurationHistogram := []metrics.Histogram{}
backendOpenConnsGauge := []metrics.Gauge{}
backendRetriesCounter := []metrics.Counter{}
backendServerUpGauge := []metrics.Gauge{}
var configReloadsCounter []metrics.Counter
var configReloadsFailureCounter []metrics.Counter
var lastConfigReloadSuccessGauge []metrics.Gauge
var lastConfigReloadFailureGauge []metrics.Gauge
var entrypointReqsCounter []metrics.Counter
var entrypointReqDurationHistogram []metrics.Histogram
var entrypointOpenConnsGauge []metrics.Gauge
var backendReqsCounter []metrics.Counter
var backendReqDurationHistogram []metrics.Histogram
var backendOpenConnsGauge []metrics.Gauge
var backendRetriesCounter []metrics.Counter
var backendServerUpGauge []metrics.Gauge

for _, r := range registries {
if r.ConfigReloadsCounter() != nil {
Expand Down

0 comments on commit 17ad515

Please sign in to comment.