forgejo-upgrade #7

Merged
jem merged 9 commits from forgejo-upgrade into main 2024-08-09 15:10:27 +00:00
3 changed files with 14 additions and 13 deletions
Showing only changes of commit 07eb505d53 - Show all commits

View file

@ -9,7 +9,7 @@
[dda.c4k-common.postgres :as postgres] [dda.c4k-common.postgres :as postgres]
[dda.c4k-common.namespace :as ns])) [dda.c4k-common.namespace :as ns]))
(def config-defaults {:issuer "staging", :deploy-federated "false"}) (def config-defaults {:issuer "staging", :deploy-federated "false", :federation-enabled "false"})
(def rate-limit-defaults {:max-rate 10, :max-concurrent-requests 5}) (def rate-limit-defaults {:max-rate 10, :max-concurrent-requests 5})
(def config? (s/keys :req-un [::forgejo/fqdn (def config? (s/keys :req-un [::forgejo/fqdn
@ -19,6 +19,7 @@
::forgejo/service-noreply-address] ::forgejo/service-noreply-address]
:opt-un [::forgejo/issuer :opt-un [::forgejo/issuer
::forgejo/deploy-federated ::forgejo/deploy-federated
::forgejo/federation-enabled
::forgejo/default-app-name ::forgejo/default-app-name
::forgejo/service-domain-whitelist ::forgejo/service-domain-whitelist
::forgejo/forgejo-image-version-overwrite ::forgejo/forgejo-image-version-overwrite

View file

@ -33,6 +33,7 @@
(s/def ::default-app-name string?) (s/def ::default-app-name string?)
(s/def ::fqdn pred/fqdn-string?) (s/def ::fqdn pred/fqdn-string?)
(s/def ::deploy-federated boolean-string?) (s/def ::deploy-federated boolean-string?)
(s/def ::federation-enabled boolean-string?)
(s/def ::mailer-from pred/bash-env-string?) (s/def ::mailer-from pred/bash-env-string?)
(s/def ::mailer-host pred/bash-env-string?) (s/def ::mailer-host pred/bash-env-string?)
(s/def ::mailer-port pred/bash-env-string?) (s/def ::mailer-port pred/bash-env-string?)
@ -53,6 +54,7 @@
::service-noreply-address] ::service-noreply-address]
:opt-un [::issuer :opt-un [::issuer
::deploy-federated ::deploy-federated
::federation-enabled
::default-app-name ::default-app-name
::service-domain-whitelist ::service-domain-whitelist
::forgejo-image-version-overwrite])) ::forgejo-image-version-overwrite]))
@ -88,7 +90,7 @@
(defn generate-appini-env (defn generate-appini-env
[config] [config]
(let [{:keys [default-app-name (let [{:keys [default-app-name
deploy-federated federation-enabled
fqdn fqdn
mailer-from mailer-from
mailer-host mailer-host
@ -97,7 +99,7 @@
service-noreply-address] service-noreply-address]
:or {default-app-name "forgejo instance" :or {default-app-name "forgejo instance"
service-domain-whitelist fqdn}} config service-domain-whitelist fqdn}} config
deploy-federated-bool (boolean-from-string deploy-federated)] federation-enabled-bool (boolean-from-string federation-enabled)]
(-> (->
(yaml/load-as-edn "forgejo/appini-env-configmap.yaml") (yaml/load-as-edn "forgejo/appini-env-configmap.yaml")
(cm/replace-all-matching-values-by-new-value "APPNAME" default-app-name) (cm/replace-all-matching-values-by-new-value "APPNAME" default-app-name)
@ -109,7 +111,7 @@
(cm/replace-all-matching-values-by-new-value "WHITELISTDOMAINS" service-domain-whitelist) (cm/replace-all-matching-values-by-new-value "WHITELISTDOMAINS" service-domain-whitelist)
(cm/replace-all-matching-values-by-new-value "NOREPLY" service-noreply-address) (cm/replace-all-matching-values-by-new-value "NOREPLY" service-noreply-address)
(cm/replace-all-matching-values-by-new-value "IS_FEDERATED" (cm/replace-all-matching-values-by-new-value "IS_FEDERATED"
(if deploy-federated-bool (if federation-enabled-bool
"true" "true"
"false"))))) "false")))))
@ -166,11 +168,9 @@
(defn-spec generate-deployment pred/map-or-seq? (defn-spec generate-deployment pred/map-or-seq?
[config config?] [config config?]
(let [{:keys [deploy-federated]} config
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" (generate-image-str config))))) (cm/replace-all-matching-values-by-new-value "IMAGE_NAME" (generate-image-str config))))
(defn generate-service (defn generate-service
[] []

View file

@ -14,7 +14,7 @@
(deftest should-generate-image-str (deftest should-generate-image-str
(testing "non-federated-image" (testing "non-federated-image"
(is (= "codeberg.org/forgejo/forgejo:1.19" (is (= "codeberg.org/forgejo/forgejo:7.0"
(cut/generate-image-str {:fqdn "test.de" (cut/generate-image-str {:fqdn "test.de"
:mailer-from "" :mailer-from ""
:mailer-host "m.t.de" :mailer-host "m.t.de"
@ -63,12 +63,12 @@
:FORGEJO__server__ROOT_URL-c2 "https://test.com", :FORGEJO__server__ROOT_URL-c2 "https://test.com",
:FORGEJO__server__SSH_DOMAIN-c1 "test.de", :FORGEJO__server__SSH_DOMAIN-c1 "test.de",
:FORGEJO__server__SSH_DOMAIN-c2 "test.com", :FORGEJO__server__SSH_DOMAIN-c2 "test.com",
:FORGEJO__service__EMAIL_DOMAIN_WHITELIST-c1 "adb.de", :FORGEJO__service__EMAIL_DOMAIN_ALLOWLIST-c1 "adb.de",
:FORGEJO__service__EMAIL_DOMAIN_WHITELIST-c2 "test.com,test.net", :FORGEJO__service__EMAIL_DOMAIN_ALLOWLIST-c2 "test.com,test.net",
:FORGEJO__service__NO_REPLY_ADDRESS-c1 "", :FORGEJO__service__NO_REPLY_ADDRESS-c1 "",
: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" :federation-enabled "false"
:fqdn "test.de" :fqdn "test.de"
:mailer-from "" :mailer-from ""
:mailer-host "m.t.de" :mailer-host "m.t.de"
@ -76,7 +76,7 @@
: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" :federation-enabled "true"
:fqdn "test.com" :fqdn "test.com"
:mailer-from "test@test.com" :mailer-from "test@test.com"
:mailer-host "mail.test.com" :mailer-host "mail.test.com"
@ -97,7 +97,7 @@
:spec :spec
{:containers {:containers
[{:name "forgejo", [{:name "forgejo",
:image "codeberg.org/forgejo/forgejo:1.19", :image "codeberg.org/forgejo/forgejo:7.0",
:imagePullPolicy "IfNotPresent", :imagePullPolicy "IfNotPresent",
:envFrom [{:configMapRef {:name "forgejo-env"}} {:secretRef {:name "forgejo-secrets"}}], :envFrom [{:configMapRef {:name "forgejo-env"}} {:secretRef {:name "forgejo-secrets"}}],
:volumeMounts [{:name "forgejo-data-volume", :mountPath "/data"}], :volumeMounts [{:name "forgejo-data-volume", :mountPath "/data"}],