Skip to content

Make DockerCompose.get_service_info public - #240

Closed
csikb wants to merge 3 commits into
testcontainers:mainfrom
csikb:master
Closed

Make DockerCompose.get_service_info public#240
csikb wants to merge 3 commits into
testcontainers:mainfrom
csikb:master

Conversation

@csikb

@csikbcsikb commented Aug 28, 2022

Copy link
Copy Markdown

I'm new to Python. I welcome every suggestion. :)

@codecov-commenter

codecov-commenter commented Aug 28, 2022

Copy link
Copy Markdown

Codecov Report

Merging #240 (d879694) into master (b65c8a0) will not change coverage.
The diff coverage is 100.00%.

@@ Coverage Diff @@## master #240 +/- ##
=======================================
Coverage 86.05% 86.05% =======================================
Files 27 27 Lines 746 746 Branches 70 70 =======================================
Hits 642 642 Misses 80 80 Partials 24 24 
Impacted FilesCoverage Δ
testcontainers/compose.py98.36% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Comment threadtestcontainers/compose.py Outdated
Co-authored-by: Till Hoffmann <tillahoffmann@gmail.com>
@csikb

Copy link
Copy Markdown
Author

In the future it would make sense to depreciate the get_host and get_port methods in favour of this.

assert host == "0.0.0.0"
assert port == "3306"

host = compose.get_service_host("hub", 4444)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One more small change: let's check both methods for getting the information here to ensure we main backwards compatibility.

@alexanderankin

Copy link
Copy Markdown
Member

hi @csikb unfortunately this module has changed and your PR doesn't land so neatly - feel free to reply to this issue if this API is not sufficient as it seems to be similar in intent: with DockerCompose() as d: d.get_container(service_name).get_publisher(by_port=port) API.

it returns this object which contains the URL and PublishedPort

classPublishedPort:
"""
Class that represents the response we get from compose when inquiring status
via `DockerCompose.get_running_containers()`.
"""
URL: Optional[str] =None
TargetPort: Optional[str] =None
PublishedPort: Optional[str] =None
Protocol: Optional[str] =None

unfortunately it doesn't quite work as expected on #457 (we normalize the host in the public API of the module), arguably we should normalize it "sooner"?

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@csikb@codecov-commenter@alexanderankin@tillahoffmann