Skip to content
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

Return container IP when attached to a single named network #491

Merged

Conversation

leszko
Copy link
Contributor

@leszko leszko commented Jul 28, 2022

In many cases the container is attached to a single, named network of the "bridge" mode. In such scenarios, DockerContainer.ContainerIP() should resolve this IP and return it.

For example, imaging the following container definition.

testcontainers.ContainerRequest{
    // ...
    Networks:     []string{"some-network"},
}

Before this change, the function container.ContainerIP(ctx) returns an empty string. After this change, it returns the correct container IP.

Copy link
Collaborator

@mdelapenya mdelapenya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution, also updating the tests! At first look, LGTM, will give it a try on CI before a final review.

docker.go Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Jul 28, 2022

Codecov Report

Merging #491 (1ebb44c) into main (d3af318) will increase coverage by 0.41%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #491      +/-   ##
==========================================
+ Coverage   69.65%   70.06%   +0.41%     
==========================================
  Files          21       21              
  Lines        2040     2048       +8     
==========================================
+ Hits         1421     1435      +14     
+ Misses        495      491       -4     
+ Partials      124      122       -2     
Impacted Files Coverage Δ
docker.go 71.97% <100.00%> (+0.88%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us.

@leszko leszko requested a review from mdelapenya July 29, 2022 07:47
@mdelapenya mdelapenya self-assigned this Aug 1, 2022
@leszko
Copy link
Contributor Author

leszko commented Aug 1, 2022

@mdelapenya If the PR is ok, can we get it merged into main?

@mdelapenya mdelapenya merged commit dea438c into testcontainers:main Aug 1, 2022
@mdelapenya
Copy link
Collaborator

Merged, thanks for your contribution, much much appreciated!

@leszko
Copy link
Contributor Author

leszko commented Aug 1, 2022

Merged, thanks for your contribution, much much appreciated!

Thanks for merging :)

@mdelapenya
Copy link
Collaborator

My pleasure!!

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants