New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create init method on provider interface #3580
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGTM 🐯
Just a small comment 😉
configuration/provider_aggregator.go
Outdated
err := provider.Init(constraint) | ||
if err != nil { | ||
providerType := reflect.TypeOf(provider) | ||
log.Errorf("Error initializing provider %v: %v", providerType, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not using %T
instead of %v
and not use reflect
above ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👼 I like that one
configuration/provider_aggregator.go
Outdated
if err != nil { | ||
log.Errorf("Error starting provider %v: %s", providerType, err) | ||
log.Errorf("Error starting provider %T: %s", p, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
%v
instead of %s
provider/file/file.go
Outdated
@@ -27,9 +27,15 @@ type Provider struct { | |||
TraefikFile string | |||
} | |||
|
|||
// Init the provider | |||
func (p *Provider) Init(constraints types.Constraints) error { | |||
p.BaseProvider.Init(constraints) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return p.BaseProvider.Init(constraints)
provider/eureka/eureka.go
Outdated
@@ -22,9 +22,15 @@ type Provider struct { | |||
RefreshSeconds flaeg.Duration `description:"Override default configuration time between refresh" export:"true"` | |||
} | |||
|
|||
// Init the provider | |||
func (p *Provider) Init(constraints types.Constraints) error { | |||
p.BaseProvider.Init(constraints) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return p.BaseProvider.Init(constraints)
provider/ecs/ecs.go
Outdated
@@ -65,6 +65,12 @@ type awsClient struct { | |||
ec2 *ec2.EC2 | |||
} | |||
|
|||
// Init the provider | |||
func (p *Provider) Init(constraints types.Constraints) error { | |||
p.BaseProvider.Init(constraints) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return p.BaseProvider.Init(constraints)
provider/dynamodb/dynamodb.go
Outdated
@@ -37,6 +37,12 @@ type dynamoClient struct { | |||
db dynamodbiface.DynamoDBAPI | |||
} | |||
|
|||
// Init the provider | |||
func (p *Provider) Init(constraints types.Constraints) error { | |||
p.BaseProvider.Init(constraints) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return p.BaseProvider.Init(constraints)
provider/kubernetes/kubernetes.go
Outdated
@@ -95,9 +95,15 @@ func (p *Provider) newK8sClient(ingressLabelSelector string) (Client, error) { | |||
return cl, err | |||
} | |||
|
|||
// Init the provider | |||
func (p *Provider) Init(constraints types.Constraints) error { | |||
p.BaseProvider.Init(constraints) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return p.BaseProvider.Init(constraints)
provider/marathon/marathon.go
Outdated
@@ -72,10 +72,15 @@ type Basic struct { | |||
HTTPBasicPassword string `description:"Basic authentication Password"` | |||
} | |||
|
|||
// Init the provider | |||
func (p *Provider) Init(constraints types.Constraints) error { | |||
p.BaseProvider.Init(constraints) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return p.BaseProvider.Init(constraints)
provider/mesos/mesos.go
Outdated
@@ -38,9 +38,15 @@ type Provider struct { | |||
Masters []string | |||
} | |||
|
|||
// Init the provider | |||
func (p *Provider) Init(constraints types.Constraints) error { | |||
p.BaseProvider.Init(constraints) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return p.BaseProvider.Init(constraints)
provider/rancher/rancher.go
Outdated
@@ -51,13 +51,19 @@ func (r rancherData) String() string { | |||
return fmt.Sprintf("{name:%s, labels:%v, containers: %v, health: %s, state: %s}", r.Name, r.Labels, r.Containers, r.Health, r.State) | |||
} | |||
|
|||
// Init the provider | |||
func (p *Provider) Init(constraints types.Constraints) error { | |||
p.BaseProvider.Init(constraints) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return p.BaseProvider.Init(constraints)
provider/zk/zk.go
Outdated
func (p *Provider) Provide(configurationChan chan<- types.ConfigMessage, pool *safe.Pool, constraints types.Constraints) error { | ||
// Init the provider | ||
func (p *Provider) Init(constraints types.Constraints) error { | ||
p.Provider.Init(constraints) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't manage the error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What does this PR do?
Create an
Init
method onProvider
Motivation
The goal is to separate
Init
andProvide
in order to be able to disable aProvider
whenInit
failed.More
Fix a bug with the ACME Provider, when the storage file was invalid, the configuration listener blocked the dynamic configuration refresh. Now, if the file is invalid, the
Init
fail and then we disable ACME Provider.