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
|
@ -8,9 +8,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"
|
||||
)
|
||||
|
||||
func (p *Provider) buildConfiguration(ctx context.Context, services []rancherData) *config.Configuration {
|
||||
|
|
|
@ -14,7 +14,7 @@ func Test_buildConfiguration(t *testing.T) {
|
|||
testCases := []struct {
|
||||
desc string
|
||||
containers []rancherData
|
||||
constraints types.Constraints
|
||||
constraints []*types.Constraint
|
||||
expected *config.Configuration
|
||||
}{
|
||||
{
|
||||
|
@ -330,11 +330,11 @@ func Test_buildConfiguration(t *testing.T) {
|
|||
State: "",
|
||||
},
|
||||
},
|
||||
constraints: types.Constraints{
|
||||
&types.Constraint{
|
||||
constraints: []*types.Constraint{
|
||||
{
|
||||
Key: "tag",
|
||||
MustMatch: true,
|
||||
Regex: "bar",
|
||||
Value: "bar",
|
||||
},
|
||||
},
|
||||
expected: &config.Configuration{
|
||||
|
@ -363,11 +363,11 @@ func Test_buildConfiguration(t *testing.T) {
|
|||
State: "",
|
||||
},
|
||||
},
|
||||
constraints: types.Constraints{
|
||||
&types.Constraint{
|
||||
constraints: []*types.Constraint{
|
||||
{
|
||||
Key: "tag",
|
||||
MustMatch: true,
|
||||
Regex: "foo",
|
||||
Value: "foo",
|
||||
},
|
||||
},
|
||||
expected: &config.Configuration{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package rancher
|
||||
|
||||
import (
|
||||
"github.com/containous/traefik/pkg/provider/label"
|
||||
"github.com/containous/traefik/pkg/config/label"
|
||||
)
|
||||
|
||||
type configuration struct {
|
||||
|
|
|
@ -40,15 +40,26 @@ var _ provider.Provider = (*Provider)(nil)
|
|||
|
||||
// Provider holds configurations of the provider.
|
||||
type Provider struct {
|
||||
provider.Constrainer `mapstructure:",squash" export:"true"`
|
||||
Watch bool `description:"Watch provider" export:"true"`
|
||||
DefaultRule string `description:"Default rule"`
|
||||
ExposedByDefault bool `description:"Expose containers by default" export:"true"`
|
||||
EnableServiceHealthFilter bool
|
||||
RefreshSeconds int
|
||||
provider.Constrainer `description:"List of constraints used to filter out some containers." export:"true"`
|
||||
|
||||
Watch bool `description:"Watch provider." export:"true"`
|
||||
DefaultRule string `description:"Default rule."`
|
||||
ExposedByDefault bool `description:"Expose containers by default." export:"true"`
|
||||
EnableServiceHealthFilter bool `description:"Filter services with unhealthy states and inactive states." export:"true"`
|
||||
RefreshSeconds int `description:"Defines the polling interval in seconds." export:"true"`
|
||||
IntervalPoll bool `description:"Poll the Rancher metadata service every 'rancher.refreshseconds' (less accurate)."`
|
||||
Prefix string `description:"Prefix used for accessing the Rancher metadata service."`
|
||||
defaultRuleTpl *template.Template
|
||||
IntervalPoll bool `description:"Poll the Rancher metadata service every 'rancher.refreshseconds' (less accurate)"`
|
||||
Prefix string `description:"Prefix used for accessing the Rancher metadata service"`
|
||||
}
|
||||
|
||||
// SetDefaults sets the default values.
|
||||
func (p *Provider) SetDefaults() {
|
||||
p.Watch = true
|
||||
p.ExposedByDefault = true
|
||||
p.EnableServiceHealthFilter = true
|
||||
p.RefreshSeconds = 15
|
||||
p.DefaultRule = DefaultTemplateRule
|
||||
p.Prefix = "latest"
|
||||
}
|
||||
|
||||
type rancherData struct {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue