From 6ab69a884ecddd423cd083225730644336e6446a Mon Sep 17 00:00:00 2001 From: Maurice Faber Date: Sat, 17 Feb 2024 13:29:23 +0100 Subject: [PATCH] fix: tpl env --- bin/start-api.sh | 3 +++ lib/upstream_test.py | 6 +++--- tpl/docker-compose.yml.j2 | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/bin/start-api.sh b/bin/start-api.sh index 364c35f..57d937f 100755 --- a/bin/start-api.sh +++ b/bin/start-api.sh @@ -1,3 +1,6 @@ #!/usr/bin/env sh +. .venv/bin/activate + +kill $(fuser 8888/tcp 2>/dev/null | awk '{ print $1 }') PYTHONPATH=. python api/main.py main:app & diff --git a/lib/upstream_test.py b/lib/upstream_test.py index a2647ad..d8ec106 100644 --- a/lib/upstream_test.py +++ b/lib/upstream_test.py @@ -4,7 +4,7 @@ from unittest import TestCase, mock from unittest.mock import Mock, call -from lib.models import Project +from lib.models import Env, Project sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))) @@ -73,10 +73,10 @@ def test_write_upstream( image="morriz/hello-world:main", name="master", port=8080, - env={"TARGET": "cost concerned people", "INFORMANT": "http://test-informant:8080"}, + env=Env(**{"TARGET": "cost concerned people", "INFORMANT": "http://test-informant:8080"}), volumes=["./data/bla:/data/bla", "./etc/dida:/etc/dida"], ), - Service(image="morriz/hello-world:main", name="informant", port=8080, env={"TARGET": "boss"}), + Service(image="morriz/hello-world:main", name="informant", port=8080, env=Env(**{"TARGET": "boss"})), ] # Call the function under test diff --git a/tpl/docker-compose.yml.j2 b/tpl/docker-compose.yml.j2 index 4138e85..6cee735 100755 --- a/tpl/docker-compose.yml.j2 +++ b/tpl/docker-compose.yml.j2 @@ -19,7 +19,7 @@ services: restart: unless-stopped {% if s.env -%} environment: - {% for k, v in s.env.items() -%} + {% for k, v in s.env -%} {{ k }}: {{ v }} {% endfor -%} {% endif %}