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