From 17ae55f3c072ed8bcf5cb3e6afdfa21f991b84b6 Mon Sep 17 00:00:00 2001 From: Michael Jerger Date: Wed, 16 Aug 2023 16:10:56 +0200 Subject: [PATCH] fix drun & improve env rekognition --- build.py | 2 +- src/main/python/ddadevops/domain/init_service.py | 5 ++--- .../python/ddadevops/infrastructure/infrastructure.py | 9 +++++++-- src/test/python/domain/helper.py | 3 +++ 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/build.py b/build.py index f6db68d..f32588d 100644 --- a/build.py +++ b/build.py @@ -33,7 +33,7 @@ default_task = "dev" name = "ddadevops" MODULE = "not-used" PROJECT_ROOT_PATH = "." -version = "4.3.2-dev2" +version = "4.3.2-dev6" summary = "tools to support builds combining gopass, terraform, dda-pallet, aws & hetzner-cloud" description = __doc__ authors = [Author("meissa GmbH", "buero@meissa-gmbh.de")] diff --git a/src/main/python/ddadevops/domain/init_service.py b/src/main/python/ddadevops/domain/init_service.py index 1afa1f3..8529665 100644 --- a/src/main/python/ddadevops/domain/init_service.py +++ b/src/main/python/ddadevops/domain/init_service.py @@ -112,9 +112,8 @@ class InitService: result = {} for name in credentials.mappings.keys(): mapping = credentials.mappings[name] - env_value = self.environment_api.get(mapping.name_for_environment()) - if env_value: - result[name] = env_value + if self.environment_api.is_defined(mapping.name_for_environment()): + result[name] = self.environment_api.get(mapping.name_for_environment()) else: if mapping.gopass_type() == GopassType.FIELD: result[name] = self.credentials_api.gopass_field_from_path( diff --git a/src/main/python/ddadevops/infrastructure/infrastructure.py b/src/main/python/ddadevops/infrastructure/infrastructure.py index fda7c90..847bc57 100644 --- a/src/main/python/ddadevops/infrastructure/infrastructure.py +++ b/src/main/python/ddadevops/infrastructure/infrastructure.py @@ -58,8 +58,10 @@ class ImageApi: ) def drun(self, name: str): - self.execution_api.execute_live( - f'docker run -it --entrypoint="" {name} /bin/bash' + run( + f'docker run -it --entrypoint="" {name} /bin/bash', + shell=True, + check=True, ) def dockerhub_login(self, username: str, password: str): @@ -134,6 +136,9 @@ class EnvironmentApi: def get(self, key): return environ.get(key) + def is_defined(self, key): + return key in environ + class CredentialsApi: def __init__(self): diff --git a/src/test/python/domain/helper.py b/src/test/python/domain/helper.py index 7855dc3..7c6df4c 100644 --- a/src/test/python/domain/helper.py +++ b/src/test/python/domain/helper.py @@ -104,6 +104,9 @@ class EnvironmentApiMock: def get(self, key): return self.mappings.get(key, None) + def is_defined(self, key): + return key in self.mappings + class CredentialsApiMock: def __init__(self, mappings):