-
-
Notifications
You must be signed in to change notification settings - Fork 515
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
feat: create networks with random names #1993
Merged
mdelapenya
merged 12 commits into
testcontainers:main
from
mdelapenya:network-name-non-deterministic
Dec 18, 2023
Merged
feat: create networks with random names #1993
mdelapenya
merged 12 commits into
testcontainers:main
from
mdelapenya:network-name-non-deterministic
Dec 18, 2023
Conversation
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
mdelapenya
added
the
feature
New functionality or new behaviors on the existing one
label
Dec 14, 2023
✅ Deploy Preview for testcontainers-go ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Because it was introduced in the current release, it's fine to change the signature
It relates to Docker Swarm
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What does this PR do?
This PR creates a new
network
package that will allow Go users to use thepackage.New
idiom when creating a Docker network with Testcontainers for Go.This new package exposes functional options representing the former
NetworkRequest
struct, so that users of the old struct are still able to convert their code to the new format using this deprecation path: instead of creating a Network request, please pass functional options with the needed settings.As a consequence, the old code to create a network has been deprecated, and will eventually removed in the next major version (v1).
To continue, it's important to mention that the new network will be created with a random name: instead of passing the name as before, we want names to be non-deterministic. And this comes with two benefits:
New
function, and read the name from there.Finally, the new
network
package will have this:New
function will return a struct, not an interface as in the previousGenericNetwork
: we want to adhere to the Go idiom of "accept interface, return struct" so the consumer of the method can work with the expected, concrete, returned type, not dealing with an abstraction. In other words: producers should produce concrete types to consumers.NetworkCustomizer
interface in the case consumers want to define their own options to create the network customising more Docker types. Implementing theCustomize
function will be enough.WithNetwork
functional option used in modules, not released yet, has been moved here and refactored a bit to allow receiving an already created Network struct, and use it in downstream containers.WithNewNetwork
functional option to be used in modules has been added. It will create a new network using the functions and options in thenetwork
package.Why is it important?
We want users to create networks with random names. We have stepped-up here to create a new package, which will be a PoC for an eventual v1 release, in which we could have first-order packages for the different entities we manage: networks, images, volumes and containers.
Related issues
How to test this PR
Please read the docs: https://deploy-preview-1993--testcontainers-go.netlify.app/features/creating_networks/ there we explain how the new APIs are used.
All the modules will receive two new options: