Conversation
…eContainerCmd properties without waiting until TestContainers adds support for it.
| /** | ||
| * @deprecated set by GenericContainer and should never be set outside | ||
| */ | ||
| @Deprecated |
There was a problem hiding this comment.
decided to do the deprecations here
| public class GenericContainer<SELF extends GenericContainer<SELF>> | ||
| extends FailureDetectingExternalResource | ||
| implements Container<SELF> { | ||
| implements Container<SELF>, AutoCloseable { |
There was a problem hiding this comment.
small non-related change to simplify the testing
There was a problem hiding this comment.
FTR IntelliJ IDEA is barking about this, see https://imgur.com/a/sD1WNyG ;)
(and I cannot use try with resources in my use case)
| stop(); | ||
| } | ||
|
|
||
| public SELF withCustomizer(Consumer<CreateContainerCmd> hook) { |
There was a problem hiding this comment.
I need a help with the naming here.
There was a problem hiding this comment.
Maybe something more verbose like withPostCreateContainerCmd()?
There was a problem hiding this comment.
Funny thing - I initially named it withCreateContainerCmdHook and then was playing with different names and accidentally committed this one :D
There was a problem hiding this comment.
Like this name too ;)
Although this name does not indicate whether this is a pre- or postcreate hook. Is it important for users of the API to know about this fact? Might be.
There was a problem hiding this comment.
I've decided to go with "post" hooks only because GenericObject does "pre" part already, and this new API just allows you to configure the final result and override some configuration. Do you have any example where "pre" hook might be helpful? Because I don't :)
There was a problem hiding this comment.
No, don't think we need it. My point was only about the naming, including the word post makes the API a bit more self documenting.
There was a problem hiding this comment.
I liked pre/post, but actually doesn't it make it confusing wrt. what it is before or after?
This change is post- testcontainer's configuration step, but pre- creation of the container. So actually it seems to be confusing if we're not careful 😂
Some other ideas for the name: withConfigurationCustomizer, withConfigModifier or maybe even just with(Consumer<CreateContainerCmd> hook)..? (The latter would need heavier documentation so as to be more discoverable though)
I'm not sure though 🤷♂️
There was a problem hiding this comment.
Your post clarified the API a lot for me and now I agree, pre/post seems to introduce confusing semantics here.
From a general API naming standpoint, withConfigurationCustomizer and withConfigModifier both sound good, but isn't it actually more a withCreateContainerCmdModifier? Sounds awkward and very verbose, but kind of in line with the docker-java API (which seems appropriate, since docker-java does leak through this method after all).
There was a problem hiding this comment.
withCreateContainerCmdModifier seems OK to me - like you say, verbose but clear.
We should probably be making it clear to the developer, through naming and javadoc comments, that this does expose the underlying docker-java API so might change outside of our control.
WDYT @bsideup ?
There was a problem hiding this comment.
I agree! I'll add JavaDoc and rename the method now :)
|
What would be the syntax for |
|
@martin-g I guess we have to wait until tmpfs is supported in docker-java, then it will be something like |
|
I see. Thanks! |
| public class GenericContainer<SELF extends GenericContainer<SELF>> | ||
| extends FailureDetectingExternalResource | ||
| implements Container<SELF> { | ||
| implements Container<SELF>, AutoCloseable { |
| public void createContainerCmdHookTest() { | ||
| // Use random name to avoid the conflicts between the tests | ||
| String randomName = Base58.randomString(5); | ||
| try( |
|
|
||
| private List<Consumer<OutputFrame>> logConsumers = new ArrayList<>(); | ||
|
|
||
| private final Set<Consumer<CreateContainerCmd>> createContainerCmdMidifiers = new LinkedHashSet<>(); |
There was a problem hiding this comment.
Spelling: Midifiers -> Modifiers
|
Aside from a spelling error this LGTM! I think this warrants separate mention in the docs, though. I can try and do this at the weekend if you don't have time though - up to you. |
## [1.2.0] - 2017-03-12 ### Fixed - Fix various escaping issues that may arise when paths contain spaces (#263, #279) - General documentation fixes/improvements (#300, #303, #304) - Improve reliability of `ResourceReaper` when there are a large number of containers returned by `docker ps -a` (#295) ### Changed - Support Docker for Windows via TCP socket connection (#291, #297, #309). _Note that Docker Compose is not yet supported under Docker for Windows (see #306) - Expose `docker-java`'s `CreateContainerCmd` API for low-level container tweaking (#301) - Shade `org.newsclub` and Guava dependencies (#299, #292) - Add `org.testcontainers` label to all containers created by Testcontainers (#294)
Makes it possible to override unsupported CreateContainerCmd properties without waiting until TestContainers adds support for it.