Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lean/models/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ def parse(cls, image: str) -> 'DockerImage':
:param image: the input value
:return: the DockerImage object containing the name and the tag of the image
"""
if ":" in image:
name, tag = image.split(":")
else:
# A colon can also separate a registry host from its port, the tag is only what follows the last one
name, separator, tag = image.rpartition(":")
if separator == "" or "/" in tag:
name = image
tag = "latest"

Expand Down
6 changes: 5 additions & 1 deletion tests/models/test_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@
("lean:123", "lean", "123"),
("quantconnect/lean", "quantconnect/lean", "latest"),
("quantconnect/lean:latest", "quantconnect/lean", "latest"),
("quantconnect/lean:123", "quantconnect/lean", "123")])
("quantconnect/lean:123", "quantconnect/lean", "123"),
("localhost:5000/lean", "localhost:5000/lean", "latest"),
("localhost:5000/lean:123", "localhost:5000/lean", "123"),
("registry.example.com:5000/quantconnect/lean:123",
"registry.example.com:5000/quantconnect/lean", "123")])
def test_docker_image_name_parse_parses_value(value: str, name: str, tag: str) -> None:
result = DockerImage.parse(value)

Expand Down