1
0
Fork 0
mirror of https://github.com/yavook/kiwi-scp.git synced 2024-11-22 12:53:00 +00:00

use new utils.project routines

This commit is contained in:
Jörn-Michael Miehe 2020-08-17 14:13:42 +02:00
parent d44da6eabd
commit 4ad2b7c458
2 changed files with 14 additions and 17 deletions

View file

@ -5,27 +5,26 @@ import subprocess
# local # local
from .executable import Executable from .executable import Executable
from .project import *
def _update_kwargs(config, args, **kwargs): def _update_kwargs(config, args, **kwargs):
if args is not None and 'projects' in args and args.projects is not None: # project given in args: command affects a project in this instance
# command affects a project in this instance project_name = get_project_name(args)
if project_name is not None:
project_name = args.projects # execute command in project directory
if isinstance(project_name, list) and len(project_name) > 0: kwargs['cwd'] = get_project_dir(config, project_name)
project_name = project_name[0]
project_marker = config['markers:project']
project_dir = f'{project_name}{project_marker}'
kwargs['cwd'] = project_dir
# ensure there is an environment
if 'env' not in kwargs: if 'env' not in kwargs:
kwargs['env'] = {} kwargs['env'] = {}
# create environment variables for docker commands
kwargs['env'].update({ kwargs['env'].update({
'COMPOSE_PROJECT_NAME': project_name, 'COMPOSE_PROJECT_NAME': project_name,
'KIWI_HUB_NAME': config['network:name'],
'CONFDIR': os.path.join(config['runtime:storage'], 'conf'), 'CONFDIR': os.path.join(config['runtime:storage'], 'conf'),
'TARGETDIR': os.path.join(config['runtime:storage'], project_dir) 'TARGETDIR': os.path.join(config['runtime:storage'], get_project_dir(config, project_name))
}) })
logging.debug(f"kwargs updated: {kwargs}") logging.debug(f"kwargs updated: {kwargs}")

View file

@ -6,15 +6,13 @@ import subprocess
def _update_kwargs(config, **kwargs): def _update_kwargs(config, **kwargs):
if config is not None: if config is not None:
if config['runtime:env'] is not None: # ensure there is an environment
kwargs['env'].update(config['runtime:env'])
if 'env' not in kwargs: if 'env' not in kwargs:
kwargs['env'] = {} kwargs['env'] = {}
kwargs['env'].update({ # add common environment from config
'KIWI_HUB_NAME': config['network:name'] if config['runtime:env'] is not None:
}) kwargs['env'].update(config['runtime:env'])
logging.debug(f"kwargs updated: {kwargs}") logging.debug(f"kwargs updated: {kwargs}")