From e1929dd3127a67017caecc1aef45ab8898701fd1 Mon Sep 17 00:00:00 2001 From: Clemens Geibel Date: Fri, 5 Aug 2022 09:44:21 +0200 Subject: [PATCH] TODOs resolved --- project.clj | 2 +- src/main/cljc/dda/c4k_gitea/gitea.cljc | 19 ++++++++++--------- .../resources/gitea/appini-env-configmap.yaml | 5 +++-- src/test/cljc/dda/c4k_gitea/gitea_test.cljc | 12 ++++++++---- 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/project.clj b/project.clj index 2a71112..eb5a10c 100644 --- a/project.clj +++ b/project.clj @@ -5,7 +5,7 @@ :url "https://www.apache.org/licenses/LICENSE-2.0.html"} :dependencies [[org.clojure/clojure "1.10.3"] [org.clojure/tools.reader "1.3.6"] - [org.domaindrivenarchitecture/c4k-common-clj "3.0.0"] + [org.domaindrivenarchitecture/c4k-common-clj "3.0.1"] [hickory "0.7.1"]] :target-path "target/%s/" :source-paths ["src/main/cljc" diff --git a/src/main/cljc/dda/c4k_gitea/gitea.cljc b/src/main/cljc/dda/c4k_gitea/gitea.cljc index 6da1beb..ffc8e4d 100644 --- a/src/main/cljc/dda/c4k_gitea/gitea.cljc +++ b/src/main/cljc/dda/c4k_gitea/gitea.cljc @@ -15,19 +15,21 @@ (s/def ::default-app-name string?) (s/def ::fqdn pred/fqdn-string?) (s/def ::mailer-from pred/bash-env-string?) -(s/def ::mailer-host-port pred/host-and-port-string?) +(s/def ::mailer-host pred/fqdn-string?) +(s/def ::mailer-port pred/port-number?) (s/def ::service-domain-whitelist #(pred/string-of-separated-by? pred/fqdn-string? #"," %)) (s/def ::service-noreply-address string?) (s/def ::mailer-user pred/bash-env-string?) (s/def ::mailer-pw pred/bash-env-string?) (s/def ::issuer pred/letsencrypt-issuer?) -(s/def ::volume-total-storage-size int?) ;TODO extend this for checking lower size limits +(s/def ::volume-total-storage-size (partial pred/int-gt-n? 5)) (def config-defaults {:issuer "staging"}) (def config? (s/keys :req-un [::fqdn ::mailer-from - ::mailer-host-port + ::mailer-host + ::mailer-port ::service-noreply-address] :opt-un [::issuer ::default-app-name @@ -47,10 +49,7 @@ (defn data-storage-by-volume-size [total root] - (cond - (and (<= total 20) (> total 5)) (- total root) - (and (<= total 100) (> total 20)) (- total root) - (> total 100) (- total root))) + (- total root)) #?(:cljs @@ -76,7 +75,8 @@ (let [{:keys [default-app-name fqdn mailer-from - mailer-host-port + mailer-host + mailer-port service-domain-whitelist service-noreply-address] :or {default-app-name "Gitea instance" @@ -88,7 +88,8 @@ (cm/replace-all-matching-values-by-new-value "FQDN" fqdn) (cm/replace-all-matching-values-by-new-value "URL" (str "https://" fqdn)) (cm/replace-all-matching-values-by-new-value "FROM" mailer-from) - (cm/replace-all-matching-values-by-new-value "HOSTANDPORT" mailer-host-port) + (cm/replace-all-matching-values-by-new-value "MAILER_HOST" mailer-host) + (cm/replace-all-matching-values-by-new-value "MAILER_PORT" mailer-port) (cm/replace-all-matching-values-by-new-value "WHITELISTDOMAINS" service-domain-whitelist) (cm/replace-all-matching-values-by-new-value "NOREPLY" service-noreply-address)))) diff --git a/src/main/resources/gitea/appini-env-configmap.yaml b/src/main/resources/gitea/appini-env-configmap.yaml index 000a63e..8ccec77 100644 --- a/src/main/resources/gitea/appini-env-configmap.yaml +++ b/src/main/resources/gitea/appini-env-configmap.yaml @@ -38,8 +38,9 @@ data: GITEA__mailer__ENABLED: "true" GITEA__mailer__FROM: FROM GITEA__mailer__MAILER_TYPE: smtp+startls - # TODO: jem 2022-08-02: outdated, use SMTP_ADDR & SMTP_PORT instead - GITEA__mailer__HOST: HOSTANDPORT + GITEA__mailer__SMTP_ADDR: MAILER_HOST + GITEA__mailer__SMTP_PORT: MAILER_PORT + #[oauth2] GITEA__oauth2__ENABLE: "true" diff --git a/src/test/cljc/dda/c4k_gitea/gitea_test.cljc b/src/test/cljc/dda/c4k_gitea/gitea_test.cljc index 556a186..a7df7a1 100644 --- a/src/test/cljc/dda/c4k_gitea/gitea_test.cljc +++ b/src/test/cljc/dda/c4k_gitea/gitea_test.cljc @@ -16,8 +16,10 @@ :APP_NAME-c2 "test gitea", :GITEA__mailer__FROM-c1 "", :GITEA__mailer__FROM-c2 "test@test.com", - :GITEA__mailer__HOST-c1 "m.t.de:123", - :GITEA__mailer__HOST-c2 "mail.test.com:123", + :GITEA__mailer__SMTP_ADDR-c1 "m.t.de", + :GITEA__mailer__SMTP_PORT-c1 123, + :GITEA__mailer__SMTP_ADDR-c2 "mail.test.com", + :GITEA__mailer__SMTP_PORT-c2 456, :GITEA__server__DOMAIN-c1 "test.de", :GITEA__server__DOMAIN-c2 "test.com", :GITEA__server__ROOT_URL-c1 "https://test.de", @@ -31,14 +33,16 @@ (th/map-diff (cut/generate-appini-env {:default-app-name "" :fqdn "test.de" :mailer-from "" - :mailer-host-port "m.t.de:123" + :mailer-host "m.t.de" + :mailer-port 123 :service-domain-whitelist "adb.de" :service-noreply-address "" }) (cut/generate-appini-env {:default-app-name "test gitea" :fqdn "test.com" :mailer-from "test@test.com" - :mailer-host-port "mail.test.com:123" + :mailer-host "mail.test.com" + :mailer-port 456 :service-domain-whitelist "test.com,test.net" :service-noreply-address "noreply@test.com" })))))