From 865866de6c0be838d3d33e850d40caecea7d93a0 Mon Sep 17 00:00:00 2001 From: Marc Boorshtein Date: Fri, 11 Oct 2024 00:49:01 +0000 Subject: [PATCH] for #78 #79 refactored to line up with the refactor --- pulumi/__main__.py | 39 ++++++++++++++++----------------- pulumi/src/kv_manager/deploy.py | 2 +- pulumi/src/openunison/deploy.py | 13 ++++------- 3 files changed, 24 insertions(+), 30 deletions(-) diff --git a/pulumi/__main__.py b/pulumi/__main__.py index 9a927c4..2d0d796 100644 --- a/pulumi/__main__.py +++ b/pulumi/__main__.py @@ -85,6 +85,9 @@ def get_module_config(module_name): depends = [] +# defining a separate depends list for openunison to avoid circular dependencies +openunison_depends = [] + def safe_append(depends, resource): if resource: depends.append(resource) @@ -176,7 +179,7 @@ def run_kubevirt(): versions["kubevirt"] = {"enabled": kubevirt_enabled, "version": kubevirt[0]} kubevirt_operator = kubevirt[1] - safe_append(depends, kubevirt_operator) + safe_append(openunison_depends, kubevirt_operator) return kubevirt, kubevirt_operator return None, None @@ -354,10 +357,10 @@ def run_kubernetes_dashboard(): openunison_enabled ) - versions["kubernetes_dashboard"] = {"enabled": kubernetes_dashboard_enabled, "version": kubernetes_dashboard[0]} + versions["kubernetes_dashboard"] = {"enabled": kubernetes_dashboard_enabled, "version": kubernetes_dashboard[0], "release":kubernetes_dashboard[1]} kubernetes_dashboard_release = kubernetes_dashboard[1] - safe_append(depends, kubernetes_dashboard_release) + safe_append(openunison_depends, kubernetes_dashboard_release) return kubernetes_dashboard, kubernetes_dashboard_release return None, None @@ -374,10 +377,17 @@ def run_kubevirt_manager(): k8s_provider, ) - return kubevirt_manager - return None + versions["kubevirt_manager"] = {"enabled": kubevirt_manager_enabled, "version": kubevirt_manager[0]} + kubevirt_manager_release = kubevirt_manager[1] + + safe_append(openunison_depends, kubevirt_manager_release) -kubevirt_manager = run_kubevirt_manager() + return kubevirt_manager, kubevirt_manager_release + + + return None, None + +kubevirt_manager, kubevirt_manager_release = run_kubevirt_manager() ################################################################################## def run_openunison(): @@ -403,18 +413,10 @@ def run_openunison(): safe_append(custom_depends,nginx_release) - safe_append(custom_depends,kubernetes_dashboard_release) - if (kubevirt_manager): - safe_append(custom_depends,kubevirt_manager); - - - # if kubevirt_enabled: - # enabled["kubevirt"] = {"enabled": kubevirt_enabled} - # if prometheus_enabled: - # enabled["prometheus"] = {"enabled": prometheus_enabled} + custom_depends.extend(depends) + custom_depends.extend(openunison_depends) - pulumi.export("enabled", enabled) openunison = deploy_openunison( custom_depends, @@ -424,13 +426,10 @@ def run_openunison(): domain_suffix, cluster_issuer, cert_manager_selfsigned_cert, - kubernetes_dashboard_release, - nginx_release, openunison_github_client_id, openunison_github_client_secret, openunison_github_teams, - enabled, - kubevirt_manager != None + versions ) versions["openunison"] = {"enabled": openunison_enabled, "version": openunison[0]} diff --git a/pulumi/src/kv_manager/deploy.py b/pulumi/src/kv_manager/deploy.py index 11c6b01..df6d381 100644 --- a/pulumi/src/kv_manager/deploy.py +++ b/pulumi/src/kv_manager/deploy.py @@ -16,4 +16,4 @@ def deploy_ui_for_kubevirt(name: str, k8s_provider: Provider): # There's no helm chart for kubevirt-manager so kubevirt_manager_manifest_url = 'https://raw.githubusercontent.com/kubevirt-manager/kubevirt-manager/main/kubernetes/bundled.yaml' k8s_yaml = k8s.yaml.ConfigFile("kubevirt-manager", file=kubevirt_manager_manifest_url) - return k8s_yaml + return "1.4.1", k8s_yaml diff --git a/pulumi/src/openunison/deploy.py b/pulumi/src/openunison/deploy.py index 7f7c2f0..a247649 100644 --- a/pulumi/src/openunison/deploy.py +++ b/pulumi/src/openunison/deploy.py @@ -23,15 +23,12 @@ def deploy_openunison( domain_suffix: str, cluster_issuer: str, cert_manager_selfsigned_cert: str, - kubernetes_dashboard_release: str, - nginx_release: str, ou_github_client_id: str, ou_github_client_secret: str, ou_github_teams: str, - enabled : bool, - kubevirt_manager_enabled: bool + enabled ): - + kubernetes_dashboard_release = enabled["kubernetes_dashboard"]["release"] ns_retain = True ns_protect = False ns_annotations = {} @@ -240,10 +237,7 @@ def deploy_openunison( # if enabled["kubevirt"] and enabled["kubevirt"]["enabled"]: - if kubevirt_manager_enabled: - - - + if "kubevirt_manager" in enabled and enabled["kubevirt_manager"]["enabled"]: ou_helm_values["openunison"]["apps"].append( { "name": "kubevirt-manager", @@ -308,6 +302,7 @@ def deploy_openunison( def wait_for_dashboard_release_names(): return ou_helm_values + orchesrta_login_portal_helm_values = kubernetes_dashboard_release.name.apply(lambda _: wait_for_dashboard_release_names()) # Fetch the latest version from the helm chart index