-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
Few refactoring around the docker provider #1440
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.
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 |
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.
Extra p
or intended?
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.
oups 😓
op(c) | ||
} | ||
|
||
return *c |
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.
How about returning a pointer since we are already applying the ops on the pointer?
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.
So, we always use ContainerJSON
as not a pointer so… I prered to have just on return *c
than a lot of *containerJSON(…)
😝
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.
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 | ||
} | ||
} |
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.
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.
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.
right, so… I don't want to overdo it too. 😛
) | ||
|
||
func containerJSON(ops ...func(*docker.ContainerJSON)) docker.ContainerJSON { | ||
c := &docker.ContainerJSON{ |
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.
variable names with one letter, are you sure ?
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.
not sure, but between c
, ctnr
or cont
, I went lazy 👼 (didn't want to use container
because it would override the container
package)
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.
Wow cool @vdemeester 👍
Small comment but other than that, LGTM
provider/provider.go
Outdated
@@ -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, |
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.
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
.
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.
Oups you are right. I'll fix that ;)
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.
Shouldn't this have been caught by some test?
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.
I think it is not used in any template (in the repo) but.. Yeah.. 😅
48a134c
to
51a53b3
Compare
5bd7091
to
d835b4a
Compare
Makes it simpler to manage :) Signed-off-by: Vincent Demeester <[email protected]>
- 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 <[email protected]>
d835b4a
to
b04ba36
Compare
LGTM ⚓️ NICE WORK @vdemeester |
This is a big one, sorry for that 😛 (and this is just the beginning). This one does 2 things, separated in 2 commits
docker
provider to its own package (provider/docker
). I intend to do that for all of the providers.Note that there is still some flakyness in the unit tests 😱
🦁