Skip to content

Commit

Permalink
Fix: Make sure default image can be found (#698)
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Bauer <[email protected]>
  • Loading branch information
bimtauer authored Oct 18, 2021
1 parent 1e5c9d5 commit eeb66b3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion flytekit/core/context_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ def find_image(self, name) -> Optional[Image]:
"""
Return an image, by name, if it exists.
"""
for i in self.images:
lookup_images = self.images + [self.default_image] if self.images else [self.default_image]
for i in lookup_images:
if i.name == name:
return i
return None
Expand Down
16 changes: 16 additions & 0 deletions tests/flytekit/unit/core/test_python_auto_container.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import pytest

from flytekit.core.context_manager import Image, ImageConfig
from flytekit.core.python_auto_container import get_registerable_container_image


@pytest.fixture
def default_image_config():
default_image = Image(name="default", fqn="docker.io/xyz", tag="some-git-hash")
return ImageConfig(default_image=default_image)


def test_image_name_interpolation(default_image_config):
img_to_interpolate = "{{.image.default.fqn}}:{{.image.default.version}}-special"
img = get_registerable_container_image(img=img_to_interpolate, cfg=default_image_config)
assert img == "docker.io/xyz:some-git-hash-special"

0 comments on commit eeb66b3

Please sign in to comment.