diff --git a/cmd/traefik/storeconfig.go b/cmd/traefik/storeconfig.go index d1ef52a5d..51add25da 100644 --- a/cmd/traefik/storeconfig.go +++ b/cmd/traefik/storeconfig.go @@ -67,6 +67,7 @@ func runStoreConfig(kv *staert.KvSource, traefikConfiguration *TraefikConfigurat return err } } + if traefikConfiguration.GlobalConfiguration.ACME != nil { var object cluster.Object if len(traefikConfiguration.GlobalConfiguration.ACME.StorageFile) > 0 { @@ -76,11 +77,14 @@ func runStoreConfig(kv *staert.KvSource, traefikConfiguration *TraefikConfigurat if err != nil { return err } - } else { // Create an empty account to create all the keys into the KV store account := &acme.Account{} - account.Init() + err = account.Init() + if err != nil { + return err + } + object = account } diff --git a/cmd/traefik/traefik.go b/cmd/traefik/traefik.go index 7d08b4e1d..f94cfef91 100644 --- a/cmd/traefik/traefik.go +++ b/cmd/traefik/traefik.go @@ -32,10 +32,11 @@ import ( ) func main() { - //traefik config inits + // traefik config inits traefikConfiguration := NewTraefikConfiguration() traefikPointersConfiguration := NewTraefikDefaultPointersConfiguration() - //traefik Command init + + // traefik Command init traefikCmd := &flaeg.Command{ Name: "traefik", Description: `traefik is a modern HTTP reverse proxy and load balancer made to deploy microservices with ease. @@ -48,12 +49,12 @@ Complete documentation is available at https://traefik.io`, }, } - //storeconfig Command init + // storeconfig Command init storeConfigCmd := newStoreConfigCmd(traefikConfiguration, traefikPointersConfiguration) - //init flaeg source + // init flaeg source f := flaeg.New(traefikCmd, os.Args[1:]) - //add custom parsers + // add custom parsers f.AddParser(reflect.TypeOf(configuration.EntryPoints{}), &configuration.EntryPoints{}) f.AddParser(reflect.TypeOf(configuration.DefaultEntryPoints{}), &configuration.DefaultEntryPoints{}) f.AddParser(reflect.TypeOf(traefikTls.RootCAs{}), &traefikTls.RootCAs{}) @@ -63,7 +64,7 @@ Complete documentation is available at https://traefik.io`, f.AddParser(reflect.TypeOf([]acme.Domain{}), &acme.Domains{}) f.AddParser(reflect.TypeOf(types.Buckets{}), &types.Buckets{}) - //add commands + // add commands f.AddCommand(newVersionCmd()) f.AddCommand(newBugCmd(traefikConfiguration, traefikPointersConfiguration)) f.AddCommand(storeConfigCmd) @@ -83,12 +84,12 @@ Complete documentation is available at https://traefik.io`, os.Exit(-1) } - //staert init + // staert init s := staert.NewStaert(traefikCmd) - //init toml source + // init TOML source toml := staert.NewTomlSource("traefik", []string{traefikConfiguration.ConfigFile, "/etc/traefik/", "$HOME/.traefik/", "."}) - //add sources to staert + // add sources to staert s.AddSource(toml) s.AddSource(f) if _, err := s.LoadConfig(); err != nil { @@ -105,7 +106,7 @@ Complete documentation is available at https://traefik.io`, } storeConfigCmd.Run = runStoreConfig(kv, traefikConfiguration) - // IF a KV Store is enable and no sub-command called in args + // if a KV Store is enable and no sub-command called in args if kv != nil && usedCmd == traefikCmd { if traefikConfiguration.Cluster == nil { traefikConfiguration.Cluster = &types.Cluster{Node: uuid.Get()} @@ -223,10 +224,7 @@ func configureLogging(globalConfiguration *configuration.GlobalConfiguration) { if globalConfiguration.TraefikLog != nil && globalConfiguration.TraefikLog.Format == "json" { formatter = &logrus.JSONFormatter{} } else { - disableColors := false - if len(logFile) > 0 { - disableColors = true - } + disableColors := len(logFile) > 0 formatter = &logrus.TextFormatter{DisableColors: disableColors, FullTimestamp: true, DisableSorting: true} } log.SetFormatter(formatter) @@ -234,8 +232,7 @@ func configureLogging(globalConfiguration *configuration.GlobalConfiguration) { if len(logFile) > 0 { dir := filepath.Dir(logFile) - err := os.MkdirAll(dir, 0755) - if err != nil { + if err := os.MkdirAll(dir, 0755); err != nil { log.Errorf("Failed to create log path %s: %s", dir, err) } diff --git a/integration/consul_test.go b/integration/consul_test.go index e0fe3374b..0761709bc 100644 --- a/integration/consul_test.go +++ b/integration/consul_test.go @@ -289,41 +289,6 @@ func (s *ConsulSuite) TestGlobalConfiguration(c *check.C) { c.Assert(err, checker.IsNil) } -func (s *ConsulSuite) skipTestGlobalConfigurationWithClientTLS(c *check.C) { - c.Skip("wait for relative path issue in the composefile") - s.setupConsulTLS(c) - consulHost := s.composeProject.Container(c, "consul").NetworkSettings.IPAddress - - err := s.kv.Put("traefik/api/entrypoint", []byte("api"), nil) - c.Assert(err, checker.IsNil) - - err = s.kv.Put("traefik/entrypoints/api/address", []byte(":8081"), nil) - c.Assert(err, checker.IsNil) - - // wait for consul - err = try.Do(60*time.Second, try.KVExists(s.kv, "traefik/web/address")) - c.Assert(err, checker.IsNil) - - // start traefik - cmd, display := s.traefikCmd( - withConfigFile("fixtures/simple_web.toml"), - "--consul", - "--consul.endpoint="+consulHost+":8585", - "--consul.tls.ca=resources/tls/ca.cert", - "--consul.tls.cert=resources/tls/consul.cert", - "--consul.tls.key=resources/tls/consul.key", - "--consul.tls.insecureskipverify") - defer display(c) - - err = cmd.Start() - c.Assert(err, checker.IsNil) - defer cmd.Process.Kill() - - // wait for traefik - err = try.GetRequest("http://127.0.0.1:8081/api/providers", 60*time.Second) - c.Assert(err, checker.IsNil) -} - func (s *ConsulSuite) TestCommandStoreConfig(c *check.C) { s.setupConsul(c) consulHost := s.composeProject.Container(c, "consul").NetworkSettings.IPAddress diff --git a/log/logger.go b/log/logger.go index a0a0e120a..ed5270775 100644 --- a/log/logger.go +++ b/log/logger.go @@ -282,7 +282,7 @@ func CustomWriterLevel(level logrus.Level, maxScanTokenSize int) *io.PipeWriter // extract from github.com/Sirupsen/logrus/writer.go // Hack the buffer size -func writerScanner(reader *io.PipeReader, scanTokenSize int, printFunc func(args ...interface{})) { +func writerScanner(reader io.ReadCloser, scanTokenSize int, printFunc func(args ...interface{})) { scanner := bufio.NewScanner(reader) if scanTokenSize > bufio.MaxScanTokenSize { diff --git a/middlewares/metrics_test.go b/middlewares/metrics_test.go index ae0b1b7aa..e803e454e 100644 --- a/middlewares/metrics_test.go +++ b/middlewares/metrics_test.go @@ -19,7 +19,7 @@ func TestMetricsRetryListener(t *testing.T) { wantCounterValue := float64(2) if retryMetrics.retriesCounter.CounterValue != wantCounterValue { - t.Errorf("got counter value of %d, want %d", retryMetrics.retriesCounter.CounterValue, wantCounterValue) + t.Errorf("got counter value of %f, want %f", retryMetrics.retriesCounter.CounterValue, wantCounterValue) } wantLabelValues := []string{"backend", "backendName"} diff --git a/middlewares/redirect/redirect_test.go b/middlewares/redirect/redirect_test.go index 615b59bde..ab190daca 100644 --- a/middlewares/redirect/redirect_test.go +++ b/middlewares/redirect/redirect_test.go @@ -174,7 +174,7 @@ func TestNewRegexHandler(t *testing.T) { assert.Equal(t, test.expectedStatus, recorder.Code) location, err := recorder.Result().Location() - require.Error(t, err, "ghf %v", location) + require.Errorf(t, err, "Location %v", location) } } }) diff --git a/middlewares/retry.go b/middlewares/retry.go index c1c6b26d5..e2bfdc8af 100644 --- a/middlewares/retry.go +++ b/middlewares/retry.go @@ -125,7 +125,7 @@ type retryResponseWriterWithoutCloseNotify struct { } func (rr *retryResponseWriterWithoutCloseNotify) ShouldRetry() bool { - return *rr.netErrorOccured == true && !rr.attemptsExhausted + return *rr.netErrorOccured && !rr.attemptsExhausted } func (rr *retryResponseWriterWithoutCloseNotify) Header() http.Header { diff --git a/provider/marathon/builder_test.go b/provider/marathon/builder_test.go index 6d9a34157..9f98e5676 100644 --- a/provider/marathon/builder_test.go +++ b/provider/marathon/builder_test.go @@ -61,14 +61,6 @@ func withServiceLabel(key, value string, serviceName string) func(*marathon.Appl } } -func healthChecks(checks ...*marathon.HealthCheck) func(*marathon.Application) { - return func(app *marathon.Application) { - for _, check := range checks { - app.AddHealthCheck(*check) - } - } -} - func portDefinition(port int) func(*marathon.Application) { return func(app *marathon.Application) { app.AddPortDefinition(marathon.PortDefinition{ @@ -194,16 +186,6 @@ func state(s TaskState) func(*marathon.Task) { } } -func healthCheckResultLiveness(alive ...bool) func(*marathon.Task) { - return func(t *marathon.Task) { - for _, a := range alive { - t.HealthCheckResults = append(t.HealthCheckResults, &marathon.HealthCheckResult{ - Alive: a, - }) - } - } -} - func startedAt(timestamp string) func(*marathon.Task) { return func(t *marathon.Task) { t.StartedAt = timestamp diff --git a/provider/marathon/config_test.go b/provider/marathon/config_test.go index 3be769846..78d3c182d 100644 --- a/provider/marathon/config_test.go +++ b/provider/marathon/config_test.go @@ -1315,7 +1315,7 @@ func TestGetSticky(t *testing.T) { t.Parallel() actual := getSticky(test.application) if actual != test.expected { - t.Errorf("actual %q, expected %q", actual, test.expected) + t.Errorf("actual %v, expected %v", actual, test.expected) } }) }