1
0
Fork 0

Add validate-golint target and script …

… and *lint* the latest piece of code.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
This commit is contained in:
Vincent Demeester 2015-11-06 18:11:57 +01:00
parent 7607eb173b
commit 40391c57c2
8 changed files with 78 additions and 33 deletions

View file

@ -1,12 +1,16 @@
package main
import (
fmtlog "log"
"time"
"github.com/BurntSushi/toml"
"github.com/emilevauge/traefik/provider"
"github.com/emilevauge/traefik/types"
)
// GlobalConfiguration holds global configuration (with providers, etc.).
// It's populated from the traefik configuration file passed as an argument to the binary.
type GlobalConfiguration struct {
Port string
GraceTimeOut int64
@ -25,6 +29,7 @@ type GlobalConfiguration struct {
Boltdb *provider.BoltDb
}
// NewGlobalConfiguration returns a GlobalConfiguration with default values.
func NewGlobalConfiguration() *GlobalConfiguration {
globalConfiguration := new(GlobalConfiguration)
// default values
@ -36,4 +41,13 @@ func NewGlobalConfiguration() *GlobalConfiguration {
return globalConfiguration
}
// LoadFileConfig returns a GlobalConfiguration from reading the specified file (a toml file).
func LoadFileConfig(file string) *GlobalConfiguration {
configuration := NewGlobalConfiguration()
if _, err := toml.DecodeFile(file, configuration); err != nil {
fmtlog.Fatalf("Error reading file: %s", err)
}
return configuration
}
type configs map[string]*types.Configuration