Commit f95bd626 authored by sangeetha's avatar sangeetha

content push changes

parent 62834a9d
DB_URI=sqlite:///./ilens_versions.db
#DB_URI=mysql://svc-devops:Ut#devops$sql546@192.168.0.220:3306/
CONFIG_MAP_VARIABLES=MONGO_URI
# HELM_REPO = https://gitlab-pm.knowledgelens.com/KnowledgeLens/Products/iLens-2.0/core/devops/helm-charts
HELM_REPO = https://gitlab-pm.knowledgelens.com/Harshavardhan.C/helm-charts
#HELM_REPO = https://gitlab-pm.knowledgelens.com/KnowledgeLens/Products/iLens-2.0/core/devops/helm-charts.git
HELM_REPO = https://gitlab-pm.knowledgelens.com/Harshavardhan.C/helm-charts.git
GIT_USERNAME = harshavardhan.c
GIT_TOKEN = FEMA6PnP63fJCs6DrtZJ
GLOBAL_VARIABLES_FILE=ilens-global-configmap.yml
\ No newline at end of file
......@@ -45,13 +45,15 @@ def push_helm_deployments(repo_link: str, private_token: str, branch: str, final
pl = pl[0]
commit_actions = []
files_list = os.listdir(final_helm_path)
branches = pl.branches.list()
branches = pl.branches.list(get_all=True)
branches_names = [x.name for x in branches]
if branch not in branches_names:
pl.branches.create({'branch': branch, 'ref': 'master' if branch.split("_")[0] not in branches_names else branch.split("_")[0]})
if not files_list:
logging.debug('Files not found for pushing to git.')
for file in files_list:
_action = {
'action': 'create',
'action': 'update',
'file_path': os.path.join(HELM_PATH, file),
'content': open(f'{final_helm_path}/{file}').read()
}
......@@ -188,7 +190,7 @@ if __name__ == '__main__':
helm_out_file_path=helm_out_file_path,
global_config_data=global_config_data,
module_name=f'{_module}-celery')
# push_helm_deployments(helm_repo, git_access_token, _branch, final_helm_path=OUTPUT_PATH, base_path=helm_path)
push_helm_deployments(helm_repo, git_access_token, _branch, final_helm_path=OUTPUT_PATH, base_path=helm_path)
except Exception as e:
logging.exception(f"Exception Occurred while processing the Helm-Script Preparation {e.args}")
......
......@@ -28,12 +28,14 @@ class HelmHandler:
"value"):
global_config_vars["SERVICE_PORT"] = module_env_variables[_each]["value"]
continue
if module_env_variables.get(_each):
existing_data['deployment']['environmentVar'].append(module_env_variables[_each])
existing_data['deployment']['imageName'] = image_tag or existing_data['deployment']['imageName']
self.common_utils.convert_json_to_yaml(json_data=existing_data, output_file_path=template_file)
self.render_helm_chart(data_dict=global_config_vars, helm_template_file=f'{module_name}.yml',
outfile_path=helm_out_file_path, template_path=template_path)
return True
except Exception as e:
logging.exception(f'Exception occurred while preparing the helm deployment file {e.args}')
return False
......@@ -44,7 +46,7 @@ class HelmHandler:
environment = jinja2.Environment(
loader=jinja2.FileSystemLoader(searchpath=template_path),
trim_blocks=True,
variable_start_string='<{', variable_end_string='}>')
variable_start_string='<{', variable_end_string='}>', autoescape=True)
_render = environment.get_template(helm_template_file).render(**data_dict)
with open(outfile_path, "w") as fp:
fp.write(_render)
......
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