Skip to content
Snippets Groups Projects
Commit 6347c8ac authored by garciadeblas's avatar garciadeblas
Browse files

Support KSUs based on kubernetes manifests and env var substitution


Change-Id: I03be2333fee7e4d0973130db504d8f3687763c51
Signed-off-by: default avatargarciadeblas <gerardo.garciadeblas@telefonica.com>
parent 9f7c9c56
No related branches found
No related tags found
No related merge requests found
......@@ -64,15 +64,22 @@ async def create_ksus(self, op_id, op_params_list, content_list):
profile_name = ksu_params.get("profile", {}).get("name")
age_public_key = ksu_params.get("profile", {}).get("age_pubkey")
target_ns = oka_params.get("namespace", "default")
substitute_environment = oka_params.get("substitute_environment", "false")
substitution_filter = oka_params.get("substitution_filter", "")
custom_env_vars = oka_params.get("custom_env_vars", "")
if custom_env_vars:
custom_env_vars = "|\n" + "\n".join(
[" " * 10 + f"{k}={v}" for k, v in custom_env_vars.items()]
)
else:
custom_env_vars = '""'
substitute_environment = oka_params.get("substitute_environment", "true").lower()
custom_env_vars = oka_params.get("custom_env_vars", {})
if "APPNAME" not in custom_env_vars:
custom_env_vars["APPNAME"] = ksu_name
if "TARGET_NS" not in custom_env_vars:
custom_env_vars["TARGET_NS"] = target_ns
custom_env_vars_str = "|\n"
substitution_filter_list = []
for k, v in custom_env_vars.items():
custom_env_vars_str += " " * 10 + f"{k}={v}\n"
substitution_filter_list.append(f"${k}")
substitution_filter = ",".join(substitution_filter_list)
# TODO: add additional substitution filters
# substitution_filter = (
# f"{substitution_filter},{oka_params.get('substitution_filter', '')}".strip(",")
# )
inline_values = oka_params.get("inline_values", "")
if inline_values:
yaml_string = yaml.safe_dump(
......@@ -133,7 +140,7 @@ async def create_ksus(self, op_id, op_params_list, content_list):
templates_path=oka_path,
substitute_environment=substitute_environment,
substitution_filter=substitution_filter,
custom_env_vars=custom_env_vars,
custom_env_vars=custom_env_vars_str,
kustomization_name=kustomization_name,
helmrelease_name=helmrelease_name,
inline_values=inline_values,
......@@ -205,15 +212,22 @@ async def update_ksus(self, op_id, op_params_list, content_list):
profile_name = ksu_params.get("profile", {}).get("name")
age_public_key = ksu_params.get("profile", {}).get("age_pubkey")
target_ns = oka_params.get("namespace", "default")
substitute_environment = oka_params.get("substitute_environment", "false")
substitution_filter = oka_params.get("substitution_filter", "")
custom_env_vars = oka_params.get("custom_env_vars", "")
if custom_env_vars:
custom_env_vars = "|\n" + "\n".join(
[" " * 10 + f"{k}={v}" for k, v in custom_env_vars.items()]
)
else:
custom_env_vars = '""'
substitute_environment = oka_params.get("substitute_environment", "true").lower()
custom_env_vars = oka_params.get("custom_env_vars", {})
if "APPNAME" not in custom_env_vars:
custom_env_vars["APPNAME"] = ksu_name
if "TARGET_NS" not in custom_env_vars:
custom_env_vars["TARGET_NS"] = target_ns
custom_env_vars_str = "|\n"
substitution_filter_list = []
for k, v in custom_env_vars.items():
custom_env_vars_str += " " * 10 + f"{k}={v}\n"
substitution_filter_list.append(f"${k}")
substitution_filter = ",".join(substitution_filter_list)
# TODO: add additional substitution filters
# substitution_filter = (
# f"{substitution_filter},{oka_params.get('substitution_filter', '')}".strip(",")
# )
inline_values = oka_params.get("inline_values", "")
if inline_values:
yaml_string = yaml.safe_dump(
......@@ -273,7 +287,7 @@ async def update_ksus(self, op_id, op_params_list, content_list):
templates_path=oka_path,
substitute_environment=substitute_environment,
substitution_filter=substitution_filter,
custom_env_vars=custom_env_vars,
custom_env_vars=custom_env_vars_str,
kustomization_name=kustomization_name,
helmrelease_name=helmrelease_name,
inline_values=inline_values,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment