1
0
Fork 0
mirror of https://github.com/yavook/kiwi-scp.git synced 2024-12-25 18:42:59 +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
from .executable import Executable
from .project import *
def _update_kwargs(config, args, **kwargs):
if args is not None and 'projects' in args and args.projects is not None:
# command affects a project in this instance
project_name = args.projects
if isinstance(project_name, list) and len(project_name) > 0:
project_name = project_name[0]
project_marker = config['markers:project']
project_dir = f'{project_name}{project_marker}'
kwargs['cwd'] = project_dir
# project given in args: command affects a project in this instance
project_name = get_project_name(args)
if project_name is not None:
# execute command in project directory
kwargs['cwd'] = get_project_dir(config, project_name)
# ensure there is an environment
if 'env' not in kwargs:
kwargs['env'] = {}
# create environment variables for docker commands
kwargs['env'].update({
'COMPOSE_PROJECT_NAME': project_name,
'KIWI_HUB_NAME': config['network:name'],
'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}")

View file

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