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

Make DockerCompose.get_service_info public #240

Closed
wants to merge 3 commits into from

Conversation

csikb
Copy link

@csikb csikb commented Aug 28, 2022

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

@codecov-commenter
Copy link

codecov-commenter commented Aug 28, 2022

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 Files Coverage Δ
testcontainers/compose.py 98.36% <100.00%> (ø)

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

@csikb
Copy link
Author

csikb commented Aug 30, 2022

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

@csikb csikb requested a review from tillahoffmann September 4, 2022 18:12
@@ -64,8 +64,7 @@ def test_can_parse_multiple_compose_files():
assert host == "0.0.0.0"
assert port == "3306"

host = compose.get_service_host("hub", 4444)
Copy link
Collaborator

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
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

class PublishedPort:
"""
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 free to 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