-
-
Notifications
You must be signed in to change notification settings - Fork 466
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: remove most uses of TestcontainersConfig and deprecated TestcontainersConfig fields. #2614
Merged
mdelapenya
merged 6 commits into
testcontainers:main
from
thaJeztah:cleanup_legacy_config
Jul 2, 2024
Merged
chore: remove most uses of TestcontainersConfig and deprecated TestcontainersConfig fields. #2614
mdelapenya
merged 6 commits into
testcontainers:main
from
thaJeztah:cleanup_legacy_config
Jul 2, 2024
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
This test was verifying that DockerProvider.Config() returned a non-nil value, but Config() does not return a pointer, so it would always pass (even with an empty struct). Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
The TestcontainersConfig.RyukDisabled field is deprecated. NewDockerProvider() uses ReadConfig() internally to load the config, which always copies its value from config.Config.RyukDisabled field, which is not deprecated. This patch removes the extra redirection, and changes the code to use Config.RyukDisabled instead. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
All fields in TestcontainersConfig are deprecated, making it a wrapper around config.Config and DockerProvider internally only depends on config.Config. All deprecated fields contain a copy of values available in config.Config. However, the exported `Config()` has TestcontainersConfig as return type; filling the deprecated fields is is currently handled by ReadConfig, but straightforward, so we can inline that code in the `Config()` method. This patch: - changes the (non-exported) config field to hold a config.Config (which provides all the data used). - removes internal uses of the `Config()` method; the `Config()` method did not provide value for internal use; the `config` field is not mutated (so no synchronisation needed for concurrency). - updates the `Config()` method to handle conversion of the config.Config to a `TestcontainersConfig` (effectively inlining a copy of `ReadConfig`) After this patch, the only remaining use of `ReadConfig` in testcontainers-go itself is in tests (`TestReadConfig`); as a follow-up, we can consider deprecating `ReadConfig` and `TestcontainersConfig`, although `DockerProvider` may need a new `Config()` method with a different signature if its config must be accessible for others, which would require the `ContainerProvider` and `ReaperProvider` interfaces to be updated. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
✅ Deploy Preview for testcontainers-go ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
mdelapenya
approved these changes
Jul 2, 2024
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.
LGTM, thanks!
mdelapenya
added a commit
that referenced
this pull request
Jul 2, 2024
* main: fix: never cache JSON representation of a container (#2606) chore: remove most uses of TestcontainersConfig and deprecated TestcontainersConfig fields. (#2614) chore(deps): bump github.com/docker/docker from v27.0.2 to v27.0.3 (#2615) chore(deps): bump github.com/docker/docker from v26.1.4 to v27.0.2 (#2593)
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?
remove TestProviderHasConfig as it wasn't testing anything
This test was verifying that DockerProvider.Config() returned a
non-nil value, but Config() does not return a pointer, so it
would always pass (even with an empty struct).
TestContainerLogWithErrClosed: rename variable that shadowed import
NewDockerProvider: inline intermediate variables
modules/compose: NewDockerComposeWith: don't use deprecated RyukDisabled
The TestcontainersConfig.RyukDisabled field is deprecated.
NewDockerProvider() uses ReadConfig() internally to load the config,
which always copies its value from config.Config.RyukDisabled field,
which is not deprecated.
This patch removes the extra redirection, and changes the code to
use Config.RyukDisabled instead.
DockerProvider: don't use legacy TestcontainersConfig internally
All fields in TestcontainersConfig are deprecated, making it a
wrapper around config.Config and DockerProvider internally only
depends on config.Config. All deprecated fields contain a copy
of values available in config.Config.
However, the exported
Config()
has TestcontainersConfig as return type;filling the deprecated fields is is currently handled by ReadConfig, but
straightforward, so we can inline that code in the
Config()
method.This patch:
provides all the data used).
Config()
method; theConfig()
methoddid not provide value for internal use; the
config
field is not mutated(so no synchronisation needed for concurrency).
Config()
method to handle conversion of the config.Configto a
TestcontainersConfig
(effectively inlining a copy ofReadConfig
)After this patch, the only remaining use of
ReadConfig
in testcontainers-goitself is in tests (
TestReadConfig
); as a follow-up, we can considerdeprecating
ReadConfig
andTestcontainersConfig
, althoughDockerProvider
may need a new
Config()
method with a different signature if its configmust be accessible for others, which would require the
ContainerProvider
and
ReaperProvider
interfaces to be updated.Why is it important?
Remove uses of deprecated fields to make it easier to spot where it's still used.
Follow-ups
consider deprecating
ReadConfig
andTestcontainersConfig
, althoughDockerProvider
may need a new
Config()
method with a different signature if its configmust be accessible for others, which would require the
ContainerProvider
and
ReaperProvider
interfaces to be updated.