refactor to new commons features
This commit is contained in:
parent
7a7e05a715
commit
e6e63051ae
4 changed files with 60 additions and 75 deletions
|
@ -4,7 +4,7 @@
|
|||
"src/test/cljc"
|
||||
"src/test/cljs"
|
||||
"src/test/resources"]
|
||||
:dependencies [[org.domaindrivenarchitecture/c4k-common-cljs "6.0.1"]
|
||||
:dependencies [[org.domaindrivenarchitecture/c4k-common-cljs "6.1.0"]
|
||||
[hickory "0.7.1"]]
|
||||
:builds {:frontend {:target :browser
|
||||
:modules {:main {:init-fn dda.c4k-forgejo.browser/init}}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
(ns dda.c4k-forgejo.backup
|
||||
(:require
|
||||
[clojure.spec.alpha :as s]
|
||||
#?(:cljs [shadow.resource :as rc])
|
||||
[dda.c4k-common.yaml :as yaml]
|
||||
[dda.c4k-common.base64 :as b64]
|
||||
[dda.c4k-common.common :as cm]))
|
||||
[dda.c4k-common.common :as cm]
|
||||
#?(:cljs [dda.c4k-common.macros :refer-macros [inline-resources]])))
|
||||
|
||||
(s/def ::aws-access-key-id cm/bash-env-string?)
|
||||
(s/def ::aws-secret-access-key cm/bash-env-string?)
|
||||
|
@ -13,12 +13,7 @@
|
|||
|
||||
#?(:cljs
|
||||
(defmethod yaml/load-resource :backup [resource-name]
|
||||
(case resource-name
|
||||
"backup/config.yaml" (rc/inline "backup/config.yaml")
|
||||
"backup/cron.yaml" (rc/inline "backup/cron.yaml")
|
||||
"backup/secret.yaml" (rc/inline "backup/secret.yaml")
|
||||
"backup/backup-restore-deployment.yaml" (rc/inline "backup/backup-restore-deployment.yaml")
|
||||
(throw (js/Error. "Undefined Resource!")))))
|
||||
(get (inline-resources "backup") resource-name)))
|
||||
|
||||
(defn generate-config [my-conf]
|
||||
(let [{:keys [restic-repository]} my-conf]
|
||||
|
|
|
@ -2,17 +2,15 @@
|
|||
(:require
|
||||
[clojure.spec.alpha :as s]
|
||||
[clojure.string :as st]
|
||||
#?(:cljs [shadow.resource :as rc])
|
||||
#?(:clj [orchestra.core :refer [defn-spec]]
|
||||
:cljs [orchestra.core :refer-macros [defn-spec]])
|
||||
#?(:clj [clojure.edn :as edn]
|
||||
:cljs [cljs.reader :as edn])
|
||||
[dda.c4k-common.yaml :as yaml]
|
||||
[dda.c4k-common.common :as cm]
|
||||
[dda.c4k-common.ingress :as ing]
|
||||
[dda.c4k-common.base64 :as b64]
|
||||
[dda.c4k-common.predicate :as pred]
|
||||
[dda.c4k-common.postgres :as postgres]))
|
||||
[dda.c4k-common.postgres :as postgres]
|
||||
#?(:cljs [dda.c4k-common.macros :refer-macros [inline-resources]])))
|
||||
|
||||
(defn domain-list?
|
||||
[input]
|
||||
|
@ -68,14 +66,7 @@
|
|||
|
||||
#?(:cljs
|
||||
(defmethod yaml/load-resource :forgejo [resource-name]
|
||||
(case resource-name
|
||||
"forgejo/appini-env-configmap.yaml" (rc/inline "forgejo/appini-env-configmap.yaml")
|
||||
"forgejo/deployment.yaml" (rc/inline "forgejo/deployment.yaml")
|
||||
"forgejo/secrets.yaml" (rc/inline "forgejo/secrets.yaml")
|
||||
"forgejo/service.yaml" (rc/inline "forgejo/service.yaml")
|
||||
"forgejo/service-ssh.yaml" (rc/inline "forgejo/service-ssh.yaml")
|
||||
"forgejo/datavolume.yaml" (rc/inline "forgejo/datavolume.yaml")
|
||||
(throw (js/Error. "Undefined Resource!")))))
|
||||
(get (inline-resources "forgejo") resource-name)))
|
||||
|
||||
(defn generate-appini-env
|
||||
[config]
|
||||
|
|
|
@ -51,62 +51,61 @@
|
|||
:service-domain-whitelist "test.com,test.net"
|
||||
:service-noreply-address "noreply@test.com"})))))
|
||||
|
||||
(deftest should-generate-non-federated-deployment
|
||||
(is (= {:apiVersion "apps/v1",
|
||||
:kind "Deployment",
|
||||
:metadata {:name "forgejo", :namespace "default", :labels {:app "forgejo"}},
|
||||
:spec
|
||||
{:replicas 1,
|
||||
:selector {:matchLabels {:app "forgejo"}},
|
||||
:template
|
||||
{:metadata {:name "forgejo", :labels {:app "forgejo"}},
|
||||
(deftest should-generate-deployment
|
||||
(testing "non-federated"
|
||||
(is (= {:apiVersion "apps/v1",
|
||||
:kind "Deployment",
|
||||
:metadata {:name "forgejo", :namespace "default", :labels {:app "forgejo"}},
|
||||
:spec
|
||||
{:containers
|
||||
[{:name "forgejo",
|
||||
:image "codeberg.org/forgejo/forgejo:1.19",
|
||||
:imagePullPolicy "IfNotPresent",
|
||||
:envFrom [{:configMapRef {:name "forgejo-env"}} {:secretRef {:name "forgejo-secrets"}}],
|
||||
:volumeMounts [{:name "forgejo-data-volume", :mountPath "/data"}],
|
||||
:ports [{:containerPort 22, :name "git-ssh"} {:containerPort 3000, :name "forgejo"}]}],
|
||||
:volumes [{:name "forgejo-data-volume", :persistentVolumeClaim {:claimName "forgejo-data-pvc"}}]}}}}
|
||||
(cut/generate-deployment
|
||||
{:default-app-name ""
|
||||
:deploy-federated "false"
|
||||
:fqdn "test.de"
|
||||
:mailer-from ""
|
||||
:mailer-host "m.t.de"
|
||||
:mailer-port "123"
|
||||
:service-domain-whitelist "adb.de"
|
||||
:service-noreply-address ""}
|
||||
))))
|
||||
|
||||
(deftest should-generate-federated-deployment
|
||||
(is (= {:apiVersion "apps/v1",
|
||||
:kind "Deployment",
|
||||
:metadata {:name "forgejo", :namespace "default", :labels {:app "forgejo"}},
|
||||
:spec
|
||||
{:replicas 1,
|
||||
:selector {:matchLabels {:app "forgejo"}},
|
||||
:template
|
||||
{:metadata {:name "forgejo", :labels {:app "forgejo"}},
|
||||
{:replicas 1,
|
||||
:selector {:matchLabels {:app "forgejo"}},
|
||||
:template
|
||||
{:metadata {:name "forgejo", :labels {:app "forgejo"}},
|
||||
:spec
|
||||
{:containers
|
||||
[{:name "forgejo",
|
||||
:image "codeberg.org/forgejo/forgejo:1.19",
|
||||
:imagePullPolicy "IfNotPresent",
|
||||
:envFrom [{:configMapRef {:name "forgejo-env"}} {:secretRef {:name "forgejo-secrets"}}],
|
||||
:volumeMounts [{:name "forgejo-data-volume", :mountPath "/data"}],
|
||||
:ports [{:containerPort 22, :name "git-ssh"} {:containerPort 3000, :name "forgejo"}]}],
|
||||
:volumes [{:name "forgejo-data-volume", :persistentVolumeClaim {:claimName "forgejo-data-pvc"}}]}}}}
|
||||
(cut/generate-deployment
|
||||
{:default-app-name ""
|
||||
:deploy-federated "false"
|
||||
:fqdn "test.de"
|
||||
:mailer-from ""
|
||||
:mailer-host "m.t.de"
|
||||
:mailer-port "123"
|
||||
:service-domain-whitelist "adb.de"
|
||||
:service-noreply-address ""}))))
|
||||
(testing "federated-deployment"
|
||||
(is (= {:apiVersion "apps/v1",
|
||||
:kind "Deployment",
|
||||
:metadata {:name "forgejo", :namespace "default", :labels {:app "forgejo"}},
|
||||
:spec
|
||||
{:containers
|
||||
[{:name "forgejo",
|
||||
:image "domaindrivenarchitecture/c4k-forgejo-federated:latest",
|
||||
:imagePullPolicy "IfNotPresent",
|
||||
:envFrom [{:configMapRef {:name "forgejo-env"}} {:secretRef {:name "forgejo-secrets"}}],
|
||||
:volumeMounts [{:name "forgejo-data-volume", :mountPath "/data"}],
|
||||
:ports [{:containerPort 22, :name "git-ssh"} {:containerPort 3000, :name "forgejo"}]}],
|
||||
:volumes [{:name "forgejo-data-volume", :persistentVolumeClaim {:claimName "forgejo-data-pvc"}}]}}}}
|
||||
(cut/generate-deployment
|
||||
{:default-app-name ""
|
||||
:deploy-federated "true"
|
||||
:fqdn "test.de"
|
||||
:mailer-from ""
|
||||
:mailer-host "m.t.de"
|
||||
:mailer-port "123"
|
||||
:service-domain-whitelist "adb.de"
|
||||
:service-noreply-address ""}))))
|
||||
{:replicas 1,
|
||||
:selector {:matchLabels {:app "forgejo"}},
|
||||
:template
|
||||
{:metadata {:name "forgejo", :labels {:app "forgejo"}},
|
||||
:spec
|
||||
{:containers
|
||||
[{:name "forgejo",
|
||||
:image "domaindrivenarchitecture/c4k-forgejo-federated:latest",
|
||||
:imagePullPolicy "IfNotPresent",
|
||||
:envFrom [{:configMapRef {:name "forgejo-env"}} {:secretRef {:name "forgejo-secrets"}}],
|
||||
:volumeMounts [{:name "forgejo-data-volume", :mountPath "/data"}],
|
||||
:ports [{:containerPort 22, :name "git-ssh"} {:containerPort 3000, :name "forgejo"}]}],
|
||||
:volumes [{:name "forgejo-data-volume", :persistentVolumeClaim {:claimName "forgejo-data-pvc"}}]}}}}
|
||||
(cut/generate-deployment
|
||||
{:default-app-name ""
|
||||
:deploy-federated "true"
|
||||
:fqdn "test.de"
|
||||
:mailer-from ""
|
||||
:mailer-host "m.t.de"
|
||||
:mailer-port "123"
|
||||
:service-domain-whitelist "adb.de"
|
||||
:service-noreply-address ""})))))
|
||||
|
||||
(deftest should-generate-secret
|
||||
(is (= {:FORGEJO__database__USER-c1 "",
|
||||
|
|
Loading…
Reference in a new issue