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

Dev: code optimization fixes

parent 29ed9a0f
......@@ -31,34 +31,38 @@ class DockerVersionUpgrade:
general_temp_path = f"{int(time.time())}_tmp"
output_path = f"{int(time.time())}_docker-compose"
try:
_release_version = self.arguments["release_version"]
_client_name = self.arguments['client_name']
_git_repos = self.arguments["git_repos"]
_module_names = self.arguments["module_names"]
_branch_name = self.arguments['branch_name'] or "master"
_ilens_version = self.arguments["ilens_version"]
if not _ilens_version or not _release_version or not _client_name or not global_configmap:
print(
"global_configmap, client_name, ilens_version and release_version details "
"not found!!!!!")
sys.exit()
variables_file = "variables.yml"
if not os.path.exists(docker_temp_path):
os.makedirs(docker_temp_path)
if not os.path.exists(output_path):
os.makedirs(output_path)
docker_compose_path = os.path.join(docker_temp_path, "docker-compose")
_branch = f"{_client_name}_{_ilens_version}.{_release_version}"
if not self.git_handler_obj.clone_repository(repo_link=docker_repo, module_output_path=docker_compose_path,
clone_branch=_client_name):
logging.error(f"Cannot clone docker repo with branch: {_client_name}")
sys.exit()
self.docker_handler.process_compose_data_for_existing_files(destination_branch=_client_name,
source_branch=_branch,
variables_file=variables_file,
arguments=self.arguments,
tmp_path=general_temp_path,
output_path=output_path,
docker_compose_path=docker_compose_path)
self.process_docker_automation(docker_temp_path, output_path, general_temp_path)
except Exception as e:
logging.error(f'Exception occurred while preparing the docker compose {e.args}')
def process_docker_automation(self, docker_temp_path, output_path, general_temp_path):
_release_version = self.arguments["release_version"]
_client_name = self.arguments['client_name']
_git_repos = self.arguments["git_repos"]
_module_names = self.arguments["module_names"]
_branch_name = self.arguments['branch_name'] or "master"
_ilens_version = self.arguments["ilens_version"]
if not _ilens_version or not _release_version or not _client_name or not global_configmap:
print(
"global_configmap, client_name, ilens_version and release_version details "
"not found!!!!!")
sys.exit()
variables_file = "variables.yml"
if not os.path.exists(docker_temp_path):
os.makedirs(docker_temp_path)
if not os.path.exists(output_path):
os.makedirs(output_path)
docker_compose_path = os.path.join(docker_temp_path, "docker-compose")
_branch = f"{_client_name}_{_ilens_version}.{_release_version}"
if not self.git_handler_obj.clone_repository(repo_link=docker_repo, module_output_path=docker_compose_path,
clone_branch=_client_name):
logging.error(f"Cannot clone docker repo with branch: {_client_name}")
sys.exit()
self.docker_handler.process_compose_data_for_existing_files(destination_branch=_client_name,
source_branch=_branch,
variables_file=variables_file,
arguments=self.arguments,
tmp_path=general_temp_path,
output_path=output_path,
docker_compose_path=docker_compose_path)
import json
from scripts.config import EnvironmentVariables
if __name__ == "__main__":
from dotenv import load_dotenv
......@@ -69,6 +71,12 @@ class DockerRegistration:
arguments=self.arguments, compose_info=repo_info,
tmp_path=general_temp_path,
output_path=output_path, modules=_module_names)
# self.git_handler_obj.push_deployments_to_git(repo_link=docker_repo,
# private_token=EnvironmentVariables.git_access_token,
# branch=_branch,
# folder_path=output_path, helm_deployment=False,
# base_path=docker_compose_path)
# self.git_handler_obj.create_merge_request(repo_link=docker_repo, source_branch=_branch,
# destination_branch=_client_name)
except Exception as e:
logging.exception(f"Exception Occurred while generating the docker compose file {e.args}")
This diff is collapsed.
......@@ -33,9 +33,9 @@ class HelmHandler:
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.common_utils.render_helm_chart(data_dict=global_config_vars, jinja_template_file=f'{module_name}.yml',
outfile_path=helm_out_file_path, template_path=template_path,
service_type=service_type)
self.common_utils.render_deployment_chart(data_dict=global_config_vars, jinja_template_file=f'{module_name}.yml',
outfile_path=helm_out_file_path, template_path=template_path,
service_type=service_type)
return True
except Exception as e:
logging.exception(f'Exception occurred while preparing the helm deployment file {e.args}')
......@@ -61,11 +61,11 @@ class HelmHandler:
value_key = v.strip("<{ }>")
global_config_vars.update({k: global_config_vars.get(value_key, v)})
self.common_utils.render_helm_chart(data_dict={}, jinja_template_file=f'{module_name}.yml',
outfile_path=helm_out_file_path, template_path="templates",
service_type=service_type, image_url=image_tag,
variables=global_config_vars,
module_port=module_port, node_port=node_port)
self.common_utils.render_deployment_chart(data_dict={}, jinja_template_file=f'{module_name}.yml',
outfile_path=helm_out_file_path, template_path="templates",
service_type=service_type, image_url=image_tag,
variables=global_config_vars,
module_port=module_port, node_port=node_port)
return True
except Exception as e:
logging.exception(f'Exception occurred while preparing the helm deployment file {e.args}')
......
......@@ -35,7 +35,7 @@ class CommonUtils:
return False
@staticmethod
def render_helm_chart(data_dict, jinja_template_file, template_path, outfile_path, **kwargs):
def render_deployment_chart(data_dict, jinja_template_file, template_path, outfile_path, **kwargs):
try:
environment = jinja2.Environment(
loader=jinja2.FileSystemLoader(searchpath=template_path),
......
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