-
Notifications
You must be signed in to change notification settings - Fork 142
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
refactor!: get rid of associated type ImageArgs
and rename to cmd
#649
Merged
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
- really common pattern is to use `Vec<String>` - `args` isn't the best term, because in fact it's Docker's [CMD](https://docs.docker.com/reference/dockerfile/#cmd) - it was not aligned with existing `ExecCommand` - current interface is confusing and users struggle with it - essentially it should be closer to the current representation of environment variables and other parameters - new implementation allows to override args regardless of underlying type - it's still will be possible to use custom strict arguments type for particular image which can be converted to list of strings if users want Dependent PR to modules: testcontainers/testcontainers-rs-modules-community#143
✅ Deploy Preview for testcontainers-rust ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
DDtKey
added a commit
that referenced
this pull request
Jun 10, 2024
It's really helpful and allows some further refactoring for better API. In most of the cases, it should not be a problem (and even pretty common) to run test against fresher versions of Rust. PR is needed for #649 and couple of follow-up PRs
DDtKey
changed the title
refactor!: get rid of associated type for
refactor!: get rid of associated type for Jun 10, 2024
ImageArgs
ImageArgs
and rename to cmd
DDtKey
changed the title
refactor!: get rid of associated type for
refactor!: get rid of associated type Jun 10, 2024
ImageArgs
and rename to cmd
ImageArgs
and rename to cmd
This was referenced Jun 15, 2024
Closed
Merged
DDtKey
pushed a commit
that referenced
this pull request
Jun 15, 2024
## 🤖 New release * `testcontainers`: 0.17.0 -> 0.18.0 <details><summary><i><b>Changelog</b></i></summary><p> <blockquote> ## [0.18.0] - 2024-06-15 ### Details #### Bug Fixes - [❗] Make `DOCKER_CONFIG` usage consistent with Docker CLI ([#654](#654)) #### Features - [❗] Support UDP and SCTP port mappings ([#655](#655)) - Impl `From<u16>` for `ContainerPort` with TCP default ([#658](#658)) - Support HTTP wait strategy ([#659](#659)) - Allow passing `u16` to `Ports` #### Miscellaneous Tasks - Use nightly `rustfmt` ([#657](#657)) #### Refactor - [❗] Get rid of associated type `ImageArgs` and rename to `cmd` ([#649](#649)) - Avoid unnecessary owned structs and boxing ([#651](#651)) - [❗] Add `ImageExt` trait to avoid explicit conversion to `RunnableImage` ([#652](#652)) - [❗] Rename `RunnableImage` to `ContainerRequest` ([#653](#653)) - [❗] Exposed and mapped ports api ([#656](#656)) - Preliminary refactoring of `wait` strategies ([#661](#661)) </blockquote> </p></details> --- This PR was generated with [release-plz](https://github.com/MarcoIeni/release-plz/). ## Migration Guide ### Overview Most of the breaking changes introduced in this version primarily impact developers who implement their own images. For general usage, the API remains mostly the same, with some improvements and enhancements for better performance and flexibility. ### 1. Renaming of `RunnableImage` - **Old**: `RunnableImage` - **New**: `ContainerRequest` - **Update**: The explicit conversion from `Image` to `ContainerRequest` (formerly `RunnableImage`) is no longer necessary. Instead, you can now directly import `testcontainers::ImageExt` and override image parameters as needed. ### 2. Changes to `Image` Methods - **Method**: `Image::tag` and `Image::name` - **Old Return Type**: `String` - **New Return Type**: `&str` - **Update**: Update any code that relies on these methods to handle the new return type `&str`. This change helps improve performance by avoiding unnecessary allocations. ### 3. Changes to `Image::exposed_ports` - **Method**: `Image::exposed_ports` - **Old Return Type**: Implementation-specific or previously different. - **New Return Type**: `&[ContainerPort]` - **Update**: The method now returns a slice of `ContainerPort`, which supports exposing ports with protocols `TCP`, `UDP`, and `SCTP`. Update your code to handle the slice accordingly. ### 4. Removal of Associated Type `Args` in `Image` - **Old**: `Image` had an associated type `Args`. - **New**: The associated type `Args` is removed. - **Update**: Command arguments are now part of `Image::cmd`, which returns `impl IntoIterator<Item = impl Into<String>>`. This change allows more flexibility in specifying command arguments. Ensure your code is updated to work with the new method signature. ### 5. Simplification of Trait Implementation in `Image` - **Old**: `Image` required `Box<dyn ..>` for certain traits. - **New**: Utilizes Return Position `impl` Trait in Trait (RPITIT). - **Update**: Instead of requiring `Box<dyn ..>`, `Image` now uses RPITIT for trait returns. This change simplifies the code and improves readability and performance. Familiarize yourself with [RPITIT](https://rustc-dev-guide.rust-lang.org/return-position-impl-trait-in-trait.html) to understand its benefits and applications in your implementation. ### 6. Changes to `RunnableImage::with_mapped_port` - **Old**: `RunnableImage::with_mapped_port` - **New**: Accessible through `ImageExt::with_mapped_port` - **Update**: This method now accepts two parameters instead of a tuple. Adjust your method calls to pass the parameters separately. Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.
Vec<String>
args
isn't the best term, because in fact it's Docker's CMDExecCommand
Dependent PR to modules: testcontainers/testcontainers-rs-modules-community#143
Also, I'm preparing 2 follow-up PRs which will improve the user experience.