diff --git a/flaeg_test.go b/flaeg_test.go deleted file mode 100644 index bbf36c42d..000000000 --- a/flaeg_test.go +++ /dev/null @@ -1,91 +0,0 @@ -package main - -import ( - "github.com/cocap10/flaeg" - "reflect" - "testing" - "time" -) - -func TestLoad(t *testing.T) { - var configuration GlobalConfiguration - defaultConfiguration := NewGlobalConfiguration() - args := []string{ - // "-h", - "--docker", - "--file", - "--web", - "--marathon", - "--consul", - "--consulcatalog", - "--etcd", - "--zookeeper", - "--boltdb", - } - if err := flaeg.Load(&configuration, defaultConfiguration, args); err != nil { - t.Fatalf("Error: %s", err) - } - // fmt.Printf("result : \n%+v\n", configuration) - if !reflect.DeepEqual(configuration, *defaultConfiguration) { - t.Fatalf("\nexpected\t: %+v\ngot\t\t\t: %+v", *defaultConfiguration, configuration) - } -} - -func TestLoadWithParsers(t *testing.T) { - var configuration GlobalConfiguration - defaultConfiguration := NewGlobalConfiguration() - args := []string{ - // "-h", - "--docker", - // "--file", - "--web.address=:8888", - "--marathon", - "--consul", - "--consulcatalog", - "--etcd.tls.insecureskipverify", - "--zookeeper", - "--boltdb", - "--accesslogsfile=log2/access.log", - "--entrypoints=Name:http Address::8000 Redirect.EntryPoint:https", - "--entrypoints=Name:https Address::8443 Redirect.EntryPoint:http", - "--defaultentrypoints=https", - "--defaultentrypoints=ssh", - "--providersthrottleduration=4s", - } - parsers := map[reflect.Type]flaeg.Parser{} - var defaultEntryPointsParser DefaultEntryPoints - parsers[reflect.TypeOf(DefaultEntryPoints{})] = &defaultEntryPointsParser - entryPointsParser := EntryPoints{} - parsers[reflect.TypeOf(EntryPoints{})] = &entryPointsParser - - if err := flaeg.LoadWithParsers(&configuration, defaultConfiguration, args, parsers); err != nil { - t.Fatalf("Error: %s", err) - } - // fmt.Printf("result : \n%+v\n", configuration) - - //Check - check := *defaultConfiguration - check.File = nil - check.Web.Address = ":8888" - check.AccessLogsFile = "log2/access.log" - check.Etcd.TLS.InsecureSkipVerify = true - check.EntryPoints = make(map[string]*EntryPoint) - check.EntryPoints["http"] = &EntryPoint{ - Address: ":8000", - Redirect: &Redirect{ - EntryPoint: "https", - }, - } - check.EntryPoints["https"] = &EntryPoint{ - Address: ":8443", - Redirect: &Redirect{ - EntryPoint: "http", - }, - } - check.DefaultEntryPoints = []string{"https", "ssh"} - check.ProvidersThrottleDuration = time.Duration(4 * time.Second) - - if !reflect.DeepEqual(&configuration, &check) { - t.Fatalf("\nexpected\t: %+v\ngot\t\t\t: %+v", check, configuration) - } -} diff --git a/provider/boltdb.go b/provider/boltdb.go index 966a4b8da..4c2a33844 100644 --- a/provider/boltdb.go +++ b/provider/boltdb.go @@ -9,7 +9,7 @@ import ( // BoltDb holds configurations of the BoltDb provider. type BoltDb struct { - Kv `mapstructure:",squash" description:"go through"` + Kv } // Provide allows the provider to provide configurations to traefik diff --git a/provider/consul.go b/provider/consul.go index d6d81f3e7..d94dc7e03 100644 --- a/provider/consul.go +++ b/provider/consul.go @@ -9,7 +9,7 @@ import ( // Consul holds configurations of the Consul provider. type Consul struct { - Kv `mapstructure:",squash" description:"go through"` + Kv } // Provide allows the provider to provide configurations to traefik diff --git a/provider/consul_catalog.go b/provider/consul_catalog.go index c17cfe0a9..2aecc4622 100644 --- a/provider/consul_catalog.go +++ b/provider/consul_catalog.go @@ -23,11 +23,11 @@ const ( // ConsulCatalog holds configurations of the Consul catalog provider. type ConsulCatalog struct { - BaseProvider `mapstructure:",squash"` - Endpoint string `description:"Consul server endpoint"` - Domain string `description:"Default domain used"` - client *api.Client - Prefix string + BaseProvider + Endpoint string `description:"Consul server endpoint"` + Domain string `description:"Default domain used"` + client *api.Client + Prefix string } type serviceUpdate struct { diff --git a/provider/docker.go b/provider/docker.go index 55b73f8b6..75f5c4ef8 100644 --- a/provider/docker.go +++ b/provider/docker.go @@ -29,10 +29,10 @@ const DockerAPIVersion string = "1.21" // Docker holds configurations of the Docker provider. type Docker struct { - BaseProvider `mapstructure:",squash"` - Endpoint string `description:"Docker server endpoint. Can be a tcp or a unix socket endpoint"` - Domain string `description:"Default domain used"` - TLS *DockerTLS `description:"Enable Docker TLS support"` + BaseProvider + Endpoint string `description:"Docker server endpoint. Can be a tcp or a unix socket endpoint"` + Domain string `description:"Default domain used"` + TLS *DockerTLS `description:"Enable Docker TLS support"` } // DockerTLS holds TLS specific configurations diff --git a/provider/etcd.go b/provider/etcd.go index 3344245e4..a7fd7ae6a 100644 --- a/provider/etcd.go +++ b/provider/etcd.go @@ -9,7 +9,7 @@ import ( // Etcd holds configurations of the Etcd provider. type Etcd struct { - Kv `mapstructure:",squash" description:"go through"` + Kv } // Provide allows the provider to provide configurations to traefik diff --git a/provider/file.go b/provider/file.go index c5597ec19..1b463593a 100644 --- a/provider/file.go +++ b/provider/file.go @@ -14,7 +14,7 @@ import ( // File holds configurations of the File provider. type File struct { - BaseProvider `mapstructure:",squash" description:"go through"` + BaseProvider } // Provide allows the provider to provide configurations to traefik diff --git a/provider/kubernetes.go b/provider/kubernetes.go index 3dd3e9e4e..cab4217ea 100644 --- a/provider/kubernetes.go +++ b/provider/kubernetes.go @@ -49,7 +49,7 @@ func (ns *Namespaces) SetValue(val interface{}) { // Kubernetes holds configurations of the Kubernetes provider. type Kubernetes struct { - BaseProvider `mapstructure:",squash"` + BaseProvider Endpoint string `description:"Kubernetes server endpoint"` DisablePassHostHeaders bool `description:"Kubernetes disable PassHost Headers"` Namespaces Namespaces `description:"Kubernetes namespaces"` diff --git a/provider/kv.go b/provider/kv.go index 852799dcb..713416781 100644 --- a/provider/kv.go +++ b/provider/kv.go @@ -22,12 +22,12 @@ import ( // Kv holds common configurations of key-value providers. type Kv struct { - BaseProvider `mapstructure:",squash" description:"go through"` - Endpoint string `description:"Comma sepparated server endpoints"` - Prefix string `description:"Prefix used for KV store"` - TLS *KvTLS `description:"Enable TLS support"` - storeType store.Backend - kvclient store.Store + BaseProvider + Endpoint string `description:"Comma sepparated server endpoints"` + Prefix string `description:"Prefix used for KV store"` + TLS *KvTLS `description:"Enable TLS support"` + storeType store.Backend + kvclient store.Store } // KvTLS holds TLS specific configurations diff --git a/traefik.go b/traefik.go index 636514f2d..fbc6a4f7f 100644 --- a/traefik.go +++ b/traefik.go @@ -76,7 +76,7 @@ Complete documentation is available at https://traefik.io`, traefikConfiguration.File.Filename = toml.ConfigFileUsed() } if len(traefikConfiguration.EntryPoints) == 0 { - traefikConfiguration.EntryPoints = map[string]*EntryPoint{"http": &EntryPoint{Address: ":80"}} + traefikConfiguration.EntryPoints = map[string]*EntryPoint{"http": {Address: ":80"}} traefikConfiguration.DefaultEntryPoints = []string{"http"} } if err := s.Run(); err != nil {