Skip to content

Commit

Permalink
Use YAML parser for local deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelldls committed Mar 21, 2024
1 parent 0fe7297 commit a1cc6e5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
23 changes: 14 additions & 9 deletions src/edge_containers_cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from typing import Optional

import typer
from ruamel.yaml import YAML

import edge_containers_cli.globals as globals
from edge_containers_cli.logging import log
Expand All @@ -23,16 +24,20 @@ def get_instance_image_name(svc_instance: Path, tag: Optional[str] = None) -> st
log.error(f"values.yaml not found in {svc_instance}")
raise typer.Exit(1)

values_text = values.read_text()
matches = re.findall(r"image: (.*):(.*)", values_text)
if len(matches) == 1:
tag = tag or matches[0][1]
image = matches[0][0] + f":{tag}"
else:
log.error(f"image tag definition not found in {values}")
raise typer.Exit(1)
with open(values) as fp:
yaml = YAML(typ="safe").load(fp)

try:
read_image = yaml["shared"]["ioc-instance"]["image"] + f":{tag}"
base_image, base_tag = read_image.split(":")[:2]
except KeyError:
log.error(f"shared.ioc-instance.image not found in {values}")
raise typer.Exit(1) from None

Check warning on line 35 in src/edge_containers_cli/utils.py

View check run for this annotation

Codecov / codecov/patch

src/edge_containers_cli/utils.py#L33-L35

Added lines #L33 - L35 were not covered by tests

tag = tag or base_tag
full_image = base_image + f":{tag}"

return image
return full_image


def check_instance_path(service_path: Path):
Expand Down
4 changes: 3 additions & 1 deletion tests/data/services/bl45p-ea-ioc-01/values.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
image: ghcr.io/epics-containers/ioc-adaravis-linux-runtime:23.9.4
shared:
ioc-instance:
image: ghcr.io/epics-containers/ioc-adaravis-linux-runtime:23.9.4

0 comments on commit a1cc6e5

Please sign in to comment.