Skip to content

Commit

Permalink
refactor!: exposed and mapped ports api
Browse files Browse the repository at this point in the history
- rename `ExposedPort` to `ContainerPort` (after #655)
- `with_mapped_port`: accept two arguments  instead of tuple
- introduce `IntoContainerPort` to make a shortcut for conversion from `u16` to `ContainerPort`
  • Loading branch information
DDtKey committed Jun 14, 2024
1 parent a2add5f commit ce6548d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions testcontainers/src/core/image/image_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ pub trait ImageExt<I: Image> {
///
/// let image = GenericImage::new("image", "tag").with_mapped_port(8080, 80.tcp());
/// ```
fn with_mapped_port(self, host_port: u16, container_port: ContainerPort) -> ContainerRequest<I>;
fn with_mapped_port(self, host_port: u16, container_port: ContainerPort)
-> ContainerRequest<I>;

/// Sets the container to run in privileged mode.
fn with_privileged(self, privileged: bool) -> ContainerRequest<I>;
Expand Down Expand Up @@ -147,7 +148,11 @@ impl<RI: Into<ContainerRequest<I>>, I: Image> ImageExt<I> for RI {
runnable
}

fn with_mapped_port(self, host_port: u16, container_port: ContainerPort) -> ContainerRequest<I> {
fn with_mapped_port(
self,
host_port: u16,
container_port: ContainerPort,
) -> ContainerRequest<I> {
let runnable = self.into();
let mut ports = runnable.ports.unwrap_or_default();
ports.push(PortMapping::new(host_port, container_port.into()));
Expand Down

0 comments on commit ce6548d

Please sign in to comment.