Skip to content

Make DockerCompose.get_service_info public #239

Description

@csikb

Return a touple with the host and the port

defget_service_info(self, service, port):
""" Returns the host and the port for one of the services. Parameters ---------- service: str Name of the docker compose service port: int The internal port to get the host for Returns ------- (str, str): The hostname for the service, The port for the service """port_cmd=self.docker_compose_command() + ["port", service, str(port)]
output=subprocess.check_output(port_cmd, cwd=self.filepath).decode("utf-8")
result=str(output).rstrip().split(":")
iflen(result) !=2ornotall(result):
raiseNoSuchPortExposed(f"port {port} is not exposed for service {service}")
returnresult[0], result[1]
# old approachhost=compose.get_service_host("hub", 4444)
port=compose.get_service_port("hub", 4444)
# new approachhost, port=compose.get_service_info("hub", 4444)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions