fix drun & improve env rekognition

This commit is contained in:
Michael Jerger 2023-08-16 16:10:56 +02:00
parent ec0844d53b
commit 17ae55f3c0
4 changed files with 13 additions and 6 deletions

View file

@ -33,7 +33,7 @@ default_task = "dev"
name = "ddadevops" name = "ddadevops"
MODULE = "not-used" MODULE = "not-used"
PROJECT_ROOT_PATH = "." 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" summary = "tools to support builds combining gopass, terraform, dda-pallet, aws & hetzner-cloud"
description = __doc__ description = __doc__
authors = [Author("meissa GmbH", "buero@meissa-gmbh.de")] authors = [Author("meissa GmbH", "buero@meissa-gmbh.de")]

View file

@ -112,9 +112,8 @@ class InitService:
result = {} result = {}
for name in credentials.mappings.keys(): for name in credentials.mappings.keys():
mapping = credentials.mappings[name] mapping = credentials.mappings[name]
env_value = self.environment_api.get(mapping.name_for_environment()) if self.environment_api.is_defined(mapping.name_for_environment()):
if env_value: result[name] = self.environment_api.get(mapping.name_for_environment())
result[name] = env_value
else: else:
if mapping.gopass_type() == GopassType.FIELD: if mapping.gopass_type() == GopassType.FIELD:
result[name] = self.credentials_api.gopass_field_from_path( result[name] = self.credentials_api.gopass_field_from_path(

View file

@ -58,8 +58,10 @@ class ImageApi:
) )
def drun(self, name: str): def drun(self, name: str):
self.execution_api.execute_live( run(
f'docker run -it --entrypoint="" {name} /bin/bash' f'docker run -it --entrypoint="" {name} /bin/bash',
shell=True,
check=True,
) )
def dockerhub_login(self, username: str, password: str): def dockerhub_login(self, username: str, password: str):
@ -134,6 +136,9 @@ class EnvironmentApi:
def get(self, key): def get(self, key):
return environ.get(key) return environ.get(key)
def is_defined(self, key):
return key in environ
class CredentialsApi: class CredentialsApi:
def __init__(self): def __init__(self):

View file

@ -104,6 +104,9 @@ class EnvironmentApiMock:
def get(self, key): def get(self, key):
return self.mappings.get(key, None) return self.mappings.get(key, None)
def is_defined(self, key):
return key in self.mappings
class CredentialsApiMock: class CredentialsApiMock:
def __init__(self, mappings): def __init__(self, mappings):