added option to override image-version tag
This commit is contained in:
parent
48b00899ea
commit
eaf06724e4
3 changed files with 53 additions and 10 deletions
|
@ -20,6 +20,7 @@
|
|||
::forgejo/deploy-federated
|
||||
::forgejo/default-app-name
|
||||
::forgejo/service-domain-whitelist
|
||||
::forgejo/forgejo-image-version-overwrite
|
||||
::backup/restic-repository
|
||||
::mon/mon-cfg]))
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
(s/def ::mailer-port pred/bash-env-string?)
|
||||
(s/def ::service-domain-whitelist domain-list?)
|
||||
(s/def ::service-noreply-address string?)
|
||||
(s/def ::forgejo-image-version-overwrite string?)
|
||||
(s/def ::mailer-user pred/bash-env-string?)
|
||||
(s/def ::mailer-pw pred/bash-env-string?)
|
||||
(s/def ::issuer pred/letsencrypt-issuer?)
|
||||
|
@ -53,7 +54,8 @@
|
|||
:opt-un [::issuer
|
||||
::deploy-federated
|
||||
::default-app-name
|
||||
::service-domain-whitelist]))
|
||||
::service-domain-whitelist
|
||||
::forgejo-image-version-overwrite]))
|
||||
|
||||
(def rate-limit-config? (s/keys :req-un [::max-rate
|
||||
::max-concurrent-requests]))
|
||||
|
@ -66,8 +68,18 @@
|
|||
[total]
|
||||
total)
|
||||
|
||||
(def federated-image-name "domaindrivenarchitecture/c4k-forgejo-federated:latest")
|
||||
(def non-federated-image-name "codeberg.org/forgejo/forgejo:1.19")
|
||||
(def federated-image-name "domaindrivenarchitecture/c4k-forgejo-federated")
|
||||
(def federated-image-version "latest")
|
||||
(def non-federated-image-name "codeberg.org/forgejo/forgejo")
|
||||
(def non-federated-image-version "1.19")
|
||||
|
||||
(defn-spec generate-image-str string?
|
||||
[config config?]
|
||||
(let [{:keys [deploy-federated forgejo-image-version-overwrite]} config
|
||||
deploy-federated-bool (boolean-from-string deploy-federated)]
|
||||
(if deploy-federated-bool
|
||||
(str federated-image-name ":" (or forgejo-image-version-overwrite federated-image-version))
|
||||
(str non-federated-image-name ":" (or forgejo-image-version-overwrite non-federated-image-version)))))
|
||||
|
||||
#?(:cljs
|
||||
(defmethod yaml/load-resource :forgejo [resource-name]
|
||||
|
@ -158,10 +170,7 @@
|
|||
deploy-federated-bool (boolean-from-string deploy-federated)]
|
||||
(->
|
||||
(yaml/load-as-edn "forgejo/deployment.yaml")
|
||||
(cm/replace-all-matching-values-by-new-value "IMAGE_NAME"
|
||||
(if deploy-federated-bool
|
||||
federated-image-name
|
||||
non-federated-image-name)))))
|
||||
(cm/replace-all-matching-values-by-new-value "IMAGE_NAME" (generate-image-str config)))))
|
||||
|
||||
(defn generate-service
|
||||
[]
|
||||
|
|
|
@ -12,6 +12,40 @@
|
|||
(st/instrument `cut/generate-ingress)
|
||||
(st/instrument `cut/generate-secrets)
|
||||
|
||||
(deftest should-generate-image-str
|
||||
(testing "non-federated-image"
|
||||
(is (= "codeberg.org/forgejo/forgejo:1.19"
|
||||
(cut/generate-image-str {:fqdn "test.de"
|
||||
:mailer-from ""
|
||||
:mailer-host "m.t.de"
|
||||
:mailer-port "123"
|
||||
:service-noreply-address ""
|
||||
:deploy-federated "false"})))
|
||||
(is (= "codeberg.org/forgejo/forgejo:1.19.3-0"
|
||||
(cut/generate-image-str {:fqdn "test.de"
|
||||
:mailer-from ""
|
||||
:mailer-host "m.t.de"
|
||||
:mailer-port "123"
|
||||
:service-noreply-address ""
|
||||
:deploy-federated "false"
|
||||
:forgejo-image-version-overwrite "1.19.3-0"}))))
|
||||
(testing "federated-image"
|
||||
(is (= "domaindrivenarchitecture/c4k-forgejo-federated:latest"
|
||||
(cut/generate-image-str {:fqdn "test.de"
|
||||
:mailer-from ""
|
||||
:mailer-host "m.t.de"
|
||||
:mailer-port "123"
|
||||
:service-noreply-address ""
|
||||
:deploy-federated "true"})))
|
||||
(is (= "domaindrivenarchitecture/c4k-forgejo-federated:3.2.0"
|
||||
(cut/generate-image-str {:fqdn "test.de"
|
||||
:mailer-from ""
|
||||
:mailer-host "m.t.de"
|
||||
:mailer-port "123"
|
||||
:service-noreply-address ""
|
||||
:deploy-federated "true"
|
||||
:forgejo-image-version-overwrite "3.2.0"})))))
|
||||
|
||||
(deftest should-generate-appini-env
|
||||
(is (= {:APP_NAME-c1 "",
|
||||
:APP_NAME-c2 "test forgejo",
|
||||
|
@ -35,13 +69,12 @@
|
|||
:FORGEJO__service__NO_REPLY_ADDRESS-c2 "noreply@test.com"}
|
||||
(th/map-diff (cut/generate-appini-env {:default-app-name ""
|
||||
:deploy-federated "false"
|
||||
:fqdn "test.de"
|
||||
:fqdn "test.de"
|
||||
:mailer-from ""
|
||||
:mailer-host "m.t.de"
|
||||
:mailer-port "123"
|
||||
:service-domain-whitelist "adb.de"
|
||||
:service-noreply-address ""
|
||||
})
|
||||
:service-noreply-address ""})
|
||||
(cut/generate-appini-env {:default-app-name "test forgejo"
|
||||
:deploy-federated "true"
|
||||
:fqdn "test.com"
|
||||
|
|
Loading…
Reference in a new issue