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] ["@pulumi/vault" :as vault]
["fs" :as fs] ["fs" :as fs]
["js-yaml" :as yaml] ["js-yaml" :as yaml]
["path" :as path] ["path" :as path]))
[clojure.core.async :refer [go]]))
(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 (defn- get-secret-val
"Extract a specific key from a Vault secret Output/Promise." "Extract a specific key from a Vault secret Output/Promise."
@@ -24,7 +38,7 @@
ns (new (.. core-v1 -Namespace) ns (new (.. core-v1 -Namespace)
"nextcloud-ns" "nextcloud-ns"
(clj->js {:metadata {:name "nextcloud"}}) (clj->js {:metadata {:name "my-nextcloud"}})
(clj->js {:provider provider})) (clj->js {:provider provider}))
admin-secret (new (.. core-v1 -Secret) admin-secret (new (.. core-v1 -Secret)
@@ -43,21 +57,27 @@
(clj->js {:provider provider})) (clj->js {:provider provider}))
values-path (.join path js/__dirname ".." "resources" "nextcloud.yml") values-path (.join path js/__dirname ".." "resources" "nextcloud.yml")
helm-values (-> values-path helm-values (js->clj (-> values-path
(fs/readFileSync "utf8") (fs/readFileSync "utf8")
(yaml/load)) (yaml/load)))
_ (aset (aget (aget (aget helm-values "ingress") "hosts") 0) hostname (get-secret-val nextcloud-secrets "host")
"host"
(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) chart (new (.. helm-v3 -Chart)
"nextcloud" "nextcloud"
(clj->js {:chart "nextcloud" (clj->js {:chart "nextcloud"
:fetchOpts {:repo "https://nextcloud.github.io/helm/"} :fetchOpts {:repo "https://nextcloud.github.io/helm/"}
:namespace (.. ns -metadata -name) :namespace (.. ns -metadata -name)
:values helm-values}) :values final-helm-values})
(clj->js {:provider provider (clj->js {:provider provider
:dependsOn [admin-secret db-secret]}))] :dependsOn [admin-secret db-secret]
:transformations [add-skip-await-transformation]}))]
{:namespace ns {:namespace ns
:admin-secret admin-secret :admin-secret admin-secret