1
0
Fork 0

Code cleaning.

This commit is contained in:
Ludovic Fernandez 2017-08-18 02:18:02 +02:00 committed by Traefiker
parent c360395afc
commit 759c269dee
19 changed files with 64 additions and 56 deletions

View file

@ -132,6 +132,10 @@ func (p *Provider) Provide(configurationChan chan<- types.ConfigMessage, pool *s
ctx := context.Background()
version, err := dockerClient.ServerVersion(ctx)
if err != nil {
log.Errorf("Failed to retrieve information of the docker client and server host: %s", err)
return err
}
log.Debugf("Provider connection established with docker %s (API %s)", version.Version, version.APIVersion)
var dockerDataList []dockerData
if p.SwarmMode {
@ -908,7 +912,7 @@ func parseTasks(task swarmtypes.Task, serviceDockerData dockerData, networkMap m
NetworkSettings: networkSettings{},
}
if isGlobalSvc == true {
if isGlobalSvc {
dockerData.Name = serviceDockerData.Name + "." + task.ID
}

View file

@ -38,7 +38,7 @@ func TestProvideSingleFileAndWatch(t *testing.T) {
expectedNumFrontends = 1
expectedNumBackends = 1
tempFile = createFile(t,
createFile(t,
tempDir, "simple.toml",
createFrontendConfiguration(expectedNumFrontends),
createBackendConfiguration(expectedNumBackends))
@ -72,7 +72,7 @@ func TestProvideSingleFileAndNotWatch(t *testing.T) {
expectedNumFrontends = 1
expectedNumBackends = 1
tempFile = createFile(t,
createFile(t,
tempDir, "simple.toml",
createFrontendConfiguration(expectedNumFrontends),
createBackendConfiguration(expectedNumBackends))

View file

@ -427,10 +427,7 @@ func shouldProcessIngress(ingressClass string) bool {
}
func (p *Provider) getPassHostHeader() bool {
if p.DisablePassHostHeaders {
return false
}
return true
return !p.DisablePassHostHeaders
}
func (p *Provider) loadConfig(templateObjects types.Configuration) *types.Configuration {

View file

@ -152,7 +152,7 @@ func (p *Provider) loadConfig() *types.Configuration {
}
for key, frontend := range configuration.Frontends {
if _, ok := configuration.Backends[frontend.Backend]; ok == false {
if _, ok := configuration.Backends[frontend.Backend]; !ok {
delete(configuration.Frontends, key)
}
}
@ -231,7 +231,7 @@ func (p *Provider) checkConstraints(keys ...string) bool {
constraintTags := strings.Split(value, ",")
ok, failingConstraint := p.MatchConstraints(constraintTags)
if ok == false {
if !ok {
if failingConstraint != nil {
log.Debugf("Constraint %v not matching with following tags: %v", failingConstraint.String(), value)
}

View file

@ -282,7 +282,7 @@ func TestKvWatchTree(t *testing.T) {
}
select {
case _ = <-configChan:
case <-configChan:
t.Fatalf("configChan should be empty")
default:
}
@ -371,9 +371,7 @@ func (s *Mock) AtomicDelete(key string, previous *store.KVPair) (bool, error) {
}
// Close mock
func (s *Mock) Close() {
return
}
func (s *Mock) Close() {}
func TestKVLoadConfig(t *testing.T) {
provider := &Provider{