Skip to content
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

Merged
merged 9 commits into from Jul 11, 2018
Merged

Conversation

juliens
Copy link
Member

@juliens juliens commented Jul 9, 2018

What does this PR do?

Create an Init method on Provider

Motivation

The goal is to separate Init and Provide in order to be able to disable a Provider when Init 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.

Copy link
Contributor

@vdemeester vdemeester left a 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 😉

err := provider.Init(constraint)
if err != nil {
providerType := reflect.TypeOf(provider)
log.Errorf("Error initializing provider %v: %v", providerType, err)
Copy link
Contributor

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 ?

Copy link
Collaborator

@SantoDE SantoDE left a 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

@ldez ldez self-requested a review July 9, 2018 22:46
if err != nil {
log.Errorf("Error starting provider %v: %s", providerType, err)
log.Errorf("Error starting provider %T: %s", p, err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

%v instead of %s

@@ -27,9 +27,15 @@ type Provider struct {
TraefikFile string
}

// Init the provider
func (p *Provider) Init(constraints types.Constraints) error {
p.BaseProvider.Init(constraints)
Copy link
Member

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)

@@ -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)
Copy link
Member

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)

@@ -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)
Copy link
Member

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)

@@ -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)
Copy link
Member

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)

@@ -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)
Copy link
Member

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)

@@ -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)
Copy link
Member

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)

@@ -38,9 +38,15 @@ type Provider struct {
Masters []string
}

// Init the provider
func (p *Provider) Init(constraints types.Constraints) error {
p.BaseProvider.Init(constraints)
Copy link
Member

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)

@@ -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)
Copy link
Member

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)

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)
Copy link
Member

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

Copy link
Member

@mmatur mmatur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@ldez ldez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants