rm useless StrucTag
This commit is contained in:
parent
ab138e7df1
commit
6752b49536
10 changed files with 21 additions and 112 deletions
|
@ -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)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
|
|
||||||
// BoltDb holds configurations of the BoltDb provider.
|
// BoltDb holds configurations of the BoltDb provider.
|
||||||
type BoltDb struct {
|
type BoltDb struct {
|
||||||
Kv `mapstructure:",squash" description:"go through"`
|
Kv
|
||||||
}
|
}
|
||||||
|
|
||||||
// Provide allows the provider to provide configurations to traefik
|
// Provide allows the provider to provide configurations to traefik
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
|
|
||||||
// Consul holds configurations of the Consul provider.
|
// Consul holds configurations of the Consul provider.
|
||||||
type Consul struct {
|
type Consul struct {
|
||||||
Kv `mapstructure:",squash" description:"go through"`
|
Kv
|
||||||
}
|
}
|
||||||
|
|
||||||
// Provide allows the provider to provide configurations to traefik
|
// Provide allows the provider to provide configurations to traefik
|
||||||
|
|
|
@ -23,11 +23,11 @@ const (
|
||||||
|
|
||||||
// ConsulCatalog holds configurations of the Consul catalog provider.
|
// ConsulCatalog holds configurations of the Consul catalog provider.
|
||||||
type ConsulCatalog struct {
|
type ConsulCatalog struct {
|
||||||
BaseProvider `mapstructure:",squash"`
|
BaseProvider
|
||||||
Endpoint string `description:"Consul server endpoint"`
|
Endpoint string `description:"Consul server endpoint"`
|
||||||
Domain string `description:"Default domain used"`
|
Domain string `description:"Default domain used"`
|
||||||
client *api.Client
|
client *api.Client
|
||||||
Prefix string
|
Prefix string
|
||||||
}
|
}
|
||||||
|
|
||||||
type serviceUpdate struct {
|
type serviceUpdate struct {
|
||||||
|
|
|
@ -29,10 +29,10 @@ const DockerAPIVersion string = "1.21"
|
||||||
|
|
||||||
// Docker holds configurations of the Docker provider.
|
// Docker holds configurations of the Docker provider.
|
||||||
type Docker struct {
|
type Docker struct {
|
||||||
BaseProvider `mapstructure:",squash"`
|
BaseProvider
|
||||||
Endpoint string `description:"Docker server endpoint. Can be a tcp or a unix socket endpoint"`
|
Endpoint string `description:"Docker server endpoint. Can be a tcp or a unix socket endpoint"`
|
||||||
Domain string `description:"Default domain used"`
|
Domain string `description:"Default domain used"`
|
||||||
TLS *DockerTLS `description:"Enable Docker TLS support"`
|
TLS *DockerTLS `description:"Enable Docker TLS support"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// DockerTLS holds TLS specific configurations
|
// DockerTLS holds TLS specific configurations
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
|
|
||||||
// Etcd holds configurations of the Etcd provider.
|
// Etcd holds configurations of the Etcd provider.
|
||||||
type Etcd struct {
|
type Etcd struct {
|
||||||
Kv `mapstructure:",squash" description:"go through"`
|
Kv
|
||||||
}
|
}
|
||||||
|
|
||||||
// Provide allows the provider to provide configurations to traefik
|
// Provide allows the provider to provide configurations to traefik
|
||||||
|
|
|
@ -14,7 +14,7 @@ import (
|
||||||
|
|
||||||
// File holds configurations of the File provider.
|
// File holds configurations of the File provider.
|
||||||
type File struct {
|
type File struct {
|
||||||
BaseProvider `mapstructure:",squash" description:"go through"`
|
BaseProvider
|
||||||
}
|
}
|
||||||
|
|
||||||
// Provide allows the provider to provide configurations to traefik
|
// Provide allows the provider to provide configurations to traefik
|
||||||
|
|
|
@ -49,7 +49,7 @@ func (ns *Namespaces) SetValue(val interface{}) {
|
||||||
|
|
||||||
// Kubernetes holds configurations of the Kubernetes provider.
|
// Kubernetes holds configurations of the Kubernetes provider.
|
||||||
type Kubernetes struct {
|
type Kubernetes struct {
|
||||||
BaseProvider `mapstructure:",squash"`
|
BaseProvider
|
||||||
Endpoint string `description:"Kubernetes server endpoint"`
|
Endpoint string `description:"Kubernetes server endpoint"`
|
||||||
DisablePassHostHeaders bool `description:"Kubernetes disable PassHost Headers"`
|
DisablePassHostHeaders bool `description:"Kubernetes disable PassHost Headers"`
|
||||||
Namespaces Namespaces `description:"Kubernetes namespaces"`
|
Namespaces Namespaces `description:"Kubernetes namespaces"`
|
||||||
|
|
|
@ -22,12 +22,12 @@ import (
|
||||||
|
|
||||||
// Kv holds common configurations of key-value providers.
|
// Kv holds common configurations of key-value providers.
|
||||||
type Kv struct {
|
type Kv struct {
|
||||||
BaseProvider `mapstructure:",squash" description:"go through"`
|
BaseProvider
|
||||||
Endpoint string `description:"Comma sepparated server endpoints"`
|
Endpoint string `description:"Comma sepparated server endpoints"`
|
||||||
Prefix string `description:"Prefix used for KV store"`
|
Prefix string `description:"Prefix used for KV store"`
|
||||||
TLS *KvTLS `description:"Enable TLS support"`
|
TLS *KvTLS `description:"Enable TLS support"`
|
||||||
storeType store.Backend
|
storeType store.Backend
|
||||||
kvclient store.Store
|
kvclient store.Store
|
||||||
}
|
}
|
||||||
|
|
||||||
// KvTLS holds TLS specific configurations
|
// KvTLS holds TLS specific configurations
|
||||||
|
|
|
@ -76,7 +76,7 @@ Complete documentation is available at https://traefik.io`,
|
||||||
traefikConfiguration.File.Filename = toml.ConfigFileUsed()
|
traefikConfiguration.File.Filename = toml.ConfigFileUsed()
|
||||||
}
|
}
|
||||||
if len(traefikConfiguration.EntryPoints) == 0 {
|
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"}
|
traefikConfiguration.DefaultEntryPoints = []string{"http"}
|
||||||
}
|
}
|
||||||
if err := s.Run(); err != nil {
|
if err := s.Run(); err != nil {
|
||||||
|
|
Loading…
Reference in a new issue