Commit a7c4c9b1 authored by Tulio Ruiz's avatar Tulio Ruiz
Browse files

[IMP] main app not required and all modules installed if not provided

[FIX] Exclude install variable

[FIX] Remove blank lines
parent 397b97cd
Pipeline #56104 passed with stage
in 21 seconds
......@@ -7,6 +7,7 @@ from sys import exit
CHECK = u'\033[92mV\033[0m '
CROSS = u'\033[91mX\033[0m '
CIRCLE = u'\033[1;33;40mO\033[0m '
def read_varsfile():
......@@ -55,7 +56,7 @@ def check_varsfile():
def check_required_envars():
fail = False
for v in required:
if v in environ.keys():
......@@ -92,7 +93,10 @@ def check_envars():
def check_mainapp():
fValues = get_file_values()
main_app = fValues['MAIN_APP']
main_app = fValues.get('MAIN_APP', False)
if not main_app:
print(CIRCLE + 'No main app defined, all modules will be installed')
apps = main_app.split(',')
fail = False
for app in apps:
# coding: utf-8
from deployv_addon_gitlab_tools.get_addons import get_module_list
from deployv.helpers import utils
import distutils.spawn
from docker import errors, APIClient as Client
......@@ -31,7 +32,7 @@ def pull_images(images):
def check_env_vars(*args, **kwargs):
missing = []
not_required = ['psql_image', 'push_image']
not_required = ['psql_image', 'push_image', 'install']
for key in args:
if key not in not_required and not (key.upper() in environ and environ[key.upper()]):
......@@ -48,10 +49,7 @@ def check_env_vars(*args, **kwargs):
def get_main_app(config):
if config.get('install', False):
_logger.warning('Deprecation warning: you should not use INSTALL env var, replace it with MAIN_APP instead')
return config.get('install')
return config.get('main_app', False)
return config.get('main_app', get_module_list())
def generate_image_name(name):
......@@ -178,7 +176,7 @@ def get_config(**kwargs):
postgres_image = 'vauxoo/docker-postgresql:{0}-ci'.format(res.get('psql_version', '9.6'))
res.update({'postgres_image': postgres_image})
customer = res.get('customer', res.get('ci_project_name', res.get('main_app'))).strip()
customer = res.get('customer', res.get('ci_project_name')).strip()
version_tag = res.get('version').replace('.', '')
customer_img = '{customer}{ver}'.format(customer=customer,
......@@ -203,6 +201,10 @@ def get_config(**kwargs):
res.update({'docker_repo': res.get('docker_repo', '')})
res.update({'image_repo_url': res.get('image_repo_url', '')})
res.update({'postgres_container': 'postgres{0}_{1}_{2}'.format(res['base_name'], res['ci_pipeline_id'], rand_str)})
'main_app': get_main_app(res)
return res
#!/usr/bin/env python
Usage: get-addons [-m] path1 [path2 ...]
Given a list of paths, finds and returns a list of valid addons paths.
With -m flag, will return a list of modules names instead.
from __future__ import print_function
import ast
import os
from itertools import ifilter, imap
except ImportError:
ifilter = filter
imap = map
def is_module(path):
"""return False if the path doesn't contain an odoo module, and the full
path to the module manifest otherwise"""
if not os.path.isdir(path):
return False
files = os.listdir(path)
filtered = [x for x in files if x in (MANIFEST_FILES + [''])]
if len(filtered) == 2 and '' in filtered:
return os.path.join(
path, next(x for x in filtered if x != ''))
return False
def find_module(module, paths):
'''Find module in paths
:param module: String with name of module to find in paths.
:param paths: List of strings with paths to search.
:return: String with full path of manifest file found'''
for path in paths:
module_path = is_module(os.path.join(path, module))
if module_path:
return module_path
def is_installable_module(path):
"""return False if the path doesn't contain an installable odoo module,
and the full path to the module manifest otherwise"""
manifest_path = is_module(path)
if manifest_path:
manifest = ast.literal_eval(open(manifest_path).read())
if manifest.get('installable', True):
return manifest_path
return False
def get_modules(path):
# Avoid empty basename when path ends with slash
if not os.path.basename(path):
path = os.path.dirname(path)
res = []
if os.path.isdir(path):
res = [x for x in os.listdir(path)
if is_installable_module(os.path.join(path, x))]
return res
def is_addons(path):
res = get_modules(path) != []
return res
def get_addons(path):
if is_addons(path):
res = [path]
res = [os.path.join(path, x)
for x in os.listdir(path)
if is_addons(os.path.join(path, x))]
return res
def get_depends(addons_path_list, modules_list):
"""Get recursive depends from addons_paths and modules list
:param modules_list: List of strings with name of modules
:param addons_path_list: List of strings with path of modules
:return set: Unsorted set of recursive dependencies of modules
modules = set(modules_list)
addons_paths = set(addons_path_list)
visited = set()
while modules != visited:
module = (modules - visited).pop()
manifest_path = find_module(module, addons_path_list)
assert manifest_path, "Module not found %s in addons_paths %s" % (
module, addons_path_list)
manifest_filename = next(ifilter(
imap(lambda p: os.path.join(p, manifest_path), addons_paths)
except StopIteration:
# For some reason the module wasn't found
manifest = eval(open(manifest_filename).read())
modules.update(manifest.get('depends', []))
return modules
def get_module_list():
exclude_modules = [x.strip() for x in os.environ.get('EXCLUDE', '').split(',')]
lists = get_modules('.')
if exclude_modules:
lists = [x for x in lists if x not in exclude_modules]
return ','.join(lists)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment