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

Few refactoring around the docker provider #1440

Merged
merged 2 commits into from Apr 17, 2017

Conversation

vdemeester
Copy link
Contributor

This is a big one, sorry for that 😛 (and this is just the beginning). This one does 2 things, separated in 2 commits

  • Move the docker provider to its own package (provider/docker). I intend to do that for all of the providers.
  • Refactor some test to be less noisy using builders. This is just the first step… they are still too noisy 😛

Note that there is still some flakyness in the unit tests 😱

🦁

Copy link
Contributor

@timoreimann timoreimann left a comment

Choose a reason for hiding this comment

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

Just a few minor details (rather questions).

Now that the Docker tests live in their own package / namespace, all test prefixes TestDocker* should be renamed to Test* IMHO.

}

// dockerData holds the need data to the Docker provider
// dockerData holds the need data to the Provider p
Copy link
Contributor

Choose a reason for hiding this comment

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

Extra p or intended?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oups 😓

op(c)
}

return *c
Copy link
Contributor

Choose a reason for hiding this comment

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

How about returning a pointer since we are already applying the ops on the pointer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, we always use ContainerJSON as not a pointer so… I prered to have just on return *c than a lot of *containerJSON(…) 😝

Copy link
Contributor

Choose a reason for hiding this comment

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

My point was that we pass-by-pointer when we apply the ops only to do a return-by-value eventually. But I suppose it's fine this way.

return func(s *network.EndpointSettings) {
s.IPAddress = ip
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm on the fence whether the builder deserves its on set if tests. It doesn't seem strictly required but would be helpful to have them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right, so… I don't want to overdo it too. 😛

)

func containerJSON(ops ...func(*docker.ContainerJSON)) docker.ContainerJSON {
c := &docker.ContainerJSON{
Copy link
Member

Choose a reason for hiding this comment

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

variable names with one letter, are you sure ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure, but between c, ctnr or cont, I went lazy 👼 (didn't want to use container because it would override the container package)

Copy link
Member

@emilevauge emilevauge left a comment

Choose a reason for hiding this comment

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

Wow cool @vdemeester 👍
Small comment but other than that, LGTM

@@ -60,7 +61,7 @@ func (p *BaseProvider) getConfiguration(defaultTemplateFile string, funcMap temp
var defaultFuncMap = template.FuncMap{
"replace": replace,
"tolower": strings.ToLower,
"normalize": normalize,
"Normalize": Normalize,
Copy link
Member

Choose a reason for hiding this comment

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

I suppose that a regression might have been introduced here as no template have been modified. We should leave the first one in low caps to stay consistent "normalize": Normalize.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oups you are right. I'll fix that ;)

Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this have been caught by some test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it is not used in any template (in the repo) but.. Yeah.. 😅

Makes it simpler to manage :)

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
- Split the file into smaller ones (docker, swarm and service tests)
- Use some builder to reduce a little bit the noise for creating containers

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
@SantoDE
Copy link
Collaborator

SantoDE commented Apr 17, 2017

LGTM ⚓️ NICE WORK @vdemeester

@vdemeester vdemeester merged commit 2118f69 into traefik:master Apr 17, 2017
@vdemeester vdemeester deleted the docker-provider-refacto branch April 17, 2017 15:28
@ldez ldez modified the milestone: 1.3 Apr 23, 2017
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

5 participants