From 957b17ee1b7fbd1b51e18cea429b8d5fb10bd15b Mon Sep 17 00:00:00 2001 From: Atul Bagga Date: Mon, 20 Jan 2020 13:05:42 +0530 Subject: [PATCH] add logging --- .../azext_aks_deploy/dev/aks/arguments.py | 2 +- .../dev/aks/docker_helm_template.py | 57 ++++++++++--------- 2 files changed, 31 insertions(+), 28 deletions(-) diff --git a/deploy-aks/azext_aks_deploy/dev/aks/arguments.py b/deploy-aks/azext_aks_deploy/dev/aks/arguments.py index 0b182a9..318a6ce 100644 --- a/deploy-aks/azext_aks_deploy/dev/aks/arguments.py +++ b/deploy-aks/azext_aks_deploy/dev/aks/arguments.py @@ -6,4 +6,4 @@ def load_aks_arguments(self, _): with self.argument_context('aks up') as context: - context.argument('pat', options_list='--pat') + context.argument('repository', options_list=('--repository', '-r')) diff --git a/deploy-aks/azext_aks_deploy/dev/aks/docker_helm_template.py b/deploy-aks/azext_aks_deploy/dev/aks/docker_helm_template.py index 9edfa8d..87fa1a7 100644 --- a/deploy-aks/azext_aks_deploy/dev/aks/docker_helm_template.py +++ b/deploy-aks/azext_aks_deploy/dev/aks/docker_helm_template.py @@ -19,7 +19,9 @@ FILE_ABSOLUTE_PATH = abspath(dirname(dirname(abspath(__file__)))) def get_docker_templates(language, port): files = [] language_packs_path = get_supported_language_packs_path(language) - if language_packs_path: + if not language_packs_path: + logger.debug('get_docker_templates(): No language packs found.') + else: docker_file_path = r'Dockerfile' file_path = FILE_ABSOLUTE_PATH + language_packs_path + docker_file_path file_content = get_file_content(file_path) @@ -43,32 +45,33 @@ def get_helm_charts(language, acr_details, port): language_packs_path = get_supported_language_packs_path(language) files = [] if not language_packs_path: - return files - try: - abs_pack_path = FILE_ABSOLUTE_PATH + language_packs_path - # r=root, d=directories, f = files - logger.debug("Checking in helm charts") - for r, _d, f in os.walk(abs_pack_path): - if 'charts' not in r: - continue - for file in f: - if '__pycache__' not in r and '__init__.py' not in file: - file_path = os.path.join(r, file) - file_content = get_file_content(file_path) - # replace values in charts - if 'values.yaml' in file_path: - logger.debug("Replacing values in values.yaml") - file_content = replace_values(file_content, acr_details) - file_content = replace_port(file_content, port) - if file_path.startswith(abs_pack_path): - file_path = file_path[len(abs_pack_path):] - file_path = file_path.replace('\\', '/') - file_obj = Files(path=file_path, content=file_content) - logger.debug("Checkin file path: %s", file_path) - logger.debug("Checkin file content: %s", file_content) - files.append(file_obj) - except Exception as ex: - raise CLIError(ex) + logger.debug('get_helm_charts(): No language packs found.') + else: + try: + abs_pack_path = FILE_ABSOLUTE_PATH + language_packs_path + # r=root, d=directories, f = files + logger.debug("Checking in helm charts") + for r, _d, f in os.walk(abs_pack_path): + if 'charts' not in r: + continue + for file in f: + if '__pycache__' not in r and '__init__.py' not in file: + file_path = os.path.join(r, file) + file_content = get_file_content(file_path) + # replace values in charts + if 'values.yaml' in file_path: + logger.debug("Replacing values in values.yaml") + file_content = replace_values(file_content, acr_details) + file_content = replace_port(file_content, port) + if file_path.startswith(abs_pack_path): + file_path = file_path[len(abs_pack_path):] + file_path = file_path.replace('\\', '/') + file_obj = Files(path=file_path, content=file_content) + logger.debug("Checkin file path: %s", file_path) + logger.debug("Checkin file content: %s", file_content) + files.append(file_obj) + except Exception as ex: + raise CLIError(ex) return files