Skip to content

Commit

Permalink
fix gitlab image dict crash
Browse files Browse the repository at this point in the history
  • Loading branch information
funkecoder23 authored and funkecoder23 committed Jun 27, 2024
1 parent 33be5ed commit 23083e3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion scuba/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ def from_dict(
return cls(
name=name,
script=script,
image=node.get("image"),
image=_get_str(node, "image"),
entrypoint=_get_entrypoint(node),
environment=_process_environment(
node.get("environment"), f"{name}.environment"
Expand Down
29 changes: 29 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,35 @@ def test_load_config_safe_external(self) -> None:
SCUBA_YML.write_text(f"image: !from_yaml {external_yml} danger")
self.__test_load_config_safe(external_yml)

def test_load_config_image_name(self) -> None:
"""
.gitlab-ci.yml supports a long-form `image` specification
with `name` and other sub-keys:
https://docs.gitlab.com/ee/ci/yaml/#image
Scuba doesn't currently support that, so make sure we handle
this error gracefully.
TODO(#230): Support this complex `image` format.
"""

GITLAB_YML.write_text(
"""
two:
stage: build
image:
name: dummian:8.2
"""
)
invalid_config(
config_text=f"""
aliases:
two:
image: !from_yaml {GITLAB_YML} two.image
script: rip
"""
)


class TestConfigHooks(ConfigTest):
def test_hooks_mixed(self) -> None:
Expand Down

0 comments on commit 23083e3

Please sign in to comment.