import yaml
+MAP_PROFILE = {
+ "infra_controller_profiles": "infra-controllers",
+ "infra_config_profiles": "infra-controllers",
+ "resource_profiles": "managed_resources",
+ "app_profiles": "apps",
+}
+
+
async def create_ksus(self, op_id, op_params_list, content_list):
self.logger.info("Create KSU workflow Enter")
self.logger.info(
raise Exception(
"There is no ODU workflow yet able to manage multiple OKAs for a KSU"
)
- oka_path = oka_list[0]["sw_catalog_path"]
+ oka_item = oka_list[0]
+ if "sw_catalog_path" in oka_item:
+ oka_path = oka_item["sw_catalog_path"]
+ else:
+ oka_type = "infra-controllers"
+ oka_name = oka_item["git_name"]
+ oka_path = f"{oka_type}/{oka_name}/templates"
workflow_template = "launcher-create-ksu-hr.j2"
workflow_name = f"create-ksus-{op_id}"
osm_project_name = "osm_admin" # TODO: get project name from db_ksu
kustomization_name = ksu_name
helmrelease_name = ksu_name
- target_ns = ksu_params.get("namespace")
+ target_ns = ksu_params.get("namespace", "default")
profile_type = ksu_params.get("profile", {}).get("profile_type")
+ profile_type = MAP_PROFILE[profile_type]
profile_name = ksu_params.get("profile", {}).get("name")
age_public_key = ksu_params.get("profile", {}).get("age_pubkey")
substitute_environment = ksu_params.get("substitute_environment", "false")
custom_env_vars = ksu_params.get("custom_env_vars", "")
if custom_env_vars:
custom_env_vars = "|\n" + "\n".join(
- [" " * 12 + f"{k}={v}" for k, v in custom_env_vars.items()]
+ [" " * 10 + f"{k}={v}" for k, v in custom_env_vars.items()]
)
+ else:
+ custom_env_vars = '""'
inline_values = ksu_params.get("inline_values", "")
if inline_values:
yaml_string = yaml.safe_dump(
inline_values = "|\n" + "\n".join(
[" " * 8 + line for line in yaml_string.splitlines()]
)
+ else:
+ inline_values = '""'
is_preexisting_cm = "false"
- values_configmap_name = f"cm-{ksu_name}"
cm_values = ksu_params.get("configmap_values", "")
if cm_values:
yaml_string = yaml.safe_dump(
cm_values, sort_keys=False, default_flow_style=False
)
- custom_env_vars = "|\n" + "\n".join(
+ cm_values = "|\n" + "\n".join(
[" " * 8 + line for line in yaml_string.splitlines()]
)
+ values_configmap_name = f"cm-{ksu_name}"
+ cm_key = "values.yaml"
+ else:
+ values_configmap_name = ""
+ cm_key = ""
+ cm_values = '""'
is_preexisting_secret = "false"
secret_values = ksu_params.get("secret_values", "")
if secret_values:
)
else:
values_secret_name = ""
- reference_secret_for_values = ""
- reference_key_for_values = ""
+ reference_secret_for_values = "this-secret-does-not-exist"
+ reference_key_for_values = "this-key-does-not-exist"
sync = "true"
if secret_values:
reference_key_for_values=reference_key_for_values,
is_preexisting_cm=is_preexisting_cm,
values_configmap_name=values_configmap_name,
+ cm_key=cm_key,
cm_values=cm_values,
ksu_name=ksu_name,
profile_name=profile_name,
osm_project_name = "osm_admin" # TODO: get project name from db_ksu
kustomization_name = ksu_name
helmrelease_name = ksu_name
- target_ns = ksu_params.get("namespace")
+ target_ns = ksu_params.get("namespace", "default")
profile_type = ksu_params.get("profile", {}).get("profile_type")
+ profile_type = MAP_PROFILE[profile_type]
profile_name = ksu_params.get("profile", {}).get("name")
age_public_key = ksu_params.get("profile", {}).get("age_pubkey")
substitute_environment = ksu_params.get("substitute_environment", "false")
custom_env_vars = ksu_params.get("custom_env_vars", "")
if custom_env_vars:
custom_env_vars = "|\n" + "\n".join(
- [" " * 12 + f"{k}={v}" for k, v in custom_env_vars.items()]
+ [" " * 10 + f"{k}={v}" for k, v in custom_env_vars.items()]
)
+ else:
+ custom_env_vars = '""'
inline_values = ksu_params.get("inline_values", "")
if inline_values:
yaml_string = yaml.safe_dump(
inline_values = "|\n" + "\n".join(
[" " * 8 + line for line in yaml_string.splitlines()]
)
+ else:
+ inline_values = '""'
is_preexisting_cm = "false"
- values_configmap_name = f"cm-{ksu_name}"
cm_values = ksu_params.get("configmap_values", "")
if cm_values:
yaml_string = yaml.safe_dump(
cm_values, sort_keys=False, default_flow_style=False
)
- custom_env_vars = "|\n" + "\n".join(
+ cm_values = "|\n" + "\n".join(
[" " * 8 + line for line in yaml_string.splitlines()]
)
+ values_configmap_name = f"cm-{ksu_name}"
+ cm_key = "values.yaml"
+ else:
+ values_configmap_name = ""
+ cm_key = ""
+ cm_values = '""'
is_preexisting_secret = "false"
secret_values = ksu_params.get("secret_values", "")
if secret_values:
)
else:
values_secret_name = ""
- reference_secret_for_values = ""
- reference_key_for_values = ""
+ reference_secret_for_values = "this-secret-does-not-exist"
+ reference_key_for_values = "this-key-does-not-exist"
if secret_values:
secret_namespace = "osm-workflows"
reference_key_for_values=reference_key_for_values,
is_preexisting_cm=is_preexisting_cm,
values_configmap_name=values_configmap_name,
+ cm_key=cm_key,
cm_values=cm_values,
ksu_name=ksu_name,
profile_name=profile_name,
osm_project_name = "osm_admin" # TODO: get project name from db_ksu
profile_name = ksu_params.get("profile", {}).get("name")
profile_type = ksu_params.get("profile", {}).get("profile_type")
+ profile_type = MAP_PROFILE[profile_type]
# Render workflow
manifest = self.render_jinja_template(