Add skips so we conclude properly and streamline the helm-value assocs

This commit is contained in:
2025-09-26 00:36:28 -05:00
parent 574202eb3c
commit 42bc1ec316

View File

@@ -5,8 +5,22 @@
["@pulumi/vault" :as vault]
["fs" :as fs]
["js-yaml" :as yaml]
["path" :as path]
[clojure.core.async :refer [go]]))
["path" :as path]))
(defn- add-skip-await-transformation
"A Pulumi transformation that adds the skipAwait annotation to problematic resources."
[args _opts]
(let [kind (get-in args [:kind])]
(if (or (= kind "StatefulSet")
(= kind "PersistentVolumeClaim")
(= kind "Ingress"))
(let [
metadata (get-in args [:metadata] {})
annotations (get metadata :annotations {})
new-annotations (assoc annotations "pulumi.com/skipAwait" "true")
new-metadata (assoc metadata :annotations new-annotations)]
(assoc args :metadata new-metadata))
args)))
(defn- get-secret-val
"Extract a specific key from a Vault secret Output/Promise."
@@ -17,14 +31,14 @@
"Deploy Nextcloud using direct vault connection info."
[provider vault-provider]
(let [core-v1 (.. k8s -core -v1)
helm-v3 (.. k8s -helm -v3)
helm-v3 (.. k8s -helm -v3)
nextcloud-secrets (.getSecret (.-generic vault)
(clj->js {:path "secret/nextcloud"})
(clj->js {:provider vault-provider}))
ns (new (.. core-v1 -Namespace)
"nextcloud-ns"
(clj->js {:metadata {:name "nextcloud"}})
(clj->js {:metadata {:name "my-nextcloud"}})
(clj->js {:provider provider}))
admin-secret (new (.. core-v1 -Secret)
@@ -43,21 +57,27 @@
(clj->js {:provider provider}))
values-path (.join path js/__dirname ".." "resources" "nextcloud.yml")
helm-values (-> values-path
helm-values (js->clj (-> values-path
(fs/readFileSync "utf8")
(yaml/load))
_ (aset (aget (aget (aget helm-values "ingress") "hosts") 0)
"host"
(get-secret-val nextcloud-secrets "host"))
(yaml/load)))
hostname (get-secret-val nextcloud-secrets "host")
final-helm-values (-> helm-values
(assoc-in [:ingress :hosts 0 :host] hostname)
(assoc-in [:ingress :enabled] true)
(assoc-in [:nextcloud :host] hostname)
(assoc-in [:nextcloud :trusted_domains] [hostname]))
chart (new (.. helm-v3 -Chart)
"nextcloud"
(clj->js {:chart "nextcloud"
:fetchOpts {:repo "https://nextcloud.github.io/helm/"}
:namespace (.. ns -metadata -name)
:values helm-values})
:values final-helm-values})
(clj->js {:provider provider
:dependsOn [admin-secret db-secret]}))]
:dependsOn [admin-secret db-secret]
:transformations [add-skip-await-transformation]}))]
{:namespace ns
:admin-secret admin-secret