Commit fe62e06e authored by harshavardhan.c's avatar harshavardhan.c

enh: mysql connection updation.

parent f95bd626
DB_URI=sqlite:///./ilens_versions.db
#DB_URI=mysql://svc-devops:Ut#devops$sql546@192.168.0.220:3306/
#DB_URI=sqlite:///./ilens_versions.db
DB_URI=mysql+pymysql://ut-devops:Utdevopssql546@192.168.0.220:3306/devops_version_db
CONFIG_MAP_VARIABLES=MONGO_URI
#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
......
......@@ -39,7 +39,7 @@ def push_helm_deployments(repo_link: str, private_token: str, branch: str, final
return False
gl = gitlab.Gitlab(url=base_url, private_token=private_token)
search_str = repo_link_split[-1].replace(".git", "")
pl = gl.projects.list(search=search_str.split("/")[-1])
pl = gl.projects.list(search=search_str)
if not pl:
return False
pl = pl[0]
......@@ -48,7 +48,9 @@ def push_helm_deployments(repo_link: str, private_token: str, branch: str, final
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]})
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:
......@@ -173,23 +175,26 @@ if __name__ == '__main__':
input_data=GetRequest(module_name=_module, client='iLens', ilens_version=_ilens_version,
release_version=_release_version), db=session_obj)
session_obj.close()
image_url = ''
image_url = module_info.get("image_url")
existing_yml_path = os.path.join(base_helm_directory_path, f'{_module}.yml')
helm_handler.create_helm_deployment_file(template_yml_path=existing_yml_path, image_tag=image_url,
module_env_variables=module_env_variables,
template_file=template_file, template_path=template_path,
helm_out_file_path=helm_out_file_path,
global_config_data=global_config_data, module_name=_module)
celery_yml_path = os.path.join(base_helm_directory_path, f'{_module}-celery.yml')
if os.path.exists(celery_yml_path):
helm_out_file_path = os.path.join(OUTPUT_PATH, f'{_module}-celery.yml')
template_file = os.path.join(template_path, f'{_module}-celery.yml')
helm_handler.create_helm_deployment_file(template_yml_path=celery_yml_path, image_tag=image_url,
files_info = os.listdir(base_helm_directory_path)
sorted_files = list(filter(lambda f: f.startswith(_module), files_info))
updated_files_info = [x for x in sorted_files if f'{_module}.yml' != x]
for _file in updated_files_info:
sub_file_path = os.path.join(base_helm_directory_path, _file)
helm_out_file_path = os.path.join(OUTPUT_PATH, _file)
template_file = os.path.join(template_path, _file)
helm_handler.create_helm_deployment_file(template_yml_path=sub_file_path, image_tag=image_url,
module_env_variables=module_env_variables,
template_file=template_file, template_path=template_path,
helm_out_file_path=helm_out_file_path,
global_config_data=global_config_data,
module_name=f'{_module}-celery')
module_name=_file.split(".yml")[0])
push_helm_deployments(helm_repo, git_access_token, _branch, final_helm_path=OUTPUT_PATH, base_path=helm_path)
except Exception as e:
......
......@@ -5,4 +5,6 @@ jinja2~=3.1.2
fastapi~=0.73.0
sqlalchemy~=1.3.24
python-gitlab~=3.9.0
ruamel.yaml~=0.17.21
\ No newline at end of file
ruamel.yaml~=0.17.21
PyMySQL==1.0.2
mysqlclient==2.1.1
\ No newline at end of file
......@@ -28,7 +28,8 @@ class ILensVersionMaster(SQLDBUtils):
try:
if data := (db.query(self.table).order_by(desc(self.table.ilens_version), desc(self.table.release_version),
desc(self.table.feature_version),
desc(self.table.patch_version)).filter(
desc(self.table.patch_version),
desc(self.table.updated_at)).filter(
self.table.module_name == input_data.module_name, self.table.client == input_data.client)):
if input_data.ilens_version:
data = data.filter(self.table.ilens_version == input_data.ilens_version)
......
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