New static configuration loading system.
Co-authored-by: Mathieu Lonjaret <mathieu.lonjaret@gmail.com>
This commit is contained in:
parent
d18edd6f77
commit
8d7eccad5d
165 changed files with 10894 additions and 6076 deletions
|
@ -10,9 +10,9 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/containous/traefik/pkg/config"
|
||||
"github.com/containous/traefik/pkg/config/label"
|
||||
"github.com/containous/traefik/pkg/log"
|
||||
"github.com/containous/traefik/pkg/provider"
|
||||
"github.com/containous/traefik/pkg/provider/label"
|
||||
"github.com/gambol99/go-marathon"
|
||||
)
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
testCases := []struct {
|
||||
desc string
|
||||
applications *marathon.Applications
|
||||
constraints types.Constraints
|
||||
constraints []*types.Constraint
|
||||
filterMarathonConstraints bool
|
||||
defaultRule string
|
||||
expected *config.Configuration
|
||||
|
@ -1065,11 +1065,11 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
withTasks(localhostTask(taskPorts(80, 81))),
|
||||
withLabel("traefik.tags", "foo"),
|
||||
)),
|
||||
constraints: types.Constraints{
|
||||
&types.Constraint{
|
||||
constraints: []*types.Constraint{
|
||||
{
|
||||
Key: "tag",
|
||||
MustMatch: true,
|
||||
Regex: "bar",
|
||||
Value: "bar",
|
||||
},
|
||||
},
|
||||
expected: &config.Configuration{
|
||||
|
@ -1094,11 +1094,11 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
constraint("rack_id:CLUSTER:rack-1"),
|
||||
)),
|
||||
filterMarathonConstraints: true,
|
||||
constraints: types.Constraints{
|
||||
&types.Constraint{
|
||||
constraints: []*types.Constraint{
|
||||
{
|
||||
Key: "tag",
|
||||
MustMatch: true,
|
||||
Regex: "rack_id:CLUSTER:rack-2",
|
||||
Value: "rack_id:CLUSTER:rack-2",
|
||||
},
|
||||
},
|
||||
expected: &config.Configuration{
|
||||
|
@ -1123,11 +1123,11 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
constraint("rack_id:CLUSTER:rack-1"),
|
||||
)),
|
||||
filterMarathonConstraints: true,
|
||||
constraints: types.Constraints{
|
||||
&types.Constraint{
|
||||
constraints: []*types.Constraint{
|
||||
{
|
||||
Key: "tag",
|
||||
MustMatch: true,
|
||||
Regex: "rack_id:CLUSTER:rack-1",
|
||||
Value: "rack_id:CLUSTER:rack-1",
|
||||
},
|
||||
},
|
||||
expected: &config.Configuration{
|
||||
|
@ -1168,11 +1168,11 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
withLabel("traefik.tags", "bar"),
|
||||
)),
|
||||
|
||||
constraints: types.Constraints{
|
||||
&types.Constraint{
|
||||
constraints: []*types.Constraint{
|
||||
{
|
||||
Key: "tag",
|
||||
MustMatch: true,
|
||||
Regex: "bar",
|
||||
Value: "bar",
|
||||
},
|
||||
},
|
||||
expected: &config.Configuration{
|
||||
|
@ -1466,7 +1466,7 @@ func TestApplicationFilterEnabled(t *testing.T) {
|
|||
t.Run(test.desc, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
provider := &Provider{ExposedByDefault: test.exposedByDefault}
|
||||
provider := &Provider{ExposedByDefault: true}
|
||||
|
||||
app := application(withLabel("traefik.enable", test.enabledLabel))
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"math"
|
||||
"strings"
|
||||
|
||||
"github.com/containous/traefik/pkg/provider/label"
|
||||
"github.com/containous/traefik/pkg/config/label"
|
||||
"github.com/gambol99/go-marathon"
|
||||
)
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/cenkalti/backoff"
|
||||
"github.com/containous/flaeg/parse"
|
||||
"github.com/containous/traefik/pkg/config"
|
||||
"github.com/containous/traefik/pkg/job"
|
||||
"github.com/containous/traefik/pkg/log"
|
||||
|
@ -46,31 +45,44 @@ var _ provider.Provider = (*Provider)(nil)
|
|||
|
||||
// Provider holds configuration of the provider.
|
||||
type Provider struct {
|
||||
provider.Constrainer `mapstructure:",squash" export:"true"`
|
||||
provider.Constrainer `description:"List of constraints used to filter out some containers." export:"true"`
|
||||
|
||||
Trace bool `description:"Display additional provider logs." export:"true"`
|
||||
Watch bool `description:"Watch provider" export:"true"`
|
||||
Endpoint string `description:"Marathon server endpoint. You can also specify multiple endpoint for Marathon" export:"true"`
|
||||
DefaultRule string `description:"Default rule"`
|
||||
ExposedByDefault bool `description:"Expose Marathon apps by default" export:"true"`
|
||||
DCOSToken string `description:"DCOSToken for DCOS environment, This will override the Authorization header" export:"true"`
|
||||
FilterMarathonConstraints bool `description:"Enable use of Marathon constraints in constraint filtering" export:"true"`
|
||||
TLS *types.ClientTLS `description:"Enable TLS support" export:"true"`
|
||||
DialerTimeout parse.Duration `description:"Set a dialer timeout for Marathon" export:"true"`
|
||||
ResponseHeaderTimeout parse.Duration `description:"Set a response header timeout for Marathon" export:"true"`
|
||||
TLSHandshakeTimeout parse.Duration `description:"Set a TLS handhsake timeout for Marathon" export:"true"`
|
||||
KeepAlive parse.Duration `description:"Set a TCP Keep Alive time in seconds" export:"true"`
|
||||
Watch bool `description:"Watch provider." export:"true"`
|
||||
Endpoint string `description:"Marathon server endpoint. You can also specify multiple endpoint for Marathon." export:"true"`
|
||||
DefaultRule string `description:"Default rule."`
|
||||
ExposedByDefault bool `description:"Expose Marathon apps by default." export:"true"`
|
||||
DCOSToken string `description:"DCOSToken for DCOS environment, This will override the Authorization header." export:"true"`
|
||||
FilterMarathonConstraints bool `description:"Enable use of Marathon constraints in constraint filtering." export:"true"`
|
||||
TLS *types.ClientTLS `description:"Enable TLS support." export:"true"`
|
||||
DialerTimeout types.Duration `description:"Set a dialer timeout for Marathon." export:"true"`
|
||||
ResponseHeaderTimeout types.Duration `description:"Set a response header timeout for Marathon." export:"true"`
|
||||
TLSHandshakeTimeout types.Duration `description:"Set a TLS handshake timeout for Marathon." export:"true"`
|
||||
KeepAlive types.Duration `description:"Set a TCP Keep Alive time." export:"true"`
|
||||
ForceTaskHostname bool `description:"Force to use the task's hostname." export:"true"`
|
||||
Basic *Basic `description:"Enable basic authentication" export:"true"`
|
||||
RespectReadinessChecks bool `description:"Filter out tasks with non-successful readiness checks during deployments" export:"true"`
|
||||
Basic *Basic `description:"Enable basic authentication." export:"true"`
|
||||
RespectReadinessChecks bool `description:"Filter out tasks with non-successful readiness checks during deployments." export:"true"`
|
||||
readyChecker *readinessChecker
|
||||
marathonClient marathon.Marathon
|
||||
defaultRuleTpl *template.Template
|
||||
}
|
||||
|
||||
// SetDefaults sets the default values.
|
||||
func (p *Provider) SetDefaults() {
|
||||
p.Watch = true
|
||||
p.Endpoint = "http://127.0.0.1:8080"
|
||||
p.ExposedByDefault = true
|
||||
p.DialerTimeout = types.Duration(5 * time.Second)
|
||||
p.ResponseHeaderTimeout = types.Duration(60 * time.Second)
|
||||
p.TLSHandshakeTimeout = types.Duration(5 * time.Second)
|
||||
p.KeepAlive = types.Duration(10 * time.Second)
|
||||
p.DefaultRule = DefaultTemplateRule
|
||||
}
|
||||
|
||||
// Basic holds basic authentication specific configurations
|
||||
type Basic struct {
|
||||
HTTPBasicAuthUser string `description:"Basic authentication User"`
|
||||
HTTPBasicPassword string `description:"Basic authentication Password"`
|
||||
HTTPBasicAuthUser string `description:"Basic authentication User."`
|
||||
HTTPBasicPassword string `description:"Basic authentication Password."`
|
||||
}
|
||||
|
||||
// Init the provider
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue