chore: remove most uses of TestcontainersConfig and deprecated TestcontainersConfig fields.#2614
Merged
mdelapenya merged 6 commits intotestcontainers:mainfrom Jul 2, 2024
Merged
Conversation
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
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)
This file contains hidden or 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
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
configfield 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
ReadConfigin testcontainers-goitself is in tests (
TestReadConfig); as a follow-up, we can considerdeprecating
ReadConfigandTestcontainersConfig, althoughDockerProvidermay need a new
Config()method with a different signature if its configmust be accessible for others, which would require the
ContainerProviderand
ReaperProviderinterfaces 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
ReadConfigandTestcontainersConfig, althoughDockerProvidermay need a new
Config()method with a different signature if its configmust be accessible for others, which would require the
ContainerProviderand
ReaperProviderinterfaces to be updated.