Skip to content

Commit

Permalink
Using default value of docker network if not set otherwise, fixes #17452
Browse files Browse the repository at this point in the history
Running the config command from run-tests will trigger  fastapi/typer#106 and we only have an object but not the default string.

Also using correct path to determine if new config needs to be generated before running unit tests.
  • Loading branch information
tilman19 committed Jan 2, 2023
1 parent f8d540c commit 30611f7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/fastiot/cli/commands/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ def config(deployments: Optional[List[str]] = typer.Argument(default=None,
if key in infrastructure_ports:
infrastructure_ports[key] = int(value)

if not isinstance(net, str): # Workaround for https://github.com/tiangolo/typer/issues/106
net = net.default

for deployment_name in deployment_names:
deployment_dir = context.deployment_build_dir(name=deployment_name)
shutil.rmtree(deployment_dir, ignore_errors=True)
Expand Down Expand Up @@ -140,7 +143,7 @@ def config(deployments: Optional[List[str]] = typer.Argument(default=None,
with open(os.path.join(deployment_dir, 'docker-compose.yaml'), "w") as docker_compose_file:
docker_compose_template = get_jinja_env().get_template('docker-compose.yaml.j2')
docker_compose_file.write(docker_compose_template.render(
docker_net_name=str(net),
docker_net_name=net,
environment_for_docker_compose_file=env_service_internal_modifications,
services=services + infrastructure_services,
env_file=env or env_additions
Expand Down
7 changes: 4 additions & 3 deletions src/fastiot/cli/commands/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

from fastiot.cli.commands.start import start
from fastiot.cli.commands.stop import stop
from fastiot.cli.constants import DEPLOYMENTS_CONFIG_DIR
from fastiot.cli.model.project import ProjectContext
from fastiot.cli.typer_app import DEFAULT_CONTEXT_SETTINGS, app

Expand Down Expand Up @@ -49,11 +50,11 @@ def run_tests(start_deployment: bool = typer.Option(False, help="Also start and
"Skipping the step")
return

if not os.path.isfile(os.path.join(context.project_root_dir, 'src', context.test_package,
'generated.py')):
if not os.path.isfile(os.path.join(context.project_root_dir, 'build', DEPLOYMENTS_CONFIG_DIR,
context.integration_test_deployment, '.env')):
from fastiot.cli.commands.config import config # pylint: disable=import-outside-toplevel

logging.warning("No file `generated.py` found in testpackage %s.\n"
logging.warning("No generated configuration could found in build/%s.\n"
"\tRunning config command to create one now.", context.test_package)
config(use_test_deployment=True, port_offset=0)

Expand Down
1 change: 0 additions & 1 deletion src/fastiot/cli/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
DEPLOYMENTS_CONFIG_DIR = 'deployments'
DEPLOYMENTS_CONFIG_FILE = 'deployment.yaml'
MANIFEST_FILENAME = 'manifest.yaml'
GENERATED_FILENAME = 'generated.py'
DOCKER_BUILD_DIR = 'docker'
IMPORT_NAME_CONFIGURE_PY = 'fastiot_configure'
BUILDER_NAME = 'fastiot_builder'
Expand Down

0 comments on commit 30611f7

Please sign in to comment.