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

fix: code fixes while registering new helm_template.

parent afc35f18
......@@ -25,12 +25,10 @@ class HelmHandler:
existing_env_variables = {_v['name']: _v for _v in
existing_data.get('deployment', {}).get('environmentVar', [])}
diff_keys = list(set(existing_env_variables.keys()).symmetric_difference(set(module_env_variables.keys())))
module_port = ''
for _each in diff_keys:
if _each.lower() in {'port', 'service_port', 'module_port', 'node_port'} and module_env_variables.get(
_each) and \
if _each.lower() in {'port', 'service_port', 'module_port'} and module_env_variables.get(_each) and \
module_env_variables[_each].get("value"):
module_port = module_env_variables[_each]["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])
......@@ -39,7 +37,7 @@ class HelmHandler:
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,
service_type=service_type, module_port=module_port)
service_type=service_type)
return True
except Exception as e:
logging.exception(f'Exception occurred while preparing the helm deployment file {e.args}')
......@@ -66,12 +64,13 @@ class HelmHandler:
logging.debug(f"{template_yml_path} not found!! Skipping Helm File Preparation")
return False
global_config_vars = global_config_data.get('data', {})
module_port = node_port = ''
for k, v in module_env_variables.items():
if k.lower() in {'port', 'service_port', 'module_port'} and v:
if 'module_port' not in global_config_vars:
global_config_vars["module_port"] = v
module_port = v
if 'node_port' not in global_config_vars:
global_config_vars["node_port"] = v
node_port = v
continue
if global_config_vars.get(k):
continue
......@@ -80,7 +79,8 @@ class HelmHandler:
self.render_helm_chart(data_dict={}, helm_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)
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}')
......
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