-
-
Notifications
You must be signed in to change notification settings - Fork 523
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
chore: move host-config and endpoint settings to a specific modifiers #633
Merged
mdelapenya
merged 41 commits into
testcontainers:main
from
mdelapenya:pre-creation-hook
Feb 16, 2023
Merged
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
19d7296
feat: support preconfiguring Docker's host config and endpoint settin…
mdelapenya 2d5ce5c
chore: deprecate ExtraHosts from the container request
mdelapenya 0150814
chore: deprecate Binds from the container request
mdelapenya 894bcee
chore: deprecate Tmpfs from the container request
mdelapenya 0748a89
chore: deprecate AutoRemove from the container request
mdelapenya d70b26a
chore: deprecate Privileged from the container request
mdelapenya 064467d
chore: deprecate Resources from the container request
mdelapenya 793cd61
chore: deprecate ShmSize from the container request
mdelapenya feaec02
chore: deprecate CapAdd from the container request
mdelapenya c327e65
chore: deprecate CapDrop from the container request
mdelapenya 27e1ae6
chore: deprecate NetworkMode from the container request
mdelapenya dbfb237
chore: consistent name for endpointSettings variable
mdelapenya 595a0b5
chore: rename callback to hook
mdelapenya 6dfd1fd
chore: extract default pre-creation hook to a function
mdelapenya 55f98c9
fix: wording
mdelapenya 7b2bcdf
chore: extract preCreation code to a function
mdelapenya 8a67f21
chore: rename methods to use modifier
mdelapenya ec4ba50
chore: extract life cycle to a separate file
mdelapenya 8342a00
fix: update comments
mdelapenya dd9bd20
chore: push Tmpfs back to layer 1
mdelapenya 0a09cf6
chore: push Privileged back to layer 1
mdelapenya 35849bb
Merge branch 'main' into pre-creation-hook
mdelapenya b437b88
fix: remove outdated comments
mdelapenya dac0df0
chore: bring ShmSize back to the first layer
mdelapenya 3cbf64e
Merge branch 'main' into pre-creation-hook
mdelapenya 17b8e1b
chore: separate concerns for modifiers
mdelapenya 66c5f4a
fix: typo in variable
mdelapenya f2cb127
Merge branch 'main' into pre-creation-hook
mdelapenya a15e33d
chore: add modifier for Docker config
mdelapenya cc267c1
chore: unit tests for the preCreateHook
mdelapenya 70f89e3
fix: check for the existence of aliases when there are multiple networks
mdelapenya 4fb482b
chore: adjust error messages in tests
mdelapenya 74e32d2
chore: include mounts in the unit tests
mdelapenya d7d38ea
fix: handle error in tests
mdelapenya e802e51
fix: handle error in tests
mdelapenya 668ad6d
Merge branch 'main' into pre-creation-hook
mdelapenya f1b6e26
chore: execute modifiers the last
mdelapenya 586b0e2
chore: rename file
mdelapenya b511560
Revert "chore: execute modifiers the last"
mdelapenya e1854a8
docs: document the modifiers
mdelapenya 43998c8
fix: typo
mdelapenya File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -87,6 +87,17 @@ func TestIntegrationNginxLatestReturn(t *testing.T) { | |||||
} | ||||||
``` | ||||||
|
||||||
### Advanced Settings | ||||||
|
||||||
The aforementioned `GenericContainer` function and the `ContainerRequest` struct represent a straightforward manner to configure the containers, but you could need to create your containers with more advance settings regarding the config, host config and endpoint settings Docker types. For those more advance settings, _Testcontainers for Go_ offers a way to fully customise the container request and those internal Docker types. These customisations, called _modifiers_, will be applied just before the internal call to the Docker client to create the container. | ||||||
|
||||||
<!--codeinclude--> | ||||||
[Using modifiers](../../lifecycle_test.go) inside_block:reqWithModifiers | ||||||
<!--/codeinclude--> | ||||||
|
||||||
!!!warning | ||||||
The only special case where the modifiers are not applied last, is when there are no exposed ports in the container request and the container does not use a network mode from a container (e.g. `req.NetworkMode = container.NetworkMode("container:$CONTAINER_ID")`). In that case, _Testcontainers for Go_ will extract the ports from the underliying Docker image and export them. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
## Reusable container | ||||||
|
||||||
With `Reuse` option you can reuse an existing container. Reusing will work only if you pass an | ||||||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.