Flaeg integration
This commit is contained in:
parent
7804787e9e
commit
fe0a8f3363
16 changed files with 361 additions and 401 deletions
91
flaeg_test.go
Normal file
91
flaeg_test.go
Normal file
|
@ -0,0 +1,91 @@
|
|||
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)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue