rm useless StrucTag

This commit is contained in:
Martin 2016-05-24 17:31:50 +02:00
parent ab138e7df1
commit 6752b49536
10 changed files with 21 additions and 112 deletions

View file

@ -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)
}
}

View file

@ -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

View file

@ -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

View file

@ -23,7 +23,7 @@ const (
// ConsulCatalog holds configurations of the Consul catalog provider.
type ConsulCatalog struct {
BaseProvider `mapstructure:",squash"`
BaseProvider
Endpoint string `description:"Consul server endpoint"`
Domain string `description:"Default domain used"`
client *api.Client

View file

@ -29,7 +29,7 @@ const DockerAPIVersion string = "1.21"
// Docker holds configurations of the Docker provider.
type Docker struct {
BaseProvider `mapstructure:",squash"`
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"`

View file

@ -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

View file

@ -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

View file

@ -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"`

View file

@ -22,7 +22,7 @@ import (
// Kv holds common configurations of key-value providers.
type Kv struct {
BaseProvider `mapstructure:",squash" description:"go through"`
BaseProvider
Endpoint string `description:"Comma sepparated server endpoints"`
Prefix string `description:"Prefix used for KV store"`
TLS *KvTLS `description:"Enable TLS support"`

View file

@ -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 {