Skip to content

Commit

Permalink
add hotfix for gitlab extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
funkecoder23 authored and funkecoder23 committed May 27, 2024
1 parent 325fb58 commit 44b59c0
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
5 changes: 4 additions & 1 deletion scuba/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,12 @@ def override(self, node: yaml.nodes.Node) -> OverrideMixin:
assert isinstance(obj, OverrideMixin)
return obj

def not_yet_implemented(self, node: yaml.nodes.Node):
pass

Loader.add_constructor("!from_yaml", Loader.from_yaml)
Loader.add_constructor("!override", Loader.override)
Loader.add_constructor("!reference", Loader.not_yet_implemented)


def find_config() -> Tuple[Path, Path, ScubaConfig]:
Expand Down Expand Up @@ -517,7 +520,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
38 changes: 38 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,44 @@ 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_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
"""
)

def test_load_config_gitlab_extensions(self) -> None:
GITLAB_YML.write_text(
"""
include: included.yml
image: dummian:8.2
one:
image: !reference [another, job, somewhere]
two:
extends: one
normal:
image: dummian:12
"""
)

load_config(config_text=f"image: !from_yaml {GITLAB_YML} normal.image")


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

0 comments on commit 44b59c0

Please sign in to comment.